diff options
author | Jack Lloyd <[email protected]> | 2016-12-16 22:11:16 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2016-12-16 22:11:16 -0500 |
commit | 35c14c786e4cc7e20ac5b551819db005cfed295a (patch) | |
tree | 7b3540587b5e4bcbfd7bcee36c89a878e86fbca6 /src/lib | |
parent | 9539a0b88c476844fa77326d2c17bd8ecb20ecc2 (diff) |
Fix clang-analyzer warning in AES code
The previous assert had been already put there for the benefit
of clang-analyzer, but in Clang 3.9 it does not help. Instead
test X value directly, which works.
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/block/aes/aes.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/lib/block/aes/aes.cpp b/src/lib/block/aes/aes.cpp index 8c7000135..f0e66bc1b 100644 --- a/src/lib/block/aes/aes.cpp +++ b/src/lib/block/aes/aes.cpp @@ -345,12 +345,6 @@ 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 }; @@ -360,6 +354,10 @@ void aes_key_schedule(const byte key[], size_t length, secure_vector<u32bit> XEK(length + 32), XDK(length + 32); const size_t X = length / 4; + + // Make clang-analyzer happy + BOTAN_ASSERT(X == 4 || X == 6 || X == 8, "Valid AES key size"); + for(size_t i = 0; i != X; ++i) XEK[i] = load_be<u32bit>(key, i); |