Skip to content

Commit 3f2a62b

Browse files
authored
Merge pull request #251 from dgarske/fix_ecdh_no_derive
Fix ECDH without DERIVE flag with `WOLF_CRYPTOCB_ONLY_ECC`
2 parents bfb5d90 + 6430749 commit 3f2a62b

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

test/wh_test_crypto.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3953,10 +3953,25 @@ int whTest_CryptoKeyUsagePolicies(whClientContext* client, WC_RNG* rng)
39533953
ret = wh_Client_EccSetKeyId(privKey, keyId);
39543954
}
39553955
if (ret == 0) {
3956+
const byte qx[] = {
3957+
0xbb, 0x33, 0xac, 0x4c, 0x27, 0x50, 0x4a, 0xc6,
3958+
0x4a, 0xa5, 0x04, 0xc3, 0x3c, 0xde, 0x9f, 0x36,
3959+
0xdb, 0x72, 0x2d, 0xce, 0x94, 0xea, 0x2b, 0xfa,
3960+
0xcb, 0x20, 0x09, 0x39, 0x2c, 0x16, 0xe8, 0x61
3961+
};
3962+
const byte qy[] = {
3963+
0x02, 0xe9, 0xaf, 0x4d, 0xd3, 0x02, 0x93, 0x9a,
3964+
0x31, 0x5b, 0x97, 0x92, 0x21, 0x7f, 0xf0, 0xcf,
3965+
0x18, 0xda, 0x91, 0x11, 0x02, 0x34, 0x86, 0xe8,
3966+
0x20, 0x58, 0x33, 0x0b, 0x80, 0x34, 0x89, 0xd8
3967+
};
3968+
int curveId = ECC_SECP256R1;
3969+
39563970
/* Generate a public key locally for ECDH */
39573971
ret = wc_ecc_init_ex(pubKey, NULL, INVALID_DEVID);
39583972
if (ret == 0) {
3959-
ret = wc_ecc_make_key(rng, 32, pubKey);
3973+
/* Import public key */
3974+
ret = wc_ecc_import_unsigned(pubKey, qx, qy, NULL, curveId);
39603975
if (ret == 0) {
39613976
/* Try ECDH - should fail with WH_ERROR_USAGE */
39623977
ret = wc_ecc_shared_secret(

0 commit comments

Comments
 (0)