diff options
author | Jack Lloyd <[email protected]> | 2018-08-05 18:57:54 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-08-05 19:19:58 -0400 |
commit | df169024a36b5f72eaa40fef5f9fc6ca17261035 (patch) | |
tree | b1b0d624414c550f88d9989beb21093f4461b3be /src/lib/modes/aead/ocb | |
parent | f3ecd15b216a8a890308089ddb1dec1bc4ff0c75 (diff) |
Fix crashes when modes were used unkeyed.
Fix crashes in OCB, GCM and CFB when called without a key being set.
Diffstat (limited to 'src/lib/modes/aead/ocb')
-rw-r--r-- | src/lib/modes/aead/ocb/ocb.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/lib/modes/aead/ocb/ocb.cpp b/src/lib/modes/aead/ocb/ocb.cpp index 317b417b3..35366260d 100644 --- a/src/lib/modes/aead/ocb/ocb.cpp +++ b/src/lib/modes/aead/ocb/ocb.cpp @@ -231,7 +231,7 @@ void OCB_Mode::key_schedule(const uint8_t key[], size_t length) void OCB_Mode::set_associated_data(const uint8_t ad[], size_t ad_len) { - BOTAN_ASSERT(m_L, "A key was set"); + verify_key_set(m_L != nullptr); m_ad_hash = ocb_hash(*m_L, *m_cipher, ad, ad_len); } @@ -331,7 +331,7 @@ void OCB_Mode::start_msg(const uint8_t nonce[], size_t nonce_len) if(!valid_nonce_length(nonce_len)) throw Invalid_IV_Length(name(), nonce_len); - BOTAN_ASSERT(m_L, "A key was set"); + verify_key_set(m_L != nullptr); m_L->init(update_nonce(nonce, nonce_len)); zeroise(m_checksum); @@ -340,9 +340,9 @@ void OCB_Mode::start_msg(const uint8_t nonce[], size_t nonce_len) void OCB_Encryption::encrypt(uint8_t buffer[], size_t blocks) { - const size_t BS = block_size(); + verify_key_set(m_L != nullptr); - BOTAN_ASSERT(m_L, "A key was set"); + const size_t BS = block_size(); while(blocks) { @@ -370,6 +370,8 @@ size_t OCB_Encryption::process(uint8_t buf[], size_t sz) void OCB_Encryption::finish(secure_vector<uint8_t>& buffer, size_t offset) { + verify_key_set(m_L != nullptr); + const size_t BS = block_size(); BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane"); @@ -427,6 +429,8 @@ void OCB_Encryption::finish(secure_vector<uint8_t>& buffer, size_t offset) void OCB_Decryption::decrypt(uint8_t buffer[], size_t blocks) { + verify_key_set(m_L != nullptr); + const size_t BS = block_size(); while(blocks) @@ -455,6 +459,8 @@ size_t OCB_Decryption::process(uint8_t buf[], size_t sz) void OCB_Decryption::finish(secure_vector<uint8_t>& buffer, size_t offset) { + verify_key_set(m_L != nullptr); + const size_t BS = block_size(); BOTAN_ASSERT(buffer.size() >= offset, "Offset is sane"); |