diff options
author | Jack Lloyd <[email protected]> | 2015-12-11 09:42:06 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2015-12-11 09:42:06 -0500 |
commit | 6b9a3a534071ef84c121c406559f8fc7ad546104 (patch) | |
tree | c11480ad1f07e443ba4e992fefcd618b532c2e93 /src/lib/modes/aead | |
parent | 79a51627ee11f4d7f55d589751b30463d1f02a76 (diff) |
Reroot the exception hierarchy into a toplevel Exception class
As the alternatives are unfortunate for applications trying to catch
all library errors, and it seems deriving from std::runtime_error
causes problems with MSVC DLLs (GH #340)
Effectively reverts 2837e915d82e43
Diffstat (limited to 'src/lib/modes/aead')
-rw-r--r-- | src/lib/modes/aead/ccm/ccm.cpp | 6 | ||||
-rw-r--r-- | src/lib/modes/aead/chacha20poly1305/chacha20poly1305.cpp | 2 | ||||
-rw-r--r-- | src/lib/modes/aead/gcm/gcm.cpp | 2 | ||||
-rw-r--r-- | src/lib/modes/aead/ocb/ocb.cpp | 4 |
4 files changed, 7 insertions, 7 deletions
diff --git a/src/lib/modes/aead/ccm/ccm.cpp b/src/lib/modes/aead/ccm/ccm.cpp index bd4e0f4be..df33685f3 100644 --- a/src/lib/modes/aead/ccm/ccm.cpp +++ b/src/lib/modes/aead/ccm/ccm.cpp @@ -20,13 +20,13 @@ CCM_Mode::CCM_Mode(BlockCipher* cipher, size_t tag_size, size_t L) : m_cipher(cipher) { if(m_cipher->block_size() != BS) - throw std::invalid_argument(m_cipher->name() + " cannot be used with CCM mode"); + throw Invalid_Argument(m_cipher->name() + " cannot be used with CCM mode"); if(L < 2 || L > 8) - throw std::invalid_argument("Invalid CCM L value " + std::to_string(L)); + throw Invalid_Argument("Invalid CCM L value " + std::to_string(L)); if(tag_size < 4 || tag_size > 16 || tag_size % 2 != 0) - throw std::invalid_argument("invalid CCM tag length " + std::to_string(tag_size)); + throw Invalid_Argument("invalid CCM tag length " + std::to_string(tag_size)); } void CCM_Mode::clear() diff --git a/src/lib/modes/aead/chacha20poly1305/chacha20poly1305.cpp b/src/lib/modes/aead/chacha20poly1305/chacha20poly1305.cpp index 0aef6a747..2350e2e6a 100644 --- a/src/lib/modes/aead/chacha20poly1305/chacha20poly1305.cpp +++ b/src/lib/modes/aead/chacha20poly1305/chacha20poly1305.cpp @@ -39,7 +39,7 @@ void ChaCha20Poly1305_Mode::key_schedule(const byte key[], size_t length) void ChaCha20Poly1305_Mode::set_associated_data(const byte ad[], size_t length) { if(m_ctext_len) - throw std::runtime_error("Too late to set AD for ChaCha20Poly1305"); + throw Exception("Too late to set AD for ChaCha20Poly1305"); m_ad.assign(ad, ad + length); } diff --git a/src/lib/modes/aead/gcm/gcm.cpp b/src/lib/modes/aead/gcm/gcm.cpp index 15820069d..a77c3e4d4 100644 --- a/src/lib/modes/aead/gcm/gcm.cpp +++ b/src/lib/modes/aead/gcm/gcm.cpp @@ -163,7 +163,7 @@ GCM_Mode::GCM_Mode(BlockCipher* cipher, size_t tag_size) : m_cipher_name(cipher->name()) { if(cipher->block_size() != BS) - throw std::invalid_argument("GCM requires a 128 bit cipher so cannot be used with " + + throw Invalid_Argument("GCM requires a 128 bit cipher so cannot be used with " + cipher->name()); m_ghash.reset(new GHASH); diff --git a/src/lib/modes/aead/ocb/ocb.cpp b/src/lib/modes/aead/ocb/ocb.cpp index ff3317dd9..08157cd47 100644 --- a/src/lib/modes/aead/ocb/ocb.cpp +++ b/src/lib/modes/aead/ocb/ocb.cpp @@ -123,10 +123,10 @@ OCB_Mode::OCB_Mode(BlockCipher* cipher, size_t tag_size) : m_tag_size(tag_size) { if(BS() != 16) - throw std::invalid_argument("OCB is not compatible with " + m_cipher->name()); + throw Invalid_Argument("OCB is not compatible with " + m_cipher->name()); if(m_tag_size % 4 != 0 || m_tag_size < 8 || m_tag_size > BS()) - throw std::invalid_argument("OCB cannot produce a " + std::to_string(m_tag_size) + + throw Invalid_Argument("OCB cannot produce a " + std::to_string(m_tag_size) + " byte tag"); } |