diff options
author | Jack Lloyd <[email protected]> | 2018-03-10 15:01:09 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-03-10 15:01:09 -0500 |
commit | afe4ae0f83b7207873afac760cb3c32ed40ce4c9 (patch) | |
tree | 93f65bd1ab32d3cf161888ccada926e633fd1e82 | |
parent | 920001cae022190bc86ec818ab4af0ac7513777c (diff) |
Minor tweaks for coverage
-rw-r--r-- | src/lib/block/cascade/cascade.cpp | 9 | ||||
-rw-r--r-- | src/lib/modes/aead/gcm/gcm.cpp | 3 | ||||
-rw-r--r-- | src/tests/test_modes.cpp | 5 |
3 files changed, 11 insertions, 6 deletions
diff --git a/src/lib/block/cascade/cascade.cpp b/src/lib/block/cascade/cascade.cpp index e54d3e5b5..6607fd5b2 100644 --- a/src/lib/block/cascade/cascade.cpp +++ b/src/lib/block/cascade/cascade.cpp @@ -58,7 +58,7 @@ namespace { size_t euclids_algorithm(size_t a, size_t b) { - while(b != 0) // gcd + while(b != 0) { size_t t = b; b = a % b; @@ -73,7 +73,7 @@ size_t block_size_for_cascade(size_t bs, size_t bs2) if(bs == bs2) return bs; - size_t gcd = euclids_algorithm(bs, bs2); + const size_t gcd = euclids_algorithm(bs, bs2); return (bs * bs2) / gcd; } @@ -85,8 +85,9 @@ Cascade_Cipher::Cascade_Cipher(BlockCipher* c1, BlockCipher* c2) : { m_block = block_size_for_cascade(c1->block_size(), c2->block_size()); - if(block_size() % c1->block_size() || block_size() % c2->block_size()) - throw Internal_Error("Failure in " + name() + " constructor"); + BOTAN_ASSERT(m_block % c1->block_size() == 0 && + m_block % c2->block_size() == 0, + "Combined block size is a multiple of each ciphers block"); } } diff --git a/src/lib/modes/aead/gcm/gcm.cpp b/src/lib/modes/aead/gcm/gcm.cpp index dfaffedb7..b0240eb7f 100644 --- a/src/lib/modes/aead/gcm/gcm.cpp +++ b/src/lib/modes/aead/gcm/gcm.cpp @@ -86,8 +86,7 @@ void GCM_Mode::set_associated_data(const uint8_t ad[], size_t ad_len) void GCM_Mode::start_msg(const uint8_t nonce[], size_t nonce_len) { - if(!valid_nonce_length(nonce_len)) - throw Invalid_IV_Length(name(), nonce_len); + // any size is valid for GCM nonce secure_vector<uint8_t> y0(GCM_BS); diff --git a/src/tests/test_modes.cpp b/src/tests/test_modes.cpp index d707f4419..89b201873 100644 --- a/src/tests/test_modes.cpp +++ b/src/tests/test_modes.cpp @@ -78,6 +78,11 @@ class Cipher_Mode_Tests final : public Text_Based_Test result.test_gte("enc buffer sizes ok", enc->update_granularity(), enc->minimum_final_size()); result.test_gte("dec buffer sizes ok", dec->update_granularity(), dec->minimum_final_size()); + result.confirm("default nonce size is allowed", + enc->valid_nonce_length(enc->default_nonce_length())); + result.confirm("default nonce size is allowed", + dec->valid_nonce_length(dec->default_nonce_length())); + // Test that disallowed nonce sizes result in an exception const size_t large_nonce_size = 65000; result.test_eq("Large nonce not allowed", enc->valid_nonce_length(large_nonce_size), false); |