summaryrefslogtreecommitdiff
path: root/cipher
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>1998-01-16 21:15:20 +0000
committerWerner Koch <wk@gnupg.org>1998-01-16 21:15:20 +0000
commit4e60a56970d7991a3bd0a593b729148a3680cdc9 (patch)
tree43cd6854514caa40604bd18599eca5fdb2ca9263 /cipher
parent8265ccf255d9b4b6ac8fb28ec271133b36ff2695 (diff)
downloadlibgcrypt-4e60a56970d7991a3bd0a593b729148a3680cdc9.tar.gz
added some trust model stuff
Diffstat (limited to 'cipher')
-rw-r--r--cipher/blowfish.c2
-rw-r--r--cipher/md.c2
-rw-r--r--cipher/md5.c1
-rw-r--r--cipher/misc.c6
-rw-r--r--cipher/primegen.c4
-rw-r--r--cipher/random.c16
6 files changed, 20 insertions, 11 deletions
diff --git a/cipher/blowfish.c b/cipher/blowfish.c
index 5dbaf719..81e33d08 100644
--- a/cipher/blowfish.c
+++ b/cipher/blowfish.c
@@ -412,7 +412,7 @@ selftest()
void
blowfish_setkey( BLOWFISH_context *c, byte *key, unsigned keylen )
{
- int i, j, k;
+ int i, j;
u32 data, datal, datar;
static int initialized;
diff --git a/cipher/md.c b/cipher/md.c
index e88a45c7..eb7b7b84 100644
--- a/cipher/md.c
+++ b/cipher/md.c
@@ -144,7 +144,7 @@ md_read( MD_HANDLE a, int algo )
if( algo == DIGEST_ALGO_MD5 )
return md5_read( &a->md5 );
}
- log_bug(NULL);
+ BUG();
}
int
diff --git a/cipher/md5.c b/cipher/md5.c
index 6906503d..c9f9a86b 100644
--- a/cipher/md5.c
+++ b/cipher/md5.c
@@ -73,7 +73,6 @@
#endif
-static void Init( MD5_CONTEXT *mdContext);
static void Transform(u32 *buf,u32 *in);
static byte PADDING[64] = {
diff --git a/cipher/misc.c b/cipher/misc.c
index cd0d31a4..7c8f2e3c 100644
--- a/cipher/misc.c
+++ b/cipher/misc.c
@@ -67,7 +67,7 @@ string_to_cipher_algo( const char *string )
int i;
const char *s;
- for(i=0; s=cipher_names[i].name; i++ )
+ for(i=0; (s=cipher_names[i].name); i++ )
if( !stricmp( s, string ) )
return cipher_names[i].algo;
return 0;
@@ -83,7 +83,7 @@ string_to_pubkey_algo( const char *string )
int i;
const char *s;
- for(i=0; s=pubkey_names[i].name; i++ )
+ for(i=0; (s=pubkey_names[i].name); i++ )
if( !stricmp( s, string ) )
return pubkey_names[i].algo;
return 0;
@@ -98,7 +98,7 @@ string_to_digest_algo( const char *string )
int i;
const char *s;
- for(i=0; s=digest_names[i].name; i++ )
+ for(i=0; (s=digest_names[i].name); i++ )
if( !stricmp( s, string ) )
return digest_names[i].algo;
return 0;
diff --git a/cipher/primegen.c b/cipher/primegen.c
index 3f6c1f32..9514fdae 100644
--- a/cipher/primegen.c
+++ b/cipher/primegen.c
@@ -319,8 +319,6 @@ check_prime( MPI prime )
int i;
unsigned x;
int count=0;
- MPI result;
- MPI val_2;
/* check against small primes */
for(i=0; (x = small_prime_numbers[i]); i++ ) {
@@ -431,7 +429,7 @@ m_out_of_n( char *array, int m, int n )
array[i] = 1;
return;
}
- log_bug(NULL);
+ BUG();
}
for(j=1; j < n; j++ ) {
diff --git a/cipher/random.c b/cipher/random.c
index 41f001e7..b082022a 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;