openssl 3.3.2 → 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 +85 -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 +31 -68
  28. data/ext/openssl/ossl_pkey_dsa.c +15 -54
  29. data/ext/openssl/ossl_pkey_ec.c +179 -237
  30. data/ext/openssl/ossl_pkey_rsa.c +56 -103
  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,7 +14,7 @@
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 { \
@@ -22,7 +22,7 @@
22
22
  GetPKeyRSA((obj), _pkey); \
23
23
  (rsa) = EVP_PKEY_get0_RSA(_pkey); \
24
24
  if ((rsa) == NULL) \
25
- ossl_raise(eRSAError, "failed to get RSA from EVP_PKEY"); \
25
+ ossl_raise(ePKeyError, "failed to get RSA from EVP_PKEY"); \
26
26
  } while (0)
27
27
 
28
28
  static inline int
@@ -44,7 +44,6 @@ RSA_PRIVATE(VALUE obj, OSSL_3_const RSA *rsa)
44
44
  * Classes
45
45
  */
46
46
  VALUE cRSA;
47
- static VALUE eRSAError;
48
47
 
49
48
  /*
50
49
  * Private
@@ -61,6 +60,7 @@ static VALUE eRSAError;
61
60
  * If called without arguments, creates a new instance with no key components
62
61
  * set. They can be set individually by #set_key, #set_factors, and
63
62
  * #set_crt_params.
63
+ * This form is not compatible with OpenSSL 3.0 or later.
64
64
  *
65
65
  * If called with a String, tries to parse as DER or PEM encoding of an \RSA key.
66
66
  * Note that if _password_ is not specified, but the key is encrypted with a
@@ -91,10 +91,15 @@ ossl_rsa_initialize(int argc, VALUE *argv, VALUE self)
91
91
  /* The RSA.new(size, generator) form is handled by lib/openssl/pkey.rb */
92
92
  rb_scan_args(argc, argv, "02", &arg, &pass);
93
93
  if (argc == 0) {
94
- 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();
95
99
  if (!rsa)
96
- ossl_raise(eRSAError, "RSA_new");
100
+ ossl_raise(ePKeyError, "RSA_new");
97
101
  goto legacy;
102
+ #endif
98
103
  }
99
104
 
100
105
  pass = ossl_pem_passwd_value(pass);
@@ -115,12 +120,12 @@ ossl_rsa_initialize(int argc, VALUE *argv, VALUE self)
115
120
  pkey = ossl_pkey_read_generic(in, pass);
116
121
  BIO_free(in);
117
122
  if (!pkey)
118
- ossl_raise(eRSAError, "Neither PUB key nor PRIV key");
123
+ ossl_raise(ePKeyError, "Neither PUB key nor PRIV key");
119
124
 
120
125
  type = EVP_PKEY_base_id(pkey);
121
126
  if (type != EVP_PKEY_RSA) {
122
127
  EVP_PKEY_free(pkey);
123
- rb_raise(eRSAError, "incorrect pkey type: %s", OBJ_nid2sn(type));
128
+ rb_raise(ePKeyError, "incorrect pkey type: %s", OBJ_nid2sn(type));
124
129
  }
125
130
  RTYPEDDATA_DATA(self) = pkey;
126
131
  return self;
@@ -131,13 +136,14 @@ ossl_rsa_initialize(int argc, VALUE *argv, VALUE self)
131
136
  if (!pkey || EVP_PKEY_assign_RSA(pkey, rsa) != 1) {
132
137
  EVP_PKEY_free(pkey);
133
138
  RSA_free(rsa);
134
- ossl_raise(eRSAError, "EVP_PKEY_assign_RSA");
139
+ ossl_raise(ePKeyError, "EVP_PKEY_assign_RSA");
135
140
  }
136
141
  RTYPEDDATA_DATA(self) = pkey;
137
142
  return self;
138
143
  }
139
144
 
140
145
  #ifndef HAVE_EVP_PKEY_DUP
146
+ /* :nodoc: */
141
147
  static VALUE
142
148
  ossl_rsa_initialize_copy(VALUE self, VALUE other)
143
149
  {
@@ -153,12 +159,12 @@ ossl_rsa_initialize_copy(VALUE self, VALUE other)
153
159
  (d2i_of_void *)d2i_RSAPrivateKey,
154
160
  (char *)rsa);
155
161
  if (!rsa_new)
156
- ossl_raise(eRSAError, "ASN1_dup");
162
+ ossl_raise(ePKeyError, "ASN1_dup");
157
163
 
