Skip to content

Commit 3088eba

Browse files
committed
Add sm2 compatibility test
1 parent ad0aef6 commit 3088eba

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

ext/openssl/tests/ecc_sm2.phpt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ var_dump($details["bits"]);
2323
var_dump(strlen($details["key"]));
2424
var_dump($details["ec"]["curve_name"]);
2525
var_dump($details["type"] == OPENSSL_KEYTYPE_EC);
26+
$public_key = openssl_pkey_get_public($details["key"]);
27+
$details_public_key = openssl_pkey_get_details($public_key);
28+
var_dump(strlen($details["key"]));
29+
var_dump($details_public_key["ec"]["curve_name"]);
30+
var_dump($details["type"] == OPENSSL_KEYTYPE_EC);
31+
var_dump($details_public_key["ec"]["x"] === $details["ec"]["x"]);
32+
var_dump($details_public_key["ec"]["y"] === $details["ec"]["y"]);
2633

2734
// EC - generate keypair with explicit parameters (SM2 curve)
2835
echo "Testing openssl_pkey_new with ec explicit parameters (SM2 curve)\n";
@@ -48,6 +55,12 @@ $details = openssl_pkey_get_details($ec);
4855
var_dump($details['bits']);
4956
var_dump(strlen($details['key']));
5057
var_dump($details['type'] == OPENSSL_KEYTYPE_EC);
58+
$public_key = openssl_pkey_get_public($details["key"]);
59+
$details_public_key = openssl_pkey_get_details($public_key);
60+
var_dump(strlen($details["key"]));
61+
var_dump($details["type"] == OPENSSL_KEYTYPE_EC);
62+
var_dump($details_public_key["ec"]["x"] === $details["ec"]["x"]);
63+
var_dump($details_public_key["ec"]["y"] === $details["ec"]["y"]);
5164
?>
5265
--EXPECTF--
5366
Testing openssl_pkey_new with ec curve_name SM2
@@ -57,7 +70,16 @@ int(256)
5770
int(178)
5871
string(3) "SM2"
5972
bool(true)
73+
int(178)
74+
string(3) "SM2"
75+
bool(true)
76+
bool(true)
77+
bool(true)
6078
Testing openssl_pkey_new with ec explicit parameters (SM2 curve)
6179
int(256)
6280
int(475)
6381
bool(true)
82+
int(475)
83+
bool(true)
84+
bool(true)
85+
bool(true)

0 commit comments

Comments
 (0)