diff options
author | Daniel Neus <[email protected]> | 2016-01-08 15:36:49 +0100 |
---|---|---|
committer | Daniel Neus <[email protected]> | 2016-03-02 21:23:17 +0100 |
commit | c4e5802112b4000950aca376ca13cd125085a177 (patch) | |
tree | e7797d2a8ba10c552e91e7f69c57619762b78ca9 | |
parent | 6a32844a7478617e1b6c686bb643c1eef317cba4 (diff) |
added an assert for aes key length >= 4 in aes_key_schedule to prevent division by zero found by clang-analyzer
-rw-r--r-- | src/lib/block/aes/aes.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/lib/block/aes/aes.cpp b/src/lib/block/aes/aes.cpp index 6cca701af..aac277b4f 100644 --- a/src/lib/block/aes/aes.cpp +++ b/src/lib/block/aes/aes.cpp @@ -345,6 +345,12 @@ void aes_key_schedule(const byte key[], size_t length, secure_vector<byte>& ME, secure_vector<byte>& MD) { + + // if length is < 4, X = 0, the first for loop is not entered and in + // the second for loop "RC[(i-X)/X]" = division by zero + // But obviously valid aes length values are only 16, 24 and 32 + BOTAN_ASSERT( length >= 4, "aes key length has valid size" ); + static const u32bit RC[10] = { 0x01000000, 0x02000000, 0x04000000, 0x08000000, 0x10000000, 0x20000000, 0x40000000, 0x80000000, 0x1B000000, 0x36000000 }; |