From 584ded11d3b91aabdfbf3f059194bf0bb2d18fc6 Mon Sep 17 00:00:00 2001 From: Jeremiah Mackey Date: Tue, 28 Apr 2026 16:56:03 +0000 Subject: [PATCH] validate falcon level before check --- wolfcrypt/src/falcon.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/wolfcrypt/src/falcon.c b/wolfcrypt/src/falcon.c index 9a9e1eeebb..17eb006f19 100644 --- a/wolfcrypt/src/falcon.c +++ b/wolfcrypt/src/falcon.c @@ -700,6 +700,14 @@ int wc_falcon_check_key(falcon_key* key) return BAD_FUNC_ARG; } + if ((key->level != 1) && (key->level != 5)) { + return BAD_FUNC_ARG; + } + + if (!key->pubKeySet || !key->prvKeySet) { + return PUBLIC_KEY_E; + } + /* The public key is also decoded and stored within the private key buffer * behind the private key. Hence, we can compare both stored public keys. */ if (key->level == 1) {