openssl 3.3.1 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +3 -0
  3. data/History.md +107 -0
  4. data/README.md +12 -11
  5. data/ext/openssl/extconf.rb +30 -69
  6. data/ext/openssl/openssl_missing.h +0 -206
  7. data/ext/openssl/ossl.c +280 -301
  8. data/ext/openssl/ossl.h +15 -10
  9. data/ext/openssl/ossl_asn1.c +598 -406
  10. data/ext/openssl/ossl_asn1.h +15 -1
  11. data/ext/openssl/ossl_bio.c +3 -3
  12. data/ext/openssl/ossl_bn.c +286 -291
  13. data/ext/openssl/ossl_cipher.c +252 -203
  14. data/ext/openssl/ossl_cipher.h +10 -1
  15. data/ext/openssl/ossl_config.c +1 -6
  16. data/ext/openssl/ossl_digest.c +74 -43
  17. data/ext/openssl/ossl_digest.h +9 -1
  18. data/ext/openssl/ossl_engine.c +39 -103
  19. data/ext/openssl/ossl_hmac.c +30 -36
  20. data/ext/openssl/ossl_kdf.c +42 -53
  21. data/ext/openssl/ossl_ns_spki.c +31 -37
  22. data/ext/openssl/ossl_ocsp.c +214 -241
  23. data/ext/openssl/ossl_pkcs12.c +26 -26
  24. data/ext/openssl/ossl_pkcs7.c +175 -145
  25. data/ext/openssl/ossl_pkey.c +162 -178
  26. data/ext/openssl/ossl_pkey.h +99 -99
  27. data/ext/openssl/ossl_pkey_dh.c +32 -67
  28. data/ext/openssl/ossl_pkey_dsa.c +16 -53
  29. data/ext/openssl/ossl_pkey_ec.c +180 -236
  30. data/ext/openssl/ossl_pkey_rsa.c +57 -102
  31. data/ext/openssl/ossl_provider.c +0 -7
  32. data/ext/openssl/ossl_rand.c +7 -14
  33. data/ext/openssl/ossl_ssl.c +478 -353
  34. data/ext/openssl/ossl_ssl.h +8 -8
  35. data/ext/openssl/ossl_ssl_session.c +93 -97
  36. data/ext/openssl/ossl_ts.c +81 -127
  37. data/ext/openssl/ossl_x509.c +9 -28
  38. data/ext/openssl/ossl_x509attr.c +33 -54
  39. data/ext/openssl/ossl_x509cert.c +69 -100
  40. data/ext/openssl/ossl_x509crl.c +78 -89
  41. data/ext/openssl/ossl_x509ext.c +45 -66
  42. data/ext/openssl/ossl_x509name.c +63 -88
  43. data/ext/openssl/ossl_x509req.c +55 -62
  44. data/ext/openssl/ossl_x509revoked.c +27 -41
  45. data/ext/openssl/ossl_x509store.c +38 -56
  46. data/lib/openssl/buffering.rb +30 -24
  47. data/lib/openssl/digest.rb +1 -1
  48. data/lib/openssl/pkey.rb +71 -49
  49. data/lib/openssl/ssl.rb +12 -79
  50. data/lib/openssl/version.rb +2 -1
  51. data/lib/openssl/x509.rb +9 -0
  52. data/lib/openssl.rb +9 -6
  53. metadata +1 -3
  54. data/ext/openssl/openssl_missing.c +0 -40
  55. data/lib/openssl/asn1.rb +0 -188
@@ -14,13 +14,15 @@
14
14
  #define GetPKeyRSA(obj, pkey) do { \
15
15
  GetPKey((obj), (pkey)); \
16
16
  if (EVP_PKEY_base_id(pkey) != EVP_PKEY_RSA) { /* PARANOIA? */ \
17
- ossl_raise(rb_eRuntimeError, "THIS IS NOT A RSA!") ; \
17
+ ossl_raise(rb_eRuntimeError, "THIS IS NOT A RSA!") ; \
18
18
  } \
