aboutsummaryrefslogtreecommitdiffstats
path: root/cipher/random.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>1998-01-16 21:15:24 +0000
committerWerner Koch <[email protected]>1998-01-16 21:15:24 +0000
commit4ec1775f3eaf8733a5285460b631253b90d3c6fb (patch)
tree3061decd5793f93c5a51dab58cb45c8e79a26403 /cipher/random.c
parent*** empty log message *** (diff)
downloadgnupg-4ec1775f3eaf8733a5285460b631253b90d3c6fb.tar.gz
gnupg-4ec1775f3eaf8733a5285460b631253b90d3c6fb.zip
added some trust model stuff
Diffstat (limited to 'cipher/random.c')
-rw-r--r--cipher/random.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/cipher/random.c b/cipher/random.c
index 41f001e7e..b082022af 100644
--- a/cipher/random.c
+++ b/cipher/random.c
@@ -30,6 +30,7 @@
#include <fcntl.h>
#include "util.h"
#include "cipher.h"
+#include "ttyio.h"
struct cache {
int len;
@@ -41,6 +42,18 @@ static struct cache cache[3];
static void fill_buffer( byte *buffer, size_t length, int level );
+static int quick_test;
+
+
+int
+quick_random_gen( int onoff )
+{
+ int last = quick_test;
+ if( onoff != -1 )
+ quick_test = onoff;
+ return last;
+}
+
/****************
* Fill the buffer with LENGTH bytes of cryptologic strong
@@ -95,14 +108,13 @@ open_device( const char *name, int minor )
static void
fill_buffer( byte *buffer, size_t length, int level )
{
- FILE *fp;
static int fd_urandom = -1;
static int fd_random = -1;
int fd;
int n;
int warn=0;
- if( level == 2 ) {
+ if( level == 2 && !quick_test ) {
if( fd_random == -1 )
fd_random = open_device( "/dev/random", 8 );
fd = fd_random;