aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2017-09-30 15:22:58 -0400
committerJack Lloyd <[email protected]>2017-09-30 15:22:58 -0400
commit584d04af150847984b44c29c75458199932af1bc (patch)
treef146bf43bd70a26e40042729c8cee2fc08f18a0e
parentd6fe1fd536feca8683eafbf7e01fb5533506e4a5 (diff)
Change this code so Sonar understands div by zero can't happen
-rw-r--r--src/lib/block/aes/aes.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/lib/block/aes/aes.cpp b/src/lib/block/aes/aes.cpp
index b4be14d3d..a632c01ac 100644
--- a/src/lib/block/aes/aes.cpp
+++ b/src/lib/block/aes/aes.cpp
@@ -354,8 +354,9 @@ void aes_key_schedule(const uint8_t key[], size_t length,
const size_t X = length / 4;
- // Make clang-analyzer happy
- BOTAN_ASSERT(X == 4 || X == 6 || X == 8, "Valid AES key size");
+ // Can't happen, but make static analyzers happy
+ if(X != 4 && X != 6 && X != 8)
+ throw Invalid_Argument("Invalid AES key size");
for(size_t i = 0; i != X; ++i)
XEK[i] = load_be<uint32_t>(key, i);