Ruby: ext/openssl/ossl_pkey.c Source File

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

ossl_pkey.c
Go to the documentation of this file.
1/*
2 * 'OpenSSL for Ruby' project
3 * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
4 * All rights reserved.
5 */
6/*
7 * This program is licensed under the same licence as Ruby.
8 * (See the file 'LICENCE'.)
9 */
10#include "ossl.h"
11
12/*
13 * Classes
14 */
15 VALUE mPKey;
16 VALUE cPKey;
17 VALUE ePKeyError;
18static ID id_private_q;
19
20/*
21 * callback for generating keys
22 */
23static VALUE
24call_check_ints0(VALUE arg)
25{
26 rb_thread_check_ints();
27 return Qnil;
28}
29
30static void *
31call_check_ints(void *arg)
32{
33 int state;
34 rb_protect(call_check_ints0, Qnil, &state);
35 return (void *)(VALUE)state;
36}
37
38int
39ossl_generate_cb_2(int p, int n, BN_GENCB *cb)
40{
41 VALUE ary;
42 struct ossl_generate_cb_arg *arg;
43 int state;
44
45 arg = (struct ossl_generate_cb_arg *)BN_GENCB_get_arg(cb);
46 if (arg->yield) {
47 ary = rb_ary_new2(2);
48 rb_ary_store(ary, 0, INT2NUM(p));
49 rb_ary_store(ary, 1, INT2NUM(n));
50
51 /*
52 * can be break by raising exception or 'break'
53 */
54 rb_protect(rb_yield, ary, &state);
55 if (state) {
56 arg->state = state;
57 return 0;
58 }
59 }
60 if (arg->interrupted) {
61 arg->interrupted = 0;
62 state = (int)(VALUE)rb_thread_call_with_gvl(call_check_ints, NULL);
63 if (state) {
64 arg->state = state;
65 return 0;
66 }
67 }
68 return 1;
69}
70
71void
72ossl_generate_cb_stop(void *ptr)
73{
74 struct ossl_generate_cb_arg *arg = (struct ossl_generate_cb_arg *)ptr;
75 arg->interrupted = 1;
76}
77
78static void
79ossl_evp_pkey_free(void *ptr)
80{
81 EVP_PKEY_free(ptr);
82}
83
84/*
85 * Public
86 */
87 const rb_data_type_t ossl_evp_pkey_type = {
88 "OpenSSL/EVP_PKEY",
89 {
90 0, ossl_evp_pkey_free,
91 },
92 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
93};
94
95static VALUE
96pkey_new0(EVP_PKEY *pkey)
97{
98 VALUE obj;
99 int type;
100
101 if (!pkey || (type = EVP_PKEY_base_id(pkey)) == EVP_PKEY_NONE)
102 ossl_raise(rb_eRuntimeError, "pkey is empty");
103
104 switch (type) {
105#if !defined(OPENSSL_NO_RSA)
106 case EVP_PKEY_RSA:
107 return ossl_rsa_new(pkey);
108#endif
109#if !defined(OPENSSL_NO_DSA)
110 case EVP_PKEY_DSA:
111 return ossl_dsa_new(pkey);
112#endif
113#if !defined(OPENSSL_NO_DH)
114 case EVP_PKEY_DH:
115 return ossl_dh_new(pkey);
116#endif
117#if !defined(OPENSSL_NO_EC)
118 case EVP_PKEY_EC:
119 return ossl_ec_new(pkey);
120#endif
121 default:
122 obj = NewPKey(cPKey);
123 SetPKey(obj, pkey);
124 return obj;
125 }
126}
127
128 VALUE
129ossl_pkey_new(EVP_PKEY *pkey)
130{
131 VALUE obj;
132 int status;
133
134 obj = rb_protect((VALUE (*)(VALUE))pkey_new0, (VALUE)pkey, &status);
135 if (status) {
136 EVP_PKEY_free(pkey);
137 rb_jump_tag(status);
138 }
139
140 return obj;
141}
142
143/*
144 * call-seq:
145 * OpenSSL::PKey.read(string [, pwd ]) -> PKey
146 * OpenSSL::PKey.read(io [, pwd ]) -> PKey
147 *
148 * Reads a DER or PEM encoded string from _string_ or _io_ and returns an
149 * instance of the appropriate PKey class.
150 *
151 * === Parameters
152 * * _string+ is a DER- or PEM-encoded string containing an arbitrary private
153 * or public key.
154 * * _io_ is an instance of IO containing a DER- or PEM-encoded
155 * arbitrary private or public key.
156 * * _pwd_ is an optional password in case _string_ or _io_ is an encrypted
157 * PEM resource.
158 */
159static VALUE
160ossl_pkey_new_from_data(int argc, VALUE *argv, VALUE self)
161{
162 EVP_PKEY *pkey;
163 BIO *bio;
164 VALUE data, pass;
165
166 rb_scan_args(argc, argv, "11", &data, &pass);
167 pass = ossl_pem_passwd_value(pass);
168
169 bio = ossl_obj2bio(&data);
170 if ((pkey = d2i_PrivateKey_bio(bio, NULL)))
171 goto ok;
172 OSSL_BIO_reset(bio);
173 if ((pkey = d2i_PKCS8PrivateKey_bio(bio, NULL, ossl_pem_passwd_cb, (void *)pass)))
174 goto ok;
175 OSSL_BIO_reset(bio);
176 if ((pkey = d2i_PUBKEY_bio(bio, NULL)))
177 goto ok;
178 OSSL_BIO_reset(bio);
179 /* PEM_read_bio_PrivateKey() also parses PKCS #8 formats */
180 if ((pkey = PEM_read_bio_PrivateKey(bio, NULL, ossl_pem_passwd_cb, (void *)pass)))
181 goto ok;
182 OSSL_BIO_reset(bio);
183 if ((pkey = PEM_read_bio_PUBKEY(bio, NULL, NULL, NULL)))
184 goto ok;
185
186 BIO_free(bio);
187 ossl_raise(ePKeyError, "Could not parse PKey");
188
189ok:
190 BIO_free(bio);
191 return ossl_pkey_new(pkey);
192}
193
194void
195ossl_pkey_check_public_key(const EVP_PKEY *pkey)
196{
197 void *ptr;
198 const BIGNUM *n, *e, *pubkey;
199
200 if (EVP_PKEY_missing_parameters(pkey))
201 ossl_raise(ePKeyError, "parameters missing");
202
203 /* OpenSSL < 1.1.0 takes non-const pointer */
204 ptr = EVP_PKEY_get0((EVP_PKEY *)pkey);
205 switch (EVP_PKEY_base_id(pkey)) {
206 case EVP_PKEY_RSA:
207 RSA_get0_key(ptr, &n, &e, NULL);
208 if (n && e)
209 return;
210 break;
211 case EVP_PKEY_DSA:
212 DSA_get0_key(ptr, &pubkey, NULL);
213 if (pubkey)
214 return;
215 break;
216 case EVP_PKEY_DH:
217 DH_get0_key(ptr, &pubkey, NULL);
218 if (pubkey)
219 return;
220 break;
221#if !defined(OPENSSL_NO_EC)
222 case EVP_PKEY_EC:
223 if (EC_KEY_get0_public_key(ptr))
224 return;
225 break;
226#endif
227 default:
228 /* unsupported type; assuming ok */
229 return;
230 }
231 ossl_raise(ePKeyError, "public key missing");
232}
233
234EVP_PKEY *
235GetPKeyPtr(VALUE obj)
236{
237 EVP_PKEY *pkey;
238
239 GetPKey(obj, pkey);
240
241 return pkey;
242}
243
244EVP_PKEY *
245GetPrivPKeyPtr(VALUE obj)
246{
247 EVP_PKEY *pkey;
248
249 if (rb_funcallv(obj, id_private_q, 0, NULL) != Qtrue) {
250 ossl_raise(rb_eArgError, "Private key is needed.");
251 }
252 GetPKey(obj, pkey);
253
254 return pkey;
255}
256
257EVP_PKEY *
258DupPKeyPtr(VALUE obj)
259{
260 EVP_PKEY *pkey;
261
262 GetPKey(obj, pkey);
263 EVP_PKEY_up_ref(pkey);
264
265 return pkey;
266}
267
268/*
269 * Private
270 */
271static VALUE
272ossl_pkey_alloc(VALUE klass)
273{
274 EVP_PKEY *pkey;
275 VALUE obj;
276
277 obj = NewPKey(klass);
278 if (!(pkey = EVP_PKEY_new())) {
279 ossl_raise(ePKeyError, NULL);
280 }
281 SetPKey(obj, pkey);
282
283 return obj;
284}
285
286/*
287 * call-seq:
288 * PKeyClass.new -> self
289 *
290 * Because PKey is an abstract class, actually calling this method explicitly
291 * will raise a NotImplementedError.
292 */
293static VALUE
294ossl_pkey_initialize(VALUE self)
295{
296 if (rb_obj_is_instance_of(self, cPKey)) {
297 ossl_raise(rb_eTypeError, "OpenSSL::PKey::PKey can't be instantiated directly");
298 }
299 return self;
300}
301
302/*
303 * call-seq:
304 * pkey.oid -> string
305 *
306 * Returns the short name of the OID associated with _pkey_.
307 */
308static VALUE
309ossl_pkey_oid(VALUE self)
310{
311 EVP_PKEY *pkey;
312 int nid;
313
314 GetPKey(self, pkey);
315 nid = EVP_PKEY_id(pkey);
316 return rb_str_new_cstr(OBJ_nid2sn(nid));
317}
318
319/*
320 * call-seq:
321 * pkey.inspect -> string
322 *
323 * Returns a string describing the PKey object.
324 */
325static VALUE
326ossl_pkey_inspect(VALUE self)
327{
328 EVP_PKEY *pkey;
329 int nid;
330
331 GetPKey(self, pkey);
332 nid = EVP_PKEY_id(pkey);
333 return rb_sprintf("#<%"PRIsVALUE":%p oid=%s>",
334 rb_class_name(CLASS_OF(self)), (void *)self,
335 OBJ_nid2sn(nid));
336}
337
338static VALUE
339do_pkcs8_export(int argc, VALUE *argv, VALUE self, int to_der)
340{
341 EVP_PKEY *pkey;
342 VALUE cipher, pass;
343 const EVP_CIPHER *enc = NULL;
344 BIO *bio;
345
346 GetPKey(self, pkey);
347 rb_scan_args(argc, argv, "02", &cipher, &pass);
348 if (argc > 0) {
349 /*
350 * TODO: EncryptedPrivateKeyInfo actually has more options.
351 * Should they be exposed?
352 */
353 enc = ossl_evp_get_cipherbyname(cipher);
354 pass = ossl_pem_passwd_value(pass);
355 }
356
357 bio = BIO_new(BIO_s_mem());
358 if (!bio)
359 ossl_raise(ePKeyError, "BIO_new");
360 if (to_der) {
361 if (!i2d_PKCS8PrivateKey_bio(bio, pkey, enc, NULL, 0,
362 ossl_pem_passwd_cb, (void *)pass)) {
363 BIO_free(bio);
364 ossl_raise(ePKeyError, "i2d_PKCS8PrivateKey_bio");
365 }
366 }
367 else {
368 if (!PEM_write_bio_PKCS8PrivateKey(bio, pkey, enc, NULL, 0,
369 ossl_pem_passwd_cb, (void *)pass)) {
370 BIO_free(bio);
371 ossl_raise(ePKeyError, "PEM_write_bio_PKCS8PrivateKey");
372 }
373 }
374 return ossl_membio2str(bio);
375}
376
377/*
378 * call-seq:
379 * pkey.private_to_der -> string
380 * pkey.private_to_der(cipher, password) -> string
381 *
382 * Serializes the private key to DER-encoded PKCS #8 format. If called without
383 * arguments, unencrypted PKCS #8 PrivateKeyInfo format is used. If called with
384 * a cipher name and a password, PKCS #8 EncryptedPrivateKeyInfo format with
385 * PBES2 encryption scheme is used.
386 */
387static VALUE
388ossl_pkey_private_to_der(int argc, VALUE *argv, VALUE self)
389{
390 return do_pkcs8_export(argc, argv, self, 1);
391}
392
393/*
394 * call-seq:
395 * pkey.private_to_pem -> string
396 * pkey.private_to_pem(cipher, password) -> string
397 *
398 * Serializes the private key to PEM-encoded PKCS #8 format. See #private_to_der
399 * for more details.
400 */
401static VALUE
402ossl_pkey_private_to_pem(int argc, VALUE *argv, VALUE self)
403{
404 return do_pkcs8_export(argc, argv, self, 0);
405}
406
407static VALUE
408do_spki_export(VALUE self, int to_der)
409{
410 EVP_PKEY *pkey;
411 BIO *bio;
412
413 GetPKey(self, pkey);
414 bio = BIO_new(BIO_s_mem());
415 if (!bio)
416 ossl_raise(ePKeyError, "BIO_new");
417 if (to_der) {
418 if (!i2d_PUBKEY_bio(bio, pkey)) {
419 BIO_free(bio);
420 ossl_raise(ePKeyError, "i2d_PUBKEY_bio");
421 }
422 }
423 else {
424 if (!PEM_write_bio_PUBKEY(bio, pkey)) {
425 BIO_free(bio);
426 ossl_raise(ePKeyError, "PEM_write_bio_PUBKEY");
427 }
428 }
429 return ossl_membio2str(bio);
430}
431
432/*
433 * call-seq:
434 * pkey.public_to_der -> string
435 *
436 * Serializes the public key to DER-encoded X.509 SubjectPublicKeyInfo format.
437 */
438static VALUE
439ossl_pkey_public_to_der(VALUE self)
440{
441 return do_spki_export(self, 1);
442}
443
444/*
445 * call-seq:
446 * pkey.public_to_pem -> string
447 *
448 * Serializes the public key to PEM-encoded X.509 SubjectPublicKeyInfo format.
449 */
450static VALUE
451ossl_pkey_public_to_pem(VALUE self)
452{
453 return do_spki_export(self, 0);
454}
455
456/*
457 * call-seq:
458 * pkey.sign(digest, data) -> String
459 *
460 * To sign the String _data_, _digest_, an instance of OpenSSL::Digest, must
461 * be provided. The return value is again a String containing the signature.
462 * A PKeyError is raised should errors occur.
463 * Any previous state of the Digest instance is irrelevant to the signature
464 * outcome, the digest instance is reset to its initial state during the
465 * operation.
466 *
467 * == Example
468 * data = 'Sign me!'
469 * digest = OpenSSL::Digest.new('SHA256')
470 * pkey = OpenSSL::PKey::RSA.new(2048)
471 * signature = pkey.sign(digest, data)
472 */
473static VALUE
474ossl_pkey_sign(VALUE self, VALUE digest, VALUE data)
475{
476 EVP_PKEY *pkey;
477 const EVP_MD *md;
478 EVP_MD_CTX *ctx;
479 unsigned int buf_len;
480 VALUE str;
481 int result;
482
483 pkey = GetPrivPKeyPtr(self);
484 md = ossl_evp_get_digestbyname(digest);
485 StringValue(data);
486 str = rb_str_new(0, EVP_PKEY_size(pkey));
487
488 ctx = EVP_MD_CTX_new();
489 if (!ctx)
490 ossl_raise(ePKeyError, "EVP_MD_CTX_new");
491 if (!EVP_SignInit_ex(ctx, md, NULL)) {
492 EVP_MD_CTX_free(ctx);
493 ossl_raise(ePKeyError, "EVP_SignInit_ex");
494 }
495 if (!EVP_SignUpdate(ctx, RSTRING_PTR(data), RSTRING_LEN(data))) {
496 EVP_MD_CTX_free(ctx);
497 ossl_raise(ePKeyError, "EVP_SignUpdate");
498 }
499 result = EVP_SignFinal(ctx, (unsigned char *)RSTRING_PTR(str), &buf_len, pkey);
500 EVP_MD_CTX_free(ctx);
501 if (!result)
502 ossl_raise(ePKeyError, "EVP_SignFinal");
503 rb_str_set_len(str, buf_len);
504
505 return str;
506}
507
508/*
509 * call-seq:
510 * pkey.verify(digest, signature, data) -> String
511 *
512 * To verify the String _signature_, _digest_, an instance of
513 * OpenSSL::Digest, must be provided to re-compute the message digest of the
514 * original _data_, also a String. The return value is +true+ if the
515 * signature is valid, +false+ otherwise. A PKeyError is raised should errors
516 * occur.
517 * Any previous state of the Digest instance is irrelevant to the validation
518 * outcome, the digest instance is reset to its initial state during the
519 * operation.
520 *
521 * == Example
522 * data = 'Sign me!'
523 * digest = OpenSSL::Digest.new('SHA256')
524 * pkey = OpenSSL::PKey::RSA.new(2048)
525 * signature = pkey.sign(digest, data)
526 * pub_key = pkey.public_key
527 * puts pub_key.verify(digest, signature, data) # => true
528 */
529static VALUE
530ossl_pkey_verify(VALUE self, VALUE digest, VALUE sig, VALUE data)
531{
532 EVP_PKEY *pkey;
533 const EVP_MD *md;
534 EVP_MD_CTX *ctx;
535 int siglen, result;
536
537 GetPKey(self, pkey);
538 ossl_pkey_check_public_key(pkey);
539 md = ossl_evp_get_digestbyname(digest);
540 StringValue(sig);
541 siglen = RSTRING_LENINT(sig);
542 StringValue(data);
543
544 ctx = EVP_MD_CTX_new();
545 if (!ctx)
546 ossl_raise(ePKeyError, "EVP_MD_CTX_new");
547 if (!EVP_VerifyInit_ex(ctx, md, NULL)) {
548 EVP_MD_CTX_free(ctx);
549 ossl_raise(ePKeyError, "EVP_VerifyInit_ex");
550 }
551 if (!EVP_VerifyUpdate(ctx, RSTRING_PTR(data), RSTRING_LEN(data))) {
552 EVP_MD_CTX_free(ctx);
553 ossl_raise(ePKeyError, "EVP_VerifyUpdate");
554 }
555 result = EVP_VerifyFinal(ctx, (unsigned char *)RSTRING_PTR(sig), siglen, pkey);
556 EVP_MD_CTX_free(ctx);
557 switch (result) {
558 case 0:
559 ossl_clear_error();
560 return Qfalse;
561 case 1:
562 return Qtrue;
563 default:
564 ossl_raise(ePKeyError, "EVP_VerifyFinal");
565 }
566}
567
568/*
569 * INIT
570 */
571void
572Init_ossl_pkey(void)
573{
574#undef rb_intern
575#if 0
576 mOSSL = rb_define_module("OpenSSL");
577 eOSSLError = rb_define_class_under(mOSSL, "OpenSSLError", rb_eStandardError);
578#endif
579
580 /* Document-module: OpenSSL::PKey
581 *
582 * == Asymmetric Public Key Algorithms
583 *
584 * Asymmetric public key algorithms solve the problem of establishing and
585 * sharing secret keys to en-/decrypt messages. The key in such an
586 * algorithm consists of two parts: a public key that may be distributed
587 * to others and a private key that needs to remain secret.
588 *
589 * Messages encrypted with a public key can only be decrypted by
590 * recipients that are in possession of the associated private key.
591 * Since public key algorithms are considerably slower than symmetric
592 * key algorithms (cf. OpenSSL::Cipher) they are often used to establish
593 * a symmetric key shared between two parties that are in possession of
594 * each other's public key.
595 *
596 * Asymmetric algorithms offer a lot of nice features that are used in a
597 * lot of different areas. A very common application is the creation and
598 * validation of digital signatures. To sign a document, the signatory
599 * generally uses a message digest algorithm (cf. OpenSSL::Digest) to
600 * compute a digest of the document that is then encrypted (i.e. signed)
601 * using the private key. Anyone in possession of the public key may then
602 * verify the signature by computing the message digest of the original
603 * document on their own, decrypting the signature using the signatory's
604 * public key and comparing the result to the message digest they
605 * previously computed. The signature is valid if and only if the
606 * decrypted signature is equal to this message digest.
607 *
608 * The PKey module offers support for three popular public/private key
609 * algorithms:
610 * * RSA (OpenSSL::PKey::RSA)
611 * * DSA (OpenSSL::PKey::DSA)
612 * * Elliptic Curve Cryptography (OpenSSL::PKey::EC)
613 * Each of these implementations is in fact a sub-class of the abstract
614 * PKey class which offers the interface for supporting digital signatures
615 * in the form of PKey#sign and PKey#verify.
616 *
617 * == Diffie-Hellman Key Exchange
618 *
619 * Finally PKey also features OpenSSL::PKey::DH, an implementation of
620 * the Diffie-Hellman key exchange protocol based on discrete logarithms
621 * in finite fields, the same basis that DSA is built on.
622 * The Diffie-Hellman protocol can be used to exchange (symmetric) keys
623 * over insecure channels without needing any prior joint knowledge
624 * between the participating parties. As the security of DH demands
625 * relatively long "public keys" (i.e. the part that is overtly
626 * transmitted between participants) DH tends to be quite slow. If
627 * security or speed is your primary concern, OpenSSL::PKey::EC offers
628 * another implementation of the Diffie-Hellman protocol.
629 *
630 */
631 mPKey = rb_define_module_under(mOSSL, "PKey");
632
633 /* Document-class: OpenSSL::PKey::PKeyError
634 *
635 *Raised when errors occur during PKey#sign or PKey#verify.
636 */
637 ePKeyError = rb_define_class_under(mPKey, "PKeyError", eOSSLError);
638
639 /* Document-class: OpenSSL::PKey::PKey
640 *
641 * An abstract class that bundles signature creation (PKey#sign) and
642 * validation (PKey#verify) that is common to all implementations except
643 * OpenSSL::PKey::DH
644 * * OpenSSL::PKey::RSA
645 * * OpenSSL::PKey::DSA
646 * * OpenSSL::PKey::EC
647 */
648 cPKey = rb_define_class_under(mPKey, "PKey", rb_cObject);
649
650 rb_define_module_function(mPKey, "read", ossl_pkey_new_from_data, -1);
651
652 rb_define_alloc_func(cPKey, ossl_pkey_alloc);
653 rb_define_method(cPKey, "initialize", ossl_pkey_initialize, 0);
654 rb_define_method(cPKey, "oid", ossl_pkey_oid, 0);
655 rb_define_method(cPKey, "inspect", ossl_pkey_inspect, 0);
656 rb_define_method(cPKey, "private_to_der", ossl_pkey_private_to_der, -1);
657 rb_define_method(cPKey, "private_to_pem", ossl_pkey_private_to_pem, -1);
658 rb_define_method(cPKey, "public_to_der", ossl_pkey_public_to_der, 0);
659 rb_define_method(cPKey, "public_to_pem", ossl_pkey_public_to_pem, 0);
660
661 rb_define_method(cPKey, "sign", ossl_pkey_sign, 2);
662 rb_define_method(cPKey, "verify", ossl_pkey_verify, 3);
663
664 id_private_q = rb_intern("private?");
665
666 /*
667 * INIT rsa, dsa, dh, ec
668 */
669 Init_ossl_rsa();
670 Init_ossl_dsa();
671 Init_ossl_dh();
672 Init_ossl_ec();
673}
rb_ary_store
void rb_ary_store(VALUE ary, long idx, VALUE val)
Definition: array.c:1141
rb_define_method
#define rb_define_method(klass, mid, func, arity)
Defines klass#mid.
Definition: cxxanyargs.hpp:653
rb_define_module_function
#define rb_define_module_function(klass, mid, func, arity)
Defines klass#mid and makes it a module function.
Definition: cxxanyargs.hpp:672
ptr
struct RIMemo * ptr
Definition: debug.c:88
str
char str[HTML_ESCAPE_MAX_LEN+1]
Definition: escape.c:18
RSTRING_LEN
#define RSTRING_LEN(string)
Definition: fbuffer.h:22
RSTRING_PTR
#define RSTRING_PTR(string)
Definition: fbuffer.h:19
PRIsVALUE
#define PRIsVALUE
Definition: function.c:10
CLASS_OF
#define CLASS_OF
Definition: globals.h:153
rb_define_class_under
VALUE rb_define_class_under(VALUE outer, const char *name, VALUE super)
Defines a class under the namespace of outer.
Definition: class.c:797
rb_define_module
VALUE rb_define_module(const char *name)
Definition: class.c:871
rb_define_module_under
VALUE rb_define_module_under(VALUE outer, const char *name)
Definition: class.c:895
rb_scan_args
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
Definition: class.c:2296
rb_eStandardError
VALUE rb_eStandardError
Definition: error.c:1054
rb_eTypeError
VALUE rb_eTypeError
Definition: error.c:1057
rb_protect
VALUE rb_protect(VALUE(*proc)(VALUE), VALUE data, int *pstate)
Protects a function call from potential global escapes from the function.
Definition: eval.c:1105
rb_eRuntimeError
VALUE rb_eRuntimeError
Definition: error.c:1055
rb_eArgError
VALUE rb_eArgError
Definition: error.c:1058
rb_jump_tag
void rb_jump_tag(int tag)
Continues the exception caught by rb_protect() and rb_eval_string_protect().
Definition: eval.c:921
rb_cObject
VALUE rb_cObject
Object class.
Definition: object.c:49
rb_obj_is_instance_of
VALUE rb_obj_is_instance_of(VALUE, VALUE)
Determines if obj is an instance of c.
Definition: object.c:707
rb_ary_new2
#define rb_ary_new2
Definition: array.h:72
rb_str_new
#define rb_str_new(str, len)
Definition: string.h:213
rb_str_set_len
void rb_str_set_len(VALUE, long)
Definition: string.c:2842
rb_str_new_cstr
#define rb_str_new_cstr(str)
Definition: string.h:219
rb_thread_check_ints
void rb_thread_check_ints(void)
Definition: thread.c:1577
rb_class_name
VALUE rb_class_name(VALUE)
Definition: variable.c:293
rb_define_alloc_func
void rb_define_alloc_func(VALUE, rb_alloc_func_t)
rb_intern
ID rb_intern(const char *)
Definition: symbol.c:785
rb_thread_call_with_gvl
void * rb_thread_call_with_gvl(void *(*func)(void *), void *data1)
Definition: thread.c:1892
INT2NUM
#define INT2NUM
Definition: int.h:43
rb_funcallv
#define rb_funcallv(...)
Definition: internal.h:77
int
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
rb_yield
VALUE rb_yield(VALUE)
Definition: vm_eval.c:1341
ruby::backward::cxxanyargs::type
VALUE type(ANYARGS)
ANYARGS-ed function type.
Definition: cxxanyargs.hpp:56
nid
int nid
Definition: openssl_missing.c:28
EVP_PKEY_up_ref
#define EVP_PKEY_up_ref(x)
Definition: openssl_missing.h:146
EVP_MD_CTX_free
#define EVP_MD_CTX_free
Definition: openssl_missing.h:54
EVP_MD_CTX_new
#define EVP_MD_CTX_new
Definition: openssl_missing.h:50
BN_GENCB_get_arg
#define BN_GENCB_get_arg(cb)
Definition: openssl_missing.h:46
mOSSL
VALUE mOSSL
Definition: ossl.c:231
ossl_pem_passwd_cb
int ossl_pem_passwd_cb(char *buf, int max_len, int flag, void *pwd_)
Definition: ossl.c:177
ossl_pem_passwd_value
VALUE ossl_pem_passwd_value(VALUE pass)
Definition: ossl.c:151
ossl_raise
void ossl_raise(VALUE exc, const char *fmt,...)
Definition: ossl.c:293
eOSSLError
VALUE eOSSLError
Definition: ossl.c:236
ossl_clear_error
void ossl_clear_error(void)
Definition: ossl.c:304
ossl.h
OSSL_BIO_reset
#define OSSL_BIO_reset(bio)
Definition: ossl.h:116
ossl_obj2bio
BIO * ossl_obj2bio(volatile VALUE *pobj)
Definition: ossl_bio.c:13
ossl_membio2str
VALUE ossl_membio2str(BIO *bio)
Definition: ossl_bio.c:29
ossl_evp_get_cipherbyname
const EVP_CIPHER * ossl_evp_get_cipherbyname(VALUE obj)
Definition: ossl_cipher.c:52
ossl_evp_get_digestbyname
const EVP_MD * ossl_evp_get_digestbyname(VALUE obj)
Definition: ossl_digest.c:45
GetPrivPKeyPtr
EVP_PKEY * GetPrivPKeyPtr(VALUE obj)
Definition: ossl_pkey.c:245
cPKey
VALUE cPKey
Definition: ossl_pkey.c:16
ossl_evp_pkey_type
const rb_data_type_t ossl_evp_pkey_type
Definition: ossl_pkey.c:87
mPKey
VALUE mPKey
Definition: ossl_pkey.c:15
ossl_pkey_check_public_key
void ossl_pkey_check_public_key(const EVP_PKEY *pkey)
Definition: ossl_pkey.c:195
ossl_generate_cb_2
int ossl_generate_cb_2(int p, int n, BN_GENCB *cb)
Definition: ossl_pkey.c:39
ossl_generate_cb_stop
void ossl_generate_cb_stop(void *ptr)
Definition: ossl_pkey.c:72
DupPKeyPtr
EVP_PKEY * DupPKeyPtr(VALUE obj)
Definition: ossl_pkey.c:258
GetPKeyPtr
EVP_PKEY * GetPKeyPtr(VALUE obj)
Definition: ossl_pkey.c:235
Init_ossl_pkey
void Init_ossl_pkey(void)
Definition: ossl_pkey.c:572
ossl_pkey_new
VALUE ossl_pkey_new(EVP_PKEY *pkey)
Definition: ossl_pkey.c:129
ePKeyError
VALUE ePKeyError
Definition: ossl_pkey.c:17
Init_ossl_dh
void Init_ossl_dh(void)
Definition: ossl_pkey_dh.c:576
Init_ossl_ec
void Init_ossl_ec(void)
Definition: ossl_pkey_ec.c:1678
ossl_dsa_new
VALUE ossl_dsa_new(EVP_PKEY *)
Definition: ossl_pkey_dsa.c:72
ossl_ec_new
VALUE ossl_ec_new(EVP_PKEY *)
Definition: ossl_pkey_ec.c:87
Init_ossl_rsa
void Init_ossl_rsa(void)
Definition: ossl_pkey_rsa.c:888
Init_ossl_dsa
void Init_ossl_dsa(void)
Definition: ossl_pkey_dsa.c:609
ossl_dh_new
VALUE ossl_dh_new(EVP_PKEY *)
Definition: ossl_pkey_dh.c:58
GetPKey
#define GetPKey(obj, pkey)
Definition: ossl_pkey.h:31
ossl_rsa_new
VALUE ossl_rsa_new(EVP_PKEY *)
Definition: ossl_pkey_rsa.c:73
SetPKey
#define SetPKey(obj, pkey)
Definition: ossl_pkey.h:24
NewPKey
#define NewPKey(klass)
Definition: ossl_pkey.h:22
NULL
#define NULL
Definition: regenc.h:69
StringValue
#define StringValue(v)
Definition: rstring.h:50
RUBY_TYPED_FREE_IMMEDIATELY
@ RUBY_TYPED_FREE_IMMEDIATELY
Definition: rtypeddata.h:62
argc
int argc
Definition: ruby.c:240
argv
char ** argv
Definition: ruby.c:241
Qtrue
#define Qtrue
Definition: special_consts.h:52
Qnil
#define Qnil
Definition: special_consts.h:51
Qfalse
#define Qfalse
Definition: special_consts.h:50
rb_sprintf
VALUE rb_sprintf(const char *,...)
Definition: sprintf.c:1203
ossl_generate_cb_arg
Definition: ossl_pkey.h:38
ossl_generate_cb_arg::interrupted
int interrupted
Definition: ossl_pkey.h:40
ossl_generate_cb_arg::state
int state
Definition: ossl_pkey.h:41
ossl_generate_cb_arg::yield
int yield
Definition: ossl_pkey.h:39
rb_data_type_struct
Definition: rtypeddata.h:70
state
Definition: blast.c:41
VALUE
unsigned long VALUE
Definition: value.h:38
ID
unsigned long ID
Definition: value.h:39