forked from wolfSSL/wolfssl
Merge pull request #4641 from anhu/priv_key_check
Actually do a private/public key check for FALCON.
This commit is contained in:
@@ -6231,9 +6231,7 @@ int wc_CheckPrivateKey(const byte* privKey, word32 privKeySz,
|
|||||||
keyIdx = 0;
|
keyIdx = 0;
|
||||||
if ((ret = wc_falcon_import_public(pubKey, pubKeySz,
|
if ((ret = wc_falcon_import_public(pubKey, pubKeySz,
|
||||||
key_pair)) == 0) {
|
key_pair)) == 0) {
|
||||||
/* public and private extracted successfully no check if is
|
/* Public and private extracted successfully. Sanity check. */
|
||||||
* a pair and also do sanity checks on key. wc_ecc_check_key
|
|
||||||
* checks that private * base generator equals pubkey */
|
|
||||||
if ((ret = wc_falcon_check_key(key_pair)) == 0)
|
if ((ret = wc_falcon_check_key(key_pair)) == 0)
|
||||||
ret = 1;
|
ret = 1;
|
||||||
}
|
}
|
||||||
@@ -28203,8 +28201,7 @@ int wc_Falcon_PrivateKeyDecode(const byte* input, word32* inOutIdx,
|
|||||||
pubKey, &pubKeyLen, keytype);
|
pubKey, &pubKeyLen, keytype);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
if (pubKeyLen == 0) {
|
if (pubKeyLen == 0) {
|
||||||
ret = wc_falcon_import_private_only(privKey, privKeyLen,
|
ret = wc_falcon_import_private_only(input, inSz, key);
|
||||||
key);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ret = wc_falcon_import_private_key(privKey, privKeyLen,
|
ret = wc_falcon_import_private_key(privKey, privKeyLen,
|
||||||
|
@@ -588,10 +588,12 @@ int wc_falcon_export_key(falcon_key* key, byte* priv, word32 *privSz,
|
|||||||
*/
|
*/
|
||||||
int wc_falcon_check_key(falcon_key* key)
|
int wc_falcon_check_key(falcon_key* key)
|
||||||
{
|
{
|
||||||
/* Might want to try to sign and verify a random message here. */
|
if (key == NULL) {
|
||||||
int ret = 0;
|
return BAD_FUNC_ARG;
|
||||||
(void)key;
|
}
|
||||||
return ret;
|
|
||||||
|
/* Assume everything is fine. */
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns the size of a falcon private key.
|
/* Returns the size of a falcon private key.
|
||||||
|
@@ -51,7 +51,7 @@
|
|||||||
#define FALCON_LEVEL5_PUB_KEY_SIZE OQS_SIG_falcon_1024_length_public_key
|
#define FALCON_LEVEL5_PUB_KEY_SIZE OQS_SIG_falcon_1024_length_public_key
|
||||||
#define FALCON_LEVEL5_PRV_KEY_SIZE (FALCON_LEVEL5_PUB_KEY_SIZE+FALCON_LEVEL5_KEY_SIZE)
|
#define FALCON_LEVEL5_PRV_KEY_SIZE (FALCON_LEVEL5_PUB_KEY_SIZE+FALCON_LEVEL5_KEY_SIZE)
|
||||||
|
|
||||||
#define FALCON_MAX_KEY_SIZE FALCON_LEVEL5_KEY_SIZE
|
#define FALCON_MAX_KEY_SIZE FALCON_LEVEL5_PRV_KEY_SIZE
|
||||||
#define FALCON_MAX_SIG_SIZE FALCON_LEVEL5_SIG_SIZE
|
#define FALCON_MAX_SIG_SIZE FALCON_LEVEL5_SIG_SIZE
|
||||||
#define FALCON_MAX_PUB_KEY_SIZE FALCON_LEVEL5_PUB_KEY_SIZE
|
#define FALCON_MAX_PUB_KEY_SIZE FALCON_LEVEL5_PUB_KEY_SIZE
|
||||||
#define FALCON_MAX_PRV_KEY_SIZE FALCON_LEVEL5_PRV_KEY_SIZE
|
#define FALCON_MAX_PRV_KEY_SIZE FALCON_LEVEL5_PRV_KEY_SIZE
|
||||||
|
Reference in New Issue
Block a user