19
19
  } while (0)
20
20
  #define GetRSA(obj, rsa) do { \
21
21
  EVP_PKEY *_pkey; \
22
22
  GetPKeyRSA((obj), _pkey); \
23
23
  (rsa) = EVP_PKEY_get0_RSA(_pkey); \
24
+ if ((rsa) == NULL) \
25
+ ossl_raise(ePKeyError, "failed to get RSA from EVP_PKEY"); \
24
26
  } while (0)
25
27
 
26
28
  static inline int
@@ -42,7 +44,6 @@ RSA_PRIVATE(VALUE obj, OSSL_3_const RSA *rsa)
42
44
  * Classes
43
45
  */
44
46
  VALUE cRSA;
45
- static VALUE eRSAError;
46
47
 
47
48
  /*
48
49
  * Private
@@ -59,6 +60,7 @@ static VALUE eRSAError;
59
60
  * If called without arguments, creates a new instance with no key components
60
61
  * set. They can be set individually by #set_key, #set_factors, and
61
62
  * #set_crt_params.
63
+ * This form is not compatible with OpenSSL 3.0 or later.
62
64
  *
63
65
  * If called with a String, tries to parse as DER or PEM encoding of an \RSA key.
64
66
  * Note that if _password_ is not specified, but the key is encrypted with a
@@ -89,10 +91,15 @@ ossl_rsa_initialize(int argc, VALUE *argv, VALUE self)
89
91
  /* The RSA.new(size, generator) form is handled by lib/openssl/pkey.rb */
90
92
  rb_scan_args(argc, argv, "02", &arg, &pass);
91
93
  if (argc == 0) {
92
- rsa = RSA_new();
94
+ #ifdef OSSL_HAVE_IMMUTABLE_PKEY
95
+ rb_raise(rb_eArgError, "OpenSSL::PKey::RSA.new cannot be called " \
96
+ "without arguments; pkeys are immutable with OpenSSL 3.0");
97
+ #else
98
+ rsa = RSA_new();
93
99
  if (!rsa)
94
- ossl_raise(eRSAError, "RSA_new");
100
+ ossl_raise(ePKeyError, "RSA_new");
95
101
  goto legacy;
102
+ #endif
96
103
  }
97
104
 
98
105
  pass = ossl_pem_passwd_value(pass);
@@ -113,12 +120,12 @@ ossl_rsa_initialize(int argc, VALUE *argv, VALUE self)
113
120
  pkey = ossl_pkey_read_generic(in, pass);
114
121
  BIO_free(in);
115
122
  if (!pkey)
116
- ossl_raise(eRSAError, "Neither PUB key nor PRIV key");
123
+ ossl_raise(ePKeyError, "Neither PUB key nor PRIV key");
117
124
 
118
125
  type = EVP_PKEY_base_id(pkey);
119
126
  if (type != EVP_PKEY_RSA) {
120
127
  EVP_PKEY_free(pkey);
121
- rb_raise(eRSAError, "incorrect pkey type: %s", OBJ_nid2sn(type));
128
+ rb_raise(ePKeyError, "incorrect pkey type: %s", OBJ_nid2sn(type));
122
129
  }
123
130
  RTYPEDDATA_DATA(self) = pkey;
124
131
  return self;
@@ -129,13 +136,14 @@ ossl_rsa_initialize(int argc, VALUE *argv, VALUE self)
129
136
  if (!pkey || EVP_PKEY_assign_RSA(pkey, rsa) != 1) {
130
137
  EVP_PKEY_free(pkey);
131
138
  RSA_free(rsa);
132
- ossl_raise(eRSAError, "EVP_PKEY_assign_RSA");
139
+ ossl_raise(ePKeyError, "EVP_PKEY_assign_RSA");
133
140
  }
134
141
  RTYPEDDATA_DATA(self) = pkey;
135
142
  return self;
136
143
  }
137
144
 
138
145
  #ifndef HAVE_EVP_PKEY_DUP
