@@ -147,9 +147,14 @@ static VALUE ossl_ec_key_initialize(int argc, VALUE *argv, VALUE self)
147
147
148
148
rb_scan_args (argc , argv , "02" , & arg , & pass );
149
149
if (NIL_P (arg )) {
150
+ #ifdef OSSL_HAVE_IMMUTABLE_PKEY
151
+ rb_raise (rb_eArgError , "OpenSSL::PKey::EC.new cannot be called " \
152
+ "without arguments; pkeys are immutable with OpenSSL 3.0" );
153
+ #else
150
154
if (!(ec = EC_KEY_new ()))
151
155
ossl_raise (eECError , "EC_KEY_new" );
152
156
goto legacy ;
157
+ #endif
153
158
}
154
159
else if (rb_obj_is_kind_of (arg , cEC_GROUP )) {
155
160
ec = ec_key_new_from_group (arg );
@@ -246,7 +251,7 @@ ossl_ec_key_get_group(VALUE self)
246
251
static VALUE
247
252
ossl_ec_key_set_group (VALUE self , VALUE group_v )
248
253
{
249
- #if OSSL_OPENSSL_PREREQ ( 3 , 0 , 0 )
254
+ #ifdef OSSL_HAVE_IMMUTABLE_PKEY
250
255
rb_raise (ePKeyError , "pkeys are immutable on OpenSSL 3.0" );
251
256
#else
252
257
EC_KEY * ec ;
@@ -288,7 +293,7 @@ static VALUE ossl_ec_key_get_private_key(VALUE self)
288
293
*/
289
294
static VALUE ossl_ec_key_set_private_key (VALUE self , VALUE private_key )
290
295
{
291
- #if OSSL_OPENSSL_PREREQ ( 3 , 0 , 0 )
296
+ #ifdef OSSL_HAVE_IMMUTABLE_PKEY
292
297
rb_raise (ePKeyError , "pkeys are immutable on OpenSSL 3.0" );
293
298
#else
294
299
EC_KEY * ec ;
@@ -339,7 +344,7 @@ static VALUE ossl_ec_key_get_public_key(VALUE self)
339
344
*/
340
345
static VALUE ossl_ec_key_set_public_key (VALUE self , VALUE public_key )
341
346
{
342
- #if OSSL_OPENSSL_PREREQ ( 3 , 0 , 0 )
347
+ #ifdef OSSL_HAVE_IMMUTABLE_PKEY
343
348
rb_raise (ePKeyError , "pkeys are immutable on OpenSSL 3.0" );
344
349
#else
345
350
EC_KEY * ec ;
@@ -511,7 +516,7 @@ ossl_ec_key_to_der(VALUE self)
511
516
*/
512
517
static VALUE ossl_ec_key_generate_key (VALUE self )
513
518
{
514
- #if OSSL_OPENSSL_PREREQ ( 3 , 0 , 0 )
519
+ #ifdef OSSL_HAVE_IMMUTABLE_PKEY
515
520
rb_raise (ePKeyError , "pkeys are immutable on OpenSSL 3.0" );
516
521
#else
517
522
EC_KEY * ec ;
@@ -1368,7 +1373,7 @@ static VALUE ossl_ec_point_make_affine(VALUE self)
1368
1373
GetECPointGroup (self , group );
1369
1374
1370
1375
rb_warn ("OpenSSL::PKey::EC::Point#make_affine! is deprecated" );
1371
- #if !OSSL_OPENSSL_PREREQ ( 3 , 0 , 0 ) && !defined(OPENSSL_IS_AWSLC )
1376
+ #if !defined( OSSL_HAVE_IMMUTABLE_PKEY ) && !defined(OPENSSL_IS_AWSLC )
1372
1377
if (EC_POINT_make_affine (group , point , ossl_bn_ctx ) != 1 )
1373
1378
ossl_raise (eEC_POINT , "EC_POINT_make_affine" );
1374
1379
#endif
0 commit comments