From 52af3c5da02d4096845e9e0ac7e746b2ef20688a Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Mon, 21 May 2018 22:21:17 +0200 Subject: [PATCH] test/crypto: fix wrong output buffer size in AES.DecryptNoBl. Signed-off-by: Radoslaw Zarzynski --- src/test/crypto.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/test/crypto.cc b/src/test/crypto.cc index 90191f8248260..18df8418cdb8a 100644 --- a/src/test/crypto.cc +++ b/src/test/crypto.cc @@ -365,13 +365,15 @@ TEST(AES, DecryptNoBl) { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, }; - unsigned char plaintext[sizeof(want_plaintext)]; + constexpr static std::size_t plain_buf_size = \ + CryptoKey::get_max_outbuf_size(sizeof(want_plaintext)); + unsigned char plaintext[plain_buf_size]; std::string error; std::unique_ptr kh(h->get_key_handler(secret, error)); CryptoKey::in_slice_t cipher_slice { sizeof(ciphertext), ciphertext }; - CryptoKey::out_slice_t plain_slice { sizeof(ciphertext), plaintext }; + CryptoKey::out_slice_t plain_slice { sizeof(plaintext), plaintext }; const auto plain_size = kh->decrypt(cipher_slice, plain_slice); ASSERT_EQ(plain_size, sizeof(want_plaintext)); -- 2.39.5