146
+ /* :nodoc: */
139
147
  static VALUE
140
148
  ossl_rsa_initialize_copy(VALUE self, VALUE other)
141
149
  {
@@ -151,12 +159,12 @@ ossl_rsa_initialize_copy(VALUE self, VALUE other)
151
159
  (d2i_of_void *)d2i_RSAPrivateKey,
152
160
  (char *)rsa);
153
161
  if (!rsa_new)
154
- ossl_raise(eRSAError, "ASN1_dup");
162
+ ossl_raise(ePKeyError, "ASN1_dup");
155
163
 
156
164
  pkey = EVP_PKEY_new();
157
165
  if (!pkey || EVP_PKEY_assign_RSA(pkey, rsa_new) != 1) {
158
166
  RSA_free(rsa_new);
159
- ossl_raise(eRSAError, "EVP_PKEY_assign_RSA");
167
+ ossl_raise(ePKeyError, "EVP_PKEY_assign_RSA");
160
168
  }
161
169
  RTYPEDDATA_DATA(self) = pkey;
162
170
 
@@ -311,7 +319,7 @@ ossl_rsa_to_der(VALUE self)
311
319
  * Signs _data_ using the Probabilistic Signature Scheme (RSA-PSS) and returns
312
320
  * the calculated signature.
313
321
  *
314
- * RSAError will be raised if an error occurs.
322
+ * PKeyError will be raised if an error occurs.
315
323
  *
316
324
  * See #verify_pss for the verification operation.
317
325
  *
@@ -340,7 +348,7 @@ ossl_rsa_to_der(VALUE self)
340
348
  static VALUE
341
349
  ossl_rsa_sign_pss(int argc, VALUE *argv, VALUE self)
342
350
  {
343
- VALUE digest, data, options, kwargs[2], signature;
351
+ VALUE digest, data, options, kwargs[2], signature, mgf1md_holder, md_holder;
344
352
  static ID kwargs_ids[2];
345
353
  EVP_PKEY *pkey;
346
354
  EVP_PKEY_CTX *pkey_ctx;
@@ -350,46 +358,46 @@ ossl_rsa_sign_pss(int argc, VALUE *argv, VALUE self)
350
358
  int salt_len;
351
359
 
352
360
  if (!kwargs_ids[0]) {
353
- kwargs_ids[0] = rb_intern_const("salt_length");
354
- kwargs_ids[1] = rb_intern_const("mgf1_hash");
361
+ kwargs_ids[0] = rb_intern_const("salt_length");
362
+ kwargs_ids[1] = rb_intern_const("mgf1_hash");
355
363
  }
356
364
  rb_scan_args(argc, argv, "2:", &digest, &data, &options);
357
365
  rb_get_kwargs(options, kwargs_ids, 2, 0, kwargs);
358
366
  if (kwargs[0] == ID2SYM(rb_intern("max")))
359
- salt_len = -2; /* RSA_PSS_SALTLEN_MAX_SIGN */
367
+ salt_len = -2; /* RSA_PSS_SALTLEN_MAX_SIGN */
360
368
  else if (kwargs[0] == ID2SYM(rb_intern("digest")))
361
- salt_len = -1; /* RSA_PSS_SALTLEN_DIGEST */
369
+ salt_len = -1; /* RSA_PSS_SALTLEN_DIGEST */
362
370
  else
363
- salt_len = NUM2INT(kwargs[0]);
364
- mgf1md = ossl_evp_get_digestbyname(kwargs[1]);
371
+ salt_len = NUM2INT(kwargs[0]);
372
+ mgf1md = ossl_evp_md_fetch(kwargs[1], &mgf1md_holder);
365
373
 
366
374
  pkey = GetPrivPKeyPtr(self);
367
375
  buf_len = EVP_PKEY_size(pkey);
368
- md = ossl_evp_get_digestbyname(digest);
376
+ md = ossl_evp_md_fetch(digest, &md_holder);
369
377
  StringValue(data);
370
378
  signature = rb_str_new(NULL, (long)buf_len);
371
379
 
372
380
  md_ctx = EVP_MD_CTX_new();
373
381
  if (!md_ctx)
374
- goto err;
382
+ goto err;
375
383
 
376
384
  if (EVP_DigestSignInit(md_ctx, &pkey_ctx, md, NULL, pkey) != 1)
377
- goto err;
385
+ goto err;
378
386
 
379
387
  if (EVP_PKEY_CTX_set_rsa_padding(pkey_ctx, RSA_PKCS1_PSS_PADDING) != 1)
380
- goto err;
388
+ goto err;
381
389
 
382
390
  if (EVP_PKEY_CTX_set_rsa_pss_saltlen(pkey_ctx, salt_len) != 1)
383
- goto err;
391
+ goto err;
384
392
 
385
393
  if (EVP_PKEY_CTX_set_rsa_mgf1_md(pkey_ctx, mgf1md) != 1)
386
- goto err;
394
+ goto err;
387
395
 
388
396
  if (EVP_DigestSignUpdate(md_ctx, RSTRING_PTR(data), RSTRING_LEN(data)) != 1)
389
- goto err;
397
+ goto err;
390
398
 
391
399
  if (EVP_DigestSignFinal(md_ctx, (unsigned char *)RSTRING_PTR(signature), &buf_len) != 1)
392
- goto err;
400
+ goto err;
393
401
 
394
402
  rb_str_set_len(signature, (long)buf_len);
395
403
 
@@ -398,7 +406,7 @@ ossl_rsa_sign_pss(int argc, VALUE *argv, VALUE self)
398
406
 
399
407
  err:
400
408
  EVP_MD_CTX_free(md_ctx);
401
- ossl_raise(eRSAError, NULL);
409
+ ossl_raise(ePKeyError, NULL);
402
410
  }
