From e6d45052efedfe49e99adb6318aaf56e0a9e8d7b Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Thu, 26 Oct 2017 20:31:30 -0400 Subject: Add checks that keyed algorithms are actually keyed before use Previously calling update or encrypt without calling set_key first would result in invalid outputs or else crashing. --- src/lib/block/serpent/serpent.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/lib/block/serpent') diff --git a/src/lib/block/serpent/serpent.cpp b/src/lib/block/serpent/serpent.cpp index 6e1d79766..39968e87e 100644 --- a/src/lib/block/serpent/serpent.cpp +++ b/src/lib/block/serpent/serpent.cpp @@ -57,6 +57,8 @@ inline void i_transform(uint32_t& B0, uint32_t& B1, uint32_t& B2, uint32_t& B3) */ void Serpent::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const { + verify_key_set(m_round_key.empty() == false); + #if defined(BOTAN_HAS_SERPENT_SIMD) if(CPUID::has_simd_32()) { @@ -117,6 +119,8 @@ void Serpent::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const */ void Serpent::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const { + verify_key_set(m_round_key.empty() == false); + #if defined(BOTAN_HAS_SERPENT_SIMD) if(CPUID::has_simd_32()) { -- cgit v1.2.3