Ed make public key wasn't checking whether private key set

Ed25519 and Ed448 make public key APIs now check whether the private key
was set.
The private key and public key flags setting and clearing also updated.
Testing of unset private key and calling make public key added for
Ed25519 and Ed448.
This commit is contained in:
Sean Parkinson
2022-09-05 12:21:51 +10:00
parent 49065373aa
commit f807c70637
3 changed files with 41 additions and 5 deletions

View File

@@ -21426,11 +21426,21 @@ static int test_wc_ed25519_make_key(void)
#if defined(HAVE_ED25519)
ed25519_key key;
WC_RNG rng;
unsigned char pubkey[ED25519_PUB_KEY_SIZE];
ret = wc_InitRng(&rng);
if (ret == 0) {
ret = wc_ed25519_init(&key);
}
if (ret == 0) {
ret = wc_ed25519_make_public(&key, pubkey, sizeof(pubkey));
if (ret == ECC_PRIV_KEY_E) {
ret = 0;
}
else if (ret == 0) {
ret = -1;
}
}
printf(testingFmt, "wc_ed25519_make_key()");
if (ret == 0) {
ret = wc_ed25519_make_key(&rng, ED25519_KEY_SIZE, &key);
@@ -23249,11 +23259,21 @@ static int test_wc_ed448_make_key(void)
#if defined(HAVE_ED448)
ed448_key key;
WC_RNG rng;
unsigned char pubkey[ED448_PUB_KEY_SIZE];
ret = wc_InitRng(&rng);
if (ret == 0) {
ret = wc_ed448_init(&key);
}
if (ret == 0) {
ret = wc_ed448_make_public(&key, pubkey, sizeof(pubkey));
if (ret == ECC_PRIV_KEY_E) {
ret = 0;
}
else if (ret == 0) {
ret = -1;
}
}
printf(testingFmt, "wc_ed448_make_key()");
if (ret == 0) {
ret = wc_ed448_make_key(&rng, ED448_KEY_SIZE, &key);