403
411
 
404
412
  /*
@@ -408,7 +416,7 @@ ossl_rsa_sign_pss(int argc, VALUE *argv, VALUE self)
408
416
  * Verifies _data_ using the Probabilistic Signature Scheme (RSA-PSS).
409
417
  *
410
418
  * The return value is +true+ if the signature is valid, +false+ otherwise.
411
- * RSAError will be raised if an error occurs.
419
+ * PKeyError will be raised if an error occurs.
412
420
  *
413
421
  * See #sign_pss for the signing operation and an example code.
414
422
  *
@@ -427,7 +435,7 @@ ossl_rsa_sign_pss(int argc, VALUE *argv, VALUE self)
427
435
  static VALUE
428
436
  ossl_rsa_verify_pss(int argc, VALUE *argv, VALUE self)
429
437
  {
430
- VALUE digest, signature, data, options, kwargs[2];
438
+ VALUE digest, signature, data, options, kwargs[2], mgf1md_holder, md_holder;
431
439
  static ID kwargs_ids[2];
432
440
  EVP_PKEY *pkey;
433
441
  EVP_PKEY_CTX *pkey_ctx;
@@ -436,98 +444,61 @@ ossl_rsa_verify_pss(int argc, VALUE *argv, VALUE self)
436
444
  int result, salt_len;
437
445
 
438
446
  if (!kwargs_ids[0]) {
439
- kwargs_ids[0] = rb_intern_const("salt_length");
440
- kwargs_ids[1] = rb_intern_const("mgf1_hash");
447
+ kwargs_ids[0] = rb_intern_const("salt_length");
448
+ kwargs_ids[1] = rb_intern_const("mgf1_hash");
441
449
  }
442
450
  rb_scan_args(argc, argv, "3:", &digest, &signature, &data, &options);
443
451
  rb_get_kwargs(options, kwargs_ids, 2, 0, kwargs);
444
452
  if (kwargs[0] == ID2SYM(rb_intern("auto")))
445
- salt_len = -2; /* RSA_PSS_SALTLEN_AUTO */
453
+ salt_len = -2; /* RSA_PSS_SALTLEN_AUTO */
446
454
  else if (kwargs[0] == ID2SYM(rb_intern("digest")))
