@@ -4299,31 +4299,37 @@ static bool php_openssl_pkey_init_legacy_ec(EC_KEY *eckey, zval *data, bool *is_
4299
4299
if (!EC_KEY_set_group (eckey , group )) {
4300
4300
goto clean_exit ;
4301
4301
}
4302
+
4303
+ /* custom params not supported with SM2, SKIP */
4304
+ if (!curve_name_zv ||
4305
+ (Z_TYPE_P (curve_name_zv ) == IS_STRING &&
4306
+ OPENSSL_strcasecmp (Z_STRVAL_P (curve_name_zv ), "SM2" ) != 0 )){
4307
+ OPENSSL_PKEY_SET_BN (data , d );
4308
+ OPENSSL_PKEY_SET_BN (data , x );
4309
+ OPENSSL_PKEY_SET_BN (data , y );
4302
4310
4303
- OPENSSL_PKEY_SET_BN (data , d );
4304
- OPENSSL_PKEY_SET_BN (data , x );
4305
- OPENSSL_PKEY_SET_BN (data , y );
4306
- if (d ) {
4307
- * is_private = true;
4308
- if (!EC_KEY_set_private_key (eckey , d )) {
4309
- goto clean_exit ;
4310
- }
4311
-
4312
- point_q = EC_POINT_new (group );
4313
- if (!point_q || !EC_POINT_mul (group , point_q , d , NULL , NULL , bctx )) {
4314
- goto clean_exit ;
4315
- }
4316
- } else if (x && y ) {
4317
- /* OpenSSL does not allow setting EC_PUB_X/EC_PUB_Y, so convert to encoded format. */
4318
- point_q = EC_POINT_new (group );
4319
- if (!point_q || !EC_POINT_set_affine_coordinates (group , point_q , x , y , bctx )) {
4320
- goto clean_exit ;
4311
+ if (d ) {
4312
+ * is_private = true;
4313
+ if (!EC_KEY_set_private_key (eckey , d )) {
4314
+ goto clean_exit ;
4315
+ }
4316
+
4317
+ point_q = EC_POINT_new (group );
4318
+ if (!point_q || !EC_POINT_mul (group , point_q , d , NULL , NULL , bctx )) {
4319
+ goto clean_exit ;
4320
+ }
4321
+ } else if (x && y ) {
4322
+ /* OpenSSL does not allow setting EC_PUB_X/EC_PUB_Y, so convert to encoded format. */
4323
+ point_q = EC_POINT_new (group );
4324
+ if (!point_q || !EC_POINT_set_affine_coordinates (group , point_q , x , y , bctx )) {
4325
+ goto clean_exit ;
4326
+ }
4321
4327
}
4322
- }
4323
4328
4324
- if (point_q != NULL ) {
4325
- if (!EC_KEY_set_public_key (eckey , point_q )) {
4326
- goto clean_exit ;
4329
+ if (point_q != NULL ) {
4330
+ if (!EC_KEY_set_public_key (eckey , point_q )) {
4331
+ goto clean_exit ;
4332
+ }
4327
4333
}
4328
4334
}
4329
4335
0 commit comments