Skip to content

Commit 90377e1

Browse files
authored
Merge pull request #9979 from anhu/falcon_no_elseif
Fixes Falcon else-if chain key detection
2 parents 96661a5 + 3b36db0 commit 90377e1

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

wolfcrypt/src/asn.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9582,8 +9582,8 @@ int wc_GetKeyOID(byte* key, word32 keySz, const byte** curveOID, word32* oidSz,
95829582
return MEMORY_E;
95839583

95849584
if (wc_falcon_init(falcon) == 0) {
9585-
tmpIdx = 0;
9586-
if (wc_falcon_set_level(falcon, 1) == 0) {
9585+
if ((*algoID == 0) && (wc_falcon_set_level(falcon, 1) == 0)) {
9586+
tmpIdx = 0;
95879587
if (wc_Falcon_PrivateKeyDecode(key, &tmpIdx, falcon, keySz)
95889588
== 0) {
95899589
*algoID = FALCON_LEVEL1k;
@@ -9592,7 +9592,8 @@ int wc_GetKeyOID(byte* key, word32 keySz, const byte** curveOID, word32* oidSz,
95929592
WOLFSSL_MSG("Not Falcon Level 1 DER key");
95939593
}
95949594
}
9595-
else if (wc_falcon_set_level(falcon, 5) == 0) {
9595+
if ((*algoID == 0) && (wc_falcon_set_level(falcon, 5) == 0)) {
9596+
tmpIdx = 0;
95969597
if (wc_Falcon_PrivateKeyDecode(key, &tmpIdx, falcon, keySz)
95979598
== 0) {
95989599
*algoID = FALCON_LEVEL5k;
@@ -9601,7 +9602,7 @@ int wc_GetKeyOID(byte* key, word32 keySz, const byte** curveOID, word32* oidSz,
96019602
WOLFSSL_MSG("Not Falcon Level 5 DER key");
96029603
}
96039604
}
9604-
else {
9605+
if (*algoID == 0) {
96059606
WOLFSSL_MSG("GetKeyOID falcon initialization failed");
96069607
}
96079608
wc_falcon_free(falcon);

0 commit comments

Comments
 (0)