From 3b36db0c9d8ee1cbcde0f562f96d7b4c51bf67df Mon Sep 17 00:00:00 2001 From: Anthony Hu Date: Mon, 16 Mar 2026 10:55:28 -0400 Subject: [PATCH] Fixes Falcon else-if chain key detection F-750 --- wolfcrypt/src/asn.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index 2451b8624e0..58f61aef153 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -9582,8 +9582,8 @@ int wc_GetKeyOID(byte* key, word32 keySz, const byte** curveOID, word32* oidSz, return MEMORY_E; if (wc_falcon_init(falcon) == 0) { - tmpIdx = 0; - if (wc_falcon_set_level(falcon, 1) == 0) { + if ((*algoID == 0) && (wc_falcon_set_level(falcon, 1) == 0)) { + tmpIdx = 0; if (wc_Falcon_PrivateKeyDecode(key, &tmpIdx, falcon, keySz) == 0) { *algoID = FALCON_LEVEL1k; @@ -9592,7 +9592,8 @@ int wc_GetKeyOID(byte* key, word32 keySz, const byte** curveOID, word32* oidSz, WOLFSSL_MSG("Not Falcon Level 1 DER key"); } } - else if (wc_falcon_set_level(falcon, 5) == 0) { + if ((*algoID == 0) && (wc_falcon_set_level(falcon, 5) == 0)) { + tmpIdx = 0; if (wc_Falcon_PrivateKeyDecode(key, &tmpIdx, falcon, keySz) == 0) { *algoID = FALCON_LEVEL5k; @@ -9601,7 +9602,7 @@ int wc_GetKeyOID(byte* key, word32 keySz, const byte** curveOID, word32* oidSz, WOLFSSL_MSG("Not Falcon Level 5 DER key"); } } - else { + if (*algoID == 0) { WOLFSSL_MSG("GetKeyOID falcon initialization failed"); } wc_falcon_free(falcon);