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
@@ -172,7 +172,7 @@ dsa_generate(int size)
172
172
  * from scratch.
173
173
  *
174
174
  * === Parameters
175
- * * +size+ is an integer representing the desired key size.
175
+ * * _size_ is an integer representing the desired key size.
176
176
  *
177
177
  */
178
178
  static VALUE
@@ -195,12 +195,12 @@ ossl_dsa_s_generate(VALUE klass, VALUE size)
195
195
  * DSA.new(size) -> dsa
196
196
  * DSA.new(string [, pass]) -> dsa
197
197
  *
198
- * Creates a new DSA instance by reading an existing key from +string+.
198
+ * Creates a new DSA instance by reading an existing key from _string_.
199
199
  *
200
200
  * === Parameters
201
- * * +size+ is an integer representing the desired key size.
202
- * * +string+ contains a DER or PEM encoded key.
203
- * * +pass+ is a string that contains an optional password.
201
+ * * _size_ is an integer representing the desired key size.
202
+ * * _string_ contains a DER or PEM encoded key.
203
+ * * _pass_ is a string that contains an optional password.
204
204
  *
205
205
  * === Examples
206
206
  * DSA.new -> dsa
@@ -329,8 +329,8 @@ ossl_dsa_is_private(VALUE self)
329
329
  * Encodes this DSA to its PEM encoding.
330
330
  *
331
331
  * === Parameters
332
- * * +cipher+ is an OpenSSL::Cipher.
333
- * * +password+ is a string containing your password.
332
+ * * _cipher_ is an OpenSSL::Cipher.
333
+ * * _password_ is a string containing your password.
334
334
  *
335
335
  * === Examples
336
336
  * DSA.to_pem -> aString
@@ -348,7 +348,7 @@ ossl_dsa_export(int argc, VALUE *argv, VALUE self)
348
348
  GetDSA(self, dsa);
349
349
  rb_scan_args(argc, argv, "02", &cipher, &pass);
350
350
  if (!NIL_P(cipher)) {
351
- ciph = GetCipherPtr(cipher);
351
+ ciph = ossl_evp_get_cipherbyname(cipher);
352
352
  pass = ossl_pem_passwd_value(pass);
353
353
  }
