aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/rng/system_rng/system_rng.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/rng/system_rng/system_rng.cpp')
-rw-r--r--src/lib/rng/system_rng/system_rng.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/lib/rng/system_rng/system_rng.cpp b/src/lib/rng/system_rng/system_rng.cpp
index ae027d021..8abf8afdc 100644
--- a/src/lib/rng/system_rng/system_rng.cpp
+++ b/src/lib/rng/system_rng/system_rng.cpp
@@ -50,7 +50,7 @@ class System_RNG_Impl final : public RandomNumberGenerator
{
bool success = m_rtlgenrandom(buf, ULONG(len)) == TRUE;
if(!success)
- throw Exception("RtlGenRandom failed");
+ throw System_Error("RtlGenRandom failed");
}
void add_entropy(const uint8_t[], size_t) override { /* ignored */ }
@@ -79,7 +79,7 @@ class System_RNG_Impl final : public RandomNumberGenerator
BCRYPT_RNG_ALGORITHM,
MS_PRIMITIVE_PROVIDER, 0);
if(ret != STATUS_SUCCESS)
- throw Exception("System_RNG failed to acquire crypto provider");
+ throw System_Error("System_RNG failed to acquire crypto provider", ret);
}
~System_RNG_Impl()
@@ -91,7 +91,7 @@ class System_RNG_Impl final : public RandomNumberGenerator
{
NTSTATUS ret = ::BCryptGenRandom(m_prov, static_cast<PUCHAR>(buf), static_cast<ULONG>(len), 0);
if(ret != STATUS_SUCCESS)
- throw Exception("System_RNG call to BCryptGenRandom failed");
+ throw System_Error("System_RNG call to BCryptGenRandom failed", ret);
}
void add_entropy(const uint8_t in[], size_t length) override
@@ -148,7 +148,7 @@ class System_RNG_Impl final : public RandomNumberGenerator
{
if(errno == EINTR)
continue;
- throw Exception("System_RNG getrandom failed error " + std::to_string(errno));
+ throw System_Error("System_RNG getrandom failed", errno);
}
buf += got;
@@ -194,7 +194,7 @@ class System_RNG_Impl final : public RandomNumberGenerator
}
if(m_fd < 0)
- throw Exception("System_RNG failed to open RNG device");
+ throw System_Error("System_RNG failed to open RNG device", errno);
}
~System_RNG_Impl()
@@ -224,10 +224,10 @@ void System_RNG_Impl::randomize(uint8_t buf[], size_t len)
{
if(errno == EINTR)
continue;
- throw Exception("System_RNG read failed error " + std::to_string(errno));
+ throw System_Error("System_RNG read failed", errno);
}
if(got == 0)
- throw Exception("System_RNG EOF on device"); // ?!?
+ throw System_Error("System_RNG EOF on device"); // ?!?
buf += got;
len -= got;
@@ -264,7 +264,7 @@ void System_RNG_Impl::add_entropy(const uint8_t input[], size_t len)
return;
// maybe just ignore any failure here and return?
- throw Exception("System_RNG write failed error " + std::to_string(errno));
+ throw System_Error("System_RNG write failed", errno);
}
input += got;