Remove redundant length-check in |ec_wNAF_mul|. Right now, |g_wNAF| and |p_wNAF| are of same size. This change makes GCC's "-Werror=logical-op" happy and adds a compile-time assertion in case the initial size of either array ever changes. Change-Id: I29e39a7a121a0a9d016c53da6b7c25675ddecbdc Reviewed-on: https://boringssl-review.googlesource.com/26104 Reviewed-by: David Benjamin <davidben@google.com> Commit-Queue: David Benjamin <davidben@google.com> CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
diff --git a/crypto/fipsmodule/ec/wnaf.c b/crypto/fipsmodule/ec/wnaf.c index c8bdadd..7bc0bc7 100644 --- a/crypto/fipsmodule/ec/wnaf.c +++ b/crypto/fipsmodule/ec/wnaf.c
@@ -73,6 +73,7 @@ #include <openssl/err.h> #include <openssl/mem.h> #include <openssl/thread.h> +#include <openssl/type_check.h> #include "internal.h" #include "../bn/internal.h" @@ -250,8 +251,12 @@ size_t wsize = window_bits_for_scalar_size(bits); size_t wNAF_len = bits + 1; size_t precomp_len = (size_t)1 << (wsize - 1); + + OPENSSL_COMPILE_ASSERT( + OPENSSL_ARRAY_SIZE(g_wNAF) == OPENSSL_ARRAY_SIZE(p_wNAF), + g_wNAF_and_p_wNAF_are_different_sizes); + if (wNAF_len > OPENSSL_ARRAY_SIZE(g_wNAF) || - wNAF_len > OPENSSL_ARRAY_SIZE(p_wNAF) || 2 * precomp_len > OPENSSL_ARRAY_SIZE(precomp_storage)) { OPENSSL_PUT_ERROR(EC, ERR_R_INTERNAL_ERROR); goto err;