354
354
  if (!(out = BIO_new(BIO_s_mem()))) {
@@ -503,12 +503,12 @@ ossl_dsa_to_public_key(VALUE self)
503
503
  * call-seq:
504
504
  * dsa.syssign(string) -> aString
505
505
  *
506
- * Computes and returns the DSA signature of +string+, where +string+ is
506
+ * Computes and returns the DSA signature of _string_, where _string_ is
507
507
  * expected to be an already-computed message digest of the original input
508
508
  * data. The signature is issued using the private key of this DSA instance.
509
509
  *
510
510
  * === Parameters
511
- * * +string+ is a message digest of the original input data to be signed
511
+ * * _string_ is a message digest of the original input data to be signed.
512
512
  *
513
513
  * === Example
514
514
  * dsa = OpenSSL::PKey::DSA.new(2048)
@@ -549,11 +549,11 @@ ossl_dsa_sign(VALUE self, VALUE data)
549
549
  * dsa.sysverify(digest, sig) -> true | false
550
550
  *
551
551
  * Verifies whether the signature is valid given the message digest input. It
552
- * does so by validating +sig+ using the public key of this DSA instance.
552
+ * does so by validating _sig_ using the public key of this DSA instance.
553
553
  *
554
554
  * === Parameters
555
- * * +digest+ is a message digest of the original input data to be signed
556
- * * +sig+ is a DSA signature value
555
+ * * _digest_ is a message digest of the original input data to be signed
556
+ * * _sig_ is a DSA signature value
557
557
  *
558
558
  * === Example
559
559
  * dsa = OpenSSL::PKey::DSA.new(2048)
@@ -590,7 +590,7 @@ ossl_dsa_verify(VALUE self, VALUE digest, VALUE sig)
590
590
  * call-seq:
591
591
  * dsa.set_pqg(p, q, g) -> self
592
592
  *
593
- * Sets +p+, +q+, +g+ for the DSA instance.
593
+ * Sets _p_, _q_, _g_ to the DSA instance.
594
594
  */
595
595
  OSSL_PKEY_BN_DEF3(dsa, DSA, pqg, p, q, g)
596
596
  /*
@@ -598,7 +598,7 @@ OSSL_PKEY_BN_DEF3(dsa, DSA, pqg, p, q, g)
598
598
  * call-seq:
599
599
  * dsa.set_key(pub_key, priv_key) -> self
600
600
  *
601
- * Sets +pub_key+ and +priv_key+ for the DSA instance. +priv_key+ may be nil.
601
+ * Sets _pub_key_ and _priv_key_ for the DSA instance. _priv_key_ may be +nil+.
602
602
  */
603
603
  OSSL_PKEY_BN_DEF2(dsa, DSA, key, pub_key, priv_key)
604
604
 
@@ -627,18 +627,12 @@ Init_ossl_dsa(void)
627
627
  * DSA, the Digital Signature Algorithm, is specified in NIST's
628
628
  * FIPS 186-3. It is an asymmetric public key algorithm that may be used
629
629
  * similar to e.g. RSA.
630
- * Please note that for OpenSSL versions prior to 1.0.0 the digest
631
- * algorithms OpenSSL::Digest::DSS (equivalent to SHA) or
632
- * OpenSSL::Digest::DSS1 (equivalent to SHA-1) must be used for issuing
633
- * signatures with a DSA key using OpenSSL::PKey#sign.
634
- * Starting with OpenSSL 1.0.0, digest algorithms are no longer restricted,
635
- * any Digest may be used for signing.
636
630
  */
637
631
  cDSA = rb_define_class_under(mPKey, "DSA", cPKey);
638
632
 
639
633
  rb_define_singleton_method(cDSA, "generate", ossl_dsa_s_generate, 1);
640
634
  rb_define_method(cDSA, "initialize", ossl_dsa_initialize, -1);
641
- rb_define_copy_func(cDSA, ossl_dsa_initialize_copy);
635
+ rb_define_method(cDSA, "initialize_copy", ossl_dsa_initialize_copy, 1);
642
636
 
643
637
  rb_define_method(cDSA, "public?", ossl_dsa_is_public, 0);
644
638
  rb_define_method(cDSA, "private?", ossl_dsa_is_private, 0);
@@ -4,7 +4,7 @@
4
4
 
5
5
  #include "ossl.h"
6
6
 
7
- #if !defined(OPENSSL_NO_EC) && (OPENSSL_VERSION_NUMBER >= 0x0090802fL)
7
+ #if !defined(OPENSSL_NO_EC)
8
8
 
9
9
  #define EXPORT_PEM 0
10
10
  #define EXPORT_DER 1
@@ -23,33 +23,21 @@ static const rb_data_type_t ossl_ec_point_type;
23
23
  GetPKeyEC(obj, _pkey); \
24
24
  (key) = EVP_PKEY_get0_EC_KEY(_pkey); \
25
25
  } while (0)
26
- #define SafeGetEC(obj, key) do { \
27
- OSSL_Check_Kind(obj, cEC); \
28
- GetEC(obj, key); \
29
- } while (0)
30
26
 
31
27
  #define GetECGroup(obj, group) do { \
32
28
  TypedData_Get_Struct(obj, EC_GROUP, &ossl_ec_group_type, group); \
33
29
  if ((group) == NULL) \
34
30
  ossl_raise(eEC_GROUP, "EC_GROUP is not initialized"); \
35
31
  } while (0)
36
- #define SafeGetECGroup(obj, group) do { \
37
- OSSL_Check_Kind((obj), cEC_GROUP); \
38
- GetECGroup(obj, group); \
39
- } while (0)
40
32
 
41
33
  #define GetECPoint(obj, point) do { \
42
34
  TypedData_Get_Struct(obj, EC_POINT, &ossl_ec_point_type, point); \
43
35
  if ((point) == NULL) \
44
36
  ossl_raise(eEC_POINT, "EC_POINT is not initialized"); \
45
37
  } while (0)
46
- #define SafeGetECPoint(obj, point) do { \
47
- OSSL_Check_Kind((obj), cEC_POINT); \
48
- GetECPoint(obj, point); \
49
- } while(0)
50
38
  #define GetECPointGroup(obj, group) do { \
51
39
  VALUE _group = rb_attr_get(obj, id_i_group); \
52
- SafeGetECGroup(_group, group); \
40
+ GetECGroup(_group, group); \
53
41
  } while (0)
54
42
 
55
43
  VALUE cEC;