158
164
  pkey = EVP_PKEY_new();
159
165
  if (!pkey || EVP_PKEY_assign_RSA(pkey, rsa_new) != 1) {
160
166
  RSA_free(rsa_new);
161
- ossl_raise(eRSAError, "EVP_PKEY_assign_RSA");
167
+ ossl_raise(ePKeyError, "EVP_PKEY_assign_RSA");
162
168
  }
163
169
  RTYPEDDATA_DATA(self) = pkey;
164
170
 
@@ -313,7 +319,7 @@ ossl_rsa_to_der(VALUE self)
313
319
  * Signs _data_ using the Probabilistic Signature Scheme (RSA-PSS) and returns
314
320
  * the calculated signature.
315
321
  *
316
- * RSAError will be raised if an error occurs.
322
+ * PKeyError will be raised if an error occurs.
317
323
  *
318
324
  * See #verify_pss for the verification operation.
319
325
  *
@@ -342,7 +348,7 @@ ossl_rsa_to_der(VALUE self)
342
348
  static VALUE
343
349
  ossl_rsa_sign_pss(int argc, VALUE *argv, VALUE self)
344
350
  {
345
- VALUE digest, data, options, kwargs[2], signature;
351
+ VALUE digest, data, options, kwargs[2], signature, mgf1md_holder, md_holder;
346
352
  static ID kwargs_ids[2];
347
353
  EVP_PKEY *pkey;
348
354
  EVP_PKEY_CTX *pkey_ctx;
@@ -352,46 +358,46 @@ ossl_rsa_sign_pss(int argc, VALUE *argv, VALUE self)
352
358
  int salt_len;
353
359
 
354
360
  if (!kwargs_ids[0]) {
355
- kwargs_ids[0] = rb_intern_const("salt_length");
356
- 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");
357
363
  }
358
364
  rb_scan_args(argc, argv, "2:", &digest, &data, &options);
359
365
  rb_get_kwargs(options, kwargs_ids, 2, 0, kwargs);
360
366
  if (kwargs[0] == ID2SYM(rb_intern("max")))
361
- salt_len = -2; /* RSA_PSS_SALTLEN_MAX_SIGN */
367
+ salt_len = -2; /* RSA_PSS_SALTLEN_MAX_SIGN */
362
368
  else if (kwargs[0] == ID2SYM(rb_intern("digest")))
363
- salt_len = -1; /* RSA_PSS_SALTLEN_DIGEST */
369
+ salt_len = -1; /* RSA_PSS_SALTLEN_DIGEST */
364
370
  else
365
- salt_len = NUM2INT(kwargs[0]);
366
- mgf1md = ossl_evp_get_digestbyname(kwargs[1]);
371
+ salt_len = NUM2INT(kwargs[0]);
372
+ mgf1md = ossl_evp_md_fetch(kwargs[1], &mgf1md_holder);
367
373
 
368
374
  pkey = GetPrivPKeyPtr(self);
369
375
  buf_len = EVP_PKEY_size(pkey);
370
- md = ossl_evp_get_digestbyname(digest);
376
+ md = ossl_evp_md_fetch(digest, &md_holder);
371
377
  StringValue(data);
372
378
  signature = rb_str_new(NULL, (long)buf_len);
373
379
 
374
380
  md_ctx = EVP_MD_CTX_new();
375
381
  if (!md_ctx)
376
- goto err;
382
+ goto err;
377
383
 
378
384
  if (EVP_DigestSignInit(md_ctx, &pkey_ctx, md, NULL, pkey) != 1)
379
- goto err;
385
+ goto err;
380
386
 
381
387
  if (EVP_PKEY_CTX_set_rsa_padding(pkey_ctx, RSA_PKCS1_PSS_PADDING) != 1)
382
- goto err;
388
+ goto err;
383
389
 
384
390
  if (EVP_PKEY_CTX_set_rsa_pss_saltlen(pkey_ctx, salt_len) != 1)
385
- goto err;
391
+ goto err;
386
392
 
387
393
  if (EVP_PKEY_CTX_set_rsa_mgf1_md(pkey_ctx, mgf1md) != 1)
388
- goto err;
394
+ goto err;
389
395
 
390
396
  if (EVP_DigestSignUpdate(md_ctx, RSTRING_PTR(data), RSTRING_LEN(data)) != 1)
391
- goto err;
397
+ goto err;
392
398
 
393
399
  if (EVP_DigestSignFinal(md_ctx, (unsigned char *)RSTRING_PTR(signature), &buf_len) != 1)
394
- goto err;
400
+ goto err;
395
401
 
396
402
  rb_str_set_len(signature, (long)buf_len);
397
403
 
@@ -400,7 +406,7 @@ ossl_rsa_sign_pss(int argc, VALUE *argv, VALUE self)
400
406
 
401
407
  err:
402
408
  EVP_MD_CTX_free(md_ctx);
403
- ossl_raise(eRSAError, NULL);
409
+ ossl_raise(ePKeyError, NULL);
404
410
  }
