mirror of https://github.com/wolfSSL/wolfssl.git
ForceZero the private key on import error
parent
4a962b7fb2
commit
4caffee590
|
@ -1054,6 +1054,7 @@ int wc_ed25519_import_private_only(const byte* priv, word32 privSz,
|
|||
}
|
||||
if (ret != 0) {
|
||||
key->privKeySet = 0;
|
||||
ForceZero(key->k, ED25519_KEY_SIZE);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -1105,8 +1106,11 @@ int wc_ed25519_import_private_key_ex(const byte* priv, word32 privSz,
|
|||
|
||||
/* import public key */
|
||||
ret = wc_ed25519_import_public_ex(pub, pubSz, key, trusted);
|
||||
if (ret != 0)
|
||||
if (ret != 0) {
|
||||
key->privKeySet = 0;
|
||||
ForceZero(key->k, ED25519_KEY_SIZE);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* make the private key (priv + pub) */
|
||||
XMEMCPY(key->k + ED25519_KEY_SIZE, key->p, ED25519_PUB_KEY_SIZE);
|
||||
|
|
|
@ -1009,6 +1009,7 @@ int wc_ed448_import_private_only(const byte* priv, word32 privSz,
|
|||
if ((ret != 0) && (key != NULL)) {
|
||||
/* No private key set on error. */
|
||||
key->privKeySet = 0;
|
||||
ForceZero(key->k, ED448_KEY_SIZE);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -1059,8 +1060,11 @@ int wc_ed448_import_private_key_ex(const byte* priv, word32 privSz,
|
|||
|
||||
/* import public key */
|
||||
ret = wc_ed448_import_public_ex(pub, pubSz, key, trusted);
|
||||
if (ret != 0)
|
||||
if (ret != 0) {
|
||||
key->privKeySet = 0;
|
||||
ForceZero(key->k, ED448_KEY_SIZE);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* make the private key (priv + pub) */
|
||||
XMEMCPY(key->k + ED448_KEY_SIZE, key->p, ED448_PUB_KEY_SIZE);
|
||||
|
|
Loading…
Reference in New Issue