summaryrefslogtreecommitdiff
path: root/cipher
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2006-07-26 11:10:45 +0000
committerWerner Koch <wk@gnupg.org>2006-07-26 11:10:45 +0000
commitaa341655cd08be7b827e1bd3331d1bb6bb9df29c (patch)
tree660a6754ad2f8fa64b7e1a110f4295684fb4664e /cipher
parentc5e0e3ee0680196627758af15fae882329490c30 (diff)
downloadlibgcrypt-aa341655cd08be7b827e1bd3331d1bb6bb9df29c.tar.gz
Collected changes - see ChangeLogs
Diffstat (limited to 'cipher')
-rw-r--r--cipher/ChangeLog15
-rw-r--r--cipher/ac.c2
-rw-r--r--cipher/blowfish.c3
-rw-r--r--cipher/primegen.c12
-rw-r--r--cipher/random.c13
-rw-r--r--cipher/rmd160.c2
6 files changed, 34 insertions, 13 deletions
diff --git a/cipher/ChangeLog b/cipher/ChangeLog
index 238f9a37..a6cb45b4 100644
--- a/cipher/ChangeLog
+++ b/cipher/ChangeLog
@@ -1,3 +1,18 @@
+2006-07-26 Werner Koch <wk@g10code.com>
+
+ * rmd160.c (_gcry_rmd160_mixblock): Add cast to transform call.
+
+ * blowfish.c (selftest): Cast string to usnigned char*.
+
+ * primegen.c (prime_generate_internal): Cast unsigned/char*
+ mismatch in calling m_out_od_n.
+ (is_prime): Changed COUNT to unsigned int *.
+
+ * ac.c (_gcry_ac_data_copy): Initialize DATA_MPIS.
+
+ * random.c (gcry_create_nonce): Update the pid after a fork.
+ Reported by Uoti Urpala.
+
2006-07-04 Marcus Brinkmann <marcus@g10code.de>
* sha512.c: Fix typo in copyright notice.
diff --git a/cipher/ac.c b/cipher/ac.c
index 5ecdc101..3f0be4a7 100644
--- a/cipher/ac.c
+++ b/cipher/ac.c
@@ -256,7 +256,7 @@ ac_data_mpi_copy (gcry_ac_mpi_t *data_mpis, unsigned int data_mpis_n,
gcry_error_t
_gcry_ac_data_copy (gcry_ac_data_t *data_cp, gcry_ac_data_t data)
{
- gcry_ac_mpi_t *data_mpis;
+ gcry_ac_mpi_t *data_mpis = NULL;
gcry_ac_data_t data_new;
gcry_error_t err;
diff --git a/cipher/blowfish.c b/cipher/blowfish.c
index da9d0744..2f76ba95 100644
--- a/cipher/blowfish.c
+++ b/cipher/blowfish.c
@@ -472,7 +472,8 @@ selftest(void)
byte key3[] = { 0x41, 0x79, 0x6E, 0xA0, 0x52, 0x61, 0x6E, 0xE4 };
byte cipher3[] = { 0xE1, 0x13, 0xF4, 0x10, 0x2C, 0xFC, 0xCE, 0x43 };
- bf_setkey( (void *) &c, "abcdefghijklmnopqrstuvwxyz", 26 );
+ bf_setkey( (void *) &c,
+ (const unsigned char*)"abcdefghijklmnopqrstuvwxyz", 26 );
encrypt_block( (void *) &c, buffer, plain );
if( memcmp( buffer, "\x32\x4E\xD0\xFE\xF4\x13\xA2\x03", 8 ) )
return "Blowfish selftest failed (1).";
diff --git a/cipher/primegen.c b/cipher/primegen.c
index 7e805178..924e1fab 100644
--- a/cipher/primegen.c
+++ b/cipher/primegen.c
@@ -41,7 +41,7 @@ static gcry_mpi_t gen_prime (unsigned int nbits, int secret, int randomlevel,
void *extra_check_arg);
static int check_prime( gcry_mpi_t prime, gcry_mpi_t val_2, int rm_rounds,
gcry_prime_check_func_t cb_func, void *cb_arg );
-static int is_prime( gcry_mpi_t n, int steps, int *count );
+static int is_prime (gcry_mpi_t n, int steps, unsigned int *count);
static void m_out_of_n( char *array, int m, int n );
static void (*progress_cb) (void *,const char*,int,int, int );
@@ -313,7 +313,7 @@ prime_generate_internal (int mode,
}
else
{
- m_out_of_n (perms, n, m);
+ m_out_of_n ( (char*)perms, n, m);
for (i = j = 0; (i < m) && (j < n); i++)
if (perms[i])
{
@@ -535,8 +535,8 @@ gen_prime (unsigned int nbits, int secret, int randomlevel,
{
gcry_mpi_t prime, ptest, pminus1, val_2, val_3, result;
int i;
- unsigned x, step;
- unsigned count1, count2;
+ unsigned int x, step;
+ unsigned int count1, count2;
int *mods;
/* if ( DBG_CIPHER ) */
@@ -646,7 +646,7 @@ check_prime( gcry_mpi_t prime, gcry_mpi_t val_2, int rm_rounds,
{
int i;
unsigned int x;
- int count=0;
+ unsigned int count=0;
/* Check against small primes. */
for (i=0; (x = small_prime_numbers[i]); i++ )
@@ -691,7 +691,7 @@ check_prime( gcry_mpi_t prime, gcry_mpi_t val_2, int rm_rounds,
* Return true if n is probably a prime
*/
static int
-is_prime (gcry_mpi_t n, int steps, int *count)
+is_prime (gcry_mpi_t n, int steps, unsigned int *count)
{
gcry_mpi_t x = mpi_alloc( mpi_get_nlimbs( n ) );
gcry_mpi_t y = mpi_alloc( mpi_get_nlimbs( n ) );
diff --git a/cipher/random.c b/cipher/random.c
index 039997d4..e38b8773 100644
--- a/cipher/random.c
+++ b/cipher/random.c
@@ -1224,6 +1224,7 @@ gcry_create_nonce (unsigned char *buffer, size_t length)
compiler does not optimize the code away
in case the getpid function is badly
attributed. */
+ volatile pid_t apid;
unsigned char *p;
size_t n;
int err;
@@ -1241,11 +1242,12 @@ gcry_create_nonce (unsigned char *buffer, size_t length)
log_fatal ("failed to acquire the nonce buffer lock: %s\n",
strerror (err));
+ apid = getpid ();
/* The first time intialize our buffer. */
if (!nonce_buffer_initialized)
{
- pid_t apid = getpid ();
time_t atime = time (NULL);
+ pid_t xpid = apid;
my_pid = apid;
@@ -1256,8 +1258,8 @@ gcry_create_nonce (unsigned char *buffer, size_t length)
a failure of gcry_randomize won't affect us too much. Don't
care about the uninitialized remaining bytes. */
p = nonce_buffer;
- memcpy (p, &apid, sizeof apid);
- p += sizeof apid;
+ memcpy (p, &xpid, sizeof xpid);
+ p += sizeof xpid;
memcpy (p, &atime, sizeof atime);
/* Initialize the never changing private part of 64 bits. */
@@ -1265,11 +1267,14 @@ gcry_create_nonce (unsigned char *buffer, size_t length)
nonce_buffer_initialized = 1;
}
- else if ( my_pid != getpid () )
+ else if ( my_pid != apid )
{
/* We forked. Need to reseed the buffer - doing this for the
private part should be sufficient. */
gcry_randomize (nonce_buffer+20, 8, GCRY_WEAK_RANDOM);
+ /* Update the pid so that we won't run into here again and
+ again. */
+ my_pid = apid;
}
/* Create the nonce by hashing the entire buffer, returning the hash
diff --git a/cipher/rmd160.c b/cipher/rmd160.c
index 8d0c4ae5..1c863c02 100644
--- a/cipher/rmd160.c
+++ b/cipher/rmd160.c
@@ -447,7 +447,7 @@ _gcry_rmd160_mixblock( RMD160_CONTEXT *hd, char *buffer )
{
char *p = buffer;
- transform( hd, buffer );
+ transform( hd, (unsigned char *)buffer );
#define X(a) do { *(u32*)p = hd->h##a ; p += 4; } while(0)
X(0);
X(1);