openssl 2.0.9 → 2.1.0.beta1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of openssl might be problematic. Click here for more details.

Files changed (60) hide show
  1. checksums.yaml +5 -5
  2. data/History.md +28 -69
  3. data/README.md +1 -1
  4. data/ext/openssl/deprecation.rb +0 -3
  5. data/ext/openssl/extconf.rb +8 -52
  6. data/ext/openssl/openssl_missing.c +0 -67
  7. data/ext/openssl/openssl_missing.h +3 -50
  8. data/ext/openssl/ossl.c +81 -74
  9. data/ext/openssl/ossl.h +14 -27
  10. data/ext/openssl/ossl_asn1.c +287 -374
  11. data/ext/openssl/ossl_asn1.h +0 -4
  12. data/ext/openssl/ossl_bio.c +5 -20
  13. data/ext/openssl/ossl_bio.h +0 -2
  14. data/ext/openssl/ossl_bn.c +70 -28
  15. data/ext/openssl/ossl_cipher.c +18 -42
  16. data/ext/openssl/ossl_cipher.h +1 -1
  17. data/ext/openssl/ossl_digest.c +8 -12
  18. data/ext/openssl/ossl_digest.h +1 -1
  19. data/ext/openssl/ossl_engine.c +47 -47
  20. data/ext/openssl/ossl_hmac.c +19 -22
  21. data/ext/openssl/ossl_kdf.c +221 -0
  22. data/ext/openssl/ossl_kdf.h +6 -0
  23. data/ext/openssl/ossl_ns_spki.c +17 -21
  24. data/ext/openssl/ossl_ocsp.c +85 -80
  25. data/ext/openssl/ossl_pkcs12.c +15 -21
  26. data/ext/openssl/ossl_pkcs7.c +8 -21
  27. data/ext/openssl/ossl_pkey.c +24 -48
  28. data/ext/openssl/ossl_pkey.h +1 -6
  29. data/ext/openssl/ossl_pkey_dh.c +11 -11
  30. data/ext/openssl/ossl_pkey_dsa.c +16 -22
  31. data/ext/openssl/ossl_pkey_ec.c +43 -56
  32. data/ext/openssl/ossl_pkey_rsa.c +19 -19
  33. data/ext/openssl/ossl_rand.c +12 -12
  34. data/ext/openssl/ossl_ssl.c +291 -243
  35. data/ext/openssl/ossl_ssl.h +0 -5
  36. data/ext/openssl/ossl_ssl_session.c +7 -9
  37. data/ext/openssl/ossl_version.h +1 -1
  38. data/ext/openssl/ossl_x509.c +0 -15
  39. data/ext/openssl/ossl_x509.h +0 -7
  40. data/ext/openssl/ossl_x509attr.c +3 -7
  41. data/ext/openssl/ossl_x509cert.c +17 -54
  42. data/ext/openssl/ossl_x509crl.c +15 -25
  43. data/ext/openssl/ossl_x509ext.c +9 -14
  44. data/ext/openssl/ossl_x509name.c +76 -41
  45. data/ext/openssl/ossl_x509req.c +10 -47
  46. data/ext/openssl/ossl_x509revoked.c +8 -8
  47. data/ext/openssl/ossl_x509store.c +15 -45
  48. data/ext/openssl/ruby_missing.h +2 -13
  49. data/lib/openssl.rb +1 -0
  50. data/lib/openssl/bn.rb +2 -1
  51. data/lib/openssl/buffering.rb +24 -23
  52. data/lib/openssl/config.rb +12 -11
  53. data/lib/openssl/digest.rb +3 -6
  54. data/lib/openssl/pkcs5.rb +22 -0
  55. data/lib/openssl/pkey.rb +0 -41
  56. data/lib/openssl/ssl.rb +118 -16
  57. data/lib/openssl/x509.rb +7 -1
  58. metadata +8 -7
  59. data/ext/openssl/ossl_pkcs5.c +0 -180
  60. data/ext/openssl/ossl_pkcs5.h +0 -6
