diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2021-04-12 18:32:40 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2021-12-12 18:20:36 +0900 |
commit | 74f6c6175688502a5bf27ae35367616858630c0f (patch) | |
tree | 4503d29c84957e632f2aa0b76fc103905eb3f032 /ext/openssl/ossl_pkey.c | |
parent | 316cb2a41f154e4663d7e7fead60cfc0bfa86af9 (diff) | |
download | ruby-openssl-74f6c6175688502a5bf27ae35367616858630c0f.tar.gz |
pkey: allocate EVP_PKEY on #initialize
Allocate an EVP_PKEY when the content is ready: when #initialize
or #initialize_copy is called, rather than when a T_DATA is allocated.
This is more natural because the lower level API has been deprecated
and an EVP_PKEY is becoming the minimum unit of handling keys.
Diffstat (limited to 'ext/openssl/ossl_pkey.c')
-rw-r--r-- | ext/openssl/ossl_pkey.c | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/ext/openssl/ossl_pkey.c b/ext/openssl/ossl_pkey.c index 820e4a2c..ea75d63f 100644 --- a/ext/openssl/ossl_pkey.c +++ b/ext/openssl/ossl_pkey.c @@ -55,8 +55,8 @@ pkey_new0(VALUE arg) #endif default: klass = cPKey; break; } - obj = NewPKey(klass); - SetPKey(obj, pkey); + obj = rb_obj_alloc(klass); + RTYPEDDATA_DATA(obj) = pkey; return obj; } @@ -472,16 +472,7 @@ DupPKeyPtr(VALUE obj) static VALUE ossl_pkey_alloc(VALUE klass) { - EVP_PKEY *pkey; - VALUE obj; - - obj = NewPKey(klass); - if (!(pkey = EVP_PKEY_new())) { - ossl_raise(ePKeyError, NULL); - } - SetPKey(obj, pkey); - - return obj; + return TypedData_Wrap_Struct(klass, &ossl_evp_pkey_type, NULL); } /* |