From 0ae0b31509c10e6b8f97f8fe86e38245811e395c Mon Sep 17 00:00:00 2001 From: Anthony Hu Date: Mon, 15 Nov 2021 14:51:03 -0500 Subject: [PATCH 1/5] The following config: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ./configure --with-liboqs --enable-all --disable-psk --enable-intelasm --enable-aesni --enable-sp-math-all --enable-sp-asm CFLAGS="-O3" Yeilds the following erorr: src/internal.c: In function ‘DoServerKeyExchange’: src/internal.c:24487:28: error: ‘sigAlgo’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 24487 | if (sigAlgo == ed448_sa_algo && | ^ This fixes it. --- src/internal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/internal.c b/src/internal.c index 70a940bec..88ebce641 100644 --- a/src/internal.c +++ b/src/internal.c @@ -24450,7 +24450,7 @@ static int DoServerKeyExchange(WOLFSSL* ssl, const byte* input, #else enum wc_HashType hashType; word16 verifySz; - byte sigAlgo; + byte sigAlgo = 0; if (ssl->options.usingAnon_cipher) { break; From 5c48e74c7fd9a571970d92c7619f1fa20a19fa23 Mon Sep 17 00:00:00 2001 From: Anthony Hu Date: Mon, 15 Nov 2021 15:25:38 -0500 Subject: [PATCH 2/5] 0xFF --- src/internal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/internal.c b/src/internal.c index 88ebce641..b39c065e2 100644 --- a/src/internal.c +++ b/src/internal.c @@ -24450,7 +24450,7 @@ static int DoServerKeyExchange(WOLFSSL* ssl, const byte* input, #else enum wc_HashType hashType; word16 verifySz; - byte sigAlgo = 0; + byte sigAlgo = 0xFF; if (ssl->options.usingAnon_cipher) { break; From 49c7abb875eacaeb3903452ad63f3781b89588ce Mon Sep 17 00:00:00 2001 From: Anthony Hu Date: Tue, 16 Nov 2021 10:52:33 -0500 Subject: [PATCH 3/5] Changes suggested by SparkiDev. --- src/internal.c | 8 +++++--- wolfssl/internal.h | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/internal.c b/src/internal.c index b39c065e2..bd7f979d8 100644 --- a/src/internal.c +++ b/src/internal.c @@ -3781,6 +3781,7 @@ void InitSuites(Suites* suites, ProtocolVersion pv, int keySz, word16 haveRSA, */ static WC_INLINE void DecodeSigAlg(const byte* input, byte* hashAlgo, byte* hsType) { + *hsType = invalid_sa_algo; switch (input[0]) { case NEW_SA_MAJOR: #ifdef HAVE_ED25519 @@ -3820,7 +3821,8 @@ static WC_INLINE void DecodeSigAlg(const byte* input, byte* hashAlgo, byte* hsTy *hsType = falcon_level1_sa_algo; /* Hash performed as part of sign/verify operation. */ *hashAlgo = sha512_mac; - } else + } + else if (input[1] == FALCON_LEVEL5_SA_MINOR) { *hsType = falcon_level5_sa_algo; /* Hash performed as part of sign/verify operation. */ @@ -24449,8 +24451,8 @@ static int DoServerKeyExchange(WOLFSSL* ssl, const byte* input, ERROR_OUT(NOT_COMPILED_IN, exit_dske); #else enum wc_HashType hashType; - word16 verifySz; - byte sigAlgo = 0xFF; + word16 verifySz; + byte sigAlgo; if (ssl->options.usingAnon_cipher) { break; diff --git a/wolfssl/internal.h b/wolfssl/internal.h index 82171d2af..3f2b45a5e 100644 --- a/wolfssl/internal.h +++ b/wolfssl/internal.h @@ -3151,7 +3151,8 @@ enum SignatureAlgorithm { rsa_pss_pss_algo = 10, ed448_sa_algo = 11, falcon_level1_sa_algo = 12, - falcon_level5_sa_algo = 13 + falcon_level5_sa_algo = 13, + invalid_sa_algo = 255 }; #define PSS_RSAE_TO_PSS_PSS(macAlgo) \ From 39edf8d20644c53c36775509481a5d92c120d29c Mon Sep 17 00:00:00 2001 From: Anthony Hu Date: Tue, 16 Nov 2021 17:38:36 -0500 Subject: [PATCH 4/5] pulled up a line. --- src/internal.c | 3 +-- wolfcrypt/benchmark/benchmark.c | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/internal.c b/src/internal.c index bd7f979d8..91ccc394b 100644 --- a/src/internal.c +++ b/src/internal.c @@ -3822,8 +3822,7 @@ static WC_INLINE void DecodeSigAlg(const byte* input, byte* hashAlgo, byte* hsTy /* Hash performed as part of sign/verify operation. */ *hashAlgo = sha512_mac; } - else - if (input[1] == FALCON_LEVEL5_SA_MINOR) { + else if (input[1] == FALCON_LEVEL5_SA_MINOR) { *hsType = falcon_level5_sa_algo; /* Hash performed as part of sign/verify operation. */ *hashAlgo = sha512_mac; diff --git a/wolfcrypt/benchmark/benchmark.c b/wolfcrypt/benchmark/benchmark.c index 8a5d02e4d..ed706cc1a 100644 --- a/wolfcrypt/benchmark/benchmark.c +++ b/wolfcrypt/benchmark/benchmark.c @@ -50,6 +50,8 @@ #include "wolfcrypt/benchmark/benchmark.h" #endif +#define BENCH_EMBEDDED + /* printf mappings */ #ifdef FREESCALE_MQX #include From ab0654bb64335b6ae5eb9154f1da80a9cbcc2b99 Mon Sep 17 00:00:00 2001 From: Anthony Hu Date: Tue, 16 Nov 2021 17:51:18 -0500 Subject: [PATCH 5/5] remove something that slipped in --- wolfcrypt/benchmark/benchmark.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/wolfcrypt/benchmark/benchmark.c b/wolfcrypt/benchmark/benchmark.c index ed706cc1a..8a5d02e4d 100644 --- a/wolfcrypt/benchmark/benchmark.c +++ b/wolfcrypt/benchmark/benchmark.c @@ -50,8 +50,6 @@ #include "wolfcrypt/benchmark/benchmark.h" #endif -#define BENCH_EMBEDDED - /* printf mappings */ #ifdef FREESCALE_MQX #include