447
- salt_len = -1; /* RSA_PSS_SALTLEN_DIGEST */
455
+ salt_len = -1; /* RSA_PSS_SALTLEN_DIGEST */
448
456
  else
449
- salt_len = NUM2INT(kwargs[0]);
450
- mgf1md = ossl_evp_get_digestbyname(kwargs[1]);
457
+ salt_len = NUM2INT(kwargs[0]);
458
+ mgf1md = ossl_evp_md_fetch(kwargs[1], &mgf1md_holder);
451
459
 
452
460
  GetPKey(self, pkey);
453
- md = ossl_evp_get_digestbyname(digest);
461
+ md = ossl_evp_md_fetch(digest, &md_holder);
454
462
  StringValue(signature);
455
463
  StringValue(data);
456
464
 
457
465
  md_ctx = EVP_MD_CTX_new();
458
466
  if (!md_ctx)
459
- goto err;
467
+ goto err;
460
468
 
461
469
  if (EVP_DigestVerifyInit(md_ctx, &pkey_ctx, md, NULL, pkey) != 1)
462
- goto err;
470
+ goto err;
463
471
 
464
472
  if (EVP_PKEY_CTX_set_rsa_padding(pkey_ctx, RSA_PKCS1_PSS_PADDING) != 1)
465
- goto err;
473
+ goto err;
466
474
 
467
475
  if (EVP_PKEY_CTX_set_rsa_pss_saltlen(pkey_ctx, salt_len) != 1)
468
- goto err;
476
+ goto err;
469
477
 
470
478
  if (EVP_PKEY_CTX_set_rsa_mgf1_md(pkey_ctx, mgf1md) != 1)
471
- goto err;
479
+ goto err;
472
480
 
473
481
  if (EVP_DigestVerifyUpdate(md_ctx, RSTRING_PTR(data), RSTRING_LEN(data)) != 1)
474
- goto err;
482
+ goto err;
475
483
 
476
484
  result = EVP_DigestVerifyFinal(md_ctx,
477
- (unsigned char *)RSTRING_PTR(signature),
478
- RSTRING_LEN(signature));
485
+ (unsigned char *)RSTRING_PTR(signature),
486
+ RSTRING_LEN(signature));
487
+ EVP_MD_CTX_free(md_ctx);
479
488
 
480
489
  switch (result) {
481
490
  case 0:
482
- ossl_clear_error();
483
- EVP_MD_CTX_free(md_ctx);
484
- return Qfalse;
491
+ ossl_clear_error();
492
+ return Qfalse;
485
493
  case 1:
486
- EVP_MD_CTX_free(md_ctx);
487
- return Qtrue;
494
+ return Qtrue;
488
495
  default:
489
- goto err;
496
+ ossl_raise(ePKeyError, "EVP_DigestVerifyFinal");
490
497
  }
491
498
 
492
499
  err:
493
500
  EVP_MD_CTX_free(md_ctx);
