security: fix AES IV length check in transform::BlockCipher
AES in CBC mode requires the IV length to be equal to the
block size (which is always 128 bits), not to the key size.
Change-Id: I7b8479f84317ddd2cf758271cc50c1af6c936780
diff --git a/tests/unit-tests/security/transform/block-cipher.t.cpp b/tests/unit-tests/security/transform/block-cipher.t.cpp
index 6a6b722..0803b44 100644
--- a/tests/unit-tests/security/transform/block-cipher.t.cpp
+++ b/tests/unit-tests/security/transform/block-cipher.t.cpp
@@ -88,7 +88,12 @@
// invalid key length
const uint8_t badKey[] = {0x00, 0x01, 0x02, 0x03};
BOOST_CHECK_THROW(BlockCipher(BlockCipherAlgorithm::AES_CBC, CipherOperator::ENCRYPT,
- badKey, sizeof(badKey), badKey, sizeof(badKey)), Error);
+ badKey, sizeof(badKey), iv, sizeof(iv)), Error);
+
+ // wrong iv length
+ const uint8_t badIv[] = {0x00, 0x01, 0x02, 0x03};
+ BOOST_CHECK_THROW(BlockCipher(BlockCipherAlgorithm::AES_CBC, CipherOperator::ENCRYPT,
+ key, sizeof(key), badIv, sizeof(badIv)), Error);
}
BOOST_AUTO_TEST_CASE(InvalidAlgorithm)