405
411
 
406
412
  /*
@@ -410,7 +416,7 @@ ossl_rsa_sign_pss(int argc, VALUE *argv, VALUE self)
410
416
  * Verifies _data_ using the Probabilistic Signature Scheme (RSA-PSS).
411
417
  *
412
418
  * The return value is +true+ if the signature is valid, +false+ otherwise.
413
- * RSAError will be raised if an error occurs.
419
+ * PKeyError will be raised if an error occurs.
414
420
  *
415
421
  * See #sign_pss for the signing operation and an example code.
416
422
  *
@@ -429,7 +435,7 @@ ossl_rsa_sign_pss(int argc, VALUE *argv, VALUE self)
429
435
  static VALUE
430
436
  ossl_rsa_verify_pss(int argc, VALUE *argv, VALUE self)
431
437
  {
432
- VALUE digest, signature, data, options, kwargs[2];
438
+ VALUE digest, signature, data, options, kwargs[2], mgf1md_holder, md_holder;
433
439
  static ID kwargs_ids[2];
434
440
  EVP_PKEY *pkey;
435
441
  EVP_PKEY_CTX *pkey_ctx;
@@ -438,98 +444,61 @@ ossl_rsa_verify_pss(int argc, VALUE *argv, VALUE self)
438
444
  int result, salt_len;
439
445
 
440
446
  if (!kwargs_ids[0]) {
441
- kwargs_ids[0] = rb_intern_const("salt_length");
442
- 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");
443
449
  }
444
450
  rb_scan_args(argc, argv, "3:", &digest, &signature, &data, &options);
445
451
  rb_get_kwargs(options, kwargs_ids, 2, 0, kwargs);
446
452
  if (kwargs[0] == ID2SYM(rb_intern("auto")))
447
- salt_len = -2; /* RSA_PSS_SALTLEN_AUTO */
453
+ salt_len = -2; /* RSA_PSS_SALTLEN_AUTO */
448
454
  else if (kwargs[0] == ID2SYM(rb_intern("digest")))
449
- salt_len = -1; /* RSA_PSS_SALTLEN_DIGEST */
455
+ salt_len = -1; /* RSA_PSS_SALTLEN_DIGEST */
450
456
  else
451
- salt_len = NUM2INT(kwargs[0]);
452
- mgf1md = ossl_evp_get_digestbyname(kwargs[1]);
457
+ salt_len = NUM2INT(kwargs[0]);
458
+ mgf1md = ossl_evp_md_fetch(kwargs[1], &mgf1md_holder);
453
459
 
454
460
  GetPKey(self, pkey);
455
- md = ossl_evp_get_digestbyname(digest);
461
+ md = ossl_evp_md_fetch(digest, &md_holder);
456
462
  StringValue(signature);
457
463
  StringValue(data);
458
464
 
459
465
  md_ctx = EVP_MD_CTX_new();
460
466
  if (!md_ctx)
461
- goto err;
467
+ goto err;
462
468
 
463
469
  if (EVP_DigestVerifyInit(md_ctx, &pkey_ctx, md, NULL, pkey) != 1)
464
- goto err;
470
+ goto err;
465
471
 
466
472
  if (EVP_PKEY_CTX_set_rsa_padding(pkey_ctx, RSA_PKCS1_PSS_PADDING) != 1)
467
- goto err;
473
+ goto err;
468
474
 
469
475
  if (EVP_PKEY_CTX_set_rsa_pss_saltlen(pkey_ctx, salt_len) != 1)
470
- goto err;
476
+ goto err;
471
477
 
472
478
  if (EVP_PKEY_CTX_set_rsa_mgf1_md(pkey_ctx, mgf1md) != 1)
473
- goto err;
479
+ goto err;
474
480
 
475
481
  if (EVP_DigestVerifyUpdate(md_ctx, RSTRING_PTR(data), RSTRING_LEN(data)) != 1)
476
- goto err;
482
+ goto err;
477
483
 
