18static ID id_private_q;
24call_check_ints0(
VALUE arg)
31call_check_ints(
void *arg)
79ossl_evp_pkey_free(
void *
ptr)
90 0, ossl_evp_pkey_free,
96pkey_new0(EVP_PKEY *pkey)
101 if (!pkey || (
type = EVP_PKEY_base_id(pkey)) == EVP_PKEY_NONE)
105#if !defined(OPENSSL_NO_RSA)
109#if !defined(OPENSSL_NO_DSA)
113#if !defined(OPENSSL_NO_DH)
117#if !defined(OPENSSL_NO_EC)
170 if ((pkey = d2i_PrivateKey_bio(bio,
NULL)))
176 if ((pkey = d2i_PUBKEY_bio(bio,
NULL)))
183 if ((pkey = PEM_read_bio_PUBKEY(bio,
NULL,
NULL,
NULL)))
198 const BIGNUM *n, *e, *pubkey;
200 if (EVP_PKEY_missing_parameters(pkey))
204 ptr = EVP_PKEY_get0((EVP_PKEY *)pkey);
205 switch (EVP_PKEY_base_id(pkey)) {
207 RSA_get0_key(
ptr, &n, &e,
NULL);
212 DSA_get0_key(
ptr, &pubkey,
NULL);
217 DH_get0_key(
ptr, &pubkey,
NULL);
221#if !defined(OPENSSL_NO_EC)
223 if (EC_KEY_get0_public_key(
ptr))
272ossl_pkey_alloc(
VALUE klass)
278 if (!(pkey = EVP_PKEY_new())) {
294ossl_pkey_initialize(
VALUE self)
309ossl_pkey_oid(
VALUE self)
315 nid = EVP_PKEY_id(pkey);
326ossl_pkey_inspect(
VALUE self)
332 nid = EVP_PKEY_id(pkey);
343 const EVP_CIPHER *enc =
NULL;
357 bio = BIO_new(BIO_s_mem());
361 if (!i2d_PKCS8PrivateKey_bio(bio, pkey, enc,
NULL, 0,
368 if (!PEM_write_bio_PKCS8PrivateKey(bio, pkey, enc,
NULL, 0,
390 return do_pkcs8_export(
argc,
argv, self, 1);
404 return do_pkcs8_export(
argc,
argv, self, 0);
408do_spki_export(
VALUE self,
int to_der)
414 bio = BIO_new(BIO_s_mem());
418 if (!i2d_PUBKEY_bio(bio, pkey)) {
424 if (!PEM_write_bio_PUBKEY(bio, pkey)) {
439ossl_pkey_public_to_der(
VALUE self)
441 return do_spki_export(self, 1);
451ossl_pkey_public_to_pem(
VALUE self)
453 return do_spki_export(self, 0);
479 unsigned int buf_len;
491 if (!EVP_SignInit_ex(ctx, md,
NULL)) {
499 result = EVP_SignFinal(ctx, (
unsigned char *)
RSTRING_PTR(
str), &buf_len, pkey);
541 siglen = RSTRING_LENINT(sig);
547 if (!EVP_VerifyInit_ex(ctx, md,
NULL)) {
555 result = EVP_VerifyFinal(ctx, (
unsigned char *)
RSTRING_PTR(sig), siglen, pkey);
void rb_ary_store(VALUE ary, long idx, VALUE val)
#define rb_define_method(klass, mid, func, arity)
Defines klass#mid.
#define rb_define_module_function(klass, mid, func, arity)
Defines klass#mid and makes it a module function.
char str[HTML_ESCAPE_MAX_LEN+1]
#define RSTRING_LEN(string)
#define RSTRING_PTR(string)
VALUE rb_define_class_under(VALUE outer, const char *name, VALUE super)
Defines a class under the namespace of outer.
VALUE rb_define_module(const char *name)
VALUE rb_define_module_under(VALUE outer, const char *name)
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
VALUE rb_protect(VALUE(*proc)(VALUE), VALUE data, int *pstate)
Protects a function call from potential global escapes from the function.
void rb_jump_tag(int tag)
Continues the exception caught by rb_protect() and rb_eval_string_protect().
VALUE rb_cObject
Object class.
VALUE rb_obj_is_instance_of(VALUE, VALUE)
Determines if obj is an instance of c.
#define rb_str_new(str, len)
void rb_str_set_len(VALUE, long)
#define rb_str_new_cstr(str)
void rb_thread_check_ints(void)
VALUE rb_class_name(VALUE)
void rb_define_alloc_func(VALUE, rb_alloc_func_t)
ID rb_intern(const char *)
void * rb_thread_call_with_gvl(void *(*func)(void *), void *data1)
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
VALUE type(ANYARGS)
ANYARGS-ed function type.
#define EVP_PKEY_up_ref(x)
#define BN_GENCB_get_arg(cb)
int ossl_pem_passwd_cb(char *buf, int max_len, int flag, void *pwd_)
VALUE ossl_pem_passwd_value(VALUE pass)
void ossl_raise(VALUE exc, const char *fmt,...)
void ossl_clear_error(void)
#define OSSL_BIO_reset(bio)
BIO * ossl_obj2bio(volatile VALUE *pobj)
VALUE ossl_membio2str(BIO *bio)
const EVP_CIPHER * ossl_evp_get_cipherbyname(VALUE obj)
const EVP_MD * ossl_evp_get_digestbyname(VALUE obj)
EVP_PKEY * GetPrivPKeyPtr(VALUE obj)
const rb_data_type_t ossl_evp_pkey_type
void ossl_pkey_check_public_key(const EVP_PKEY *pkey)
int ossl_generate_cb_2(int p, int n, BN_GENCB *cb)
void ossl_generate_cb_stop(void *ptr)
EVP_PKEY * DupPKeyPtr(VALUE obj)
EVP_PKEY * GetPKeyPtr(VALUE obj)
void Init_ossl_pkey(void)
VALUE ossl_pkey_new(EVP_PKEY *pkey)
VALUE ossl_dsa_new(EVP_PKEY *)
VALUE ossl_ec_new(EVP_PKEY *)
VALUE ossl_dh_new(EVP_PKEY *)
#define GetPKey(obj, pkey)
VALUE ossl_rsa_new(EVP_PKEY *)
#define SetPKey(obj, pkey)
@ RUBY_TYPED_FREE_IMMEDIATELY
VALUE rb_sprintf(const char *,...)