@@ -17,11 +17,6 @@
17
17
  if(!(p12)) ossl_raise(rb_eRuntimeError, "PKCS12 wasn't initialized."); \
18
18
  } while (0)
19
19
 
20
- #define SafeGetPKCS12(obj, p12) do { \
21
- OSSL_Check_Kind((obj), cPKCS12); \
22
- GetPKCS12((obj), (p12)); \
23
- } while (0)
24
-
25
20
  #define ossl_pkcs12_set_key(o,v) rb_iv_set((o), "@key", (v))
26
21
  #define ossl_pkcs12_set_cert(o,v) rb_iv_set((o), "@certificate", (v))
27
22
  #define ossl_pkcs12_set_ca_certs(o,v) rb_iv_set((o), "@ca_certs", (v))
@@ -72,7 +67,7 @@ ossl_pkcs12_initialize_copy(VALUE self, VALUE other)
72
67
 
73
68
  rb_check_frozen(self);
74
69
  GetPKCS12(self, p12_old);
75
- SafeGetPKCS12(other, p12);
70
+ GetPKCS12(other, p12);
76
71
 
77
72
  p12_new = ASN1_dup((i2d_of_void *)i2d_PKCS12, (d2i_of_void *)d2i_PKCS12, (char *)p12);
78
73
  if (!p12_new)
@@ -89,20 +84,20 @@ ossl_pkcs12_initialize_copy(VALUE self, VALUE other)
89
84
  * PKCS12.create(pass, name, key, cert [, ca, [, key_pbe [, cert_pbe [, key_iter [, mac_iter [, keytype]]]]]])
90
85
  *
91
86
  * === Parameters
92
- * * +pass+ - string
93
- * * +name+ - A string describing the key.
94
- * * +key+ - Any PKey.
95
- * * +cert+ - A X509::Certificate.
87
+ * * _pass_ - string
88
+ * * _name_ - A string describing the key.
89
+ * * _key_ - Any PKey.
90
+ * * _cert_ - A X509::Certificate.
96
91
  * * The public_key portion of the certificate must contain a valid public key.
97
92
  * * The not_before and not_after fields must be filled in.
98
- * * +ca+ - An optional array of X509::Certificate's.
99
- * * +key_pbe+ - string
100
- * * +cert_pbe+ - string
101
- * * +key_iter+ - integer
102
- * * +mac_iter+ - integer
103
- * * +keytype+ - An integer representing an MSIE specific extension.
93
+ * * _ca_ - An optional array of X509::Certificate's.
94
+ * * _key_pbe_ - string
95
+ * * _cert_pbe_ - string
96
+ * * _key_iter_ - integer
97
+ * * _mac_iter_ - integer
98
+ * * _keytype_ - An integer representing an MSIE specific extension.
104
99
  *
105
- * Any optional arguments may be supplied as nil to preserve the OpenSSL defaults.
100
+ * Any optional arguments may be supplied as +nil+ to preserve the OpenSSL defaults.
106
101
  *
107
102
  * See the OpenSSL documentation for PKCS12_create().
108
103
  */
@@ -161,8 +156,8 @@ ossl_pkcs12_s_create(int argc, VALUE *argv, VALUE self)
161
156
  * PKCS12.new(str, pass) -> pkcs12
162
157
  *
163
158
  * === Parameters
164
- * * +str+ - Must be a DER encoded PKCS12 string.
165
- * * +pass+ - string
159
+ * * _str_ - Must be a DER encoded PKCS12 string.
160
+ * * _pass_ - string
166
161
  */
167
162
  static VALUE
168
163
  ossl_pkcs12_initialize(int argc, VALUE *argv, VALUE self)
@@ -237,7 +232,6 @@ ossl_pkcs12_to_der(VALUE self)
237
232
  void
