aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/misc
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2015-12-11 09:42:06 -0500
committerJack Lloyd <[email protected]>2015-12-11 09:42:06 -0500
commit6b9a3a534071ef84c121c406559f8fc7ad546104 (patch)
treec11480ad1f07e443ba4e992fefcd618b532c2e93 /src/lib/misc
parent79a51627ee11f4d7f55d589751b30463d1f02a76 (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/misc')
-rw-r--r--src/lib/misc/benchmark/benchmark.cpp2
-rw-r--r--src/lib/misc/fpe_fe1/fpe_fe1.cpp4
-rw-r--r--src/lib/misc/rfc3394/rfc3394.cpp8
-rw-r--r--src/lib/misc/srp6/srp6.cpp6
4 files changed, 10 insertions, 10 deletions
diff --git a/src/lib/misc/benchmark/benchmark.cpp b/src/lib/misc/benchmark/benchmark.cpp
index d5e3694b5..4ecca1566 100644
--- a/src/lib/misc/benchmark/benchmark.cpp
+++ b/src/lib/misc/benchmark/benchmark.cpp
@@ -119,7 +119,7 @@ double find_first_in(const std::map<std::string, double>& m,
return i->second;
}
- throw std::runtime_error("In algo benchmark no usable keys found in result");
+ throw Exception("In algo benchmark no usable keys found in result");
}
std::set<std::string> get_all_providers_of(const std::string& algo)
diff --git a/src/lib/misc/fpe_fe1/fpe_fe1.cpp b/src/lib/misc/fpe_fe1/fpe_fe1.cpp
index f2502014b..bc14c425c 100644
--- a/src/lib/misc/fpe_fe1/fpe_fe1.cpp
+++ b/src/lib/misc/fpe_fe1/fpe_fe1.cpp
@@ -57,7 +57,7 @@ void factor(BigInt n, BigInt& a, BigInt& b)
std::swap(a, b);
if(a <= 1 || b <= 1)
- throw std::runtime_error("Could not factor n for use in FPE");
+ throw Exception("Could not factor n for use in FPE");
}
/*
@@ -100,7 +100,7 @@ FPE_Encryptor::FPE_Encryptor(const SymmetricKey& key,
std::vector<byte> n_bin = BigInt::encode(n);
if(n_bin.size() > MAX_N_BYTES)
- throw std::runtime_error("N is too large for FPE encryption");
+ throw Exception("N is too large for FPE encryption");
mac->update_be(static_cast<u32bit>(n_bin.size()));
mac->update(n_bin.data(), n_bin.size());
diff --git a/src/lib/misc/rfc3394/rfc3394.cpp b/src/lib/misc/rfc3394/rfc3394.cpp
index 582e8c92d..1044e4de4 100644
--- a/src/lib/misc/rfc3394/rfc3394.cpp
+++ b/src/lib/misc/rfc3394/rfc3394.cpp
@@ -16,10 +16,10 @@ secure_vector<byte> rfc3394_keywrap(const secure_vector<byte>& key,
const SymmetricKey& kek)
{
if(key.size() % 8 != 0)
- throw std::invalid_argument("Bad input key size for NIST key wrap");
+ throw Invalid_Argument("Bad input key size for NIST key wrap");
if(kek.size() != 16 && kek.size() != 24 && kek.size() != 32)
- throw std::invalid_argument("Bad KEK length " + std::to_string(kek.size()) + " for NIST key wrap");
+ throw Invalid_Argument("Bad KEK length " + std::to_string(kek.size()) + " for NIST key wrap");
const std::string cipher_name = "AES-" + std::to_string(8*kek.size());
std::unique_ptr<BlockCipher> aes(BlockCipher::create(cipher_name));
@@ -63,10 +63,10 @@ secure_vector<byte> rfc3394_keyunwrap(const secure_vector<byte>& key,
const SymmetricKey& kek)
{
if(key.size() < 16 || key.size() % 8 != 0)
- throw std::invalid_argument("Bad input key size for NIST key unwrap");
+ throw Invalid_Argument("Bad input key size for NIST key unwrap");
if(kek.size() != 16 && kek.size() != 24 && kek.size() != 32)
- throw std::invalid_argument("Bad KEK length " + std::to_string(kek.size()) + " for NIST key unwrap");
+ throw Invalid_Argument("Bad KEK length " + std::to_string(kek.size()) + " for NIST key unwrap");
const std::string cipher_name = "AES-" + std::to_string(8*kek.size());
std::unique_ptr<BlockCipher> aes(BlockCipher::create(cipher_name));
diff --git a/src/lib/misc/srp6/srp6.cpp b/src/lib/misc/srp6/srp6.cpp
index f567db875..7fca6461f 100644
--- a/src/lib/misc/srp6/srp6.cpp
+++ b/src/lib/misc/srp6/srp6.cpp
@@ -70,7 +70,7 @@ std::string srp6_group_identifier(const BigInt& N, const BigInt& g)
if(group.get_p() == N && group.get_g() == g)
return group_name;
- throw std::runtime_error("Unknown SRP params");
+ throw Exception("Unknown SRP params");
}
catch(...)
{
@@ -94,7 +94,7 @@ srp6_client_agree(const std::string& identifier,
const size_t p_bytes = group.get_p().bytes();
if(B <= 0 || B >= p)
- throw std::runtime_error("Invalid SRP parameter from server");
+ throw Exception("Invalid SRP parameter from server");
BigInt k = hash_seq(hash_id, p_bytes, p, g);
@@ -150,7 +150,7 @@ BigInt SRP6_Server_Session::step1(const BigInt& v,
SymmetricKey SRP6_Server_Session::step2(const BigInt& A)
{
if(A <= 0 || A >= m_p)
- throw std::runtime_error("Invalid SRP parameter from client");
+ throw Exception("Invalid SRP parameter from client");
const BigInt u = hash_seq(m_hash_id, m_p_bytes, A, m_B);