mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
ossl_pkey.c: typed data
* ext/openssl/ossl_pkey.c (ossl_evp_pkey_type): use typed data. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48806 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
bf368e4f48
commit
68c8994a69
2 changed files with 17 additions and 2 deletions
|
@ -69,9 +69,23 @@ ossl_generate_cb_stop(void *ptr)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static void
|
||||||
|
ossl_evp_pkey_free(void *ptr)
|
||||||
|
{
|
||||||
|
EVP_PKEY_free(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Public
|
* Public
|
||||||
*/
|
*/
|
||||||
|
const rb_data_type_t ossl_evp_pkey_type = {
|
||||||
|
"OpenSSL/EVP_PKEY",
|
||||||
|
{
|
||||||
|
0, ossl_evp_pkey_free,
|
||||||
|
},
|
||||||
|
0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
|
||||||
|
};
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
ossl_pkey_new(EVP_PKEY *pkey)
|
ossl_pkey_new(EVP_PKEY *pkey)
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,6 +15,7 @@ extern VALUE mPKey;
|
||||||
extern VALUE cPKey;
|
extern VALUE cPKey;
|
||||||
extern VALUE ePKeyError;
|
extern VALUE ePKeyError;
|
||||||
extern ID id_private_q;
|
extern ID id_private_q;
|
||||||
|
extern const rb_data_type_t ossl_evp_pkey_type;
|
||||||
|
|
||||||
#define OSSL_PKEY_SET_PRIVATE(obj) rb_iv_set((obj), "private", Qtrue)
|
#define OSSL_PKEY_SET_PRIVATE(obj) rb_iv_set((obj), "private", Qtrue)
|
||||||
#define OSSL_PKEY_SET_PUBLIC(obj) rb_iv_set((obj), "private", Qfalse)
|
#define OSSL_PKEY_SET_PUBLIC(obj) rb_iv_set((obj), "private", Qfalse)
|
||||||
|
@ -24,11 +25,11 @@ extern ID id_private_q;
|
||||||
if (!(pkey)) { \
|
if (!(pkey)) { \
|
||||||
rb_raise(rb_eRuntimeError, "PKEY wasn't initialized!"); \
|
rb_raise(rb_eRuntimeError, "PKEY wasn't initialized!"); \
|
||||||
} \
|
} \
|
||||||
(obj) = Data_Wrap_Struct((klass), 0, EVP_PKEY_free, (pkey)); \
|
(obj) = TypedData_Wrap_Struct((klass), &ossl_evp_pkey_type, (pkey)); \
|
||||||
OSSL_PKEY_SET_PUBLIC(obj); \
|
OSSL_PKEY_SET_PUBLIC(obj); \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define GetPKey(obj, pkey) do {\
|
#define GetPKey(obj, pkey) do {\
|
||||||
Data_Get_Struct((obj), EVP_PKEY, (pkey));\
|
TypedData_Get_Struct((obj), EVP_PKEY, &ossl_evp_pkey_type, (pkey)); \
|
||||||
if (!(pkey)) { \
|
if (!(pkey)) { \
|
||||||
rb_raise(rb_eRuntimeError, "PKEY wasn't initialized!");\
|
rb_raise(rb_eRuntimeError, "PKEY wasn't initialized!");\
|
||||||
} \
|
} \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue