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
@@ -15,25 +15,27 @@ static const rb_data_type_t ossl_ec_point_type;
15
15
  #define GetPKeyEC(obj, pkey) do { \
16
16
  GetPKey((obj), (pkey)); \
17
17
  if (EVP_PKEY_base_id(pkey) != EVP_PKEY_EC) { \
18
- ossl_raise(rb_eRuntimeError, "THIS IS NOT A EC PKEY!"); \
18
+ ossl_raise(rb_eRuntimeError, "THIS IS NOT A EC PKEY!"); \
19
19
  } \
20
20
  } while (0)
21
21
  #define GetEC(obj, key) do { \
22
22
  EVP_PKEY *_pkey; \
23
23
  GetPKeyEC(obj, _pkey); \
24
24
  (key) = EVP_PKEY_get0_EC_KEY(_pkey); \
25
+ if ((key) == NULL) \
26
+ ossl_raise(ePKeyError, "failed to get EC_KEY from EVP_PKEY"); \
25
27
  } while (0)
26
28
 
27
29
  #define GetECGroup(obj, group) do { \
28
30
  TypedData_Get_Struct(obj, EC_GROUP, &ossl_ec_group_type, group); \
29
31
  if ((group) == NULL) \
30
- ossl_raise(eEC_GROUP, "EC_GROUP is not initialized"); \
32
+ ossl_raise(eEC_GROUP, "EC_GROUP is not initialized"); \
31
33
  } while (0)
32
34
 
33
35
  #define GetECPoint(obj, point) do { \
34
36
  TypedData_Get_Struct(obj, EC_POINT, &ossl_ec_point_type, point); \
35
37
  if ((point) == NULL) \
36
- ossl_raise(eEC_POINT, "EC_POINT is not initialized"); \
38
+ ossl_raise(eEC_POINT, "EC_POINT is not initialized"); \
37
39
  } while (0)
38
40
  #define GetECPointGroup(obj, group) do { \
39
41
  VALUE _group = rb_attr_get(obj, id_i_group); \
@@ -41,17 +43,13 @@ static const rb_data_type_t ossl_ec_point_type;
41
43
  } while (0)
42
44
 
43
45
  VALUE cEC;
44
- static VALUE eECError;
45
46
  static VALUE cEC_GROUP;
46
47
  static VALUE eEC_GROUP;
47
48
  static VALUE cEC_POINT;
48
49
  static VALUE eEC_POINT;
49
50
 
50
- static ID s_GFp, s_GF2m;
51
-
52
- static ID ID_uncompressed;
53
- static ID ID_compressed;
54
- static ID ID_hybrid;
51
+ static VALUE sym_GFp, sym_GF2m;
52
+ static VALUE sym_uncompressed, sym_compressed, sym_hybrid;
55
53
 
56
54
  static ID id_i_group;
57
55
 
@@ -68,27 +66,27 @@ ec_key_new_from_group(VALUE arg)
68
66
  EC_KEY *ec;
69
67
 
70
68
  if (rb_obj_is_kind_of(arg, cEC_GROUP)) {
71
- EC_GROUP *group;
69
+ EC_GROUP *group;
72
70
 
73
- GetECGroup(arg, group);
74
- if (!(ec = EC_KEY_new()))
75
- ossl_raise(eECError, NULL);
71
+ GetECGroup(arg, group);
72
+ if (!(ec = EC_KEY_new()))
73
+ ossl_raise(ePKeyError, NULL);
76
74
 
77
- if (!EC_KEY_set_group(ec, group)) {
78
- EC_KEY_free(ec);
79
- ossl_raise(eECError, NULL);
80
- }
75
+ if (!EC_KEY_set_group(ec, group)) {
76
+ EC_KEY_free(ec);
77
+ ossl_raise(ePKeyError, NULL);
78
+ }
81
79
  } else {
82
- int nid = OBJ_sn2nid(StringValueCStr(arg));
80
+ int nid = OBJ_sn2nid(StringValueCStr(arg));
83
81
 
84
- if (nid == NID_undef)
85
- ossl_raise(eECError, "invalid curve name");
82
+ if (nid == NID_undef)
83
+ ossl_raise(ePKeyError, "invalid curve name");
86
84
 
87
- if (!(ec = EC_KEY_new_by_curve_name(nid)))
88
- ossl_raise(eECError, NULL);
85
+ if (!(ec = EC_KEY_new_by_curve_name(nid)))
86
+ ossl_raise(ePKeyError, NULL);
89
87
 
90
- EC_KEY_set_asn1_flag(ec, OPENSSL_EC_NAMED_CURVE);
91
- EC_KEY_set_conv_form(ec, POINT_CONVERSION_UNCOMPRESSED);
88
+ EC_KEY_set_asn1_flag(ec, OPENSSL_EC_NAMED_CURVE);
89
+ EC_KEY_set_conv_form(ec, POINT_CONVERSION_UNCOMPRESSED);
92
90
  }
93
91
 
94
92
  return ec;
@@ -115,12 +113,12 @@ ossl_ec_key_s_generate(VALUE klass, VALUE arg)
115
113
  if (!pkey || EVP_PKEY_assign_EC_KEY(pkey, ec) != 1) {
116
114
  EVP_PKEY_free(pkey);
117
115
  EC_KEY_free(ec);
118
- ossl_raise(eECError, "EVP_PKEY_assign_EC_KEY");
116
+ ossl_raise(ePKeyError, "EVP_PKEY_assign_EC_KEY");
119
117
  }
120
118
  RTYPEDDATA_DATA(obj) = pkey;
121
119
 
122
120
  if (!EC_KEY_generate_key(ec))
123
- ossl_raise(eECError, "EC_KEY_generate_key");
121
+ ossl_raise(ePKeyError, "EC_KEY_generate_key");
124
122
 
125
123
  return obj;
126
124
  }
@@ -150,9 +148,14 @@ static VALUE ossl_ec_key_initialize(int argc, VALUE *argv, VALUE self)
150
148
 
151
149
  rb_scan_args(argc, argv, "02", &arg, &pass);