494
- ossl_raise(eRSAError, NULL);
495
- }
496
-
497
- /*
498
- * call-seq:
499
- * rsa.params => hash
500
- *
501
- * THIS METHOD IS INSECURE, PRIVATE INFORMATION CAN LEAK OUT!!!
502
- *
503
- * Stores all parameters of key to the hash. The hash has keys 'n', 'e', 'd',
504
- * 'p', 'q', 'dmp1', 'dmq1', 'iqmp'.
505
- *
506
- * Don't use :-)) (It's up to you)
507
- */
508
- static VALUE
509
- ossl_rsa_get_params(VALUE self)
510
- {
511
- OSSL_3_const RSA *rsa;
512
- VALUE hash;
513
- const BIGNUM *n, *e, *d, *p, *q, *dmp1, *dmq1, *iqmp;
514
-
515
- GetRSA(self, rsa);
516
- RSA_get0_key(rsa, &n, &e, &d);
517
- RSA_get0_factors(rsa, &p, &q);
518
- RSA_get0_crt_params(rsa, &dmp1, &dmq1, &iqmp);
519
-
520
- hash = rb_hash_new();
521
- rb_hash_aset(hash, rb_str_new2("n"), ossl_bn_new(n));
522
- rb_hash_aset(hash, rb_str_new2("e"), ossl_bn_new(e));
523
- rb_hash_aset(hash, rb_str_new2("d"), ossl_bn_new(d));
524
- rb_hash_aset(hash, rb_str_new2("p"), ossl_bn_new(p));
525
- rb_hash_aset(hash, rb_str_new2("q"), ossl_bn_new(q));
526
- rb_hash_aset(hash, rb_str_new2("dmp1"), ossl_bn_new(dmp1));
527
- rb_hash_aset(hash, rb_str_new2("dmq1"), ossl_bn_new(dmq1));
528
- rb_hash_aset(hash, rb_str_new2("iqmp"), ossl_bn_new(iqmp));
529
-
530
- return hash;
501
+ ossl_raise(ePKeyError, NULL);
531
502
  }
532
503
 
