summaryrefslogtreecommitdiff
path: root/osrng.cpp
diff options
context:
space:
mode:
authorweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2006-12-13 04:08:09 +0000
committerweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2006-12-13 04:08:09 +0000
commitdc81588b334adc1af91b743d26d460fa31a48f0c (patch)
tree8f14443db57670fc9e6b3e4ff3a4bbc396740916 /osrng.cpp
parent62bad39ed8e644de8ff24cfb2557ee3e59336b14 (diff)
downloadcryptopp-dc81588b334adc1af91b743d26d460fa31a48f0c.tar.gz
fix BlockingRng for OpenBSD
git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@257 57ff6487-cd31-0410-9ec3-f628ee90f5f0
Diffstat (limited to 'osrng.cpp')
-rw-r--r--osrng.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/osrng.cpp b/osrng.cpp
index 3d307b4..c310575 100644
--- a/osrng.cpp
+++ b/osrng.cpp
@@ -101,11 +101,19 @@ void NonblockingRng::GenerateBlock(byte *output, size_t size)
#ifdef BLOCKING_RNG_AVAILABLE
+#ifndef CRYPTOPP_BLOCKING_RNG_FILENAME
+#ifdef __OpenBSD__
+#define CRYPTOPP_BLOCKING_RNG_FILENAME "/dev/srandom"
+#else
+#define CRYPTOPP_BLOCKING_RNG_FILENAME "/dev/random"
+#endif
+#endif
+
BlockingRng::BlockingRng()
{
- m_fd = open("/dev/random",O_RDONLY);
+ m_fd = open(CRYPTOPP_BLOCKING_RNG_FILENAME,O_RDONLY);
if (m_fd == -1)
- throw OS_RNG_Err("open /dev/random");
+ throw OS_RNG_Err("open " CRYPTOPP_BLOCKING_RNG_FILENAME);
}
BlockingRng::~BlockingRng()
@@ -128,7 +136,7 @@ void BlockingRng::GenerateBlock(byte *output, size_t size)
// are available, on others it will returns immediately
ssize_t len = read(m_fd, output, size);
if (len < 0)
- throw OS_RNG_Err("read /dev/random");
+ throw OS_RNG_Err("read " CRYPTOPP_BLOCKING_RNG_FILENAME);
size -= len;
output += len;
if (size)