18 static ID id_private_q;
45 if (arg->
stop)
return 0;
57 ossl_evp_pkey_free(
void *ptr)
68 0, ossl_evp_pkey_free,
74 pkey_new0(EVP_PKEY *pkey)
79 if (!pkey || (type = EVP_PKEY_base_id(pkey)) == EVP_PKEY_NONE)
83 #if !defined(OPENSSL_NO_RSA) 87 #if !defined(OPENSSL_NO_DSA) 91 #if !defined(OPENSSL_NO_DH) 95 #if !defined(OPENSSL_NO_EC) 148 if (!(pkey = d2i_PrivateKey_bio(bio,
NULL))) {
152 if (!(pkey = d2i_PUBKEY_bio(bio,
NULL))) {
167 pkey_check_public_key(EVP_PKEY *pkey)
170 const BIGNUM *n, *e, *pubkey;
172 if (EVP_PKEY_missing_parameters(pkey))
175 ptr = EVP_PKEY_get0(pkey);
176 switch (EVP_PKEY_base_id(pkey)) {
178 RSA_get0_key(ptr, &n, &e,
NULL);
183 DSA_get0_key(ptr, &pubkey,
NULL);
188 DH_get0_key(ptr, &pubkey,
NULL);
192 #if !defined(OPENSSL_NO_EC) 194 if (EC_KEY_get0_public_key(ptr))
243 ossl_pkey_alloc(
VALUE klass)
249 if (!(pkey = EVP_PKEY_new())) {
265 ossl_pkey_initialize(
VALUE self)
296 unsigned int buf_len;
308 if (!EVP_SignInit_ex(ctx, md,
NULL)) {
316 result = EVP_SignFinal(ctx, (
unsigned char *)
RSTRING_PTR(str), &buf_len, pkey);
355 pkey_check_public_key(pkey);
364 if (!EVP_VerifyInit_ex(ctx, md,
NULL)) {
372 result = EVP_VerifyFinal(ctx, (
unsigned char *)
RSTRING_PTR(sig), siglen, pkey);
VALUE rb_protect(VALUE(*proc)(VALUE), VALUE data, int *pstate)
Protects a function call from potential global escapes from the function.
#define RUBY_TYPED_FREE_IMMEDIATELY
void rb_jump_tag(int tag)
Continues the exception caught by rb_protect() and rb_eval_string_protect().
#define SetPKey(obj, pkey)
EVP_PKEY * GetPrivPKeyPtr(VALUE obj)
VALUE ossl_dsa_new(EVP_PKEY *)
BIO * ossl_obj2bio(volatile VALUE *pobj)
void rb_str_set_len(VALUE, long)
VALUE rb_define_class_under(VALUE outer, const char *name, VALUE super)
Defines a class under the namespace of outer.
void rb_define_alloc_func(VALUE, rb_alloc_func_t)
#define GetPKey(obj, pkey)
VALUE ossl_rsa_new(EVP_PKEY *)
VALUE ossl_pkey_new(EVP_PKEY *pkey)
const rb_data_type_t ossl_evp_pkey_type
void ossl_generate_cb_stop(void *ptr)
void ossl_clear_error(void)
RUBY_EXTERN VALUE rb_cObject
#define OSSL_BIO_reset(bio)
VALUE ossl_dh_new(EVP_PKEY *)
void rb_ary_store(VALUE ary, long idx, VALUE val)
VALUE rb_obj_is_instance_of(VALUE, VALUE)
call-seq: obj.instance_of?(class) -> true or false
#define BN_GENCB_get_arg(cb)
int ossl_pem_passwd_cb(char *buf, int max_len, int flag, void *pwd_)
void rb_define_module_function(VALUE module, const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a module function for module.
int ossl_generate_cb_2(int p, int n, BN_GENCB *cb)
const EVP_MD * ossl_evp_get_digestbyname(VALUE obj)
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
VALUE ossl_pem_passwd_value(VALUE pass)
VALUE rb_define_module_under(VALUE outer, const char *name)
#define EVP_PKEY_up_ref(x)
void ossl_raise(VALUE exc, const char *fmt,...)
EVP_PKEY * GetPKeyPtr(VALUE obj)
EVP_PKEY * DupPKeyPtr(VALUE obj)
#define RSTRING_LENINT(str)
void Init_ossl_pkey(void)
VALUE rb_define_module(const char *name)
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
VALUE ossl_ec_new(EVP_PKEY *)
VALUE rb_str_new(const char *, long)