From 1c60ea235e214ab3ed4d967e201c2b5c9e5b3c03 Mon Sep 17 00:00:00 2001 From: Ben Wiederhake Date: Fri, 28 Aug 2020 11:13:30 +0200 Subject: [PATCH] LibCrypto: Do not silently ignore key size mismatch Before, when the actually passed key was too long, the extra bytes were silently ignored. This can lead to all sorts of trouble, so ... don't do that. The original intention was maybe to support non-integer amounts of key bytes. But that doesn't happen anyway with AES. --- Libraries/LibCrypto/Cipher/AES.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libraries/LibCrypto/Cipher/AES.cpp b/Libraries/LibCrypto/Cipher/AES.cpp index a6266fd1be..95fbb70515 100644 --- a/Libraries/LibCrypto/Cipher/AES.cpp +++ b/Libraries/LibCrypto/Cipher/AES.cpp @@ -67,7 +67,7 @@ void AESCipherKey::expand_encrypt_key(const ByteBuffer& user_key, size_t bits) ASSERT(!user_key.is_null()); ASSERT(is_valid_key_size(bits)); - ASSERT(user_key.size() >= bits / 8); + ASSERT(user_key.size() == bits / 8); round_key = round_keys();