Ruby  3.1.0dev(2021-09-10revisionb76ad15ed0da636161de0243c547ee1e6fc95681)
ossl_pkey_rsa.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 #if !defined(OPENSSL_NO_RSA)
13 
14 #define GetPKeyRSA(obj, pkey) do { \
15  GetPKey((obj), (pkey)); \
16  if (EVP_PKEY_base_id(pkey) != EVP_PKEY_RSA) { /* PARANOIA? */ \
17  ossl_raise(rb_eRuntimeError, "THIS IS NOT A RSA!") ; \
18  } \
19 } while (0)
20 #define GetRSA(obj, rsa) do { \
21  EVP_PKEY *_pkey; \
22  GetPKeyRSA((obj), _pkey); \
23  (rsa) = EVP_PKEY_get0_RSA(_pkey); \
24 } while (0)
25 
26 static inline int
27 RSA_HAS_PRIVATE(RSA *rsa)
28 {
29  const BIGNUM *e, *d;
30 
31  RSA_get0_key(rsa, NULL, &e, &d);
32  return e && d;
33 }
34 
35 static inline int
36 RSA_PRIVATE(VALUE obj, RSA *rsa)
37 {
38  return RSA_HAS_PRIVATE(rsa) || OSSL_PKEY_IS_PRIVATE(obj);
39 }
40 
41 /*
42  * Classes
43  */
46 
47 /*
48  * Private
49  */
50 /*
51  * call-seq:
52  * RSA.new -> rsa
53  * RSA.new(encoded_key [, passphrase]) -> rsa
54  * RSA.new(encoded_key) { passphrase } -> rsa
55  * RSA.new(size [, exponent]) -> rsa
56  *
57  * Generates or loads an \RSA keypair.
58  *
59  * If called without arguments, creates a new instance with no key components
60  * set. They can be set individually by #set_key, #set_factors, and
61  * #set_crt_params.
62  *
63  * If called with a String, tries to parse as DER or PEM encoding of an \RSA key.
64  * Note that, if _passphrase_ is not specified but the key is encrypted with a
65  * passphrase, \OpenSSL will prompt for it.
66  * See also OpenSSL::PKey.read which can parse keys of any kinds.
67  *
68  * If called with a number, generates a new key pair. This form works as an
69  * alias of RSA.generate.
70  *
71  * Examples:
72  * OpenSSL::PKey::RSA.new 2048
73  * OpenSSL::PKey::RSA.new File.read 'rsa.pem'
74  * OpenSSL::PKey::RSA.new File.read('rsa.pem'), 'my pass phrase'
75  */
76 static VALUE
77 ossl_rsa_initialize(int argc, VALUE *argv, VALUE self)
78 {
79  EVP_PKEY *pkey, *tmp;
80  RSA *rsa = NULL;
81  BIO *in;
82  VALUE arg, pass;
83 
84  GetPKey(self, pkey);
85  /* The RSA.new(size, generator) form is handled by lib/openssl/pkey.rb */
86  rb_scan_args(argc, argv, "02", &arg, &pass);
87  if (argc == 0) {
88  rsa = RSA_new();
89  if (!rsa)
90  ossl_raise(eRSAError, "RSA_new");
91  }
92  else {
93  pass = ossl_pem_passwd_value(pass);
94  arg = ossl_to_der_if_possible(arg);
95  in = ossl_obj2bio(&arg);
96 
97  tmp = ossl_pkey_read_generic(in, pass);
98  if (tmp) {
99  if (EVP_PKEY_base_id(tmp) != EVP_PKEY_RSA)
100  rb_raise(eRSAError, "incorrect pkey type: %s",
101  OBJ_nid2sn(EVP_PKEY_base_id(tmp)));
102  rsa = EVP_PKEY_get1_RSA(tmp);
103  EVP_PKEY_free(tmp);
104  }
105  if (!rsa) {
106  OSSL_BIO_reset(in);
107  rsa = PEM_read_bio_RSAPublicKey(in, NULL, NULL, NULL);
108  }
109  if (!rsa) {
110  OSSL_BIO_reset(in);
111  rsa = d2i_RSAPublicKey_bio(in, NULL);
112  }
113  BIO_free(in);
114  if (!rsa) {
116  ossl_raise(eRSAError, "Neither PUB key nor PRIV key");
117  }
118  }
119  if (!EVP_PKEY_assign_RSA(pkey, rsa)) {
120  RSA_free(rsa);
121  ossl_raise(eRSAError, "EVP_PKEY_assign_RSA");
122  }
123 
124  return self;
125 }
126 
127 static VALUE
128 ossl_rsa_initialize_copy(VALUE self, VALUE other)
129 {
130  EVP_PKEY *pkey;
131  RSA *rsa, *rsa_new;
132 
133  GetPKey(self, pkey);
134  if (EVP_PKEY_base_id(pkey) != EVP_PKEY_NONE)
135  ossl_raise(eRSAError, "RSA already initialized");
136  GetRSA(other, rsa);
137 
138  rsa_new = ASN1_dup((i2d_of_void *)i2d_RSAPrivateKey, (d2i_of_void *)d2i_RSAPrivateKey, (char *)rsa);
139  if (!rsa_new)
140  ossl_raise(eRSAError, "ASN1_dup");
141 
142  EVP_PKEY_assign_RSA(pkey, rsa_new);
143 
144  return self;
145 }
146 
147 /*
148  * call-seq:
149  * rsa.public? => true
150  *
151  * The return value is always +true+ since every private key is also a public
152  * key.
153  */
154 static VALUE
155 ossl_rsa_is_public(VALUE self)
156 {
157  RSA *rsa;
158 
159  GetRSA(self, rsa);
160  /*
161  * This method should check for n and e. BUG.
162  */
163  (void)rsa;
164  return Qtrue;
165 }
166 
167 /*
168  * call-seq:
169  * rsa.private? => true | false
170  *
171  * Does this keypair contain a private key?
172  */
173 static VALUE
174 ossl_rsa_is_private(VALUE self)
175 {
176  RSA *rsa;
177 
178  GetRSA(self, rsa);
179 
180  return RSA_PRIVATE(self, rsa) ? Qtrue : Qfalse;
181 }
182 
183 static int
184 can_export_rsaprivatekey(VALUE self)
185 {
186  RSA *rsa;
187  const BIGNUM *n, *e, *d, *p, *q, *dmp1, *dmq1, *iqmp;
188 
189  GetRSA(self, rsa);
190 
191  RSA_get0_key(rsa, &n, &e, &d);
192  RSA_get0_factors(rsa, &p, &q);
193  RSA_get0_crt_params(rsa, &dmp1, &dmq1, &iqmp);
194 
195  return n && e && d && p && q && dmp1 && dmq1 && iqmp;
196 }
197 
198 /*
199  * call-seq:
200  * rsa.export([cipher, pass_phrase]) => PEM-format String
201  * rsa.to_pem([cipher, pass_phrase]) => PEM-format String
202  * rsa.to_s([cipher, pass_phrase]) => PEM-format String
203  *
204  * Outputs this keypair in PEM encoding. If _cipher_ and _pass_phrase_ are
205  * given they will be used to encrypt the key. _cipher_ must be an
206  * OpenSSL::Cipher instance.
207  */
208 static VALUE
209 ossl_rsa_export(int argc, VALUE *argv, VALUE self)
210 {
211  if (can_export_rsaprivatekey(self))
212  return ossl_pkey_export_traditional(argc, argv, self, 0);
213  else
214  return ossl_pkey_export_spki(self, 0);
215 }
216 
217 /*
218  * call-seq:
219  * rsa.to_der => DER-format String
220  *
221  * Outputs this keypair in DER encoding.
222  */
223 static VALUE
224 ossl_rsa_to_der(VALUE self)
225 {
226  if (can_export_rsaprivatekey(self))
227  return ossl_pkey_export_traditional(0, NULL, self, 1);
228  else
229  return ossl_pkey_export_spki(self, 1);
230 }
231 
232 /*
233  * call-seq:
234  * rsa.sign_pss(digest, data, salt_length:, mgf1_hash:) -> String
235  *
236  * Signs _data_ using the Probabilistic Signature Scheme (RSA-PSS) and returns
237  * the calculated signature.
238  *
239  * RSAError will be raised if an error occurs.
240  *
241  * See #verify_pss for the verification operation.
242  *
243  * === Parameters
244  * _digest_::
245  * A String containing the message digest algorithm name.
246  * _data_::
247  * A String. The data to be signed.
248  * _salt_length_::
249  * The length in octets of the salt. Two special values are reserved:
250  * +:digest+ means the digest length, and +:max+ means the maximum possible
251  * length for the combination of the private key and the selected message
252  * digest algorithm.
253  * _mgf1_hash_::
254  * The hash algorithm used in MGF1 (the currently supported mask generation
255  * function (MGF)).
256  *
257  * === Example
258  * data = "Sign me!"
259  * pkey = OpenSSL::PKey::RSA.new(2048)
260  * signature = pkey.sign_pss("SHA256", data, salt_length: :max, mgf1_hash: "SHA256")
261  * pub_key = OpenSSL::PKey.read(pkey.public_to_der)
262  * puts pub_key.verify_pss("SHA256", signature, data,
263  * salt_length: :auto, mgf1_hash: "SHA256") # => true
264  */
265 static VALUE
266 ossl_rsa_sign_pss(int argc, VALUE *argv, VALUE self)
267 {
268  VALUE digest, data, options, kwargs[2], signature;
269  static ID kwargs_ids[2];
270  EVP_PKEY *pkey;
271  EVP_PKEY_CTX *pkey_ctx;
272  const EVP_MD *md, *mgf1md;
273  EVP_MD_CTX *md_ctx;
274  size_t buf_len;
275  int salt_len;
276 
277  if (!kwargs_ids[0]) {
278  kwargs_ids[0] = rb_intern_const("salt_length");
279  kwargs_ids[1] = rb_intern_const("mgf1_hash");
280  }
281  rb_scan_args(argc, argv, "2:", &digest, &data, &options);
282  rb_get_kwargs(options, kwargs_ids, 2, 0, kwargs);
283  if (kwargs[0] == ID2SYM(rb_intern("max")))
284  salt_len = -2; /* RSA_PSS_SALTLEN_MAX_SIGN */
285  else if (kwargs[0] == ID2SYM(rb_intern("digest")))
286  salt_len = -1; /* RSA_PSS_SALTLEN_DIGEST */
287  else
288  salt_len = NUM2INT(kwargs[0]);
289  mgf1md = ossl_evp_get_digestbyname(kwargs[1]);
290 
291  pkey = GetPrivPKeyPtr(self);
292  buf_len = EVP_PKEY_size(pkey);
293  md = ossl_evp_get_digestbyname(digest);
294  StringValue(data);
295  signature = rb_str_new(NULL, (long)buf_len);
296 
297  md_ctx = EVP_MD_CTX_new();
298  if (!md_ctx)
299  goto err;
300 
301  if (EVP_DigestSignInit(md_ctx, &pkey_ctx, md, NULL, pkey) != 1)
302  goto err;
303 
304  if (EVP_PKEY_CTX_set_rsa_padding(pkey_ctx, RSA_PKCS1_PSS_PADDING) != 1)
305  goto err;
306 
307  if (EVP_PKEY_CTX_set_rsa_pss_saltlen(pkey_ctx, salt_len) != 1)
308  goto err;
309 
310  if (EVP_PKEY_CTX_set_rsa_mgf1_md(pkey_ctx, mgf1md) != 1)
311  goto err;
312 
313  if (EVP_DigestSignUpdate(md_ctx, RSTRING_PTR(data), RSTRING_LEN(data)) != 1)
314  goto err;
315 
316  if (EVP_DigestSignFinal(md_ctx, (unsigned char *)RSTRING_PTR(signature), &buf_len) != 1)
317  goto err;
318 
319  rb_str_set_len(signature, (long)buf_len);
320 
321  EVP_MD_CTX_free(md_ctx);
322  return signature;
323 
324  err:
325  EVP_MD_CTX_free(md_ctx);
327 }
328 
329 /*
330  * call-seq:
331  * rsa.verify_pss(digest, signature, data, salt_length:, mgf1_hash:) -> true | false
332  *
333  * Verifies _data_ using the Probabilistic Signature Scheme (RSA-PSS).
334  *
335  * The return value is +true+ if the signature is valid, +false+ otherwise.
336  * RSAError will be raised if an error occurs.
337  *
338  * See #sign_pss for the signing operation and an example code.
339  *
340  * === Parameters
341  * _digest_::
342  * A String containing the message digest algorithm name.
343  * _data_::
344  * A String. The data to be signed.
345  * _salt_length_::
346  * The length in octets of the salt. Two special values are reserved:
347  * +:digest+ means the digest length, and +:auto+ means automatically
348  * determining the length based on the signature.
349  * _mgf1_hash_::
350  * The hash algorithm used in MGF1.
351  */
352 static VALUE
353 ossl_rsa_verify_pss(int argc, VALUE *argv, VALUE self)
354 {
355  VALUE digest, signature, data, options, kwargs[2];
356  static ID kwargs_ids[2];
357  EVP_PKEY *pkey;
358  EVP_PKEY_CTX *pkey_ctx;
359  const EVP_MD *md, *mgf1md;
360  EVP_MD_CTX *md_ctx;
361  int result, salt_len;
362 
363  if (!kwargs_ids[0]) {
364  kwargs_ids[0] = rb_intern_const("salt_length");
365  kwargs_ids[1] = rb_intern_const("mgf1_hash");
366  }
367  rb_scan_args(argc, argv, "3:", &digest, &signature, &data, &options);
368  rb_get_kwargs(options, kwargs_ids, 2, 0, kwargs);
369  if (kwargs[0] == ID2SYM(rb_intern("auto")))
370  salt_len = -2; /* RSA_PSS_SALTLEN_AUTO */
371  else if (kwargs[0] == ID2SYM(rb_intern("digest")))
372  salt_len = -1; /* RSA_PSS_SALTLEN_DIGEST */
373  else
374  salt_len = NUM2INT(kwargs[0]);
375  mgf1md = ossl_evp_get_digestbyname(kwargs[1]);
376 
377  GetPKey(self, pkey);
378  md = ossl_evp_get_digestbyname(digest);
379  StringValue(signature);
380  StringValue(data);
381 
382  md_ctx = EVP_MD_CTX_new();
383  if (!md_ctx)
384  goto err;
385 
386  if (EVP_DigestVerifyInit(md_ctx, &pkey_ctx, md, NULL, pkey) != 1)
387  goto err;
388 
389  if (EVP_PKEY_CTX_set_rsa_padding(pkey_ctx, RSA_PKCS1_PSS_PADDING) != 1)
390  goto err;
391 
392  if (EVP_PKEY_CTX_set_rsa_pss_saltlen(pkey_ctx, salt_len) != 1)
393  goto err;
394 
395  if (EVP_PKEY_CTX_set_rsa_mgf1_md(pkey_ctx, mgf1md) != 1)
396  goto err;
397 
398  if (EVP_DigestVerifyUpdate(md_ctx, RSTRING_PTR(data), RSTRING_LEN(data)) != 1)
399  goto err;
400 
401  result = EVP_DigestVerifyFinal(md_ctx,
402  (unsigned char *)RSTRING_PTR(signature),
403  RSTRING_LEN(signature));
404 
405  switch (result) {
406  case 0:
408  EVP_MD_CTX_free(md_ctx);
409  return Qfalse;
410  case 1:
411  EVP_MD_CTX_free(md_ctx);
412  return Qtrue;
413  default:
414  goto err;
415  }
416 
417  err:
418  EVP_MD_CTX_free(md_ctx);
420 }
421 
422 /*
423  * call-seq:
424  * rsa.params => hash
425  *
426  * THIS METHOD IS INSECURE, PRIVATE INFORMATION CAN LEAK OUT!!!
427  *
428  * Stores all parameters of key to the hash. The hash has keys 'n', 'e', 'd',
429  * 'p', 'q', 'dmp1', 'dmq1', 'iqmp'.
430  *
431  * Don't use :-)) (It's up to you)
432  */
433 static VALUE
434 ossl_rsa_get_params(VALUE self)
435 {
436  RSA *rsa;
437  VALUE hash;
438  const BIGNUM *n, *e, *d, *p, *q, *dmp1, *dmq1, *iqmp;
439 
440  GetRSA(self, rsa);
441  RSA_get0_key(rsa, &n, &e, &d);
442  RSA_get0_factors(rsa, &p, &q);
443  RSA_get0_crt_params(rsa, &dmp1, &dmq1, &iqmp);
444 
445  hash = rb_hash_new();
446  rb_hash_aset(hash, rb_str_new2("n"), ossl_bn_new(n));
447  rb_hash_aset(hash, rb_str_new2("e"), ossl_bn_new(e));
448  rb_hash_aset(hash, rb_str_new2("d"), ossl_bn_new(d));
449  rb_hash_aset(hash, rb_str_new2("p"), ossl_bn_new(p));
450  rb_hash_aset(hash, rb_str_new2("q"), ossl_bn_new(q));
451  rb_hash_aset(hash, rb_str_new2("dmp1"), ossl_bn_new(dmp1));
452  rb_hash_aset(hash, rb_str_new2("dmq1"), ossl_bn_new(dmq1));
453  rb_hash_aset(hash, rb_str_new2("iqmp"), ossl_bn_new(iqmp));
454 
455  return hash;
456 }
457 
458 /*
459  * Document-method: OpenSSL::PKey::RSA#set_key
460  * call-seq:
461  * rsa.set_key(n, e, d) -> self
462  *
463  * Sets _n_, _e_, _d_ for the RSA instance.
464  */
465 OSSL_PKEY_BN_DEF3(rsa, RSA, key, n, e, d)
466 /*
467  * Document-method: OpenSSL::PKey::RSA#set_factors
468  * call-seq:
469  * rsa.set_factors(p, q) -> self
470  *
471  * Sets _p_, _q_ for the RSA instance.
472  */
473 OSSL_PKEY_BN_DEF2(rsa, RSA, factors, p, q)
474 /*
475  * Document-method: OpenSSL::PKey::RSA#set_crt_params
476  * call-seq:
477  * rsa.set_crt_params(dmp1, dmq1, iqmp) -> self
478  *
479  * Sets _dmp1_, _dmq1_, _iqmp_ for the RSA instance. They are calculated by
480  * <tt>d mod (p - 1)</tt>, <tt>d mod (q - 1)</tt> and <tt>q^(-1) mod p</tt>
481  * respectively.
482  */
483 OSSL_PKEY_BN_DEF3(rsa, RSA, crt_params, dmp1, dmq1, iqmp)
484 
485 /*
486  * INIT
487  */
488 #define DefRSAConst(x) rb_define_const(cRSA, #x, INT2NUM(RSA_##x))
489 
490 void
492 {
493 #if 0
497 #endif
498 
499  /* Document-class: OpenSSL::PKey::RSAError
500  *
501  * Generic exception that is raised if an operation on an RSA PKey
502  * fails unexpectedly or in case an instantiation of an instance of RSA
503  * fails due to non-conformant input data.
504  */
506 
507  /* Document-class: OpenSSL::PKey::RSA
508  *
509  * RSA is an asymmetric public key algorithm that has been formalized in
510  * RFC 3447. It is in widespread use in public key infrastructures (PKI)
511  * where certificates (cf. OpenSSL::X509::Certificate) often are issued
512  * on the basis of a public/private RSA key pair. RSA is used in a wide
513  * field of applications such as secure (symmetric) key exchange, e.g.
514  * when establishing a secure TLS/SSL connection. It is also used in
515  * various digital signature schemes.
516  */
518 
519  rb_define_method(cRSA, "initialize", ossl_rsa_initialize, -1);
520  rb_define_method(cRSA, "initialize_copy", ossl_rsa_initialize_copy, 1);
521 
522  rb_define_method(cRSA, "public?", ossl_rsa_is_public, 0);
523  rb_define_method(cRSA, "private?", ossl_rsa_is_private, 0);
524  rb_define_method(cRSA, "export", ossl_rsa_export, -1);
525  rb_define_alias(cRSA, "to_pem", "export");
526  rb_define_alias(cRSA, "to_s", "export");
527  rb_define_method(cRSA, "to_der", ossl_rsa_to_der, 0);
528  rb_define_method(cRSA, "sign_pss", ossl_rsa_sign_pss, -1);
529  rb_define_method(cRSA, "verify_pss", ossl_rsa_verify_pss, -1);
530 
531  DEF_OSSL_PKEY_BN(cRSA, rsa, n);
532  DEF_OSSL_PKEY_BN(cRSA, rsa, e);
533  DEF_OSSL_PKEY_BN(cRSA, rsa, d);
534  DEF_OSSL_PKEY_BN(cRSA, rsa, p);
535  DEF_OSSL_PKEY_BN(cRSA, rsa, q);
536  DEF_OSSL_PKEY_BN(cRSA, rsa, dmp1);
537  DEF_OSSL_PKEY_BN(cRSA, rsa, dmq1);
538  DEF_OSSL_PKEY_BN(cRSA, rsa, iqmp);
539  rb_define_method(cRSA, "set_key", ossl_rsa_set_key, 3);
540  rb_define_method(cRSA, "set_factors", ossl_rsa_set_factors, 2);
541  rb_define_method(cRSA, "set_crt_params", ossl_rsa_set_crt_params, 3);
542 
543  rb_define_method(cRSA, "params", ossl_rsa_get_params, 0);
544 
545 /*
546  * TODO: Test it
547  rb_define_method(cRSA, "blinding_on!", ossl_rsa_blinding_on, 0);
548  rb_define_method(cRSA, "blinding_off!", ossl_rsa_blinding_off, 0);
549  */
550 }
551 
552 #else /* defined NO_RSA */
553 void
554 Init_ossl_rsa(void)
555 {
556 }
557 #endif /* NO_RSA */
ossl_pkey_export_traditional
VALUE ossl_pkey_export_traditional(int argc, VALUE *argv, VALUE self, int to_der)
Definition: ossl_pkey.c:580
rb_get_kwargs
int rb_get_kwargs(VALUE keyword_hash, const ID *table, int required, int optional, VALUE *values)
Definition: class.c:2136
OSSL_PKEY_BN_DEF3
#define OSSL_PKEY_BN_DEF3(_keytype, _type, _group, a1, a2, a3)
Definition: ossl_pkey.h:176
rb_hash_new
VALUE rb_hash_new(void)
Definition: hash.c:1526
StringValue
#define StringValue(v)
Definition: rstring.h:50
rb_define_module_under
VALUE rb_define_module_under(VALUE outer, const char *name)
Definition: class.c:914
rb_intern
ID rb_intern(const char *)
Definition: symbol.c:784
ossl_to_der_if_possible
VALUE ossl_to_der_if_possible(VALUE obj)
Definition: ossl.c:261
ossl_pkey_export_spki
VALUE ossl_pkey_export_spki(VALUE self, int to_der)
Definition: ossl_pkey.c:695
ePKeyError
VALUE ePKeyError
Definition: ossl_pkey.c:17
ossl_obj2bio
BIO * ossl_obj2bio(volatile VALUE *pobj)
Definition: ossl_bio.c:13
OSSL_BIO_reset
#define OSSL_BIO_reset(bio)
Definition: ossl.h:115
ossl.h
rb_str_set_len
void rb_str_set_len(VALUE, long)
Definition: string.c:2833
argv
char ** argv
Definition: ruby.c:243
ID
unsigned long ID
Definition: value.h:39
ossl_clear_error
void ossl_clear_error(void)
Definition: ossl.c:310
cPKey
VALUE cPKey
Definition: ossl_pkey.c:16
NUM2INT
#define NUM2INT
Definition: int.h:44
RSTRING_LEN
#define RSTRING_LEN(string)
Definition: fbuffer.h:22
pkey_blocking_generate_arg::pkey
EVP_PKEY * pkey
Definition: ossl_pkey.c:180
OSSL_PKEY_BN_DEF2
#define OSSL_PKEY_BN_DEF2(_keytype, _type, _group, a1, a2)
Definition: ossl_pkey.h:180
rb_define_alias
void rb_define_alias(VALUE klass, const char *name1, const char *name2)
Defines an alias of a method.
Definition: class.c:2050
GetRSA
#define GetRSA(obj, rsa)
Definition: ossl_pkey_rsa.c:20
rb_str_new
#define rb_str_new(str, len)
Definition: string.h:213
rb_raise
void rb_raise(VALUE exc, const char *fmt,...)
Definition: error.c:3022
DEF_OSSL_PKEY_BN
#define DEF_OSSL_PKEY_BN(class, keytype, name)
Definition: ossl_pkey.h:184
eRSAError
VALUE eRSAError
Definition: ossl_pkey_rsa.c:45
mOSSL
VALUE mOSSL
Definition: ossl.c:237
rb_cObject
VALUE rb_cObject
Object class.
Definition: object.c:50
Qfalse
#define Qfalse
Definition: special_consts.h:50
ossl_pem_passwd_value
VALUE ossl_pem_passwd_value(VALUE pass)
Definition: ossl.c:157
GetPKey
#define GetPKey(obj, pkey)
Definition: ossl_pkey.h:31
ossl_bn_new
VALUE ossl_bn_new(const BIGNUM *bn)
Definition: ossl_bn.c:62
Init_ossl_rsa
void Init_ossl_rsa(void)
Definition: ossl_pkey_rsa.c:491
ossl_raise
void ossl_raise(VALUE exc, const char *fmt,...)
Definition: ossl.c:299
NULL
#define NULL
Definition: regenc.h:69
rb_scan_args
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
Definition: class.c:2347
key
key
Definition: openssl_missing.h:145
Qtrue
#define Qtrue
Definition: special_consts.h:52
OSSL_PKEY_IS_PRIVATE
#define OSSL_PKEY_IS_PRIVATE(obj)
Definition: ossl_pkey.h:20
VALUE
unsigned long VALUE
Definition: value.h:38
EVP_MD_CTX_free
#define EVP_MD_CTX_free
Definition: openssl_missing.h:21
mPKey
VALUE mPKey
Definition: ossl_pkey.c:15
cRSA
VALUE cRSA
Definition: ossl_pkey_rsa.c:44
RSTRING_PTR
#define RSTRING_PTR(string)
Definition: fbuffer.h:19
rb_hash_aset
VALUE rb_hash_aset(VALUE hash, VALUE key, VALUE val)
Definition: hash.c:2892
argc
int argc
Definition: ruby.c:242
rb_str_new2
#define rb_str_new2
Definition: string.h:276
err
int err
Definition: win32.c:143
ID2SYM
#define ID2SYM
Definition: symbol.h:44
eOSSLError
VALUE eOSSLError
Definition: ossl.c:242
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:809
rb_define_method
#define rb_define_method(klass, mid, func, arity)
Defines klass#mid.
Definition: cxxanyargs.hpp:655
GetPrivPKeyPtr
EVP_PKEY * GetPrivPKeyPtr(VALUE obj)
Definition: ossl_pkey.c:442
ossl_evp_get_digestbyname
const EVP_MD * ossl_evp_get_digestbyname(VALUE obj)
Definition: ossl_digest.c:45
EVP_MD_CTX_new
#define EVP_MD_CTX_new
Definition: openssl_missing.h:17
ossl_pkey_read_generic
EVP_PKEY * ossl_pkey_read_generic(BIO *bio, VALUE pass)
Definition: ossl_pkey.c:82