mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-31 19:24:42 +02:00
ForceZero the private key on import error
This commit is contained in:
@@ -1054,6 +1054,7 @@ int wc_ed25519_import_private_only(const byte* priv, word32 privSz,
|
|||||||
}
|
}
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
key->privKeySet = 0;
|
key->privKeySet = 0;
|
||||||
|
ForceZero(key->k, ED25519_KEY_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@@ -1105,8 +1106,11 @@ int wc_ed25519_import_private_key_ex(const byte* priv, word32 privSz,
|
|||||||
|
|
||||||
/* import public key */
|
/* import public key */
|
||||||
ret = wc_ed25519_import_public_ex(pub, pubSz, key, trusted);
|
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;
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/* make the private key (priv + pub) */
|
/* make the private key (priv + pub) */
|
||||||
XMEMCPY(key->k + ED25519_KEY_SIZE, key->p, ED25519_PUB_KEY_SIZE);
|
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)) {
|
if ((ret != 0) && (key != NULL)) {
|
||||||
/* No private key set on error. */
|
/* No private key set on error. */
|
||||||
key->privKeySet = 0;
|
key->privKeySet = 0;
|
||||||
|
ForceZero(key->k, ED448_KEY_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@@ -1059,8 +1060,11 @@ int wc_ed448_import_private_key_ex(const byte* priv, word32 privSz,
|
|||||||
|
|
||||||
/* import public key */
|
/* import public key */
|
||||||
ret = wc_ed448_import_public_ex(pub, pubSz, key, trusted);
|
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;
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/* make the private key (priv + pub) */
|
/* make the private key (priv + pub) */
|
||||||
XMEMCPY(key->k + ED448_KEY_SIZE, key->p, ED448_PUB_KEY_SIZE);
|
XMEMCPY(key->k + ED448_KEY_SIZE, key->p, ED448_PUB_KEY_SIZE);
|
||||||
|
Reference in New Issue
Block a user