152
150
  if (NIL_P(arg)) {
151
+ #ifdef OSSL_HAVE_IMMUTABLE_PKEY
152
+ rb_raise(rb_eArgError, "OpenSSL::PKey::EC.new cannot be called " \
153
+ "without arguments; pkeys are immutable with OpenSSL 3.0");
154
+ #else
153
155
  if (!(ec = EC_KEY_new()))
154
- ossl_raise(eECError, "EC_KEY_new");
156
+ ossl_raise(ePKeyError, "EC_KEY_new");
155
157
  goto legacy;
158
+ #endif
156
159
  }
157
160
  else if (rb_obj_is_kind_of(arg, cEC_GROUP)) {
158
161
  ec = ec_key_new_from_group(arg);
@@ -174,7 +177,7 @@ static VALUE ossl_ec_key_initialize(int argc, VALUE *argv, VALUE self)
174
177
  type = EVP_PKEY_base_id(pkey);
175
178
  if (type != EVP_PKEY_EC) {
176
179
  EVP_PKEY_free(pkey);
177
- rb_raise(eECError, "incorrect pkey type: %s", OBJ_nid2sn(type));
180
+ rb_raise(ePKeyError, "incorrect pkey type: %s", OBJ_nid2sn(type));
178
181
  }
179
182
  RTYPEDDATA_DATA(self) = pkey;
180
183
  return self;
@@ -184,13 +187,14 @@ static VALUE ossl_ec_key_initialize(int argc, VALUE *argv, VALUE self)
184
187
  if (!pkey || EVP_PKEY_assign_EC_KEY(pkey, ec) != 1) {
185
188
  EVP_PKEY_free(pkey);
186
189
  EC_KEY_free(ec);
187
- ossl_raise(eECError, "EVP_PKEY_assign_EC_KEY");
190
+ ossl_raise(ePKeyError, "EVP_PKEY_assign_EC_KEY");
188
191
  }
189
192
  RTYPEDDATA_DATA(self) = pkey;
190
193
  return self;
191
194
  }
192
195
 
193
196
  #ifndef HAVE_EVP_PKEY_DUP
197
+ /* :nodoc: */
194
198
  static VALUE
195
199
  ossl_ec_key_initialize_copy(VALUE self, VALUE other)
196
200
  {
@@ -204,12 +208,12 @@ ossl_ec_key_initialize_copy(VALUE self, VALUE other)
204
208
 
205
209
  ec_new = EC_KEY_dup(ec);
206
210
  if (!ec_new)
207
- ossl_raise(eECError, "EC_KEY_dup");
211
+ ossl_raise(ePKeyError, "EC_KEY_dup");
208
212
 
209
213
  pkey = EVP_PKEY_new();
210
214
  if (!pkey || EVP_PKEY_assign_EC_KEY(pkey, ec_new) != 1) {
211
215
  EC_KEY_free(ec_new);
212
- ossl_raise(eECError, "EVP_PKEY_assign_EC_KEY");
216
+ ossl_raise(ePKeyError, "EVP_PKEY_assign_EC_KEY");
213
217
  }
214
218
  RTYPEDDATA_DATA(self) = pkey;
215
219
 
@@ -233,7 +237,7 @@ ossl_ec_key_get_group(VALUE self)
233
237
  GetEC(self, ec);
234
238
  group = EC_KEY_get0_group(ec);
235
239
  if (!group)
236
- return Qnil;
240
+ return Qnil;
237
241
 
238
242
  return ec_group_new(group);
239
243
  }
@@ -248,7 +252,7 @@ ossl_ec_key_get_group(VALUE self)
248
252
  static VALUE
249
253
  ossl_ec_key_set_group(VALUE self, VALUE group_v)