@@ -128,7 +116,7 @@ ec_key_new_from_group(VALUE arg)
128
116
  if (rb_obj_is_kind_of(arg, cEC_GROUP)) {
129
117
  EC_GROUP *group;
130
118
 
131
- SafeGetECGroup(arg, group);
119
+ GetECGroup(arg, group);
132
120
  if (!(ec = EC_KEY_new()))
133
121
  ossl_raise(eECError, NULL);
134
122
 
@@ -208,7 +196,7 @@ static VALUE ossl_ec_key_initialize(int argc, VALUE *argv, VALUE self)
208
196
  } else if (rb_obj_is_kind_of(arg, cEC)) {
209
197
  EC_KEY *other_ec = NULL;
210
198
 
211
- SafeGetEC(arg, other_ec);
199
+ GetEC(arg, other_ec);
212
200
  if (!(ec = EC_KEY_dup(other_ec)))
213
201
  ossl_raise(eECError, NULL);
214
202
  } else if (rb_obj_is_kind_of(arg, cEC_GROUP)) {
@@ -257,7 +245,7 @@ ossl_ec_key_initialize_copy(VALUE self, VALUE other)
257
245
  GetPKey(self, pkey);
258
246
  if (EVP_PKEY_base_id(pkey) != EVP_PKEY_NONE)
259
247
  ossl_raise(eECError, "EC already initialized");
260
- SafeGetEC(other, ec);
248
+ GetEC(other, ec);
261
249
 
262
250
  ec_new = EC_KEY_dup(ec);
263
251
  if (!ec_new)
@@ -275,7 +263,7 @@ ossl_ec_key_initialize_copy(VALUE self, VALUE other)
275
263
  * key.group => group
276
264
  *
277
265
  * Returns the EC::Group that the key is associated with. Modifying the returned
278
- * group does not affect +key+.
266
+ * group does not affect _key_.
279
267
  */
280
268
  static VALUE
281
269
  ossl_ec_key_get_group(VALUE self)
@@ -296,7 +284,7 @@ ossl_ec_key_get_group(VALUE self)
296
284
  * key.group = group
297
285
  *
298
286
  * Sets the EC::Group for the key. The group structure is internally copied so
299
- * modification to +group+ after assigning to a key has no effect on the key.
287
+ * modification to _group_ after assigning to a key has no effect on the key.
300
288
  */
301
289
  static VALUE
302
290
  ossl_ec_key_set_group(VALUE self, VALUE group_v)
@@ -305,7 +293,7 @@ ossl_ec_key_set_group(VALUE self, VALUE group_v)
305
293
  EC_GROUP *group;
306
294
 
307
295
  GetEC(self, ec);
308
- SafeGetECGroup(group_v, group);
296
+ GetECGroup(group_v, group);
309
297
 
310
298
  if (EC_KEY_set_group(ec, group) != 1)
311
299
  ossl_raise(eECError, "EC_KEY_set_group");
@@ -390,7 +378,7 @@ static VALUE ossl_ec_key_set_public_key(VALUE self, VALUE public_key)
390
378
 
391
379
  GetEC(self, ec);
392
380
  if (!NIL_P(public_key))
393
- SafeGetECPoint(public_key, point);
381
+ GetECPoint(public_key, point);
394
382
 
395
383
  switch (EC_KEY_set_public_key(ec, point)) {
396
384
  case 1:
@@ -458,7 +446,7 @@ static VALUE ossl_ec_key_to_string(VALUE self, VALUE ciph, VALUE pass, int forma
458
446
  private = 1;
459
447
 
460
448
  if (!NIL_P(ciph)) {
461
- cipher = GetCipherPtr(ciph);
449
+ cipher = ossl_evp_get_cipherbyname(ciph);
462
450
  pass = ossl_pem_passwd_value(pass);
463
451
  }
464
452
 
@@ -502,8 +490,8 @@ static VALUE ossl_ec_key_to_string(VALUE self, VALUE ciph, VALUE pass, int forma
502
490
  * key.export([cipher, pass_phrase]) => String
503
491
  * key.to_pem([cipher, pass_phrase]) => String
504
492
  *
505
- * Outputs the EC key in PEM encoding. If +cipher+ and +pass_phrase+ are given
506
- * they will be used to encrypt the key. +cipher+ must be an OpenSSL::Cipher
493
+ * Outputs the EC key in PEM encoding. If _cipher_ and _pass_phrase_ are given
494
+ * they will be used to encrypt the key. _cipher_ must be an OpenSSL::Cipher
507
495
  * instance. Note that encryption will only be effective for a private key,
508
496
  * public keys will always be encoded in plain text.
509
497
  */
@@ -608,7 +596,7 @@ static VALUE ossl_ec_key_dh_compute_key(VALUE self, VALUE pubkey)
608
596
  VALUE str;
609
597
 
610
598
  GetEC(self, ec);
611
- SafeGetECPoint(pubkey, point);
599
+ GetECPoint(pubkey, point);
612
600
 
613
601
  /* BUG: need a way to figure out the maximum string size */
614
602
  buf_len = 1024;
@@ -724,7 +712,7 @@ ec_group_new(const EC_GROUP *group)
724
712
  *
725
713
  * Creates a new EC::Group object.
726
714
  *
727
- * +ec_method+ is a symbol that represents an EC_METHOD. Currently the following
715
+ * _ec_method_ is a symbol that represents an EC_METHOD. Currently the following
728
716
  * are supported:
729
717
  *
730
718
  * * :GFp_simple
@@ -771,7 +759,7 @@ static VALUE ossl_ec_group_initialize(int argc, VALUE *argv, VALUE self)
771
759
  } else if (rb_obj_is_kind_of(arg1, cEC_GROUP)) {
772
760
  const EC_GROUP *arg1_group;
773
761
 
774
- SafeGetECGroup(arg1, arg1_group);
762
+ GetECGroup(arg1, arg1_group);
775
763
  if ((group = EC_GROUP_dup(arg1_group)) == NULL)
776
764
  ossl_raise(eEC_GROUP, "EC_GROUP_dup");
777
765
  } else {
@@ -847,7 +835,7 @@ ossl_ec_group_initialize_copy(VALUE self, VALUE other)
847
835
  TypedData_Get_Struct(self, EC_GROUP, &ossl_ec_group_type, group_new);
848
836
  if (group_new)
849
837
  ossl_raise(eEC_GROUP, "EC::Group already initialized");
850
- SafeGetECGroup(other, group);
838
+ GetECGroup(other, group);
851
839
 
852
840
  group_new = EC_GROUP_dup(group);
853
841
  if (!group_new)
@@ -862,15 +850,15 @@ ossl_ec_group_initialize_copy(VALUE self, VALUE other)
862
850
  * group1.eql?(group2) => true | false
863
851
  * group1 == group2 => true | false
864
852
  *
865
- * Returns true if the two groups use the same curve and have the same
866
- * parameters, false otherwise.
853
+ * Returns +true+ if the two groups use the same curve and have the same
854
+ * parameters, +false+ otherwise.
867
855
  */
868
856
  static VALUE ossl_ec_group_eql(VALUE a, VALUE b)
869
857
  {
870
858
  EC_GROUP *group1 = NULL, *group2 = NULL;
871
859
 
872
860
  GetECGroup(a, group1);
873
- SafeGetECGroup(b, group2);
861
+ GetECGroup(b, group2);
874
862
 
875
863
  if (EC_GROUP_cmp(group1, group2, ossl_bn_ctx) == 1)
876
864
  return Qfalse;
@@ -903,8 +891,8 @@ static VALUE ossl_ec_group_get_generator(VALUE self)
903
891
  * call-seq:
904
892
  * group.set_generator(generator, order, cofactor) => self
905
893
  *
906
- * Sets the curve parameters. +generator+ must be an instance of EC::Point that
907
- * is on the curve. +order+ and +cofactor+ are integers.
894
+ * Sets the curve parameters. _generator_ must be an instance of EC::Point that
895
+ * is on the curve. _order_ and _cofactor_ are integers.
908
896
  *
909
897
  * See the OpenSSL documentation for EC_GROUP_set_generator()
910
898
  */
@@ -915,7 +903,7 @@ static VALUE ossl_ec_group_set_generator(VALUE self, VALUE generator, VALUE orde
915
903
  const BIGNUM *o, *co;
916
904
 
917
905
  GetECGroup(self, group);
918
- SafeGetECPoint(generator, point);
906
+ GetECPoint(generator, point);
919
907
  o = GetBNPtr(order);
920
908
  co = GetBNPtr(cofactor);
921
909
 
@@ -1127,14 +1115,14 @@ parse_point_conversion_form_symbol(VALUE sym)
1127
1115
  *
1128
1116
  * Sets the form how EC::Point data is encoded as ASN.1 as defined in X9.62.
1129
1117
  *
1130
- * +format+ can be one of these:
1118
+ * _format_ can be one of these:
1131
1119
  *
1132
- * :compressed::
1120
+ * +:compressed+::
1133
1121
  * Encoded as z||x, where z is an octet indicating which solution of the
1134
1122
  * equation y is. z will be 0x02 or 0x03.
1135
- * :uncompressed::
1123
+ * +:uncompressed+::
1136
1124
  * Encoded as z||x||y, where z is an octet 0x04.
1137
- * :hybrid::
1125
+ * +:hybrid+::
1138
1126
  * Encodes as z||x||y, where z is an octet indicating which solution of the
1139
1127
  * equation y is. z will be 0x06 or 0x07.
1140
1128
  *
@@ -1356,13 +1344,13 @@ static VALUE ossl_ec_point_initialize(int argc, VALUE *argv, VALUE self)
1356
1344
  const EC_POINT *arg_point;
1357
1345
 
1358
1346
  group_v = rb_attr_get(arg1, id_i_group);
1359
- SafeGetECGroup(group_v, group);
1360
- SafeGetECPoint(arg1, arg_point);
1347
+ GetECGroup(group_v, group);
1348
+ GetECPoint(arg1, arg_point);
1361
1349
 
1362
1350
  point = EC_POINT_dup(arg_point, group);
1363
1351
  } else if (rb_obj_is_kind_of(arg1, cEC_GROUP)) {
1364
1352
  group_v = arg1;
1365
- SafeGetECGroup(group_v, group);
1353
+ GetECGroup(group_v, group);
1366
1354
 
1367
1355
  point = EC_POINT_new(group);
1368
1356
  } else {
@@ -1374,7 +1362,7 @@ static VALUE ossl_ec_point_initialize(int argc, VALUE *argv, VALUE self)
1374
1362
  if (!rb_obj_is_kind_of(arg1, cEC_GROUP))
1375
1363
  ossl_raise(rb_eArgError, "1st argument must be OpenSSL::PKey::EC::Group");
1376
1364
  group_v = arg1;
1377
- SafeGetECGroup(group_v, group);
1365
+ GetECGroup(group_v, group);
1378
1366
 
1379
1367
  if (rb_obj_is_kind_of(arg2, cBN)) {
1380
1368
  const BIGNUM *bn = GetBNPtr(arg2);
@@ -1418,10 +1406,10 @@ ossl_ec_point_initialize_copy(VALUE self, VALUE other)
1418
1406
  TypedData_Get_Struct(self, EC_POINT, &ossl_ec_point_type, point_new);
1419
1407
  if (point_new)
1420
1408
  ossl_raise(eEC_POINT, "EC::Point already initialized");
1421
- SafeGetECPoint(other, point);
1409
+ GetECPoint(other, point);
1422
1410
 
1423
1411
  group_v = rb_obj_dup(rb_attr_get(other, id_i_group));
1424
- SafeGetECGroup(group_v, group);
1412
+ GetECGroup(group_v, group);
1425
1413
 
1426
1414
  point_new = EC_POINT_dup(point, group);
1427
1415
  if (!point_new)
@@ -1448,8 +1436,8 @@ static VALUE ossl_ec_point_eql(VALUE a, VALUE b)
1448
1436
  return Qfalse;
1449
1437
 
1450
1438
  GetECPoint(a, point1);
1451
- SafeGetECPoint(b, point2);
1452
- SafeGetECGroup(group_v1, group);
1439
+ GetECPoint(b, point2);
1440
+ GetECGroup(group_v1, group);
1453
1441
 
1454
1442
  if (EC_POINT_cmp(group, point1, point2, ossl_bn_ctx) == 1)
1455
1443
  return Qfalse;
@@ -1558,7 +1546,7 @@ static VALUE ossl_ec_point_set_to_infinity(VALUE self)
1558
1546
  * point.to_bn(conversion_form = nil) => OpenSSL::BN
1559
1547
  *
1560
1548
  * Convert the EC point into an octet string and store in an OpenSSL::BN. If
1561
- * +conversion_form+ is given, the point data is converted using the specified
1549
+ * _conversion_form_ is given, the point data is converted using the specified
1562
1550
  * form. If not given, the default form set in the EC::Group object is used.
1563
1551
  *
1564
1552
  * See also EC::Point#point_conversion_form=.
@@ -1597,12 +1585,12 @@ ossl_ec_point_to_bn(int argc, VALUE *argv, VALUE self)
1597
1585
  * Performs elliptic curve point multiplication.
1598
1586
  *
1599
1587
  * The first form calculates <tt>bn1 * point + bn2 * G</tt>, where +G+ is the
1600
- * generator of the group of +point+. +bn2+ may be omitted, and in that case,
1588
+ * generator of the group of _point_. _bn2_ may be omitted, and in that case,
1601
1589
  * the result is just <tt>bn1 * point</tt>.
1602
1590
  *
1603
1591
  * The second form calculates <tt>bns[0] * point + bns[1] * points[0] + ...
1604
- * + bns[-1] * points[-1] + bn2 * G</tt>. +bn2+ may be omitted. +bns+ must be
1605
- * an array of OpenSSL::BN. +points+ must be an array of
1592
+ * + bns[-1] * points[-1] + bn2 * G</tt>. _bn2_ may be omitted. _bns_ must be
1593
+ * an array of OpenSSL::BN. _points_ must be an array of
1606
1594
  * OpenSSL::PKey::EC::Point. Please note that <tt>points[0]</tt> is not
1607
1595
  * multiplied by <tt>bns[0]</tt>, but <tt>bns[1]</tt>.
1608
1596
  */
@@ -1615,7 +1603,7 @@ static VALUE ossl_ec_point_mul(int argc, VALUE *argv, VALUE self)
1615
1603
  const BIGNUM *bn_g = NULL;
1616
1604
 
1617
1605
  GetECPoint(self, point_self);
1618
- SafeGetECGroup(group_v, group);
1606
+ GetECGroup(group_v, group);
1619
1607
 
1620
1608
  result = rb_obj_alloc(cEC_POINT);
1621
1609
  ossl_ec_point_initialize(1, &group_v, result);
@@ -1656,7 +1644,7 @@ static VALUE ossl_ec_point_mul(int argc, VALUE *argv, VALUE self)
1656
1644
  points = ALLOCV_N(const EC_POINT *, tmp_p, num);
1657
1645
  points[0] = point_self; /* self */
1658
1646
  for (i = 0; i < num - 1; i++)
1659
- SafeGetECPoint(RARRAY_AREF(arg2, i), points[i + 1]);
1647
+ GetECPoint(RARRAY_AREF(arg2, i), points[i + 1]);
1660
1648
 
1661
1649
  if (!NIL_P(arg3))
1662
1650
  bn_g = GetBNPtr(arg3);
@@ -1676,7 +1664,6 @@ static VALUE ossl_ec_point_mul(int argc, VALUE *argv, VALUE self)
1676
1664
 
1677
1665
  void Init_ossl_ec(void)
1678
1666
  {
1679
- #undef rb_intern
1680
1667
  #if 0
1681
1668
  mPKey = rb_define_module_under(mOSSL, "PKey");
1682
1669
  cPKey = rb_define_class_under(mPKey, "PKey", rb_cObject);
@@ -1727,7 +1714,7 @@ void Init_ossl_ec(void)
1727
1714
 
1728
1715
  rb_define_singleton_method(cEC, "generate", ossl_ec_key_s_generate, 1);
1729
1716
  rb_define_method(cEC, "initialize", ossl_ec_key_initialize, -1);
1730
- rb_define_copy_func(cEC, ossl_ec_key_initialize_copy);
1717
+ rb_define_method(cEC, "initialize_copy", ossl_ec_key_initialize_copy, 1);
1731
1718
  /* copy/dup/cmp */
1732
1719
 
1733
1720
  rb_define_method(cEC, "group", ossl_ec_key_get_group, 0);
@@ -1764,7 +1751,7 @@ void Init_ossl_ec(void)
1764
1751
 
1765
1752
  rb_define_alloc_func(cEC_GROUP, ossl_ec_group_alloc);
1766
1753
  rb_define_method(cEC_GROUP, "initialize", ossl_ec_group_initialize, -1);
1767
- rb_define_copy_func(cEC_GROUP, ossl_ec_group_initialize_copy);
1754
+ rb_define_method(cEC_GROUP, "initialize_copy", ossl_ec_group_initialize_copy, 1);
1768
1755
  rb_define_method(cEC_GROUP, "eql?", ossl_ec_group_eql, 1);
1769
1756
  rb_define_alias(cEC_GROUP, "==", "eql?");
1770
1757
  /* copy/dup/cmp */
@@ -1800,7 +1787,7 @@ void Init_ossl_ec(void)
1800
1787
 
1801
1788
  rb_define_alloc_func(cEC_POINT, ossl_ec_point_alloc);
1802
1789
  rb_define_method(cEC_POINT, "initialize", ossl_ec_point_initialize, -1);
1803
- rb_define_copy_func(cEC_POINT, ossl_ec_point_initialize_copy);
1790
+ rb_define_method(cEC_POINT, "initialize_copy", ossl_ec_point_initialize_copy, 1);
1804
1791
  rb_attr(cEC_POINT, rb_intern("group"), 1, 0, 0);
1805
1792
  rb_define_method(cEC_POINT, "eql?", ossl_ec_point_eql, 1);
1806
1793
  rb_define_alias(cEC_POINT, "==", "eql?");
@@ -172,8 +172,8 @@ rsa_generate(int size, unsigned long exp)
172
172
  * RSA.generate(size) => RSA instance
173
173
  * RSA.generate(size, exponent) => RSA instance
174
174
  *
175
- * Generates an RSA keypair. +size+ is an integer representing the desired key
176
- * size. Keys smaller than 1024 should be considered insecure. +exponent+ is
175
+ * Generates an RSA keypair. _size_ is an integer representing the desired key
176
+ * size. Keys smaller than 1024 should be considered insecure. _exponent_ is
177
177
  * an odd number normally 3, 17, or 65537.
178
178
  */
179
179
  static VALUE
@@ -203,12 +203,12 @@ ossl_rsa_s_generate(int argc, VALUE *argv, VALUE klass)
203
203
  * RSA.new(encoded_key) => RSA instance
204
204
  * RSA.new(encoded_key, pass_phrase) => RSA instance
205
205
  *
206
- * Generates or loads an RSA keypair. If an integer +key_size+ is given it
206
+ * Generates or loads an RSA keypair. If an integer _key_size_ is given it
207
207
  * represents the desired key size. Keys less than 1024 bits should be
208
208
  * considered insecure.
209
209
  *
210
- * A key can instead be loaded from an +encoded_key+ which must be PEM or DER
211
- * encoded. A +pass_phrase+ can be used to decrypt the key. If none is given
210
+ * A key can instead be loaded from an _encoded_key_ which must be PEM or DER
211
+ * encoded. A _pass_phrase_ can be used to decrypt the key. If none is given
212
212
  * OpenSSL will prompt for the pass phrase.
213
213
  *
214
214
  * = Examples
@@ -295,7 +295,7 @@ ossl_rsa_initialize_copy(VALUE self, VALUE other)
295
295
  * call-seq:
296
296
  * rsa.public? => true
297
297
  *
298
- * The return value is always true since every private key is also a public
298
+ * The return value is always +true+ since every private key is also a public
299
299
  * key.
300
300
  */
301
301
  static VALUE
@@ -333,8 +333,8 @@ ossl_rsa_is_private(VALUE self)
333
333
  * rsa.to_pem([cipher, pass_phrase]) => PEM-format String
334
334
  * rsa.to_s([cipher, pass_phrase]) => PEM-format String
335
335
  *
336
- * Outputs this keypair in PEM encoding. If +cipher+ and +pass_phrase+ are
337
- * given they will be used to encrypt the key. +cipher+ must be an
336
+ * Outputs this keypair in PEM encoding. If _cipher_ and _pass_phrase_ are
337
+ * given they will be used to encrypt the key. _cipher_ must be an
338
338
  * OpenSSL::Cipher instance.
339
339
  */
340
340
  static VALUE
@@ -350,7 +350,7 @@ ossl_rsa_export(int argc, VALUE *argv, VALUE self)
350
350
  rb_scan_args(argc, argv, "02", &cipher, &pass);
351
351
 
352
352
  if (!NIL_P(cipher)) {
353
- ciph = GetCipherPtr(cipher);
353
+ ciph = ossl_evp_get_cipherbyname(cipher);
354
354
  pass = ossl_pem_passwd_value(pass);
355
355
  }
356
356
  if (!(out = BIO_new(BIO_s_mem()))) {
@@ -409,7 +409,7 @@ ossl_rsa_to_der(VALUE self)
409
409
  * rsa.public_encrypt(string) => String
410
410
  * rsa.public_encrypt(string, padding) => String
411
411
  *
412
- * Encrypt +string+ with the public key. +padding+ defaults to PKCS1_PADDING.
412
+ * Encrypt _string_ with the public key. _padding_ defaults to PKCS1_PADDING.
413
413
  * The encrypted string output can be decrypted using #private_decrypt.
414
414
  */
415
415
  static VALUE
@@ -441,8 +441,8 @@ ossl_rsa_public_encrypt(int argc, VALUE *argv, VALUE self)
441
441
  * rsa.public_decrypt(string) => String
442
442
  * rsa.public_decrypt(string, padding) => String
443
443
  *
444
- * Decrypt +string+, which has been encrypted with the private key, with the
445
- * public key. +padding+ defaults to PKCS1_PADDING.
444
+ * Decrypt _string_, which has been encrypted with the private key, with the
445
+ * public key. _padding_ defaults to PKCS1_PADDING.
446
446
  */
447
447
  static VALUE
448
448
  ossl_rsa_public_decrypt(int argc, VALUE *argv, VALUE self)
@@ -473,7 +473,7 @@ ossl_rsa_public_decrypt(int argc, VALUE *argv, VALUE self)
473
473
  * rsa.private_encrypt(string) => String
474
474
  * rsa.private_encrypt(string, padding) => String
475
475
  *
476
- * Encrypt +string+ with the private key. +padding+ defaults to PKCS1_PADDING.
476
+ * Encrypt _string_ with the private key. _padding_ defaults to PKCS1_PADDING.
477
477
  * The encrypted string output can be decrypted using #public_decrypt.
478
478
  */
479
479
  static VALUE
@@ -507,8 +507,8 @@ ossl_rsa_private_encrypt(int argc, VALUE *argv, VALUE self)
507
507
  * rsa.private_decrypt(string) => String
508
508
  * rsa.private_decrypt(string, padding) => String
509
509
  *
510
- * Decrypt +string+, which has been encrypted with the public key, with the
511
- * private key. +padding+ defaults to PKCS1_PADDING.
510
+ * Decrypt _string_, which has been encrypted with the public key, with the
511
+ * private key. _padding_ defaults to PKCS1_PADDING.
512
512
  */
513
513
  static VALUE
514
514
  ossl_rsa_private_decrypt(int argc, VALUE *argv, VALUE self)
@@ -659,7 +659,7 @@ ossl_rsa_blinding_off(VALUE self)
659
659
  * call-seq:
660
660
  * rsa.set_key(n, e, d) -> self
661
661
  *
662
- * Sets +n+, +e+, +d+ for the RSA instance.
662
+ * Sets _n_, _e_, _d_ for the RSA instance.
663
663
  */
664
664
  OSSL_PKEY_BN_DEF3(rsa, RSA, key, n, e, d)
665
665
  /*
@@ -667,7 +667,7 @@ OSSL_PKEY_BN_DEF3(rsa, RSA, key, n, e, d)
667
667
  * call-seq:
668
668
  * rsa.set_factors(p, q) -> self
669
669
  *
670
- * Sets +p+, +q+ for the RSA instance.
670
+ * Sets _p_, _q_ for the RSA instance.
671
671
  */
672
672
  OSSL_PKEY_BN_DEF2(rsa, RSA, factors, p, q)
673
673
  /*
@@ -675,7 +675,7 @@ OSSL_PKEY_BN_DEF2(rsa, RSA, factors, p, q)
675
675
  * call-seq:
676
676
  * rsa.set_crt_params(dmp1, dmq1, iqmp) -> self
677
677
  *
678
- * Sets +dmp1+, +dmq1+, +iqmp+ for the RSA instance. They are calculated by
678
+ * Sets _dmp1_, _dmq1_, _iqmp_ for the RSA instance. They are calculated by
679
679
  * <tt>d mod (p - 1)</tt>, <tt>d mod (q - 1)</tt> and <tt>q^(-1) mod p</tt>
680
680
  * respectively.
681
681
  */
@@ -717,7 +717,7 @@ Init_ossl_rsa(void)
717
717
 
718
718
  rb_define_singleton_method(cRSA, "generate", ossl_rsa_s_generate, -1);
719
719
  rb_define_method(cRSA, "initialize", ossl_rsa_initialize, -1);
720
- rb_define_copy_func(cRSA, ossl_rsa_initialize_copy);
720
+ rb_define_method(cRSA, "initialize_copy", ossl_rsa_initialize_copy, 1);
721
721
 
722
722
  rb_define_method(cRSA, "public?", ossl_rsa_is_public, 0);
723
723
  rb_define_method(cRSA, "private?", ossl_rsa_is_private, 0);