LIBGCRYPT-1-2-BRANCH libgcrypt (21 files)
cvs user wk
cvs at cvs.gnupg.org
Thu Jun 16 11:43:21 CEST 2005
Date: Thursday, June 16, 2005 @ 12:05:54
Author: wk
Path: /cvs/libgcrypt/libgcrypt
Tag: LIBGCRYPT-1-2-BRANCH
Modified: NEWS cipher/ChangeLog cipher/blowfish.c cipher/cipher.c
cipher/crc.c cipher/dsa.c cipher/elgamal.c cipher/md.c
cipher/primegen.c cipher/random.c cipher/rmd160.c cipher/tiger.c
mpi/ChangeLog mpi/mpicoder.c mpi/mpiutil.c src/ChangeLog
src/gcrypt-module.h src/sexp.c tests/ChangeLog tests/basic.c
tests/tsexp.c
* cipher.c (gcry_cipher_register): Changed arg ALGORITHM_ID
from unsigned int * to int*.
* rmd160.c (_gcry_rmd160_mixblock): Applied cast.
* tiger.c (round): Renamed to R to avoid conflict with builtin.
* crc.c (crc32_write): Applied cast.
* dsa.c (gen_k): Made RNDBUF unsigned.
* elgamal.c (gen_k): Ditto.
* blowfish.c (selftest): Added cast to constants.
* random.c (rndpool, keypool): Made unsigned.
(mix_pool): Changed char* to unsigned char*.
* md.c (gcry_md_ctl): Use cast to fix signed/unsigned mismatch.
* primegen.c (prime_generate_internal): Ditto.
(is_prime): Made COUNT unsigned.
* mpiutil.c (gcry_mpi_randomize): Made P unsigned.
* mpicoder.c (gcry_mpi_scan): Changed arg BUFFER to void*.
(mpi_read_from_buffer): Made BUFFER arg const.
(gcry_mpi_scan): Removed now needless cast. Add cast for arg to
mpi_fromstr.
(gcry_mpi_print): Made TMP unsigned.
* sexp.c (normalize): Made P unsigned.
(gcry_sexp_nth_data): Cast return value to char*.
(sexp_sscan): Fixed sign/usnigned conflicts.
(whitespacep): Changed arg to char*.
(unquote_string): Changed arg STRING to char*.
* gcrypt-module.h (gcry_cipher_register): Changed arg ALGORITHM_ID
from unsigned int * to int*.
* basic.c (check_one_md): Made P unsigned.
---------------------+
NEWS | 2
cipher/ChangeLog | 16 +++++++
cipher/blowfish.c | 3 -
cipher/cipher.c | 2
cipher/crc.c | 2
cipher/dsa.c | 2
cipher/elgamal.c | 2
cipher/md.c | 2
cipher/primegen.c | 12 ++---
cipher/random.c | 29 +++++++------
cipher/rmd160.c | 2
cipher/tiger.c | 18 ++++----
mpi/ChangeLog | 5 ++
mpi/mpicoder.c | 104 ++++++++++++++++++++++++++------------------------
mpi/mpiutil.c | 2
src/ChangeLog | 9 ++++
src/gcrypt-module.h | 2
src/sexp.c | 67 ++++++++++++++++----------------
tests/ChangeLog | 4 +
tests/basic.c | 10 ++--
tests/tsexp.c | 5 +-
21 files changed, 174 insertions(+), 126 deletions(-)
Index: libgcrypt/NEWS
diff -u libgcrypt/NEWS:1.69.2.4 libgcrypt/NEWS:1.69.2.5
--- libgcrypt/NEWS:1.69.2.4 Thu Jun 16 10:13:13 2005
+++ libgcrypt/NEWS Thu Jun 16 12:05:54 2005
@@ -3,6 +3,7 @@
* Minor changes to some function declarations. Buffer arguments are
now typed as void pointer. This should not affect any compilation.
+ A bug in the definition of gcry_cipher_register has been fixed.
* Interface changes relative to the 1.2.1 release:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -12,6 +13,7 @@
gcry_md_ctl CHANGED: Argument BUFFER is now void*.
gcry_sexp_sprint CHANGED: Argument BUFFER is now void*.
gcry_mpi_scan CHANGED: Argument BUFFER is now void*.
+ gcry_cipher_register CHANGED: Argument ALGORITHM_ID is now int*.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Index: libgcrypt/cipher/ChangeLog
diff -u libgcrypt/cipher/ChangeLog:1.211.2.13 libgcrypt/cipher/ChangeLog:1.211.2.14
--- libgcrypt/cipher/ChangeLog:1.211.2.13 Thu Jun 16 10:13:13 2005
+++ libgcrypt/cipher/ChangeLog Thu Jun 16 12:05:54 2005
@@ -1,3 +1,19 @@
+2005-06-16 Werner Koch <wk at g10code.com>
+
+ * cipher.c (gcry_cipher_register): Changed arg ALGORITHM_ID
+ from unsigned int * to int*.
+ * rmd160.c (_gcry_rmd160_mixblock): Applied cast.
+ * tiger.c (round): Renamed to R to avoid conflict with builtin.
+ * crc.c (crc32_write): Applied cast.
+ * dsa.c (gen_k): Made RNDBUF unsigned.
+ * elgamal.c (gen_k): Ditto.
+ * blowfish.c (selftest): Added cast to constants.
+ * random.c (rndpool, keypool): Made unsigned.
+ (mix_pool): Changed char* to unsigned char*.
+ * md.c (gcry_md_ctl): Use cast to fix signed/unsigned mismatch.
+ * primegen.c (prime_generate_internal): Ditto.
+ (is_prime): Made COUNT unsigned.
+
2005-06-15 Werner Koch <wk at g10code.com>
* cipher.c (gcry_cipher_encrypt, gcry_cipher_decrypt): Changed OUT
Index: libgcrypt/cipher/blowfish.c
diff -u libgcrypt/cipher/blowfish.c:1.38 libgcrypt/cipher/blowfish.c:1.38.2.1
--- libgcrypt/cipher/blowfish.c:1.38 Tue Dec 9 15:10:32 2003
+++ libgcrypt/cipher/blowfish.c Thu Jun 16 12:05:54 2005
@@ -473,7 +473,8 @@
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).";
Index: libgcrypt/cipher/cipher.c
diff -u libgcrypt/cipher/cipher.c:1.69.2.2 libgcrypt/cipher/cipher.c:1.69.2.3
--- libgcrypt/cipher/cipher.c:1.69.2.2 Thu Jun 16 10:13:13 2005
+++ libgcrypt/cipher/cipher.c Thu Jun 16 12:05:54 2005
@@ -250,7 +250,7 @@
and a pointer representhing this module is stored in MODULE. */
gcry_error_t
gcry_cipher_register (gcry_cipher_spec_t *cipher,
- unsigned int *algorithm_id,
+ int *algorithm_id,
gcry_module_t *module)
{
gcry_err_code_t err = 0;
Index: libgcrypt/cipher/crc.c
diff -u libgcrypt/cipher/crc.c:1.6 libgcrypt/cipher/crc.c:1.6.2.1
--- libgcrypt/cipher/crc.c:1.6 Mon Oct 27 14:08:04 2003
+++ libgcrypt/cipher/crc.c Thu Jun 16 12:05:54 2005
@@ -161,7 +161,7 @@
CRC_CONTEXT *ctx = (CRC_CONTEXT *) context;
if (!inbuf)
return;
- ctx->CRC = update_crc32 (ctx->CRC, inbuf, inlen);
+ ctx->CRC = update_crc32 (ctx->CRC, (char*)inbuf, inlen);
}
static byte *
Index: libgcrypt/cipher/dsa.c
diff -u libgcrypt/cipher/dsa.c:1.41 libgcrypt/cipher/dsa.c:1.41.2.1
--- libgcrypt/cipher/dsa.c:1.41 Tue Dec 9 15:10:32 2003
+++ libgcrypt/cipher/dsa.c Thu Jun 16 12:05:53 2005
@@ -88,7 +88,7 @@
gcry_mpi_t k = mpi_alloc_secure( mpi_get_nlimbs(q) );
unsigned int nbits = mpi_get_nbits(q);
unsigned int nbytes = (nbits+7)/8;
- char *rndbuf = NULL;
+ unsigned char *rndbuf = NULL;
if ( DBG_CIPHER )
log_debug("choosing a random k ");
Index: libgcrypt/cipher/elgamal.c
diff -u libgcrypt/cipher/elgamal.c:1.52 libgcrypt/cipher/elgamal.c:1.52.2.1
--- libgcrypt/cipher/elgamal.c:1.52 Tue Dec 9 15:10:32 2003
+++ libgcrypt/cipher/elgamal.c Thu Jun 16 12:05:53 2005
@@ -167,7 +167,7 @@
gcry_mpi_t p_1 = mpi_copy(p);
unsigned int orig_nbits = mpi_get_nbits(p);
unsigned int nbits, nbytes;
- char *rndbuf = NULL;
+ unsigned char *rndbuf = NULL;
if (small_k)
{
Index: libgcrypt/cipher/md.c
diff -u libgcrypt/cipher/md.c:1.82.2.1 libgcrypt/cipher/md.c:1.82.2.2
--- libgcrypt/cipher/md.c:1.82.2.1 Thu Jun 16 10:13:13 2005
+++ libgcrypt/cipher/md.c Thu Jun 16 12:05:53 2005
@@ -812,7 +812,7 @@
rc = gcry_err_code (gcry_md_setkey (hd, buf, buflen));
break;
case GCRYCTL_START_DUMP:
- md_start_debug (hd, buf);
+ md_start_debug (hd, (char*)buf);
break;
case GCRYCTL_STOP_DUMP:
md_stop_debug( hd );
Index: libgcrypt/cipher/primegen.c
diff -u libgcrypt/cipher/primegen.c:1.55 libgcrypt/cipher/primegen.c:1.55.2.1
--- libgcrypt/cipher/primegen.c:1.55 Fri Feb 20 19:32:40 2004
+++ libgcrypt/cipher/primegen.c Thu Jun 16 12:05:53 2005
@@ -41,7 +41,7 @@
void *extra_check_arg);
static int check_prime( gcry_mpi_t prime, gcry_mpi_t val_2,
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 @@
}
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])
{
@@ -534,8 +534,8 @@
{
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 ) */
@@ -644,7 +644,7 @@
{
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++ )
@@ -689,7 +689,7 @@
* 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 ) );
Index: libgcrypt/cipher/random.c
diff -u libgcrypt/cipher/random.c:1.69.2.4 libgcrypt/cipher/random.c:1.69.2.5
--- libgcrypt/cipher/random.c:1.69.2.4 Thu Jun 16 10:13:13 2005
+++ libgcrypt/cipher/random.c Thu Jun 16 12:05:53 2005
@@ -88,8 +88,8 @@
static int is_initialized;
#define MASK_LEVEL(a) do { (a) &= 3; } while(0)
-static char *rndpool; /* allocated size is POOLSIZE+BLOCKLEN */
-static char *keypool; /* allocated size is POOLSIZE+BLOCKLEN */
+static unsigned char *rndpool; /* allocated size is POOLSIZE+BLOCKLEN */
+static unsigned char *keypool; /* allocated size is POOLSIZE+BLOCKLEN */
static size_t pool_readpos;
static size_t pool_writepos;
static int pool_filled;
@@ -452,13 +452,13 @@
Note, that this function muts only be called with a locked pool.
*/
static void
-mix_pool(byte *pool)
+mix_pool (unsigned char *pool)
{
static unsigned char failsafe_digest[DIGESTLEN];
static int failsafe_digest_valid;
- char *hashbuf = pool + POOLSIZE;
- char *p, *pend;
+ unsigned char *hashbuf = pool + POOLSIZE;
+ unsigned char *p, *pend;
int i, n;
RMD160_CONTEXT md;
@@ -473,10 +473,10 @@
pend = pool + POOLSIZE;
memcpy(hashbuf, pend - DIGESTLEN, DIGESTLEN );
memcpy(hashbuf+DIGESTLEN, pool, BLOCKLEN-DIGESTLEN);
- _gcry_rmd160_mixblock( &md, hashbuf);
+ _gcry_rmd160_mixblock( &md, (char*)hashbuf);
memcpy(pool, hashbuf, 20 );
- if (failsafe_digest_valid && (char *)pool == rndpool)
+ if (failsafe_digest_valid && pool == rndpool)
{
for (i=0; i < 20; i++)
pool[i] ^= failsafe_digest[i];
@@ -492,7 +492,7 @@
memcpy (hashbuf+DIGESTLEN, p+DIGESTLEN, BLOCKLEN-DIGESTLEN);
else
{
- char *pp = p + DIGESTLEN;
+ unsigned char *pp = p + DIGESTLEN;
for (i=DIGESTLEN; i < BLOCKLEN; i++ )
{
@@ -502,7 +502,7 @@
}
}
- _gcry_rmd160_mixblock( &md, hashbuf);
+ _gcry_rmd160_mixblock( &md, (char*)hashbuf);
memcpy(p, hashbuf, 20 );
}
@@ -510,9 +510,10 @@
of the pool on the stack, so it is okay not to require secure
memory here. Before we use this pool, it will be copied to the
help buffer anyway. */
- if ( (char*)pool == rndpool)
+ if ( pool == rndpool)
{
- _gcry_rmd160_hash_buffer (failsafe_digest, pool, POOLSIZE);
+ _gcry_rmd160_hash_buffer ((char*)failsafe_digest,
+ (char*)pool, POOLSIZE);
failsafe_digest_valid = 1;
}
@@ -633,7 +634,7 @@
void
_gcry_update_random_seed_file()
{
- ulong *sp, *dp;
+ unsigned long *sp, *dp;
int fd, i;
int err;
@@ -1143,8 +1144,8 @@
and updating the first 20 bytes of the buffer with this hash. */
for (p = buffer; length > 0; length -= n, p += n)
{
- _gcry_sha1_hash_buffer (nonce_buffer,
- nonce_buffer, sizeof nonce_buffer);
+ _gcry_sha1_hash_buffer ((char*)nonce_buffer,
+ (char*)nonce_buffer, sizeof nonce_buffer);
n = length > 20? 20 : length;
memcpy (p, nonce_buffer, n);
}
Index: libgcrypt/cipher/rmd160.c
diff -u libgcrypt/cipher/rmd160.c:1.34 libgcrypt/cipher/rmd160.c:1.34.2.1
--- libgcrypt/cipher/rmd160.c:1.34 Thu Dec 11 16:46:12 2003
+++ libgcrypt/cipher/rmd160.c Thu Jun 16 12:05:53 2005
@@ -447,7 +447,7 @@
{
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);
Index: libgcrypt/cipher/tiger.c
diff -u libgcrypt/cipher/tiger.c:1.28 libgcrypt/cipher/tiger.c:1.28.2.1
--- libgcrypt/cipher/tiger.c:1.28 Thu Dec 11 16:46:12 2003
+++ libgcrypt/cipher/tiger.c Thu Jun 16 12:05:53 2005
@@ -600,7 +600,7 @@
}
static void
-round( u64 *ra, u64 *rb, u64 *rc, u64 x, int mul )
+R( u64 *ra, u64 *rb, u64 *rc, u64 x, int mul )
{
u64 a = *ra;
u64 b = *rb;
@@ -626,14 +626,14 @@
u64 b = *rb;
u64 c = *rc;
- round( &a, &b, &c, x[0], mul );
- round( &b, &c, &a, x[1], mul );
- round( &c, &a, &b, x[2], mul );
- round( &a, &b, &c, x[3], mul );
- round( &b, &c, &a, x[4], mul );
- round( &c, &a, &b, x[5], mul );
- round( &a, &b, &c, x[6], mul );
- round( &b, &c, &a, x[7], mul );
+ R( &a, &b, &c, x[0], mul );
+ R( &b, &c, &a, x[1], mul );
+ R( &c, &a, &b, x[2], mul );
+ R( &a, &b, &c, x[3], mul );
+ R( &b, &c, &a, x[4], mul );
+ R( &c, &a, &b, x[5], mul );
+ R( &a, &b, &c, x[6], mul );
+ R( &b, &c, &a, x[7], mul );
*ra = a;
*rb = b;
Index: libgcrypt/mpi/ChangeLog
diff -u libgcrypt/mpi/ChangeLog:1.89.2.5 libgcrypt/mpi/ChangeLog:1.89.2.6
--- libgcrypt/mpi/ChangeLog:1.89.2.5 Thu Jun 16 10:13:13 2005
+++ libgcrypt/mpi/ChangeLog Thu Jun 16 12:05:53 2005
@@ -1,6 +1,11 @@
2005-06-16 Werner Koch <wk at g10code.com>
+ * mpiutil.c (gcry_mpi_randomize): Made P unsigned.
* mpicoder.c (gcry_mpi_scan): Changed arg BUFFER to void*.
+ (mpi_read_from_buffer): Made BUFFER arg const.
+ (gcry_mpi_scan): Removed now needless cast. Add cast for arg to
+ mpi_fromstr.
+ (gcry_mpi_print): Made TMP unsigned.
2005-05-29 Moritz Schulte <moritz at g10code.com>
Index: libgcrypt/mpi/mpicoder.c
diff -u libgcrypt/mpi/mpicoder.c:1.38.4.1 libgcrypt/mpi/mpicoder.c:1.38.4.2
--- libgcrypt/mpi/mpicoder.c:1.38.4.1 Thu Jun 16 10:13:13 2005
+++ libgcrypt/mpi/mpicoder.c Thu Jun 16 12:05:53 2005
@@ -32,50 +32,55 @@
static gcry_mpi_t
-mpi_read_from_buffer(byte *buffer, unsigned *ret_nread, int secure)
+mpi_read_from_buffer (const unsigned char *buffer, unsigned int *ret_nread,
+ int secure)
{
- int i, j;
- unsigned int nbits, nbytes, nlimbs, nread=0;
- mpi_limb_t a;
- gcry_mpi_t val = MPI_NULL;
-
- if( *ret_nread < 2 )
- goto leave;
- nbits = buffer[0] << 8 | buffer[1];
- if( nbits > MAX_EXTERN_MPI_BITS ) {
- log_error("mpi too large (%u bits)\n", nbits);
- goto leave;
- }
- else if( !nbits ) {
- log_error("an mpi of size 0 is not allowed\n");
- goto leave;
+ int i, j;
+ unsigned int nbits, nbytes, nlimbs, nread=0;
+ mpi_limb_t a;
+ gcry_mpi_t val = MPI_NULL;
+
+ if (*ret_nread < 2)
+ goto leave;
+ nbits = buffer[0] << 8 | buffer[1];
+ if (nbits > MAX_EXTERN_MPI_BITS)
+ {
+ log_error ("mpi too large (%u bits)\n", nbits);
+ goto leave;
}
- buffer += 2;
- nread = 2;
-
- nbytes = (nbits+7) / 8;
- nlimbs = (nbytes+BYTES_PER_MPI_LIMB-1) / BYTES_PER_MPI_LIMB;
- val = secure? mpi_alloc_secure( nlimbs )
- : mpi_alloc( nlimbs );
- i = BYTES_PER_MPI_LIMB - nbytes % BYTES_PER_MPI_LIMB;
- i %= BYTES_PER_MPI_LIMB;
- j= val->nlimbs = nlimbs;
- val->sign = 0;
- for( ; j > 0; j-- ) {
- a = 0;
- for(; i < BYTES_PER_MPI_LIMB; i++ ) {
- if( ++nread > *ret_nread )
- log_bug("mpi larger than buffer");
- a <<= 8;
- a |= *buffer++;
- }
- i = 0;
- val->d[j-1] = a;
+ else if (!nbits)
+ {
+ log_error ("an mpi of size 0 is not allowed\n");
+ goto leave;
+ }
+ buffer += 2;
+ nread = 2;
+
+ nbytes = (nbits+7) / 8;
+ nlimbs = (nbytes+BYTES_PER_MPI_LIMB-1) / BYTES_PER_MPI_LIMB;
+ val = secure? mpi_alloc_secure( nlimbs )
+ : mpi_alloc( nlimbs );
+ i = BYTES_PER_MPI_LIMB - nbytes % BYTES_PER_MPI_LIMB;
+ i %= BYTES_PER_MPI_LIMB;
+ j= val->nlimbs = nlimbs;
+ val->sign = 0;
+ for( ; j > 0; j-- )
+ {
+ a = 0;
+ for (; i < BYTES_PER_MPI_LIMB; i++ )
+ {
+ if ( ++nread > *ret_nread )
+ log_bug ("mpi larger than buffer");
+ a <<= 8;
+ a |= *buffer++;
+ }
+ i = 0;
+ val->d[j-1] = a;
}
- leave:
- *ret_nread = nread;
- return val;
+ leave:
+ *ret_nread = nread;
+ return val;
}
@@ -385,7 +390,7 @@
return gcry_error (GPG_ERR_NO_ERROR);
}
else if( format == GCRYMPI_FMT_PGP ) {
- a = mpi_read_from_buffer( (char*)buffer, &len, secure);
+ a = mpi_read_from_buffer (buffer, &len, secure);
if( nscanned )
*nscanned = len;
if( ret_mpi && a ) {
@@ -397,7 +402,7 @@
return gcry_error (a ? GPG_ERR_NO_ERROR : GPG_ERR_INV_OBJ);
}
else if( format == GCRYMPI_FMT_SSH ) {
- const byte *s = buffer;
+ const unsigned char *s = buffer;
size_t n;
if( len && len < 4 )
@@ -438,7 +443,7 @@
return gcry_error (GPG_ERR_INV_ARG); /* can only handle C
strings for now */
a = secure? mpi_alloc_secure (0) : mpi_alloc(0);
- if( mpi_fromstr( a, buffer ) )
+ if( mpi_fromstr ( a, (const char *)buffer ) )
return gcry_error (GPG_ERR_INV_OBJ);
if( ret_mpi ) {
mpi_normalize ( a );
@@ -473,7 +478,7 @@
len = buflen;
*nwritten = 0;
if( format == GCRYMPI_FMT_STD ) {
- char *tmp;
+ unsigned char *tmp;
int extra = 0;
unsigned int n;
@@ -487,8 +492,9 @@
}
if (buffer && n > len) {
+ /* The provided buffer is too short. */
gcry_free(tmp);
- return gcry_error (GPG_ERR_TOO_SHORT); /* the provided buffer is too short */
+ return gcry_error (GPG_ERR_TOO_SHORT);
}
if( buffer ) {
byte *s = buffer;
@@ -510,7 +516,7 @@
if (buffer && n > len)
return gcry_error (GPG_ERR_TOO_SHORT); /* the provided buffer is too short */
if( buffer ) {
- char *tmp;
+ unsigned char *tmp;
tmp = _gcry_mpi_get_buffer( a, &n, NULL );
memcpy( buffer, tmp, n );
gcry_free(tmp);
@@ -527,8 +533,8 @@
if (buffer && n+2 > len)
return gcry_error (GPG_ERR_TOO_SHORT); /* the provided buffer is too short */
if( buffer ) {
- char *tmp;
- byte *s = buffer;
+ unsigned char *tmp;
+ unsigned char *s = buffer;
s[0] = nbits >> 8;
s[1] = nbits;
@@ -540,7 +546,7 @@
return gcry_error (GPG_ERR_NO_ERROR);
}
else if( format == GCRYMPI_FMT_SSH ) {
- char *tmp;
+ unsigned char *tmp;
int extra = 0;
unsigned int n;
Index: libgcrypt/mpi/mpiutil.c
diff -u libgcrypt/mpi/mpiutil.c:1.38.2.2 libgcrypt/mpi/mpiutil.c:1.38.2.3
--- libgcrypt/mpi/mpiutil.c:1.38.2.2 Sun May 29 11:32:24 2005
+++ libgcrypt/mpi/mpiutil.c Thu Jun 16 12:05:53 2005
@@ -377,7 +377,7 @@
gcry_mpi_randomize( gcry_mpi_t w,
unsigned int nbits, enum gcry_random_level level )
{
- char *p;
+ unsigned char *p;
size_t nbytes = (nbits+7)/8;
if (level == GCRY_WEAK_RANDOM)
Index: libgcrypt/src/ChangeLog
diff -u libgcrypt/src/ChangeLog:1.151.2.15 libgcrypt/src/ChangeLog:1.151.2.16
--- libgcrypt/src/ChangeLog:1.151.2.15 Thu Jun 16 10:13:13 2005
+++ libgcrypt/src/ChangeLog Thu Jun 16 12:05:53 2005
@@ -1,5 +1,14 @@
2005-06-16 Werner Koch <wk at g10code.com>
+ * sexp.c (normalize): Made P unsigned.
+ (gcry_sexp_nth_data): Cast return value to char*.
+ (sexp_sscan): Fixed sign/usnigned conflicts.
+ (whitespacep): Changed arg to char*.
+ (unquote_string): Changed arg STRING to char*.
+
+ * gcrypt-module.h (gcry_cipher_register): Changed arg ALGORITHM_ID
+ from unsigned int * to int*.
+
* gcrypt.h (gcry_mpi_scan): Changed arg BUFFER from unsigned char*
to void*.
Index: libgcrypt/src/gcrypt-module.h
diff -u libgcrypt/src/gcrypt-module.h:1.1 libgcrypt/src/gcrypt-module.h:1.1.4.1
--- libgcrypt/src/gcrypt-module.h:1.1 Mon Jul 28 12:17:44 2003
+++ libgcrypt/src/gcrypt-module.h Thu Jun 16 12:05:53 2005
@@ -89,7 +89,7 @@
CIPHER. On success, a new algorithm ID is stored in ALGORITHM_ID
and a pointer representhing this module is stored in MODULE. */
gcry_error_t gcry_cipher_register (gcry_cipher_spec_t *cipher,
- unsigned int *algorithm_id,
+ int *algorithm_id,
gcry_module_t *module);
/* Unregister the cipher identified by MODULE, which must have been
Index: libgcrypt/src/sexp.c
diff -u libgcrypt/src/sexp.c:1.40.2.4 libgcrypt/src/sexp.c:1.40.2.5
--- libgcrypt/src/sexp.c:1.40.2.4 Thu Jun 16 10:13:13 2005
+++ libgcrypt/src/sexp.c Thu Jun 16 12:05:53 2005
@@ -66,7 +66,7 @@
to the S-expressions definition. */
#undef whitespacep
static GPG_ERR_INLINE int
-whitespacep (const unsigned char *p)
+whitespacep (const char *p)
{
switch (*p)
{
@@ -172,22 +172,23 @@
static gcry_sexp_t
normalize ( gcry_sexp_t list )
{
- char *p;
- if ( !list )
- return NULL;
- p = list->d;
- if ( *p == ST_STOP ) {
- /* this is "" */
- gcry_sexp_release ( list );
- return NULL;
- }
- if( *p == ST_OPEN && p[1] == ST_CLOSE ) {
- /* this is "()" */
- gcry_sexp_release ( list );
- return NULL;
- }
+ unsigned char *p;
- return list;
+ if ( !list )
+ return NULL;
+ p = list->d;
+ if ( *p == ST_STOP ) {
+ /* this is "" */
+ gcry_sexp_release ( list );
+ return NULL;
+ }
+ if( *p == ST_OPEN && p[1] == ST_CLOSE ) {
+ /* this is "()" */
+ gcry_sexp_release ( list );
+ return NULL;
+ }
+
+ return list;
}
/* Create a new S-expression object by reading LENGTH bytes from
@@ -559,7 +560,7 @@
const char *
gcry_sexp_nth_data( const gcry_sexp_t list, int number, size_t *datalen )
{
- const byte *p;
+ const unsigned char *p;
DATALEN n;
int level = 0;
@@ -600,7 +601,7 @@
if ( *p == ST_DATA ) {
memcpy ( &n, ++p, sizeof n );
*datalen = n;
- return p + sizeof n;
+ return (const char*)p + sizeof n;
}
return NULL;
@@ -751,7 +752,7 @@
static int
-hextobyte( const byte *s )
+hextobyte( const unsigned char *s )
{
int c=0;
@@ -773,10 +774,11 @@
return c;
}
-struct make_space_ctx {
- gcry_sexp_t sexp;
- size_t allocated;
- byte *pos;
+struct make_space_ctx
+{
+ gcry_sexp_t sexp;
+ size_t allocated;
+ unsigned char *pos;
};
static void
@@ -801,8 +803,9 @@
quotes are must already be removed from STRING. We assume that the
quoted string is syntacillay correct. */
static size_t
-unquote_string (const unsigned char *string, size_t length, unsigned char *buf)
+unquote_string (const char *string_arg, size_t length, unsigned char *buf)
{
+ const unsigned char *string = (const unsigned char*)string_arg;
int esc = 0;
const unsigned char *s = string;
unsigned char *d = buf;
@@ -1040,7 +1043,7 @@
{
/* Keep it easy - we know that the unquoted string will
never be larger. */
- char *save;
+ unsigned char *save;
size_t len;
quoted++; /* Skip leading quote. */
@@ -1074,7 +1077,7 @@
{
if (whitespacep (hexfmt))
continue;
- *c.pos++ = hextobyte (hexfmt);
+ *c.pos++ = hextobyte ((const unsigned char*)hexfmt);
hexfmt++;
}
hexfmt = NULL;
@@ -1453,7 +1456,7 @@
{
*dest++ = '#';
for (i=0; i < len; i++, dest += 2 )
- sprintf (dest, "%02X", src[i]);
+ sprintf ((char*)dest, "%02X", src[i]);
*dest++ = '#';
}
return len*2+2;
@@ -1482,7 +1485,7 @@
default:
if ( (*s < 0x20 || (*s >= 0x7f && *s <= 0xa0)))
{
- sprintf (p, "\\x%02x", *s);
+ sprintf ((char*)p, "\\x%02x", *s);
p += 4;
}
else
@@ -1623,9 +1626,9 @@
return 0;
switch (type)
{
- case 1: convert_to_string (s, n, d); break;
- case 2: convert_to_token (s, n, d); break;
- default: convert_to_hex (s, n, d); break;
+ case 1: convert_to_string (s, n, (unsigned char*)d); break;
+ case 2: convert_to_token (s, n, (unsigned char*)d); break;
+ default: convert_to_hex (s, n, (unsigned char*)d); break;
}
d += nn;
}
@@ -1781,7 +1784,7 @@
*errcode = gcry_error (GPG_ERR_SEXP_NESTED_DH);
return 0;
}
- disphint = p;
+ disphint = (const char*)p;
}
else if (*p == ']')
{
Index: libgcrypt/tests/ChangeLog
diff -u libgcrypt/tests/ChangeLog:1.50 libgcrypt/tests/ChangeLog:1.50.2.1
--- libgcrypt/tests/ChangeLog:1.50 Wed Mar 3 09:08:05 2004
+++ libgcrypt/tests/ChangeLog Thu Jun 16 12:05:53 2005
@@ -1,3 +1,7 @@
+2005-06-16 Werner Koch <wk at g10code.com>
+
+ * basic.c (check_one_md): Made P unsigned.
+
2004-02-25 Werner Koch <wk at gnupg.org>
* Makefile.am (TEST): Add benchmark.
Index: libgcrypt/tests/basic.c
diff -u libgcrypt/tests/basic.c:1.27 libgcrypt/tests/basic.c:1.27.2.1
--- libgcrypt/tests/basic.c:1.27 Fri Oct 31 06:06:05 2003
+++ libgcrypt/tests/basic.c Thu Jun 16 12:05:53 2005
@@ -29,7 +29,7 @@
{
const char *secret;
const char *public;
- const char *grip;
+ const unsigned char *grip;
}
test_spec_pubkey_key_t;
@@ -583,7 +583,7 @@
check_one_md (int algo, char *data, int len, char *expect)
{
gcry_md_hd_t hd, hd2;
- char *p;
+ unsigned char *p;
int mdlen;
int i;
gcry_error_t err = 0;
@@ -979,7 +979,7 @@
" 891440464baf79827e03a36e70b814938eebdc63e964247be75dc58b014b7ea251#)\n"
" (e #010001#)))\n",
- "\x32\x10\x0c\x27\x17\x3e\xf6\xe9\xc4\xe9"
+ (const unsigned char*)"\x32\x10\x0c\x27\x17\x3e\xf6\xe9\xc4\xe9"
"\xa2\x5d\x3d\x69\xf8\x6d\x37\xa4\xf9\x39"}
},
{
@@ -1018,7 +1018,7 @@
" 6E45831AB811EEE848EBB24D9F5F2883B6E5DDC4C659DEF944DCFD80BF4D0A20"
" 42CAA7DC289F0C5A9D155F02D3D551DB741A81695B74D4C8F477F9C7838EB0FB#)))\n",
- "\xc6\x39\x83\x1a\x43\xe5\x05\x5d\xc6\xd8"
+ (const unsigned char*)"\xc6\x39\x83\x1a\x43\xe5\x05\x5d\xc6\xd8"
"\x4a\xa6\xf9\xeb\x23\xbf\xa9\x12\x2d\x5b" }
},
{
@@ -1049,7 +1049,7 @@
" D20DB4BEE9BDF916648DE6D6E419FA446C513AAB81C30CB7B34D6007637BE675"
" 56CE6473E9F9EE9B9FADD275D001563336F2186F424DEC6199A0F758F6A00FF4#)))\n",
- "\xa7\x99\x61\xeb\x88\x83\xd2\xf4\x05\xc8"
+ (const unsigned char*)"\xa7\x99\x61\xeb\x88\x83\xd2\xf4\x05\xc8"
"\x4f\xba\x06\xf8\x78\x09\xbc\x1e\x20\xe5" }
},
};
Index: libgcrypt/tests/tsexp.c
diff -u libgcrypt/tests/tsexp.c:1.10 libgcrypt/tests/tsexp.c:1.10.2.1
--- libgcrypt/tests/tsexp.c:1.10 Tue Feb 3 13:13:15 2004
+++ libgcrypt/tests/tsexp.c Thu Jun 16 12:05:53 2005
@@ -219,7 +219,7 @@
size_t expected;/* expected length or 0 on error and then ... */
size_t erroff; /* ... and at this offset */
gcry_error_t errcode; /* ... with this error code */
- unsigned char *text;
+ char *text;
} values[] = {
{ 14, 13, 0, GPG_ERR_NO_ERROR, "(9:abcdefghi) " },
{ 16, 15, 0, GPG_ERR_NO_ERROR, "(10:abcdefghix)" },
@@ -245,7 +245,8 @@
info ("checking canoncial length test function\n");
for (idx=0; values[idx].text; idx++)
{
- n = gcry_sexp_canon_len (values[idx].text, values[idx].textlen,
+ n = gcry_sexp_canon_len ((const unsigned char*)values[idx].text,
+ values[idx].textlen,
&erroff, &errcode);
if (n && n == values[idx].expected)
More information about the Gnupg-commits
mailing list