250
254
  {
251
- #if OSSL_OPENSSL_PREREQ(3, 0, 0)
255
+ #ifdef OSSL_HAVE_IMMUTABLE_PKEY
252
256
  rb_raise(ePKeyError, "pkeys are immutable on OpenSSL 3.0");
253
257
  #else
254
258
  EC_KEY *ec;
@@ -258,7 +262,7 @@ ossl_ec_key_set_group(VALUE self, VALUE group_v)
258
262
  GetECGroup(group_v, group);
259
263
 
260
264
  if (EC_KEY_set_group(ec, group) != 1)
261
- ossl_raise(eECError, "EC_KEY_set_group");
265
+ ossl_raise(ePKeyError, "EC_KEY_set_group");
262
266
 
263
267
  return group_v;
264
268
  #endif
@@ -290,7 +294,7 @@ static VALUE ossl_ec_key_get_private_key(VALUE self)
290
294
  */
291
295
  static VALUE ossl_ec_key_set_private_key(VALUE self, VALUE private_key)
292
296
  {
293
- #if OSSL_OPENSSL_PREREQ(3, 0, 0)
297
+ #ifdef OSSL_HAVE_IMMUTABLE_PKEY
294
298
  rb_raise(ePKeyError, "pkeys are immutable on OpenSSL 3.0");
295
299
  #else
296
300
  EC_KEY *ec;
@@ -301,14 +305,14 @@ static VALUE ossl_ec_key_set_private_key(VALUE self, VALUE private_key)
301
305
  bn = GetBNPtr(private_key);
302
306
 
303
307
  switch (EC_KEY_set_private_key(ec, bn)) {
304
- case 1:
308
+ case 1:
305
309
  break;
306
- case 0:
310
+ case 0:
307
311
  if (bn == NULL)
308
312
  break;
309
- /* fallthrough */
310
- default:
311
- ossl_raise(eECError, "EC_KEY_set_private_key");
313
+ /* fallthrough */
314
+ default:
315
+ ossl_raise(ePKeyError, "EC_KEY_set_private_key");
312
316
  }
313
317
 
314
318
  return private_key;
@@ -341,7 +345,7 @@ static VALUE ossl_ec_key_get_public_key(VALUE self)
341
345
  */
342
346
  static VALUE ossl_ec_key_set_public_key(VALUE self, VALUE public_key)
343
347
  {
344
- #if OSSL_OPENSSL_PREREQ(3, 0, 0)
348
+ #ifdef OSSL_HAVE_IMMUTABLE_PKEY
345
349
  rb_raise(ePKeyError, "pkeys are immutable on OpenSSL 3.0");
346
350
  #else
347
351
  EC_KEY *ec;
@@ -352,14 +356,14 @@ static VALUE ossl_ec_key_set_public_key(VALUE self, VALUE public_key)
352
356
  GetECPoint(public_key, point);
353
357
 
354
358
  switch (EC_KEY_set_public_key(ec, point)) {
355
- case 1:
359
+ case 1:
356
360
  break;
357
- case 0:
361
+ case 0:
358
362
  if (point == NULL)
359
363
  break;
360
- /* fallthrough */
361
- default:
362
- ossl_raise(eECError, "EC_KEY_set_public_key");
364
+ /* fallthrough */
365
+ default:
366
+ ossl_raise(ePKeyError, "EC_KEY_set_public_key");
363
367
  }
364
368
 
365
369
  return public_key;
@@ -463,7 +467,7 @@ ossl_ec_key_export(int argc, VALUE *argv, VALUE self)
463
467
 
464
468
  GetEC(self, ec);
465
469
  if (EC_KEY_get0_public_key(ec) == NULL)
466
- ossl_raise(eECError, "can't export - no public key set");
470
+ ossl_raise(ePKeyError, "can't export - no public key set");
467
471
  if (EC_KEY_get0_private_key(ec))
468
472
  return ossl_pkey_export_traditional(argc, argv, self, 0);
469
473
  else
@@ -491,7 +495,7 @@ ossl_ec_key_to_der(VALUE self)
491
495
 
492
496
  GetEC(self, ec);
493
497
  if (EC_KEY_get0_public_key(ec) == NULL)
494
- ossl_raise(eECError, "can't export - no public key set");
498
+ ossl_raise(ePKeyError, "can't export - no public key set");
495
499
  if (EC_KEY_get0_private_key(ec))
496
500
  return ossl_pkey_export_traditional(0, NULL, self, 1);
497
501
  else
@@ -513,14 +517,14 @@ ossl_ec_key_to_der(VALUE self)
513
517
  */
514
518
  static VALUE ossl_ec_key_generate_key(VALUE self)
515
519
  {
516
- #if OSSL_OPENSSL_PREREQ(3, 0, 0)
520
+ #ifdef OSSL_HAVE_IMMUTABLE_PKEY
517
521
  rb_raise(ePKeyError, "pkeys are immutable on OpenSSL 3.0");
518
522
  #else
519
523
  EC_KEY *ec;
520
524
 
521
525
  GetEC(self, ec);
522
526
  if (EC_KEY_generate_key(ec) != 1)
523
- ossl_raise(eECError, "EC_KEY_generate_key");
527
+ ossl_raise(ePKeyError, "EC_KEY_generate_key");
524
528
 
525
529
  return self;
526
530
  #endif
@@ -545,18 +549,18 @@ static VALUE ossl_ec_key_check_key(VALUE self)
545
549
  GetEC(self, ec);
546
550
  pctx = EVP_PKEY_CTX_new(pkey, /* engine */NULL);
547
551
  if (!pctx)
548
- ossl_raise(eECError, "EVP_PKEY_CTX_new");
552
+ ossl_raise(ePKeyError, "EVP_PKEY_CTX_new");
549
553
 
550
554
  if (EC_KEY_get0_private_key(ec) != NULL) {
551
555
  if (EVP_PKEY_check(pctx) != 1) {
552
556
  EVP_PKEY_CTX_free(pctx);
553
- ossl_raise(eECError, "EVP_PKEY_check");
557
+ ossl_raise(ePKeyError, "EVP_PKEY_check");
554
558
  }
555
559
  }
556
560
  else {
557
561
  if (EVP_PKEY_public_check(pctx) != 1) {
558
562
  EVP_PKEY_CTX_free(pctx);
559
- ossl_raise(eECError, "EVP_PKEY_public_check");
563
+ ossl_raise(ePKeyError, "EVP_PKEY_public_check");
560
564
  }
561
565
  }
562
566
 
@@ -566,7 +570,7 @@ static VALUE ossl_ec_key_check_key(VALUE self)
566
570
 
567
571
  GetEC(self, ec);
568
572
  if (EC_KEY_check_key(ec) != 1)
569
- ossl_raise(eECError, "EC_KEY_check_key");
573
+ ossl_raise(ePKeyError, "EC_KEY_check_key");
570
574
  #endif
571
575
 
572
576
  return Qtrue;
@@ -584,7 +588,7 @@ ossl_ec_group_free(void *ptr)
584
588
  static const rb_data_type_t ossl_ec_group_type = {
585
589
  "OpenSSL/ec_group",
586
590
  {
587
- 0, ossl_ec_group_free,
591
+ 0, ossl_ec_group_free,
588
592
  },
589
593
  0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
590
594
  };
@@ -604,7 +608,7 @@ ec_group_new(const EC_GROUP *group)
604
608
  obj = ossl_ec_group_alloc(cEC_GROUP);
605
609
  group_new = EC_GROUP_dup(group);
606
610
  if (!group_new)
607
- ossl_raise(eEC_GROUP, "EC_GROUP_dup");
611
+ ossl_raise(eEC_GROUP, "EC_GROUP_dup");
608
612
  RTYPEDDATA_DATA(obj) = group_new;
609
613
 
610
614
  return obj;
@@ -632,7 +636,7 @@ static VALUE ossl_ec_group_initialize(int argc, VALUE *argv, VALUE self)
632
636
  ossl_raise(rb_eRuntimeError, "EC_GROUP is already initialized");
633
637
 
634
638
  switch (rb_scan_args(argc, argv, "13", &arg1, &arg2, &arg3, &arg4)) {
635
- case 1:
639
+ case 1:
636
640
  if (rb_obj_is_kind_of(arg1, cEC_GROUP)) {
637
641
  const EC_GROUP *arg1_group;
638
642
 
@@ -644,7 +648,7 @@ static VALUE ossl_ec_group_initialize(int argc, VALUE *argv, VALUE self)
644
648
 
645
649
  group = PEM_read_bio_ECPKParameters(in, NULL, NULL, NULL);
646
650
  if (!group) {
647
- OSSL_BIO_reset(in);
651
+ OSSL_BIO_reset(in);
648
652
  group = d2i_ECPKParameters_bio(in, NULL);
649
653
  }
650
654
 
@@ -654,11 +658,14 @@ static VALUE ossl_ec_group_initialize(int argc, VALUE *argv, VALUE self)
654
658
  const char *name = StringValueCStr(arg1);
655
659
  int nid = OBJ_sn2nid(name);
656
660
 
657
- ossl_clear_error(); /* ignore errors in d2i_ECPKParameters_bio() */
661
+ ossl_clear_error(); /* ignore errors in d2i_ECPKParameters_bio() */
658
662
  if (nid == NID_undef)
659
663
  ossl_raise(eEC_GROUP, "unknown curve name (%"PRIsVALUE")", arg1);
660
-
664
+ #if !defined(OPENSSL_IS_AWSLC)
661
665
  group = EC_GROUP_new_by_curve_name(nid);
666
+ #else /* EC_GROUPs are static and immutable by default in AWS-LC. */
667
+ group = EC_GROUP_new_by_curve_name_mutable(nid);
668
+ #endif
662
669
  if (group == NULL)
663
670
  ossl_raise(eEC_GROUP, "unable to create curve (%"PRIsVALUE")", arg1);
664
671
 
@@ -668,32 +675,33 @@ static VALUE ossl_ec_group_initialize(int argc, VALUE *argv, VALUE self)
668
675
  }
669
676
 
670
677
  break;
671
- case 4:
678
+ case 4:
672
679
  if (SYMBOL_P(arg1)) {
673
- ID id = SYM2ID(arg1);
674
680
  EC_GROUP *(*new_curve)(const BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *) = NULL;
675
681
  const BIGNUM *p = GetBNPtr(arg2);
676
682
  const BIGNUM *a = GetBNPtr(arg3);
677
683
  const BIGNUM *b = GetBNPtr(arg4);
678
684
 
679
- if (id == s_GFp) {
685
+ if (arg1 == sym_GFp) {
680
686
  new_curve = EC_GROUP_new_curve_GFp;
687
+ }
681
688
  #if !defined(OPENSSL_NO_EC2M)
682
- } else if (id == s_GF2m) {
689
+ else if (arg1 == sym_GF2m) {
683
690
  new_curve = EC_GROUP_new_curve_GF2m;
691
+ }
684
692
  #endif
685
- } else {
693
+ else {
686
694
  ossl_raise(rb_eArgError, "unknown symbol, must be :GFp or :GF2m");
687
695
  }
688
696
 
689
697
  if ((group = new_curve(p, a, b, ossl_bn_ctx)) == NULL)
690
698
  ossl_raise(eEC_GROUP, "EC_GROUP_new_by_GF*");
691
699
  } else {
692
- ossl_raise(rb_eArgError, "unknown argument, must be :GFp or :GF2m");
700
+ ossl_raise(rb_eArgError, "unknown argument, must be :GFp or :GF2m");
693
701
  }
694
702
 
695
703
  break;
696
- default:
704
+ default:
697
705
  ossl_raise(rb_eArgError, "wrong number of arguments");
698
706
  }
699
707
 
@@ -703,6 +711,7 @@ static VALUE ossl_ec_group_initialize(int argc, VALUE *argv, VALUE self)
703
711
  return self;
704
712
  }
705
713
 
714
+ /* :nodoc: */
706
715
  static VALUE
707
716
  ossl_ec_group_initialize_copy(VALUE self, VALUE other)
708
717
  {
@@ -710,12 +719,12 @@ ossl_ec_group_initialize_copy(VALUE self, VALUE other)
710
719
 
711
720
  TypedData_Get_Struct(self, EC_GROUP, &ossl_ec_group_type, group_new);
712
721
  if (group_new)
713
- ossl_raise(eEC_GROUP, "EC::Group already initialized");
722
+ ossl_raise(eEC_GROUP, "EC::Group already initialized");
714
723
  GetECGroup(other, group);
715
724
 
716
725
  group_new = EC_GROUP_dup(group);
717
726
  if (!group_new)
718
- ossl_raise(eEC_GROUP, "EC_GROUP_dup");
727
+ ossl_raise(eEC_GROUP, "EC_GROUP_dup");
719
728
  RTYPEDDATA_DATA(self) = group_new;
720
729
 
721
730
  return self;
@@ -737,9 +746,9 @@ static VALUE ossl_ec_group_eql(VALUE a, VALUE b)
737
746
  GetECGroup(b, group2);
738
747
 
739
748
  switch (EC_GROUP_cmp(group1, group2, ossl_bn_ctx)) {
740
- case 0: return Qtrue;
741
- case 1: return Qfalse;
742
- default: ossl_raise(eEC_GROUP, "EC_GROUP_cmp");
749
+ case 0: return Qtrue;
750
+ case 1: return Qfalse;
751
+ default: ossl_raise(eEC_GROUP, "EC_GROUP_cmp");
743
752
  }
744
753
  }
745
754
 
@@ -759,7 +768,7 @@ static VALUE ossl_ec_group_get_generator(VALUE self)
759
768
  GetECGroup(self, group);
760
769
  generator = EC_GROUP_get0_generator(group);
761
770
  if (!generator)
762
- return Qnil;
771
+ return Qnil;
763
772
 
764
773
  return ec_point_new(generator, group);
765
774
  }
@@ -802,11 +811,10 @@ static VALUE ossl_ec_group_get_order(VALUE self)
802
811
  {
803
812
  VALUE bn_obj;
804
813
  BIGNUM *bn;
805
- EC_GROUP *group = NULL;
814
+ EC_GROUP *group;
806
815
 
807
816
  GetECGroup(self, group);
808
-
809
- bn_obj = ossl_bn_new(NULL);
817
+ bn_obj = ossl_bn_new(BN_value_one());
810
818
  bn = GetBNPtr(bn_obj);
811
819
 
812
820
  if (EC_GROUP_get_order(group, bn, ossl_bn_ctx) != 1)
@@ -827,11 +835,10 @@ static VALUE ossl_ec_group_get_cofactor(VALUE self)
827
835
  {
828
836
  VALUE bn_obj;
829
837
  BIGNUM *bn;
830
- EC_GROUP *group = NULL;
838
+ EC_GROUP *group;
831
839
 
832
840
  GetECGroup(self, group);
833
-
834
- bn_obj = ossl_bn_new(NULL);
841
+ bn_obj = ossl_bn_new(BN_value_one());
835
842
  bn = GetBNPtr(bn_obj);
836
843
 
837
844
  if (EC_GROUP_get_cofactor(group, bn, ossl_bn_ctx) != 1)
@@ -842,25 +849,23 @@ static VALUE ossl_ec_group_get_cofactor(VALUE self)
842
849
 
843
850
  /*
844
851
  * call-seq:
845
- * group.curve_name => String
852
+ * group.curve_name -> string or nil
846
853
  *
847
- * Returns the curve name (sn).
854
+ * Returns the curve name (short name) corresponding to this group, or +nil+
855
+ * if \OpenSSL does not have an OID associated with the group.
848
856
  *
849
857
  * See the OpenSSL documentation for EC_GROUP_get_curve_name()
850
858
  */
851
859
  static VALUE ossl_ec_group_get_curve_name(VALUE self)
852
860
  {
853
- EC_GROUP *group = NULL;
861
+ EC_GROUP *group;
854
862
  int nid;
855
863
 
856
864
  GetECGroup(self, group);
857
- if (group == NULL)
858
- return Qnil;
859
-
860
865
  nid = EC_GROUP_get_curve_name(group);
861
-
862
- /* BUG: an nid or asn1 object should be returned, maybe. */
863
- return rb_str_new2(OBJ_nid2sn(nid));
866
+ if (nid == NID_undef)
867
+ return Qnil;
868
+ return rb_str_new_cstr(OBJ_nid2sn(nid));
864
869
  }
865
870
 
866
871
  /*
@@ -953,37 +958,36 @@ static VALUE ossl_ec_group_set_asn1_flag(VALUE self, VALUE flag_v)
953
958
  */
954
959
  static VALUE ossl_ec_group_get_point_conversion_form(VALUE self)
955
960
  {
956
- EC_GROUP *group = NULL;
961
+ EC_GROUP *group;
957
962
  point_conversion_form_t form;
958
- VALUE ret;
959
963
 
960
964
  GetECGroup(self, group);
961
965
  form = EC_GROUP_get_point_conversion_form(group);
962
966
 
963
967
  switch (form) {
964
- case POINT_CONVERSION_UNCOMPRESSED: ret = ID_uncompressed; break;
965
- case POINT_CONVERSION_COMPRESSED: ret = ID_compressed; break;
966
- case POINT_CONVERSION_HYBRID: ret = ID_hybrid; break;
967
- default: ossl_raise(eEC_GROUP, "unsupported point conversion form: %d, this module should be updated", form);
968
+ case POINT_CONVERSION_UNCOMPRESSED:
969
+ return sym_uncompressed;
970
+ case POINT_CONVERSION_COMPRESSED:
971
+ return sym_compressed;
972
+ case POINT_CONVERSION_HYBRID:
973
+ return sym_hybrid;
974
+ default:
975
+ ossl_raise(eEC_GROUP, "unsupported point conversion form: %d, " \
976
+ "this module should be updated", form);
968
977
  }
969
-
970
- return ID2SYM(ret);
971
978
  }
972
979
 
973
980
  static point_conversion_form_t
974
981
  parse_point_conversion_form_symbol(VALUE sym)
975
982
  {
976
- ID id = SYM2ID(sym);
977
-
978
- if (id == ID_uncompressed)
979
- return POINT_CONVERSION_UNCOMPRESSED;
980
- else if (id == ID_compressed)
981
- return POINT_CONVERSION_COMPRESSED;
982
- else if (id == ID_hybrid)
983
- return POINT_CONVERSION_HYBRID;
984
- else
985
- ossl_raise(rb_eArgError, "unsupported point conversion form %+"PRIsVALUE
986
- " (expected :compressed, :uncompressed, or :hybrid)", sym);
983
+ if (sym == sym_uncompressed)
984
+ return POINT_CONVERSION_UNCOMPRESSED;
985
+ if (sym == sym_compressed)
986
+ return POINT_CONVERSION_COMPRESSED;
987
+ if (sym == sym_hybrid)
988
+ return POINT_CONVERSION_HYBRID;
989
+ ossl_raise(rb_eArgError, "unsupported point conversion form %+"PRIsVALUE
990
+ " (expected :compressed, :uncompressed, or :hybrid)", sym);
987
991
  }
988
992
 
989
993
  /*
@@ -1088,20 +1092,20 @@ static VALUE ossl_ec_group_to_string(VALUE self, int format)
1088
1092
  ossl_raise(eEC_GROUP, "BIO_new(BIO_s_mem())");
1089
1093
 
1090
1094
  switch(format) {
1091
- case EXPORT_PEM:
1095
+ case EXPORT_PEM:
1092
1096
  i = PEM_write_bio_ECPKParameters(out, group);
1093
- break;
1094
- case EXPORT_DER:
1097
+ break;
1098
+ case EXPORT_DER:
1095
1099
  i = i2d_ECPKParameters_bio(out, group);
1096
- break;
1097
- default:
1100
+ break;
1101
+ default:
1098
1102
  BIO_free(out);
1099
- ossl_raise(rb_eRuntimeError, "unknown format (internal error)");
1103
+ ossl_raise(rb_eRuntimeError, "unknown format (internal error)");
1100
1104
  }
1101
1105
 
1102
1106
  if (i != 1) {
1103
1107
  BIO_free(out);
1104
- ossl_raise(eECError, NULL);
1108
+ ossl_raise(ePKeyError, NULL);
1105
1109
  }
1106
1110
 
1107
1111
  str = ossl_membio2str(out);
@@ -1145,11 +1149,11 @@ static VALUE ossl_ec_group_to_text(VALUE self)
1145
1149
 
1146
1150
  GetECGroup(self, group);
1147
1151
  if (!(out = BIO_new(BIO_s_mem()))) {
1148
- ossl_raise(eEC_GROUP, "BIO_new(BIO_s_mem())");
1152
+ ossl_raise(eEC_GROUP, "BIO_new(BIO_s_mem())");
1149
1153
  }
1150
1154
  if (!ECPKParameters_print(out, group, 0)) {
1151
- BIO_free(out);
1152
- ossl_raise(eEC_GROUP, NULL);
1155
+ BIO_free(out);
1156
+ ossl_raise(eEC_GROUP, NULL);
1153
1157
  }
1154
1158
  str = ossl_membio2str(out);
1155
1159
 
@@ -1169,7 +1173,7 @@ ossl_ec_point_free(void *ptr)
1169
1173
  static const rb_data_type_t ossl_ec_point_type = {
1170
1174
  "OpenSSL/EC_POINT",
1171
1175
  {
1172
- 0, ossl_ec_point_free,
1176
+ 0, ossl_ec_point_free,
1173
1177
  },
1174
1178
  0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
1175
1179
  };
@@ -1189,7 +1193,7 @@ ec_point_new(const EC_POINT *point, const EC_GROUP *group)
1189
1193
  obj = ossl_ec_point_alloc(cEC_POINT);
1190
1194
  point_new = EC_POINT_dup(point, group);
1191
1195
  if (!point_new)
1192
- ossl_raise(eEC_POINT, "EC_POINT_dup");
1196
+ ossl_raise(eEC_POINT, "EC_POINT_dup");
1193
1197
  RTYPEDDATA_DATA(obj) = point_new;
1194
1198
  rb_ivar_set(obj, id_i_group, ec_group_new(group));
1195
1199
 
@@ -1217,39 +1221,39 @@ static VALUE ossl_ec_point_initialize(int argc, VALUE *argv, VALUE self)
1217
1221
 
1218
1222
  TypedData_Get_Struct(self, EC_POINT, &ossl_ec_point_type, point);
1219
1223
  if (point)
1220
- rb_raise(eEC_POINT, "EC_POINT already initialized");
1224
+ rb_raise(eEC_POINT, "EC_POINT already initialized");
1221
1225
 
1222
1226
  rb_scan_args(argc, argv, "11", &group_v, &arg2);
1223
1227
  if (rb_obj_is_kind_of(group_v, cEC_POINT)) {
1224
- if (argc != 1)
1225
- rb_raise(rb_eArgError, "invalid second argument");
1226
- return ossl_ec_point_initialize_copy(self, group_v);
1228
+ if (argc != 1)
1229
+ rb_raise(rb_eArgError, "invalid second argument");
1230
+ return ossl_ec_point_initialize_copy(self, group_v);
1227
1231
  }
1228
1232
 
1229
1233
  GetECGroup(group_v, group);
1230
1234
  if (argc == 1) {
1231
- point = EC_POINT_new(group);
1232
- if (!point)
1233
- ossl_raise(eEC_POINT, "EC_POINT_new");
1235
+ point = EC_POINT_new(group);
1236
+ if (!point)
1237
+ ossl_raise(eEC_POINT, "EC_POINT_new");
1234
1238
  }
1235
1239
  else {
1236
- if (rb_obj_is_kind_of(arg2, cBN)) {
1237
- point = EC_POINT_bn2point(group, GetBNPtr(arg2), NULL, ossl_bn_ctx);
1238
- if (!point)
1239
- ossl_raise(eEC_POINT, "EC_POINT_bn2point");
1240
- }
1241
- else {
1242
- StringValue(arg2);
1243
- point = EC_POINT_new(group);
1244
- if (!point)
1245
- ossl_raise(eEC_POINT, "EC_POINT_new");
1246
- if (!EC_POINT_oct2point(group, point,
1247
- (unsigned char *)RSTRING_PTR(arg2),
1248
- RSTRING_LEN(arg2), ossl_bn_ctx)) {
1249
- EC_POINT_free(point);
1250
- ossl_raise(eEC_POINT, "EC_POINT_oct2point");
1251
- }
1252
- }
1240
+ if (rb_obj_is_kind_of(arg2, cBN)) {
1241
+ point = EC_POINT_bn2point(group, GetBNPtr(arg2), NULL, ossl_bn_ctx);
1242
+ if (!point)
1243
+ ossl_raise(eEC_POINT, "EC_POINT_bn2point");
1244
+ }
1245
+ else {
1246
+ StringValue(arg2);
1247
+ point = EC_POINT_new(group);
1248
+ if (!point)
1249
+ ossl_raise(eEC_POINT, "EC_POINT_new");
1250
+ if (!EC_POINT_oct2point(group, point,
1251
+ (unsigned char *)RSTRING_PTR(arg2),
1252
+ RSTRING_LEN(arg2), ossl_bn_ctx)) {
1253
+ EC_POINT_free(point);
1254
+ ossl_raise(eEC_POINT, "EC_POINT_oct2point");
1255
+ }
1256
+ }
1253
1257
  }
1254
1258
 
1255
1259
  RTYPEDDATA_DATA(self) = point;
@@ -1258,6 +1262,7 @@ static VALUE ossl_ec_point_initialize(int argc, VALUE *argv, VALUE self)
1258
1262
  return self;
1259
1263
  }
1260
1264
 
1265
+ /* :nodoc: */
1261
1266
  static VALUE
1262
1267
  ossl_ec_point_initialize_copy(VALUE self, VALUE other)
1263
1268
  {
@@ -1267,7 +1272,7 @@ ossl_ec_point_initialize_copy(VALUE self, VALUE other)
1267
1272
 
1268
1273
  TypedData_Get_Struct(self, EC_POINT, &ossl_ec_point_type, point_new);
1269
1274
  if (point_new)
1270
- ossl_raise(eEC_POINT, "EC::Point already initialized");
1275
+ ossl_raise(eEC_POINT, "EC::Point already initialized");
1271
1276
  GetECPoint(other, point);
1272
1277
 
1273
1278
  group_v = rb_obj_dup(rb_attr_get(other, id_i_group));
@@ -1275,7 +1280,7 @@ ossl_ec_point_initialize_copy(VALUE self, VALUE other)
1275
1280
 
1276
1281
  point_new = EC_POINT_dup(point, group);
1277
1282
  if (!point_new)
1278
- ossl_raise(eEC_POINT, "EC_POINT_dup");
1283
+ ossl_raise(eEC_POINT, "EC_POINT_dup");
1279
1284
  RTYPEDDATA_DATA(self) = point_new;
1280
1285
  rb_ivar_set(self, id_i_group, group_v);
1281
1286
 
@@ -1302,9 +1307,9 @@ static VALUE ossl_ec_point_eql(VALUE a, VALUE b)
1302
1307
  GetECGroup(group_v1, group);
1303
1308
 
1304
1309
  switch (EC_POINT_cmp(group, point1, point2, ossl_bn_ctx)) {
1305
- case 0: return Qtrue;
1306
- case 1: return Qfalse;
1307
- default: ossl_raise(eEC_POINT, "EC_POINT_cmp");
1310
+ case 0: return Qtrue;
1311
+ case 1: return Qfalse;
1312
+ default: ossl_raise(eEC_POINT, "EC_POINT_cmp");
1308
1313
  }
1309
1314
 
1310
1315
  UNREACHABLE;
@@ -1323,9 +1328,9 @@ static VALUE ossl_ec_point_is_at_infinity(VALUE self)
1323
1328
  GetECPointGroup(self, group);
1324
1329
 
1325
1330
  switch (EC_POINT_is_at_infinity(group, point)) {
1326
- case 1: return Qtrue;
1327
- case 0: return Qfalse;
1328
- default: ossl_raise(eEC_POINT, "EC_POINT_is_at_infinity");
1331
+ case 1: return Qtrue;
1332
+ case 0: return Qfalse;
1333
+ default: ossl_raise(eEC_POINT, "EC_POINT_is_at_infinity");
1329
1334
  }
1330
1335
 
1331
1336
  UNREACHABLE;
@@ -1344,9 +1349,9 @@ static VALUE ossl_ec_point_is_on_curve(VALUE self)
1344
1349
  GetECPointGroup(self, group);
1345
1350
 
1346
1351
  switch (EC_POINT_is_on_curve(group, point, ossl_bn_ctx)) {
1347
- case 1: return Qtrue;
1348
- case 0: return Qfalse;
1349
- default: ossl_raise(eEC_POINT, "EC_POINT_is_on_curve");
1352
+ case 1: return Qtrue;
1353
+ case 0: return Qfalse;
1354
+ default: ossl_raise(eEC_POINT, "EC_POINT_is_on_curve");
1350
1355
  }
1351
1356
 
1352
1357
  UNREACHABLE;
@@ -1367,7 +1372,7 @@ static VALUE ossl_ec_point_make_affine(VALUE self)
1367
1372
  GetECPointGroup(self, group);
1368
1373
 
1369
1374
  rb_warn("OpenSSL::PKey::EC::Point#make_affine! is deprecated");
1370
- #if !OSSL_OPENSSL_PREREQ(3, 0, 0)
1375
+ #if !defined(OSSL_HAVE_IMMUTABLE_PKEY) && !defined(OPENSSL_IS_AWSLC)
1371
1376
  if (EC_POINT_make_affine(group, point, ossl_bn_ctx) != 1)
1372
1377
  ossl_raise(eEC_POINT, "EC_POINT_make_affine");
1373
1378
  #endif
@@ -1438,12 +1443,12 @@ ossl_ec_point_to_octet_string(VALUE self, VALUE conversion_form)
1438
1443
 
1439
1444
  len = EC_POINT_point2oct(group, point, form, NULL, 0, ossl_bn_ctx);
1440
1445
  if (!len)
1441
- ossl_raise(eEC_POINT, "EC_POINT_point2oct");
1446
+ ossl_raise(eEC_POINT, "EC_POINT_point2oct");
1442
1447
  str = rb_str_new(NULL, (long)len);
1443
1448
  if (!EC_POINT_point2oct(group, point, form,
1444
- (unsigned char *)RSTRING_PTR(str), len,
1445
- ossl_bn_ctx))
1446
- ossl_raise(eEC_POINT, "EC_POINT_point2oct");
1449
+ (unsigned char *)RSTRING_PTR(str), len,
1450
+ ossl_bn_ctx))
1451
+ ossl_raise(eEC_POINT, "EC_POINT_point2oct");
1447
1452
  return str;
1448
1453
  }
1449
1454
 
@@ -1478,7 +1483,6 @@ static VALUE ossl_ec_point_add(VALUE self, VALUE other)
1478
1483
  /*
1479
1484
  * call-seq:
1480
1485
  * point.mul(bn1 [, bn2]) => point
1481
- * point.mul(bns, points [, bn2]) => point
1482
1486
  *
1483
1487
  * Performs elliptic curve point multiplication.
1484
1488
  *
@@ -1486,11 +1490,9 @@ static VALUE ossl_ec_point_add(VALUE self, VALUE other)
1486
1490
  * generator of the group of _point_. _bn2_ may be omitted, and in that case,
1487
1491
  * the result is just <tt>bn1 * point</tt>.
1488
1492
  *
1489
- * The second form calculates <tt>bns[0] * point + bns[1] * points[0] + ...
1490
- * + bns[-1] * points[-1] + bn2 * G</tt>. _bn2_ may be omitted. _bns_ must be
1491
- * an array of OpenSSL::BN. _points_ must be an array of
1492
- * OpenSSL::PKey::EC::Point. Please note that <tt>points[0]</tt> is not
1493
- * multiplied by <tt>bns[0]</tt>, but <tt>bns[1]</tt>.
1493
+ * Before version 4.0.0, and when compiled with OpenSSL 1.1.1 or older, this
1494
+ * method allowed another form:
1495
+ * point.mul(bns, points [, bn2]) => point
1494
1496
  */
1495
1497
  static VALUE ossl_ec_point_mul(int argc, VALUE *argv, VALUE self)
1496
1498
  {
@@ -1508,62 +1510,15 @@ static VALUE ossl_ec_point_mul(int argc, VALUE *argv, VALUE self)
1508
1510
  GetECPoint(result, point_result);
1509
1511
 
1510
1512
  rb_scan_args(argc, argv, "12", &arg1, &arg2, &arg3);
1511
- if (!RB_TYPE_P(arg1, T_ARRAY)) {
1512
- BIGNUM *bn = GetBNPtr(arg1);
1513
+ if (RB_TYPE_P(arg1, T_ARRAY) || argc > 2)
1514
+ rb_raise(rb_eNotImpError, "OpenSSL::PKey::EC::Point#mul with arrays " \
1515
+ "is no longer supported");
1513
1516
 
1514
- if (!NIL_P(arg2))
1515
- bn_g = GetBNPtr(arg2);
1516
- if (EC_POINT_mul(group, point_result, bn_g, point_self, bn, ossl_bn_ctx) != 1)
1517
- ossl_raise(eEC_POINT, NULL);
1518
- } else {
1519
- #if (defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3) || defined(LIBRESSL_VERSION_NUMBER)
1520
- rb_raise(rb_eNotImpError, "calling #mul with arrays is not" \
1521
- "supported by this OpenSSL version");
1522
- #else
1523
- /*
1524
- * bignums | arg1[0] | arg1[1] | arg1[2] | ...
1525
- * points | self | arg2[0] | arg2[1] | ...
1526
- */
1527
- long i, num;
1528
- VALUE bns_tmp, tmp_p, tmp_b;
1529
- const EC_POINT **points;
1530
- const BIGNUM **bignums;
1531
-
1532
- Check_Type(arg1, T_ARRAY);
1533
- Check_Type(arg2, T_ARRAY);
1534
- if (RARRAY_LEN(arg1) != RARRAY_LEN(arg2) + 1) /* arg2 must be 1 larger */
1535
- ossl_raise(rb_eArgError, "bns must be 1 longer than points; see the documentation");
1536
-
1537
- rb_warning("OpenSSL::PKey::EC::Point#mul(ary, ary) is deprecated; " \
1538
- "use #mul(bn) form instead");
1539
-
1540
- num = RARRAY_LEN(arg1);
1541
- bns_tmp = rb_ary_tmp_new(num);
1542
- bignums = ALLOCV_N(const BIGNUM *, tmp_b, num);
1543
- for (i = 0; i < num; i++) {
1544
- VALUE item = RARRAY_AREF(arg1, i);
1545
- bignums[i] = GetBNPtr(item);
1546
- rb_ary_push(bns_tmp, item);
1547
- }
1548
-
1549
- points = ALLOCV_N(const EC_POINT *, tmp_p, num);
1550
- points[0] = point_self; /* self */
1551
- for (i = 0; i < num - 1; i++)
1552
- GetECPoint(RARRAY_AREF(arg2, i), points[i + 1]);
1553
-
1554
- if (!NIL_P(arg3))
1555
- bn_g = GetBNPtr(arg3);
1556
-
1557
- if (EC_POINTs_mul(group, point_result, bn_g, num, points, bignums, ossl_bn_ctx) != 1) {
1558
- ALLOCV_END(tmp_b);
1559
- ALLOCV_END(tmp_p);
1560
- ossl_raise(eEC_POINT, NULL);
1561
- }
1562
-
1563
- ALLOCV_END(tmp_b);
1564
- ALLOCV_END(tmp_p);
1565
- #endif
1566
- }
1517
+ BIGNUM *bn = GetBNPtr(arg1);
1518
+ if (!NIL_P(arg2))
1519
+ bn_g = GetBNPtr(arg2);
1520
+ if (EC_POINT_mul(group, point_result, bn_g, point_self, bn, ossl_bn_ctx) != 1)
1521
+ ossl_raise(eEC_POINT, NULL);
1567
1522
 
1568
1523
  return result;
1569
1524
  }
@@ -1571,15 +1526,6 @@ static VALUE ossl_ec_point_mul(int argc, VALUE *argv, VALUE self)
1571
1526
  void Init_ossl_ec(void)
1572
1527
  {
1573
1528
  #undef rb_intern
1574
- #if 0
1575
- mPKey = rb_define_module_under(mOSSL, "PKey");
1576
- cPKey = rb_define_class_under(mPKey, "PKey", rb_cObject);
1577
- eOSSLError = rb_define_class_under(mOSSL, "OpenSSLError", rb_eStandardError);
1578
- ePKeyError = rb_define_class_under(mPKey, "PKeyError", eOSSLError);
1579
- #endif
1580
-
1581
- eECError = rb_define_class_under(mPKey, "ECError", ePKeyError);
1582
-
1583
1529
  /*
1584
1530
  * Document-class: OpenSSL::PKey::EC
1585
1531
  *
@@ -1601,17 +1547,15 @@ void Init_ossl_ec(void)
1601
1547
  eEC_GROUP = rb_define_class_under(cEC_GROUP, "Error", eOSSLError);
1602
1548
  eEC_POINT = rb_define_class_under(cEC_POINT, "Error", eOSSLError);
1603
1549
 
1604
- s_GFp = rb_intern("GFp");
1605
- s_GF2m = rb_intern("GF2m");
1550
+ sym_GFp = ID2SYM(rb_intern_const("GFp"));
1551
+ sym_GF2m = ID2SYM(rb_intern_const("GF2m"));
1606
1552
 
1607
- ID_uncompressed = rb_intern("uncompressed");
1608
- ID_compressed = rb_intern("compressed");
1609
- ID_hybrid = rb_intern("hybrid");
1553
+ sym_uncompressed = ID2SYM(rb_intern_const("uncompressed"));
1554
+ sym_compressed = ID2SYM(rb_intern_const("compressed"));
1555
+ sym_hybrid = ID2SYM(rb_intern_const("hybrid"));
1610
1556
 
1611
1557
  rb_define_const(cEC, "NAMED_CURVE", INT2NUM(OPENSSL_EC_NAMED_CURVE));
1612
- #if defined(OPENSSL_EC_EXPLICIT_CURVE)
1613
1558
  rb_define_const(cEC, "EXPLICIT_CURVE", INT2NUM(OPENSSL_EC_EXPLICIT_CURVE));
1614
- #endif
1615
1559
 
1616
1560
  rb_define_singleton_method(cEC, "builtin_curves", ossl_s_builtin_curves, 0);
1617
1561