aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/rng
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/rng
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/rng')
-rw-r--r--src/lib/rng/rng.h2
-rw-r--r--src/lib/rng/system_rng/system_rng.cpp8
2 files changed, 5 insertions, 5 deletions
diff --git a/src/lib/rng/rng.h b/src/lib/rng/rng.h
index 1ce0d5153..23e974b92 100644
--- a/src/lib/rng/rng.h
+++ b/src/lib/rng/rng.h
@@ -66,7 +66,7 @@ class BOTAN_DLL RandomNumberGenerator
u64bit gen_mask(size_t bits)
{
if(bits == 0 || bits > 64)
- throw std::invalid_argument("RandomNumberGenerator::gen_mask invalid argument");
+ throw Invalid_Argument("RandomNumberGenerator::gen_mask invalid argument");
const u64bit mask = ((1 << bits) - 1);
return this->get_random<u64bit>() & mask;
diff --git a/src/lib/rng/system_rng/system_rng.cpp b/src/lib/rng/system_rng/system_rng.cpp
index 50ec696a0..81e235a8c 100644
--- a/src/lib/rng/system_rng/system_rng.cpp
+++ b/src/lib/rng/system_rng/system_rng.cpp
@@ -66,7 +66,7 @@ System_RNG_Impl::System_RNG_Impl()
#if defined(BOTAN_TARGET_OS_HAS_CRYPTGENRANDOM)
if(!CryptAcquireContext(&m_prov, 0, 0, BOTAN_SYSTEM_RNG_CRYPTOAPI_PROV_TYPE, CRYPT_VERIFYCONTEXT))
- throw std::runtime_error("System_RNG failed to acquire crypto provider");
+ throw Exception("System_RNG failed to acquire crypto provider");
#else
@@ -76,7 +76,7 @@ System_RNG_Impl::System_RNG_Impl()
m_fd = ::open(BOTAN_SYSTEM_RNG_DEVICE, O_RDONLY | O_NOCTTY);
if(m_fd < 0)
- throw std::runtime_error("System_RNG failed to open RNG device");
+ throw Exception("System_RNG failed to open RNG device");
#endif
}
@@ -103,10 +103,10 @@ void System_RNG_Impl::randomize(byte buf[], size_t len)
{
if(errno == EINTR)
continue;
- throw std::runtime_error("System_RNG read failed error " + std::to_string(errno));
+ throw Exception("System_RNG read failed error " + std::to_string(errno));
}
if(got == 0)
- throw std::runtime_error("System_RNG EOF on device"); // ?!?
+ throw Exception("System_RNG EOF on device"); // ?!?
buf += got;
len -= got;