478
484
  result = EVP_DigestVerifyFinal(md_ctx,
479
- (unsigned char *)RSTRING_PTR(signature),
480
- RSTRING_LEN(signature));
485
+ (unsigned char *)RSTRING_PTR(signature),
486
+ RSTRING_LEN(signature));
487
+ EVP_MD_CTX_free(md_ctx);
481
488
 
482
489
  switch (result) {
483
490
  case 0:
484
- ossl_clear_error();
485
- EVP_MD_CTX_free(md_ctx);
486
- return Qfalse;
491
+ ossl_clear_error();
492
+ return Qfalse;
487
493
  case 1:
488
- EVP_MD_CTX_free(md_ctx);
489
- return Qtrue;
494
+ return Qtrue;
490
495
  default:
491
- goto err;
496
+ ossl_raise(ePKeyError, "EVP_DigestVerifyFinal");
492
497
  }
493
498
 
494
499
  err:
495
500
  EVP_MD_CTX_free(md_ctx);
496
- ossl_raise(eRSAError, NULL);
497
- }
498
-
499
- /*
500
- * call-seq:
501
- * rsa.params => hash
502
- *
503
- * THIS METHOD IS INSECURE, PRIVATE INFORMATION CAN LEAK OUT!!!
504
- *
505
- * Stores all parameters of key to the hash. The hash has keys 'n', 'e', 'd',
506
- * 'p', 'q', 'dmp1', 'dmq1', 'iqmp'.
507
- *
508
- * Don't use :-)) (It's up to you)
509
- */
510
- static VALUE
511
- ossl_rsa_get_params(VALUE self)
512
- {
513
- OSSL_3_const RSA *rsa;
514
- VALUE hash;
515
- const BIGNUM *n, *e, *d, *p, *q, *dmp1, *dmq1, *iqmp;
516
-
517
- GetRSA(self, rsa);
518
- RSA_get0_key(rsa, &n, &e, &d);
519
- RSA_get0_factors(rsa, &p, &q);
520
- RSA_get0_crt_params(rsa, &dmp1, &dmq1, &iqmp);
521
-
522
- hash = rb_hash_new();
523
- rb_hash_aset(hash, rb_str_new2("n"), ossl_bn_new(n));
524
- rb_hash_aset(hash, rb_str_new2("e"), ossl_bn_new(e));
525
- rb_hash_aset(hash, rb_str_new2("d"), ossl_bn_new(d));
526
- rb_hash_aset(hash, rb_str_new2("p"), ossl_bn_new(p));
527
- rb_hash_aset(hash, rb_str_new2("q"), ossl_bn_new(q));
528
- rb_hash_aset(hash, rb_str_new2("dmp1"), ossl_bn_new(dmp1));
529
- rb_hash_aset(hash, rb_str_new2("dmq1"), ossl_bn_new(dmq1));
530
- rb_hash_aset(hash, rb_str_new2("iqmp"), ossl_bn_new(iqmp));
531
-
532
- return hash;
501
+ ossl_raise(ePKeyError, NULL);
533
502
  }
534
503
 
535
504
  /*
@@ -567,20 +536,6 @@ OSSL_PKEY_BN_DEF3(rsa, RSA, crt_params, dmp1, dmq1, iqmp)
567
536
  void
568
537
  Init_ossl_rsa(void)
569
538
  {
570
- #if 0
571
- mPKey = rb_define_module_under(mOSSL, "PKey");
572
- cPKey = rb_define_class_under(mPKey, "PKey", rb_cObject);
573
- ePKeyError = rb_define_class_under(mPKey, "PKeyError", eOSSLError);
574
- #endif
575
-
576
- /* Document-class: OpenSSL::PKey::RSAError
577
- *
578
- * Generic exception that is raised if an operation on an RSA PKey
579
- * fails unexpectedly or in case an instantiation of an instance of RSA
580
- * fails due to non-conformant input data.
581
- */
582
- eRSAError = rb_define_class_under(mPKey, "RSAError", ePKeyError);
583
-
584
539
  /* Document-class: OpenSSL::PKey::RSA
585
540
  *
586
541
  * RSA is an asymmetric public key algorithm that has been formalized in
@@ -619,8 +574,6 @@ Init_ossl_rsa(void)
619
574
  rb_define_method(cRSA, "set_factors", ossl_rsa_set_factors, 2);
620
575
  rb_define_method(cRSA, "set_crt_params", ossl_rsa_set_crt_params, 3);
621
576
 
622
- rb_define_method(cRSA, "params", ossl_rsa_get_params, 0);
623
-
624
577
  /*
625
578
  * TODO: Test it
626
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);