238
233
  Init_ossl_pkcs12(void)
239
234
  {
240
- #undef rb_intern
241
235
  #if 0
242
236
  mOSSL = rb_define_module("OpenSSL");
243
237
  eOSSLError = rb_define_class_under(mOSSL, "OpenSSLError", rb_eStandardError);
@@ -253,7 +247,7 @@ Init_ossl_pkcs12(void)
253
247
  rb_define_singleton_method(cPKCS12, "create", ossl_pkcs12_s_create, -1);
254
248
 
255
249
  rb_define_alloc_func(cPKCS12, ossl_pkcs12_s_allocate);
256
- rb_define_copy_func(cPKCS12, ossl_pkcs12_initialize_copy);
250
+ rb_define_method(cPKCS12, "initialize_copy", ossl_pkcs12_initialize_copy, 1);
257
251
  rb_attr(cPKCS12, rb_intern("key"), 1, 0, Qfalse);
258
252
  rb_attr(cPKCS12, rb_intern("certificate"), 1, 0, Qfalse);
259
253
  rb_attr(cPKCS12, rb_intern("ca_certs"), 1, 0, Qfalse);
@@ -23,10 +23,6 @@
23
23
  ossl_raise(rb_eRuntimeError, "PKCS7 wasn't initialized."); \
24
24
  } \
25
25
  } while (0)
26
- #define SafeGetPKCS7(obj, pkcs7) do { \
27
- OSSL_Check_Kind((obj), cPKCS7); \
28
- GetPKCS7((obj), (pkcs7)); \
29
- } while (0)
30
26
 
31
27
  #define NewPKCS7si(klass) \
32
28
  TypedData_Wrap_Struct((klass), &ossl_pkcs7_signer_info_type, 0)
@@ -42,10 +38,6 @@
42
38
  ossl_raise(rb_eRuntimeError, "PKCS7si wasn't initialized."); \
43
39
  } \
44
40
  } while (0)
45
- #define SafeGetPKCS7si(obj, p7si) do { \
46
- OSSL_Check_Kind((obj), cPKCS7Signer); \
47
- GetPKCS7si((obj), (p7si)); \
48
- } while (0)
49
41
 
50
42
  #define NewPKCS7ri(klass) \
51
43
  TypedData_Wrap_Struct((klass), &ossl_pkcs7_recip_info_type, 0)
@@ -61,10 +53,6 @@
61
53
  ossl_raise(rb_eRuntimeError, "PKCS7ri wasn't initialized."); \
62
54
  } \
63
55
  } while (0)
64
- #define SafeGetPKCS7ri(obj, p7ri) do { \
65
- OSSL_Check_Kind((obj), cPKCS7Recipient); \
66
- GetPKCS7ri((obj), (p7ri)); \
67
- } while (0)
68
56
 
69
57
  #define numberof(ary) (int)(sizeof(ary)/sizeof((ary)[0]))
70
58
 
