forked from wolfSSL/wolfssl
tests/api.c: fix test_CryptoCb_Func() to not attempt signing op on ephemeral ECC keys.
This commit is contained in:
19
tests/api.c
19
tests/api.c
@@ -50682,7 +50682,15 @@ static int test_CryptoCb_Func(int thisDevId, wc_CryptoInfo* info, void* ctx)
|
|||||||
}
|
}
|
||||||
#endif /* !NO_RSA */
|
#endif /* !NO_RSA */
|
||||||
#ifdef HAVE_ECC
|
#ifdef HAVE_ECC
|
||||||
if (info->pk.type == WC_PK_TYPE_ECDSA_SIGN) {
|
if (info->pk.type == WC_PK_TYPE_EC_KEYGEN) {
|
||||||
|
/* mark this key as ephemeral */
|
||||||
|
if (info->pk.eckg.key != NULL) {
|
||||||
|
XSTRNCPY(info->pk.eckg.key->label, "ephemeral",
|
||||||
|
sizeof(info->pk.eckg.key->label));
|
||||||
|
info->pk.eckg.key->labelLen = (int)XSTRLEN(info->pk.eckg.key->label);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (info->pk.type == WC_PK_TYPE_ECDSA_SIGN) {
|
||||||
ecc_key key;
|
ecc_key key;
|
||||||
|
|
||||||
/* perform software based ECC sign */
|
/* perform software based ECC sign */
|
||||||
@@ -50690,6 +50698,15 @@ static int test_CryptoCb_Func(int thisDevId, wc_CryptoInfo* info, void* ctx)
|
|||||||
printf("test_CryptoCb_Func: ECC Sign\n");
|
printf("test_CryptoCb_Func: ECC Sign\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (info->pk.eccsign.key != NULL &&
|
||||||
|
XSTRCMP(info->pk.eccsign.key->label, "ephemeral") == 0) {
|
||||||
|
/* this is an empheral key */
|
||||||
|
#ifdef DEBUG_WOLFSSL
|
||||||
|
printf("test_CryptoCb_Func: skipping signing op on ephemeral key\n");
|
||||||
|
#endif
|
||||||
|
return CRYPTOCB_UNAVAILABLE;
|
||||||
|
}
|
||||||
|
|
||||||
ret = load_pem_key_file_as_der(privKeyFile, &pDer, &keyFormat);
|
ret = load_pem_key_file_as_der(privKeyFile, &pDer, &keyFormat);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
return ret;
|
return ret;
|
||||||
|
Reference in New Issue
Block a user