533
504
  /*
@@ -565,20 +536,6 @@ OSSL_PKEY_BN_DEF3(rsa, RSA, crt_params, dmp1, dmq1, iqmp)
565
536
  void
566
537
  Init_ossl_rsa(void)
567
538
  {
568
- #if 0
569
- mPKey = rb_define_module_under(mOSSL, "PKey");
570
- cPKey = rb_define_class_under(mPKey, "PKey", rb_cObject);
571
- ePKeyError = rb_define_class_under(mPKey, "PKeyError", eOSSLError);
572
- #endif
573
-
574
- /* Document-class: OpenSSL::PKey::RSAError
575
- *
576
- * Generic exception that is raised if an operation on an RSA PKey
577
- * fails unexpectedly or in case an instantiation of an instance of RSA
578
- * fails due to non-conformant input data.
579
- */
580
- eRSAError = rb_define_class_under(mPKey, "RSAError", ePKeyError);
581
-
582
539
  /* Document-class: OpenSSL::PKey::RSA
583
540
  *
584
541
  * RSA is an asymmetric public key algorithm that has been formalized in
@@ -617,8 +574,6 @@ Init_ossl_rsa(void)
617
574
  rb_define_method(cRSA, "set_factors", ossl_rsa_set_factors, 2);
618
575
  rb_define_method(cRSA, "set_crt_params", ossl_rsa_set_crt_params, 3);
619
576
 
620
- rb_define_method(cRSA, "params", ossl_rsa_get_params, 0);
621
-
622
577
  /*
623
578
  * TODO: Test it
624
579
  rb_define_method(cRSA, "blinding_on!", ossl_rsa_blinding_on, 0);
@@ -5,8 +5,6 @@
5
5
  #include "ossl.h"
6
6
 
7
7
  #ifdef OSSL_USE_PROVIDER
8
- # include <openssl/provider.h>
9
-
10
8
  #define NewProvider(klass) \
11
9
  TypedData_Wrap_Struct((klass), &ossl_provider_type, 0)
12
10
  #define SetProvider(obj, provider) do { \
@@ -187,11 +185,6 @@ ossl_provider_inspect(VALUE self)
187
185
  void
188
186
  Init_ossl_provider(void)
189
187
  {
190
- #if 0
191
- mOSSL = rb_define_module("OpenSSL");
192
- eOSSLError = rb_define_class_under(mOSSL, "OpenSSLError", rb_eStandardError);
193
- #endif
194
-
195
188
  cProvider = rb_define_class_under(mOSSL, "Provider", rb_cObject);
196
189
  eProviderError = rb_define_class_under(cProvider, "ProviderError", eOSSLError);
197
190
 
@@ -68,7 +68,7 @@ static VALUE
68
68
  ossl_rand_load_file(VALUE self, VALUE filename)
69
69
  {
70
70
  if(!RAND_load_file(StringValueCStr(filename), -1)) {
71
- ossl_raise(eRandomError, NULL);
71
+ ossl_raise(eRandomError, NULL);
72
72
  }
73
73
  return Qtrue;
74
74
  }
@@ -85,14 +85,14 @@ static VALUE
85
85
  ossl_rand_write_file(VALUE self, VALUE filename)
86
86
  {
87
87
  if (RAND_write_file(StringValueCStr(filename)) == -1) {
88
- ossl_raise(eRandomError, NULL);
88
+ ossl_raise(eRandomError, NULL);
89
89
  }
90
90
  return Qtrue;
91
91
  }
92
92
 
93
93
  /*
94
94
  * call-seq:
95
- * random_bytes(length) -> string
95
+ * random_bytes(length) -> string
96
96
  *
97
97
  * Generates a String with _length_ number of cryptographically strong
98
98
  * pseudo-random bytes.
@@ -112,9 +112,9 @@ ossl_rand_bytes(VALUE self, VALUE len)
112
112
  str = rb_str_new(0, n);
113
113
  ret = RAND_bytes((unsigned char *)RSTRING_PTR(str), n);
114
114
  if (ret == 0) {
115
- ossl_raise(eRandomError, "RAND_bytes");
115
+ ossl_raise(eRandomError, "RAND_bytes");
116
116
  } else if (ret == -1) {
117
- ossl_raise(eRandomError, "RAND_bytes is not supported");
117
+ ossl_raise(eRandomError, "RAND_bytes is not supported");
118
118
  }
119
119
 
120
120
  return str;
@@ -131,7 +131,7 @@ static VALUE
131
131
  ossl_rand_egd(VALUE self, VALUE filename)
132
132
  {
133
133
  if (RAND_egd(StringValueCStr(filename)) == -1) {
134
- ossl_raise(eRandomError, NULL);
134
+ ossl_raise(eRandomError, NULL);
135
135
  }
136
136
  return Qtrue;
137
137
  }
@@ -151,7 +151,7 @@ ossl_rand_egd_bytes(VALUE self, VALUE filename, VALUE len)
151
151
  int n = NUM2INT(len);
152
152
 
153
153
  if (RAND_egd_bytes(StringValueCStr(filename), n) == -1) {
154
- ossl_raise(eRandomError, NULL);
154
+ ossl_raise(eRandomError, NULL);
155
155
  }
156
156
  return Qtrue;
157
157
  }
@@ -175,11 +175,6 @@ ossl_rand_status(VALUE self)
175
175
  void
176
176
  Init_ossl_rand(void)
177
177
  {
178
- #if 0
179
- mOSSL = rb_define_module("OpenSSL");
180
- eOSSLError = rb_define_class_under(mOSSL, "OpenSSLError", rb_eStandardError);
181
- #endif
182
-
183
178
  mRandom = rb_define_module_under(mOSSL, "Random");
184
179
 
185
180
  eRandomError = rb_define_class_under(mRandom, "RandomError", eOSSLError);
@@ -189,9 +184,7 @@ Init_ossl_rand(void)
189
184
  rb_define_module_function(mRandom, "load_random_file", ossl_rand_load_file, 1);
190
185
  rb_define_module_function(mRandom, "write_random_file", ossl_rand_write_file, 1);
191
186
  rb_define_module_function(mRandom, "random_bytes", ossl_rand_bytes, 1);
192
- #if OPENSSL_VERSION_NUMBER < 0x10101000 || defined(LIBRESSL_VERSION_NUMBER)
193
187
  rb_define_alias(rb_singleton_class(mRandom), "pseudo_bytes", "random_bytes");
194
- #endif
195
188
  #ifdef HAVE_RAND_EGD
196
189
  rb_define_module_function(mRandom, "egd", ossl_rand_egd, 1);
197
190
  rb_define_module_function(mRandom, "egd_bytes", ossl_rand_egd_bytes, 2);