@@ -162,7 +150,7 @@ DupPKCS7SignerPtr(VALUE obj)
162
150
  {
163
151
  PKCS7_SIGNER_INFO *p7si, *pkcs7;
164
152
 
165
- SafeGetPKCS7si(obj, p7si);
153
+ GetPKCS7si(obj, p7si);
166
154
  if (!(pkcs7 = ossl_PKCS7_SIGNER_INFO_dup(p7si))) {
167
155
  ossl_raise(ePKCS7Error, NULL);
168
156
  }
@@ -189,7 +177,7 @@ DupPKCS7RecipientPtr(VALUE obj)
189
177
  {
190
178
  PKCS7_RECIP_INFO *p7ri, *pkcs7;
191
179
 
192
- SafeGetPKCS7ri(obj, p7ri);
180
+ GetPKCS7ri(obj, p7ri);
193
181
  if (!(pkcs7 = ossl_PKCS7_RECIP_INFO_dup(p7ri))) {
194
182
  ossl_raise(ePKCS7Error, NULL);
195
183
  }
@@ -238,7 +226,7 @@ ossl_pkcs7_s_write_smime(int argc, VALUE *argv, VALUE klass)
238
226
  rb_scan_args(argc, argv, "12", &pkcs7, &data, &flags);
239
227
  flg = NIL_P(flags) ? 0 : NUM2INT(flags);
240
228
  if(NIL_P(data)) data = ossl_pkcs7_get_data(pkcs7);
241
- SafeGetPKCS7(pkcs7, p7);
229
+ GetPKCS7(pkcs7, p7);
242
230
  if(!NIL_P(data) && PKCS7_is_detached(p7))
243
231
  flg |= PKCS7_DETACHED;
244
232
  in = NIL_P(data) ? NULL : ossl_obj2bio(&data);
@@ -331,7 +319,7 @@ ossl_pkcs7_s_encrypt(int argc, VALUE *argv, VALUE klass)
331
319
  #endif
332
320
 
333
321
  }
334
- else ciph = GetCipherPtr(cipher); /* NO NEED TO DUP */
322
+ else ciph = ossl_evp_get_cipherbyname(cipher);
335
323
  flg = NIL_P(flags) ? 0 : NUM2INT(flags);
336
324
  ret = NewPKCS7(cPKCS7);
337
325
  in = ossl_obj2bio(&data);
@@ -414,7 +402,7 @@ ossl_pkcs7_copy(VALUE self, VALUE other)
414
402
  if (self == other) return self;
415
403
 
416
404
  GetPKCS7(self, a);
417
- SafeGetPKCS7(other, b);
405
+ GetPKCS7(other, b);
418
406
 
419
407
  pkcs7 = PKCS7_dup(b);
420
408
  if (!pkcs7) {
@@ -537,7 +525,7 @@ ossl_pkcs7_set_cipher(VALUE self, VALUE cipher)
537
525
  PKCS7 *pkcs7;
538
526
 
539
527
  GetPKCS7(self, pkcs7);
540
- if (!PKCS7_set_cipher(pkcs7, GetCipherPtr(cipher))) {
528
+ if (!PKCS7_set_cipher(pkcs7, ossl_evp_get_cipherbyname(cipher))) {
541
529
  ossl_raise(ePKCS7Error, NULL);
542
530
  }
543
531
 
@@ -933,7 +921,7 @@ ossl_pkcs7si_initialize(VALUE self, VALUE cert, VALUE key, VALUE digest)
933
921
 
934
922
  pkey = GetPrivPKeyPtr(key); /* NO NEED TO DUP */
935
923
  x509 = GetX509CertPtr(cert); /* NO NEED TO DUP */
936
- md = GetDigestPtr(digest);
924
+ md = ossl_evp_get_digestbyname(digest);
937
925
  GetPKCS7si(self, p7si);
938
926
  if (!(PKCS7_SIGNER_INFO_set(p7si, x509, pkey, (EVP_MD*)md))) {
939
927
  ossl_raise(ePKCS7Error, NULL);
@@ -1054,7 +1042,6 @@ ossl_pkcs7ri_get_enc_key(VALUE self)
1054
1042
  void
1055
1043
  Init_ossl_pkcs7(void)
1056
1044
  {
1057
- #undef rb_intern
1058
1045
  #if 0
1059
1046
  mOSSL = rb_define_module("OpenSSL");
1060
1047
  eOSSLError = rb_define_class_under(mOSSL, "OpenSSLError", rb_eStandardError);
@@ -1069,7 +1056,7 @@ Init_ossl_pkcs7(void)
1069
1056
  rb_attr(cPKCS7, rb_intern("data"), 1, 0, Qfalse);
1070
1057
  rb_attr(cPKCS7, rb_intern("error_string"), 1, 1, Qfalse);
1071
1058
  rb_define_alloc_func(cPKCS7, ossl_pkcs7_alloc);
1072
- rb_define_copy_func(cPKCS7, ossl_pkcs7_copy);
1059
+ rb_define_method(cPKCS7, "initialize_copy", ossl_pkcs7_copy, 1);
1073
1060
  rb_define_method(cPKCS7, "initialize", ossl_pkcs7_initialize, -1);
1074
1061
  rb_define_method(cPKCS7, "type=", ossl_pkcs7_set_type, 1);
1075
1062
  rb_define_method(cPKCS7, "type", ossl_pkcs7_get_type, 0);
@@ -20,21 +20,6 @@ static ID id_private_q;
20
20
  /*
21
21
  * callback for generating keys
22
22
  */
23
- static VALUE
24
- call_check_ints0(VALUE arg)
25
- {
26
- rb_thread_check_ints();
27
- return Qnil;
28
- }
29
-
30
- static void *
31
- call_check_ints(void *arg)
32
- {
33
- int state;
34
- rb_protect(call_check_ints0, Qnil, &state);
35
- return (void *)(VALUE)state;
36
- }
37
-
38
23
  int
39
24
  ossl_generate_cb_2(int p, int n, BN_GENCB *cb)
40
25
  {
@@ -53,18 +38,11 @@ ossl_generate_cb_2(int p, int n, BN_GENCB *cb)
53
38
  */
54
39
  rb_protect(rb_yield, ary, &state);
55
40
  if (state) {
41
+ arg->stop = 1;
56
42
  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
43
  }
67
44
  }
45
+ if (arg->stop) return 0;
68
46
  return 1;
69
47
  }
70
48
 
@@ -72,7 +50,7 @@ void
72
50
  ossl_generate_cb_stop(void *ptr)
73
51
  {
74
52
  struct ossl_generate_cb_arg *arg = (struct ossl_generate_cb_arg *)ptr;
75
- arg->interrupted = 1;
53
+ arg->stop = 1;
76
54
  }
77
55
 
78
56
  static void
@@ -114,7 +92,7 @@ pkey_new0(EVP_PKEY *pkey)
114
92
  case EVP_PKEY_DH:
115
93
  return ossl_dh_new(pkey);
116
94
  #endif
117
- #if !defined(OPENSSL_NO_EC) && (OPENSSL_VERSION_NUMBER >= 0x0090802fL)
95
+ #if !defined(OPENSSL_NO_EC)
118
96
  case EVP_PKEY_EC:
119
97
  return ossl_ec_new(pkey);
120
98
  #endif
@@ -145,15 +123,15 @@ ossl_pkey_new(EVP_PKEY *pkey)
145
123
  * OpenSSL::PKey.read(string [, pwd ]) -> PKey
146
124
  * OpenSSL::PKey.read(io [, pwd ]) -> PKey
147
125
  *
148
- * Reads a DER or PEM encoded string from +string+ or +io+ and returns an
126
+ * Reads a DER or PEM encoded string from _string_ or _io_ and returns an
149
127
  * instance of the appropriate PKey class.
150
128
  *
151
129
  * === Parameters
152
- * * +string+ is a DER- or PEM-encoded string containing an arbitrary private
130
+ * * _string+ is a DER- or PEM-encoded string containing an arbitrary private
153
131
  * or public key.
154
- * * +io+ is an instance of +IO+ containing a DER- or PEM-encoded
132
+ * * _io_ is an instance of IO containing a DER- or PEM-encoded
155
133
  * arbitrary private or public key.
156
- * * +pwd+ is an optional password in case +string+ or +file+ is an encrypted
134
+ * * _pwd_ is an optional password in case _string_ or _io_ is an encrypted
157
135
  * PEM resource.
158
136
  */
159
137
  static VALUE
@@ -185,8 +163,8 @@ ossl_pkey_new_from_data(int argc, VALUE *argv, VALUE self)
185
163
  return ossl_pkey_new(pkey);
186
164
  }
187
165
 
188
- void
189
- ossl_pkey_check_public_key(const EVP_PKEY *pkey)
166
+ static void
167
+ pkey_check_public_key(EVP_PKEY *pkey)
190
168
  {
191
169
  void *ptr;
192
170
  const BIGNUM *n, *e, *pubkey;
@@ -194,8 +172,7 @@ ossl_pkey_check_public_key(const EVP_PKEY *pkey)
194
172
  if (EVP_PKEY_missing_parameters(pkey))
195
173
  ossl_raise(ePKeyError, "parameters missing");
196
174
 
197
- /* OpenSSL < 1.1.0 takes non-const pointer */
198
- ptr = EVP_PKEY_get0((EVP_PKEY *)pkey);
175
+ ptr = EVP_PKEY_get0(pkey);
199
176
  switch (EVP_PKEY_base_id(pkey)) {
200
177
  case EVP_PKEY_RSA:
201
178
  RSA_get0_key(ptr, &n, &e, NULL);
@@ -230,7 +207,7 @@ GetPKeyPtr(VALUE obj)
230
207
  {
231
208
  EVP_PKEY *pkey;
232
209
 
233
- SafeGetPKey(obj, pkey);
210
+ GetPKey(obj, pkey);
234
211
 
235
212
  return pkey;
236
213
  }
@@ -243,7 +220,7 @@ GetPrivPKeyPtr(VALUE obj)
243
220
  if (rb_funcallv(obj, id_private_q, 0, NULL) != Qtrue) {
244
221
  ossl_raise(rb_eArgError, "Private key is needed.");
245
222
  }
246
- SafeGetPKey(obj, pkey);
223
+ GetPKey(obj, pkey);
247
224
 
248
225
  return pkey;
249
226
  }
@@ -253,7 +230,7 @@ DupPKeyPtr(VALUE obj)
253
230
  {
254
231
  EVP_PKEY *pkey;
255
232
 
256
- SafeGetPKey(obj, pkey);
233
+ GetPKey(obj, pkey);
257
234
  EVP_PKEY_up_ref(pkey);
258
235
 
259
236
  return pkey;
@@ -282,7 +259,7 @@ ossl_pkey_alloc(VALUE klass)
282
259
  * PKeyClass.new -> self
283
260
  *
284
261
  * Because PKey is an abstract class, actually calling this method explicitly
285
- * will raise a +NotImplementedError+.
262
+ * will raise a NotImplementedError.
286
263
  */
287
264
  static VALUE
288
265
  ossl_pkey_initialize(VALUE self)
@@ -297,10 +274,10 @@ ossl_pkey_initialize(VALUE self)
297
274
  * call-seq:
298
275
  * pkey.sign(digest, data) -> String
299
276
  *
300
- * To sign the +String+ +data+, +digest+, an instance of OpenSSL::Digest, must
301
- * be provided. The return value is again a +String+ containing the signature.
277
+ * To sign the String _data_, _digest_, an instance of OpenSSL::Digest, must
278
+ * be provided. The return value is again a String containing the signature.
302
279
  * A PKeyError is raised should errors occur.
303
- * Any previous state of the +Digest+ instance is irrelevant to the signature
280
+ * Any previous state of the Digest instance is irrelevant to the signature
304
281
  * outcome, the digest instance is reset to its initial state during the
305
282
  * operation.
306
283
  *
@@ -321,7 +298,7 @@ ossl_pkey_sign(VALUE self, VALUE digest, VALUE data)
321
298
  int result;
322
299
 
323
300
  pkey = GetPrivPKeyPtr(self);
324
- md = GetDigestPtr(digest);
301
+ md = ossl_evp_get_digestbyname(digest);
325
302
  StringValue(data);
326
303
  str = rb_str_new(0, EVP_PKEY_size(pkey));
327
304
 
@@ -349,12 +326,12 @@ ossl_pkey_sign(VALUE self, VALUE digest, VALUE data)
349
326
  * call-seq:
350
327
  * pkey.verify(digest, signature, data) -> String
351
328
  *
352
- * To verify the +String+ +signature+, +digest+, an instance of
329
+ * To verify the String _signature_, _digest_, an instance of
353
330
  * OpenSSL::Digest, must be provided to re-compute the message digest of the
354
- * original +data+, also a +String+. The return value is +true+ if the
331
+ * original _data_, also a String. The return value is +true+ if the
355
332
  * signature is valid, +false+ otherwise. A PKeyError is raised should errors
356
333
  * occur.
357
- * Any previous state of the +Digest+ instance is irrelevant to the validation
334
+ * Any previous state of the Digest instance is irrelevant to the validation
358
335
  * outcome, the digest instance is reset to its initial state during the
359
336
  * operation.
360
337
  *
@@ -375,8 +352,8 @@ ossl_pkey_verify(VALUE self, VALUE digest, VALUE sig, VALUE data)
375
352
  int siglen, result;
376
353
 
377
354
  GetPKey(self, pkey);
378
- ossl_pkey_check_public_key(pkey);
379
- md = GetDigestPtr(digest);
355
+ pkey_check_public_key(pkey);
356
+ md = ossl_evp_get_digestbyname(digest);
380
357
  StringValue(sig);
381
358
  siglen = RSTRING_LENINT(sig);
382
359
  StringValue(data);
@@ -411,7 +388,6 @@ ossl_pkey_verify(VALUE self, VALUE digest, VALUE sig, VALUE data)
411
388
  void
412
389
  Init_ossl_pkey(void)
413
390
  {
414
- #undef rb_intern
415
391
  #if 0
416
392
  mOSSL = rb_define_module("OpenSSL");
417
393
  eOSSLError = rb_define_class_under(mOSSL, "OpenSSLError", rb_eStandardError);
@@ -34,21 +34,16 @@ extern const rb_data_type_t ossl_evp_pkey_type;
34
34
  rb_raise(rb_eRuntimeError, "PKEY wasn't initialized!");\
35
35
  } \
36
36
  } while (0)
37
- #define SafeGetPKey(obj, pkey) do { \
38
- OSSL_Check_Kind((obj), cPKey); \
39
- GetPKey((obj), (pkey)); \
40
- } while (0)
41
37
 
42
38
  struct ossl_generate_cb_arg {
43
39
  int yield;
44
- int interrupted;
40
+ int stop;
45
41
  int state;
46
42
  };
47
43
  int ossl_generate_cb_2(int p, int n, BN_GENCB *cb);
48
44
  void ossl_generate_cb_stop(void *ptr);
49
45
 
50
46
  VALUE ossl_pkey_new(EVP_PKEY *);
51
- void ossl_pkey_check_public_key(const EVP_PKEY *);
52
47
  EVP_PKEY *GetPKeyPtr(VALUE);
53
48
  EVP_PKEY *DupPKeyPtr(VALUE);
54
49
  EVP_PKEY *GetPrivPKeyPtr(VALUE);
@@ -150,8 +150,8 @@ dh_generate(int size, int gen)
150
150
  * components alike.
151
151
  *
152
152
  * === Parameters
153
- * * +size+ is an integer representing the desired key size. Keys smaller than 1024 bits should be considered insecure.
154
- * * +generator+ is a small number > 1, typically 2 or 5.
153
+ * * _size_ is an integer representing the desired key size. Keys smaller than 1024 bits should be considered insecure.
154
+ * * _generator_ is a small number > 1, typically 2 or 5.
155
155
  *
156
156
  */
157
157
  static VALUE
@@ -181,15 +181,15 @@ ossl_dh_s_generate(int argc, VALUE *argv, VALUE klass)
181
181
  * DH.new(size [, generator]) -> dh
182
182
  *
183
183
  * Either generates a DH instance from scratch or by reading already existing
184
- * DH parameters from +string+. Note that when reading a DH instance from
184
+ * DH parameters from _string_. Note that when reading a DH instance from
185
185
  * data that was encoded from a DH instance by using DH#to_pem or DH#to_der
186
186
  * the result will *not* contain a public/private key pair yet. This needs to
187
187
  * be generated using DH#generate_key! first.
188
188
  *
189
189
  * === Parameters
190
- * * +size+ is an integer representing the desired key size. Keys smaller than 1024 bits should be considered insecure.
191
- * * +generator+ is a small number > 1, typically 2 or 5.
192
- * * +string+ contains the DER or PEM encoded key.
190
+ * * _size_ is an integer representing the desired key size. Keys smaller than 1024 bits should be considered insecure.
191
+ * * _generator_ is a small number > 1, typically 2 or 5.
192
+ * * _string_ contains the DER or PEM encoded key.
193
193
  *
194
194
  * === Examples
195
195
  * DH.new # -> dh
@@ -436,7 +436,7 @@ ossl_dh_to_text(VALUE self)
436
436
  * dh.public_key -> aDH
437
437
  *
438
438
  * Returns a new DH instance that carries just the public information, i.e.
439
- * the prime +p+ and the generator +g+, but no public/private key yet. Such
439
+ * the prime _p_ and the generator _g_, but no public/private key yet. Such
440
440
  * a pair may be generated using DH#generate_key!. The "public key" needed
441
441
  * for a key exchange with DH#compute_key is considered as per-session
442
442
  * information and may be retrieved with DH#pub_key once a key pair has
@@ -526,7 +526,7 @@ ossl_dh_generate_key(VALUE self)
526
526
  * See DH_compute_key() for further information.
527
527
  *
528
528
  * === Parameters
529
- * * +pub_bn+ is a OpenSSL::BN, *not* the DH instance returned by
529
+ * * _pub_bn_ is a OpenSSL::BN, *not* the DH instance returned by
530
530
  * DH#public_key as that contains the DH parameters only.
531
531
  */
532
532
  static VALUE
@@ -557,7 +557,7 @@ ossl_dh_compute_key(VALUE self, VALUE pub)
557
557
  * call-seq:
558
558
  * dh.set_pqg(p, q, g) -> self
559
559
  *
560
- * Sets +p+, +q+, +g+ for the DH instance.
560
+ * Sets _p_, _q_, _g_ to the DH instance.
561
561
  */
562
562
  OSSL_PKEY_BN_DEF3(dh, DH, pqg, p, q, g)
563
563
  /*
@@ -565,7 +565,7 @@ OSSL_PKEY_BN_DEF3(dh, DH, pqg, p, q, g)
565
565
  * call-seq:
566
566
  * dh.set_key(pub_key, priv_key) -> self
567
567
  *
568
- * Sets +pub_key+ and +priv_key+ for the DH instance. +priv_key+ may be nil.
568
+ * Sets _pub_key_ and _priv_key_ for the DH instance. _priv_key_ may be +nil+.
569
569
  */
570
570
  OSSL_PKEY_BN_DEF2(dh, DH, key, pub_key, priv_key)
571
571
 
@@ -618,7 +618,7 @@ Init_ossl_dh(void)
618
618
  cDH = rb_define_class_under(mPKey, "DH", cPKey);
619
619
  rb_define_singleton_method(cDH, "generate", ossl_dh_s_generate, -1);
620
620
  rb_define_method(cDH, "initialize", ossl_dh_initialize, -1);
621
- rb_define_copy_func(cDH, ossl_dh_initialize_copy);
621
+ rb_define_method(cDH, "initialize_copy", ossl_dh_initialize_copy, 1);
622
622
  rb_define_method(cDH, "public?", ossl_dh_is_public, 0);
623
623
  rb_define_method(cDH, "private?", ossl_dh_is_private, 0);
624
624
  rb_define_method(cDH, "to_text", ossl_dh_to_text, 0);