diff options
-rw-r--r-- | ChangeLog | 19 | ||||
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | cipher/ChangeLog | 24 | ||||
-rw-r--r-- | cipher/ac.c | 2 | ||||
-rw-r--r-- | cipher/camellia-glue.c | 39 | ||||
-rw-r--r-- | cipher/camellia.h | 4 | ||||
-rw-r--r-- | cipher/cipher.c | 2 | ||||
-rw-r--r-- | cipher/rndw32.c | 13 | ||||
-rw-r--r-- | cipher/sha1.c | 466 | ||||
-rw-r--r-- | configure.ac | 195 | ||||
-rw-r--r-- | src/ChangeLog | 5 | ||||
-rw-r--r-- | src/missing-string.c | 97 | ||||
-rw-r--r-- | tests/basic.c | 9 | ||||
-rw-r--r-- | tests/pubkey.c | 2 |
14 files changed, 524 insertions, 355 deletions
@@ -1,3 +1,20 @@ +2008-04-18 Werner Koch <wk@g10code.com> + + * configure.ac (AH_BOTTOM): Add CAMELLIA_EXT_SYM_PREFIX. + +2008-04-01 Werner Koch <wk@g10code.com> + + * configure.ac (AC_INIT): Fix quoting. + +2008-03-19 Werner Koch <wk@g10code.com> + + * configure.ac: Fix the tests for USE_<algo> to either define or + undef the macros. Suggested by Dirk Stoecker. + +2008-03-18 Werner Koch <wk@g10code.com> + + * configure.ac: Test for uintptr_t. + 2008-02-18 Werner Koch <wk@g10code.com> * configure.ac (IS_DEVELOPMENT_VERSION): Set depending on the my_svn. @@ -1248,7 +1265,7 @@ Fri Feb 13 19:43:41 1998 Werner Koch (wk@isil.d.shuttle.de) Copyright 1998, 1999, 2000, 2001, 2002, 2003, - 2004, 2006 Free Software Foundation, Inc. + 2004, 2006, 2007, 2008 Free Software Foundation, Inc. This file is free software; as a special exception the author gives unlimited permission to copy and/or distribute it, with or without @@ -4,7 +4,7 @@ Noteworthy changes in version 1.4.1 * Fixed a bug introduced by 1.3.1 which led to the comsumption of far too much entropy for the intial seeding. - * Improved AES performance for CFB and CBS modes. + * Improved AES performance for CFB and CBC modes. Noteworthy changes in version 1.4.0 (2007-12-10) diff --git a/cipher/ChangeLog b/cipher/ChangeLog index 8f91be67..48022245 100644 --- a/cipher/ChangeLog +++ b/cipher/ChangeLog @@ -1,3 +1,27 @@ +2008-04-18 Werner Koch <wk@g10code.com> + + * ac.c (ac_data_extract): Make static. + + * camellia.h [HAVE_CONFIG_H]: Include config.h. + + * rndw32.c (registry_poll): Only print the performance data + problem warning once. Suggested by Simon Josefsson. + +2008-03-19 Werner Koch <wk@g10code.com> + + * cipher.c (gcry_cipher_open) [USE_AES]: Init bulk encryption only + if requested. Suggested by Dirk Stoecker. + +2008-03-18 Werner Koch <wk@g10code.com> + + * sha1.c: Include stdint.h. + (transform): Add arg NBLOCKS so that we can work on more than one + block and avoid updates of the chaining variables. Changed all + callers to use 1. + (sha1_write): Replace loop around transform. + (transform_aligned) [WORDS_BIGENDIAN]: New. + (TRANSFORM): New macro to replace all direct calls of transform. + 2008-03-17 Werner Koch <wk@g10code.com> * rijndael.c (_gcry_aes_cfb_dec): New. diff --git a/cipher/ac.c b/cipher/ac.c index a245fa3b..acf708ad 100644 --- a/cipher/ac.c +++ b/cipher/ac.c @@ -1117,7 +1117,7 @@ _gcry_ac_io_process (gcry_ac_io_t *ac_io, (IDENTIFIER [...] (ALGORITHM <list of named MPI values>)) */ -gcry_error_t +static gcry_error_t ac_data_extract (const char *identifier, const char *algorithm, gcry_sexp_t sexp, gcry_ac_data_t *data) { diff --git a/cipher/camellia-glue.c b/cipher/camellia-glue.c index 29552cec..067af85b 100644 --- a/cipher/camellia-glue.c +++ b/cipher/camellia-glue.c @@ -27,18 +27,33 @@ There is one small change which needs to be done: Include the following code at the top of camellia.h: */ #if 0 -/* Need to redefine the external symbols to keep the libgcrypt name - space clean. */ -#define Camellia_Ekeygen _gcry_Camellia_Ekeygen -#define Camellia_EncryptBlock _gcry_Camellia_EncryptBlock -#define Camellia_DecryptBlock _gcry_Camellia_DecryptBlock -#define camellia_decrypt128 _gcry_camellia_decrypt128 -#define camellia_decrypt256 _gcry_camellia_decrypt256 -#define camellia_encrypt128 _gcry_camellia_encrypt128 -#define camellia_encrypt256 _gcry_camellia_encrypt256 -#define camellia_setup128 _gcry_camellia_setup128 -#define camellia_setup192 _gcry_camellia_setup192 -#define camellia_setup256 _gcry_camellia_setup256 + +/* To use Camellia with libraries it is often useful to keep the name + * space of the library clean. The following macro is thus useful: + * + * #define CAMELLIA_EXT_SYM_PREFIX foo_ + * + * This prefixes all external symbols with "foo_". + */ +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#ifdef CAMELLIA_EXT_SYM_PREFIX +#define CAMELLIA_PREFIX1(x,y) x ## y +#define CAMELLIA_PREFIX2(x,y) CAMELLIA_PREFIX1(x,y) +#define CAMELLIA_PREFIX(x) CAMELLIA_PREFIX2(CAMELLIA_EXT_SYM_PREFIX,x) +#define Camellia_Ekeygen CAMELLIA_PREFIX(Camellia_Ekeygen) +#define Camellia_EncryptBlock CAMELLIA_PREFIX(Camellia_EncryptBlock) +#define Camellia_DecryptBlock CAMELLIA_PREFIX(Camellia_DecryptBlock) +#define camellia_decrypt128 CAMELLIA_PREFIX(camellia_decrypt128) +#define camellia_decrypt256 CAMELLIA_PREFIX(camellia_decrypt256) +#define camellia_encrypt128 CAMELLIA_PREFIX(camellia_encrypt128) +#define camellia_encrypt256 CAMELLIA_PREFIX(camellia_encrypt256) +#define camellia_setup128 CAMELLIA_PREFIX(camellia_setup128) +#define camellia_setup192 CAMELLIA_PREFIX(camellia_setup192) +#define camellia_setup256 CAMELLIA_PREFIX(camellia_setup256) +#endif /*CAMELLIA_EXT_SYM_PREFIX*/ + #endif /* Code sample. */ diff --git a/cipher/camellia.h b/cipher/camellia.h index 3a92dc4d..4425a3a2 100644 --- a/cipher/camellia.h +++ b/cipher/camellia.h @@ -28,6 +28,9 @@ * * This prefixes all external symbols with "foo_". */ +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif #ifdef CAMELLIA_EXT_SYM_PREFIX #define CAMELLIA_PREFIX1(x,y) x ## y #define CAMELLIA_PREFIX2(x,y) CAMELLIA_PREFIX1(x,y) @@ -44,6 +47,7 @@ #define camellia_setup256 CAMELLIA_PREFIX(camellia_setup256) #endif /*CAMELLIA_EXT_SYM_PREFIX*/ + #ifdef __cplusplus extern "C" { #endif diff --git a/cipher/cipher.c b/cipher/cipher.c index 9b3b4ff9..66470ee6 100644 --- a/cipher/cipher.c +++ b/cipher/cipher.c @@ -750,6 +750,7 @@ gcry_cipher_open (gcry_cipher_hd_t *handle, /* Setup bulk encryption routines. */ switch (algo) { +#ifdef USE_AES case GCRY_CIPHER_AES128: case GCRY_CIPHER_AES192: case GCRY_CIPHER_AES256: @@ -758,6 +759,7 @@ gcry_cipher_open (gcry_cipher_hd_t *handle, h->bulk.cbc_enc = _gcry_aes_cbc_enc; h->bulk.cbc_dec = _gcry_aes_cbc_dec; break; +#endif /*USE_AES*/ default: break; diff --git a/cipher/rndw32.c b/cipher/rndw32.c index b04482db..74007e31 100644 --- a/cipher/rndw32.c +++ b/cipher/rndw32.c @@ -440,8 +440,17 @@ registry_poll (void (*add)(const void*, size_t, enum random_origins), } else { - log_debug ("rndw32: get performance data problem: ec=%ld\n", - status); + static int been_here; + + /* Silence the error message. In particular under Wine (as + of 2008) we would get swamped with such diagnotiscs. One + such diagnotiscs should be enough. */ + if (been_here != status) + { + been_here = status; + log_debug ("rndw32: get performance data problem: ec=%ld\n", + status); + } break; } } diff --git a/cipher/sha1.c b/cipher/sha1.c index 9c81f680..fe80aba8 100644 --- a/cipher/sha1.c +++ b/cipher/sha1.c @@ -1,5 +1,5 @@ /* sha1.c - SHA1 hash function - * Copyright (C) 1998, 2001, 2002, 2003 Free Software Foundation, Inc. + * Copyright (C) 1998, 2001, 2002, 2003, 2008 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * @@ -14,8 +14,7 @@ * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + * License along with this program; if not, see <http://www.gnu.org/licenses/>. */ @@ -33,20 +32,47 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#ifdef HAVE_STDINT_H +# include <stdint.h> +#endif #include "g10lib.h" #include "memory.h" #include "bithelp.h" #include "cipher.h" -typedef struct { - u32 h0,h1,h2,h3,h4; - u32 nblocks; - byte buf[64]; - int count; + +/* A macro to test whether P is properly aligned for an u32 type. + Note that config.h provides a suitable replacement for uintptr_t if + it does not exist in stdint.h. */ +#if __GNUC__ >= 2 +# define U32_ALIGNED_P(p) (!(((uintptr_t)p) % __alignof__ (u32))) +#else +# define U32_ALIGNED_P(p) (!(((uintptr_t)p) % sizeof (u32))) +#endif + +#if WORDS_BIGENDIAN +#define TRANSFORM(x,d,n) do { if (U32_ALIGNED_P ((x))) \ + transform_aligned ((x), (d), (n)); \ + else \ + transform ((x), (d), (n)); \ + } while (0) +#else +#define TRANSFORM(x,d,n) transform ((x), (d), (n)) +#endif + + + +typedef struct +{ + u32 h0,h1,h2,h3,h4; + u32 nblocks; + unsigned char buf[64]; + int count; } SHA1_CONTEXT; + static void sha1_init (void *context) { @@ -62,39 +88,7 @@ sha1_init (void *context) } -/**************** - * Transform the message X which consists of 16 32-bit-words - */ -static void -transform ( SHA1_CONTEXT *hd, const unsigned char *data ) -{ - register u32 a,b,c,d,e,tm; - u32 x[16]; - - /* Get values from the chaining vars. */ - a = hd->h0; - b = hd->h1; - c = hd->h2; - d = hd->h3; - e = hd->h4; - -#ifdef WORDS_BIGENDIAN - memcpy( x, data, 64 ); -#else - { - int i; - byte *p2; - for(i=0, p2=(byte*)x; i < 16; i++, p2 += 4 ) - { - p2[3] = *data++; - p2[2] = *data++; - p2[1] = *data++; - p2[0] = *data++; - } - } -#endif - - +/* Round function macros. */ #define K1 0x5A827999L #define K2 0x6ED9EBA1L #define K3 0x8F1BBCDCL @@ -103,108 +97,268 @@ transform ( SHA1_CONTEXT *hd, const unsigned char *data ) #define F2(x,y,z) ( x ^ y ^ z ) #define F3(x,y,z) ( ( x & y ) | ( z & ( x | y ) ) ) #define F4(x,y,z) ( x ^ y ^ z ) - - -#define M(i) ( tm = x[i&0x0f] ^ x[(i-14)&0x0f] \ - ^ x[(i-8)&0x0f] ^ x[(i-3)&0x0f] \ - , (x[i&0x0f] = rol(tm, 1)) ) - +#define M(i) ( tm = x[ i &0x0f] \ + ^ x[(i-14)&0x0f] \ + ^ x[(i-8) &0x0f] \ + ^ x[(i-3) &0x0f], \ + (x[i&0x0f] = rol(tm, 1))) #define R(a,b,c,d,e,f,k,m) do { e += rol( a, 5 ) \ - + f( b, c, d ) \ - + k \ - + m; \ + + f( b, c, d ) \ + + k \ + + m; \ b = rol( b, 30 ); \ } while(0) - R( a, b, c, d, e, F1, K1, x[ 0] ); - R( e, a, b, c, d, F1, K1, x[ 1] ); - R( d, e, a, b, c, F1, K1, x[ 2] ); - R( c, d, e, a, b, F1, K1, x[ 3] ); - R( b, c, d, e, a, F1, K1, x[ 4] ); - R( a, b, c, d, e, F1, K1, x[ 5] ); - R( e, a, b, c, d, F1, K1, x[ 6] ); - R( d, e, a, b, c, F1, K1, x[ 7] ); - R( c, d, e, a, b, F1, K1, x[ 8] ); - R( b, c, d, e, a, F1, K1, x[ 9] ); - R( a, b, c, d, e, F1, K1, x[10] ); - R( e, a, b, c, d, F1, K1, x[11] ); - R( d, e, a, b, c, F1, K1, x[12] ); - R( c, d, e, a, b, F1, K1, x[13] ); - R( b, c, d, e, a, F1, K1, x[14] ); - R( a, b, c, d, e, F1, K1, x[15] ); - R( e, a, b, c, d, F1, K1, M(16) ); - R( d, e, a, b, c, F1, K1, M(17) ); - R( c, d, e, a, b, F1, K1, M(18) ); - R( b, c, d, e, a, F1, K1, M(19) ); - R( a, b, c, d, e, F2, K2, M(20) ); - R( e, a, b, c, d, F2, K2, M(21) ); - R( d, e, a, b, c, F2, K2, M(22) ); - R( c, d, e, a, b, F2, K2, M(23) ); - R( b, c, d, e, a, F2, K2, M(24) ); - R( a, b, c, d, e, F2, K2, M(25) ); - R( e, a, b, c, d, F2, K2, M(26) ); - R( d, e, a, b, c, F2, K2, M(27) ); - R( c, d, e, a, b, F2, K2, M(28) ); - R( b, c, d, e, a, F2, K2, M(29) ); - R( a, b, c, d, e, F2, K2, M(30) ); - R( e, a, b, c, d, F2, K2, M(31) ); - R( d, e, a, b, c, F2, K2, M(32) ); - R( c, d, e, a, b, F2, K2, M(33) ); - R( b, c, d, e, a, F2, K2, M(34) ); - R( a, b, c, d, e, F2, K2, M(35) ); - R( e, a, b, c, d, F2, K2, M(36) ); - R( d, e, a, b, c, F2, K2, M(37) ); - R( c, d, e, a, b, F2, K2, M(38) ); - R( b, c, d, e, a, F2, K2, M(39) ); - R( a, b, c, d, e, F3, K3, M(40) ); - R( e, a, b, c, d, F3, K3, M(41) ); - R( d, e, a, b, c, F3, K3, M(42) ); - R( c, d, e, a, b, F3, K3, M(43) ); - R( b, c, d, e, a, F3, K3, M(44) ); - R( a, b, c, d, e, F3, K3, M(45) ); - R( e, a, b, c, d, F3, K3, M(46) ); - R( d, e, a, b, c, F3, K3, M(47) ); - R( c, d, e, a, b, F3, K3, M(48) ); - R( b, c, d, e, a, F3, K3, M(49) ); - R( a, b, c, d, e, F3, K3, M(50) ); - R( e, a, b, c, d, F3, K3, M(51) ); - R( d, e, a, b, c, F3, K3, M(52) ); - R( c, d, e, a, b, F3, K3, M(53) ); - R( b, c, d, e, a, F3, K3, M(54) ); - R( a, b, c, d, e, F3, K3, M(55) ); - R( e, a, b, c, d, F3, K3, M(56) ); - R( d, e, a, b, c, F3, K3, M(57) ); - R( c, d, e, a, b, F3, K3, M(58) ); - R( b, c, d, e, a, F3, K3, M(59) ); - R( a, b, c, d, e, F4, K4, M(60) ); - R( e, a, b, c, d, F4, K4, M(61) ); - R( d, e, a, b, c, F4, K4, M(62) ); - R( c, d, e, a, b, F4, K4, M(63) ); - R( b, c, d, e, a, F4, K4, M(64) ); - R( a, b, c, d, e, F4, K4, M(65) ); - R( e, a, b, c, d, F4, K4, M(66) ); - R( d, e, a, b, c, F4, K4, M(67) ); - R( c, d, e, a, b, F4, K4, M(68) ); - R( b, c, d, e, a, F4, K4, M(69) ); - R( a, b, c, d, e, F4, K4, M(70) ); - R( e, a, b, c, d, F4, K4, M(71) ); - R( d, e, a, b, c, F4, K4, M(72) ); - R( c, d, e, a, b, F4, K4, M(73) ); - R( b, c, d, e, a, F4, K4, M(74) ); - R( a, b, c, d, e, F4, K4, M(75) ); - R( e, a, b, c, d, F4, K4, M(76) ); - R( d, e, a, b, c, F4, K4, M(77) ); - R( c, d, e, a, b, F4, K4, M(78) ); - R( b, c, d, e, a, F4, K4, M(79) ); - - /* Update chaining vars. */ - hd->h0 += a; - hd->h1 += b; - hd->h2 += c; - hd->h3 += d; - hd->h4 += e; + + +/* + * Transform NBLOCKS of each 64 bytes (16 32-bit words) at DATA. + * Unaligned version. + */ +static void +transform (SHA1_CONTEXT *hd, const unsigned char *data, size_t nblocks) +{ + register u32 a, b, c, d, e; /* Local copies of the chaining variables. */ + register u32 tm; /* Helper. */ + u32 x[16]; /* The array we work on. */ + + /* Loop over all blocks. */ + for ( ;nblocks; nblocks--) + { +#ifdef WORDS_BIGENDIAN + memcpy (x, data, 64); + data += 64; +#else + { + int i; + unsigned char *p; + + for(i=0, p=(unsigned char*)x; i < 16; i++, p += 4 ) + { + p[3] = *data++; + p[2] = *data++; + p[1] = *data++; + p[0] = *data++; + } + } +#endif + /* Get the values of the chaining variables. */ + a = hd->h0; + b = hd->h1; + c = hd->h2; + d = hd->h3; + e = hd->h4; + + /* Transform. */ + R( a, b, c, d, e, F1, K1, x[ 0] ); + R( e, a, b, c, d, F1, K1, x[ 1] ); + R( d, e, a, b, c, F1, K1, x[ 2] ); + R( c, d, e, a, b, F1, K1, x[ 3] ); + R( b, c, d, e, a, F1, K1, x[ 4] ); + R( a, b, c, d, e, F1, K1, x[ 5] ); + R( e, a, b, c, d, F1, K1, x[ 6] ); + R( d, e, a, b, c, F1, K1, x[ 7] ); + R( c, d, e, a, b, F1, K1, x[ 8] ); + R( b, c, d, e, a, F1, K1, x[ 9] ); + R( a, b, c, d, e, F1, K1, x[10] ); + R( e, a, b, c, d, F1, K1, x[11] ); + R( d, e, a, b, c, F1, K1, x[12] ); + R( c, d, e, a, b, F1, K1, x[13] ); + R( b, c, d, e, a, F1, K1, x[14] ); + R( a, b, c, d, e, F1, K1, x[15] ); + R( e, a, b, c, d, F1, K1, M(16) ); + R( d, e, a, b, c, F1, K1, M(17) ); + R( c, d, e, a, b, F1, K1, M(18) ); + R( b, c, d, e, a, F1, K1, M(19) ); + R( a, b, c, d, e, F2, K2, M(20) ); + R( e, a, b, c, d, F2, K2, M(21) ); + R( d, e, a, b, c, F2, K2, M(22) ); + R( c, d, e, a, b, F2, K2, M(23) ); + R( b, c, d, e, a, F2, K2, M(24) ); + R( a, b, c, d, e, F2, K2, M(25) ); + R( e, a, b, c, d, F2, K2, M(26) ); + R( d, e, a, b, c, F2, K2, M(27) ); + R( c, d, e, a, b, F2, K2, M(28) ); + R( b, c, d, e, a, F2, K2, M(29) ); + R( a, b, c, d, e, F2, K2, M(30) ); + R( e, a, b, c, d, F2, K2, M(31) ); + R( d, e, a, b, c, F2, K2, M(32) ); + R( c, d, e, a, b, F2, K2, M(33) ); + R( b, c, d, e, a, F2, K2, M(34) ); + R( a, b, c, d, e, F2, K2, M(35) ); + R( e, a, b, c, d, F2, K2, M(36) ); + R( d, e, a, b, c, F2, K2, M(37) ); + R( c, d, e, a, b, F2, K2, M(38) ); + R( b, c, d, e, a, F2, K2, M(39) ); + R( a, b, c, d, e, F3, K3, M(40) ); + R( e, a, b, c, d, F3, K3, M(41) ); + R( d, e, a, b, c, F3, K3, M(42) ); + R( c, d, e, a, b, F3, K3, M(43) ); + R( b, c, d, e, a, F3, K3, M(44) ); + R( a, b, c, d, e, F3, K3, M(45) ); + R( e, a, b, c, d, F3, K3, M(46) ); + R( d, e, a, b, c, F3, K3, M(47) ); + R( c, d, e, a, b, F3, K3, M(48) ); + R( b, c, d, e, a, F3, K3, M(49) ); + R( a, b, c, d, e, F3, K3, M(50) ); + R( e, a, b, c, d, F3, K3, M(51) ); + R( d, e, a, b, c, F3, K3, M(52) ); + R( c, d, e, a, b, F3, K3, M(53) ); + R( b, c, d, e, a, F3, K3, M(54) ); + R( a, b, c, d, e, F3, K3, M(55) ); + R( e, a, b, c, d, F3, K3, M(56) ); + R( d, e, a, b, c, F3, K3, M(57) ); + R( c, d, e, a, b, F3, K3, M(58) ); + R( b, c, d, e, a, F3, K3, M(59) ); + R( a, b, c, d, e, F4, K4, M(60) ); + R( e, a, b, c, d, F4, K4, M(61) ); + R( d, e, a, b, c, F4, K4, M(62) ); + R( c, d, e, a, b, F4, K4, M(63) ); + R( b, c, d, e, a, F4, K4, M(64) ); + R( a, b, c, d, e, F4, K4, M(65) ); + R( e, a, b, c, d, F4, K4, M(66) ); + R( d, e, a, b, c, F4, K4, M(67) ); + R( c, d, e, a, b, F4, K4, M(68) ); + R( b, c, d, e, a, F4, K4, M(69) ); + R( a, b, c, d, e, F4, K4, M(70) ); + R( e, a, b, c, d, F4, K4, M(71) ); + R( d, e, a, b, c, F4, K4, M(72) ); + R( c, d, e, a, b, F4, K4, M(73) ); + R( b, c, d, e, a, F4, K4, M(74) ); + R( a, b, c, d, e, F4, K4, M(75) ); + R( e, a, b, c, d, F4, K4, M(76) ); + R( d, e, a, b, c, F4, K4, M(77) ); + R( c, d, e, a, b, F4, K4, M(78) ); + R( b, c, d, e, a, F4, K4, M(79) ); + + /* Update the chaining variables. */ + hd->h0 += a; + hd->h1 += b; + hd->h2 += c; + hd->h3 += d; + hd->h4 += e; + } } +#ifdef WORDS_BIGENDIAN +/* + * Transform NBLOCKS of each 64 bytes (16 32-bit words) at DATA. This + * version requires that DATA is aligned on a u32 boundary. Note that + * we can do this only on big endian machines because we need to sawp + * bytes on little endian anyway. + */ +static void +transform_aligned (SHA1_CONTEXT *hd, const unsigned char *data, size_t nblocks) +{ + register u32 a, b, c, d, e; /* Local copies of the chaining variables. */ + register u32 tm; /* Helper. */ + const u32 *x; /* 32 bit pointer we use for processing. */ + + x = (const u32*)data; + + /* Loop over all blocks. */ + for ( ;nblocks; nblocks--, x += 16) + { + /* Get the values of the chaining variables. */ + a = hd->h0; + b = hd->h1; + c = hd->h2; + d = hd->h3; + e = hd->h4; + + /* Transform. */ + R( a, b, c, d, e, F1, K1, x[ 0] ); + R( e, a, b, c, d, F1, K1, x[ 1] ); + R( d, e, a, b, c, F1, K1, x[ 2] ); + R( c, d, e, a, b, F1, K1, x[ 3] ); + R( b, c, d, e, a, F1, K1, x[ 4] ); + R( a, b, c, d, e, F1, K1, x[ 5] ); + R( e, a, b, c, d, F1, K1, x[ 6] ); + R( d, e, a, b, c, F1, K1, x[ 7] ); + R( c, d, e, a, b, F1, K1, x[ 8] ); + R( b, c, d, e, a, F1, K1, x[ 9] ); + R( a, b, c, d, e, F1, K1, x[10] ); + R( e, a, b, c, d, F1, K1, x[11] ); + R( d, e, a, b, c, F1, K1, x[12] ); + R( c, d, e, a, b, F1, K1, x[13] ); + R( b, c, d, e, a, F1, K1, x[14] ); + R( a, b, c, d, e, F1, K1, x[15] ); + R( e, a, b, c, d, F1, K1, M(16) ); + R( d, e, a, b, c, F1, K1, M(17) ); + R( c, d, e, a, b, F1, K1, M(18) ); + R( b, c, d, e, a, F1, K1, M(19) ); + R( a, b, c, d, e, F2, K2, M(20) ); + R( e, a, b, c, d, F2, K2, M(21) ); + R( d, e, a, b, c, F2, K2, M(22) ); + R( c, d, e, a, b, F2, K2, M(23) ); + R( b, c, d, e, a, F2, K2, M(24) ); + R( a, b, c, d, e, F2, K2, M(25) ); + R( e, a, b, c, d, F2, K2, M(26) ); + R( d, e, a, b, c, F2, K2, M(27) ); + R( c, d, e, a, b, F2, K2, M(28) ); + R( b, c, d, e, a, F2, K2, M(29) ); + R( a, b, c, d, e, F2, K2, M(30) ); + R( e, a, b, c, d, F2, K2, M(31) ); + R( d, e, a, b, c, F2, K2, M(32) ); + R( c, d, e, a, b, F2, K2, M(33) ); + R( b, c, d, e, a, F2, K2, M(34) ); + R( a, b, c, d, e, F2, K2, M(35) ); + R( e, a, b, c, d, F2, K2, M(36) ); + R( d, e, a, b, c, F2, K2, M(37) ); + R( c, d, e, a, b, F2, K2, M(38) ); + R( b, c, d, e, a, F2, K2, M(39) ); + R( a, b, c, d, e, F3, K3, M(40) ); + R( e, a, b, c, d, F3, K3, M(41) ); + R( d, e, a, b, c, F3, K3, M(42) ); + R( c, d, e, a, b, F3, K3, M(43) ); + R( b, c, d, e, a, F3, K3, M(44) ); + R( a, b, c, d, e, F3, K3, M(45) ); + R( e, a, b, c, d, F3, K3, M(46) ); + R( d, e, a, b, c, F3, K3, M(47) ); + R( c, d, e, a, b, F3, K3, M(48) ); + R( b, c, d, e, a, F3, K3, M(49) ); + R( a, b, c, d, e, F3, K3, M(50) ); + R( e, a, b, c, d, F3, K3, M(51) ); + R( d, e, a, b, c, F3, K3, M(52) ); + R( c, d, e, a, b, F3, K3, M(53) ); + R( b, c, d, e, a, F3, K3, M(54) ); + R( a, b, c, d, e, F3, K3, M(55) ); + R( e, a, b, c, d, F3, K3, M(56) ); + R( d, e, a, b, c, F3, K3, M(57) ); + R( c, d, e, a, b, F3, K3, M(58) ); + R( b, c, d, e, a, F3, K3, M(59) ); + R( a, b, c, d, e, F4, K4, M(60) ); + R( e, a, b, c, d, F4, K4, M(61) ); + R( d, e, a, b, c, F4, K4, M(62) ); + R( c, d, e, a, b, F4, K4, M(63) ); + R( b, c, d, e, a, F4, K4, M(64) ); + R( a, b, c, d, e, F4, K4, M(65) ); + R( e, a, b, c, d, F4, K4, M(66) ); + R( d, e, a, b, c, F4, K4, M(67) ); + R( c, d, e, a, b, F4, K4, M(68) ); + R( b, c, d, e, a, F4, K4, M(69) ); + R( a, b, c, d, e, F4, K4, M(70) ); + R( e, a, b, c, d, F4, K4, M(71) ); + R( d, e, a, b, c, F4, K4, M(72) ); + R( c, d, e, a, b, F4, K4, M(73) ); + R( b, c, d, e, a, F4, K4, M(74) ); + R( a, b, c, d, e, F4, K4, M(75) ); + R( e, a, b, c, d, F4, K4, M(76) ); + R( d, e, a, b, c, F4, K4, M(77) ); + R( c, d, e, a, b, F4, K4, M(78) ); + R( b, c, d, e, a, F4, K4, M(79) ); + + /* Update the chaining variables. */ + hd->h0 += a; + hd->h1 += b; + hd->h2 += c; + hd->h3 += d; + hd->h4 += e; + } +} +#endif /* WORDS_BIGENDIAN */ + + /* Update the message digest with the contents * of INBUF with length INLEN. */ @@ -213,36 +367,40 @@ sha1_write( void *context, const void *inbuf_arg, size_t inlen) { const unsigned char *inbuf = inbuf_arg; SHA1_CONTEXT *hd = context; + size_t nblocks; - if( hd->count == 64 ) /* flush the buffer */ + if (hd->count == 64) /* Flush the buffer. */ { - transform( hd, hd->buf ); + TRANSFORM( hd, hd->buf, 1 ); _gcry_burn_stack (88+4*sizeof(void*)); hd->count = 0; hd->nblocks++; } - if( !inbuf ) + if (!inbuf) return; - if( hd->count ) + if (hd->count) { - for( ; inlen && hd->count < 64; inlen-- ) + for (; inlen && hd->count < 64; inlen--) hd->buf[hd->count++] = *inbuf++; - sha1_write( hd, NULL, 0 ); - if( !inlen ) + sha1_write (hd, NULL, 0); + if (!inlen) return; } - while( inlen >= 64 ) + nblocks = inlen / 64; + if (nblocks) { - transform( hd, inbuf ); + TRANSFORM (hd, inbuf, nblocks); hd->count = 0; - hd->nblocks++; - inlen -= 64; - inbuf += 64; + hd->nblocks += nblocks; + inlen -= nblocks * 64; + inbuf += nblocks * 64; } _gcry_burn_stack (88+4*sizeof(void*)); - for( ; inlen && hd->count < 64; inlen-- ) + + /* Save remaining bytes. */ + for (; inlen && hd->count < 64; inlen--) hd->buf[hd->count++] = *inbuf++; } @@ -260,7 +418,7 @@ sha1_final(void *context) SHA1_CONTEXT *hd = context; u32 t, msb, lsb; - byte *p; + unsigned char *p; sha1_write(hd, NULL, 0); /* flush */; @@ -301,7 +459,7 @@ sha1_final(void *context) hd->buf[61] = lsb >> 16; hd->buf[62] = lsb >> 8; hd->buf[63] = lsb ; - transform( hd, hd->buf ); + TRANSFORM( hd, hd->buf, 1 ); _gcry_burn_stack (88+4*sizeof(void*)); p = hd->buf; @@ -320,7 +478,7 @@ sha1_final(void *context) } -static byte * +static unsigned char * sha1_read( void *context ) { SHA1_CONTEXT *hd = context; @@ -344,7 +502,7 @@ _gcry_sha1_hash_buffer (void *outbuf, const void *buffer, size_t length) } -static byte asn[15] = /* Object ID is 1.3.14.3.2.26 */ +static unsigned char asn[15] = /* Object ID is 1.3.14.3.2.26 */ { 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14 }; diff --git a/configure.ac b/configure.ac index 8e3c78a7..59826a37 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ # Configure.ac script for Libgcrypt # Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2006, -# 2007 Free Software Foundation, Inc. +# 2007, 2008 Free Software Foundation, Inc. # # This file is part of Libgcrypt. # @@ -32,7 +32,8 @@ m4_define([my_issvn], [yes]) m4_define([svn_revision], m4_esyscmd([echo -n $( (svn info 2>/dev/null \ || echo 'Revision: 0')|sed -n '/^Revision:/ {s/[^0-9]//gp;q;}')])) -AC_INIT([libgcrypt], my_version[]m4_if(my_issvn,[yes],[-svn[]svn_revision]), +AC_INIT([libgcrypt], + [my_version[]m4_if(my_issvn,[yes],[-svn[]svn_revision])], [bug-libgcrypt@gnupg.org]) # LT Version numbers, remember to change them just *before* a release. # (Interfaces removed: CURRENT++, AGE=0, REVISION=0) @@ -82,6 +83,11 @@ AH_BOTTOM([ # endif #endif /*DISABLED_ENDIAN_CHECK*/ +/* We basically use the original Camellia source. Make sure the symbols + properly prefixed. */ +#define CAMELLIA_EXT_SYM_PREFIX _gcry_ + + #endif /*_GCRYPT_CONFIG_H_INCLUDED*/ ]) @@ -287,6 +293,8 @@ AC_CHECK_SIZEOF(unsigned int, 4) AC_CHECK_SIZEOF(unsigned long, 4) AC_CHECK_SIZEOF(unsigned long long, 0) +AC_TYPE_UINTPTR_T + if test "$ac_cv_sizeof_unsigned_short" = "0" \ || test "$ac_cv_sizeof_unsigned_int" = "0" \ || test "$ac_cv_sizeof_unsigned_long" = "0"; then @@ -885,140 +893,161 @@ DATADIRNAME=$DATADIRNAME # selected ciphers, pubkey-ciphers, digests and random modules. LIST_MEMBER(arcfour, $enabled_ciphers) -test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS arcfour.lo" -AC_DEFINE_UNQUOTED(USE_ARCFOUR, $found, - [Defined if this module should be included]) +if test "$found" = "1"; then + GCRYPT_CIPHERS="$GCRYPT_CIPHERS arcfour.lo" + AC_DEFINE(USE_ARCFOUR, 1, [Defined if this module should be included]) +fi LIST_MEMBER(blowfish, $enabled_ciphers) -test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS blowfish.lo" -AC_DEFINE_UNQUOTED(USE_BLOWFISH, $found, - [Defined if this module should be included]) +if test "$found" = "1" ; then + GCRYPT_CIPHERS="$GCRYPT_CIPHERS blowfish.lo" + AC_DEFINE(USE_BLOWFISH, 1, [Defined if this module should be included]) +fi LIST_MEMBER(cast5, $enabled_ciphers) -test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS cast5.lo" -AC_DEFINE_UNQUOTED(USE_CAST5, $found, - [Defined if this module should be included]) +if test "$found" = "1" ; then + GCRYPT_CIPHERS="$GCRYPT_CIPHERS cast5.lo" + AC_DEFINE(USE_CAST5, 1, [Defined if this module should be included]) +fi LIST_MEMBER(des, $enabled_ciphers) -test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS des.lo" -AC_DEFINE_UNQUOTED(USE_DES, $found, - [Defined if this module should be included]) +if test "$found" = "1" ; then + GCRYPT_CIPHERS="$GCRYPT_CIPHERS des.lo" + AC_DEFINE(USE_DES, 1, [Defined if this module should be included]) +fi LIST_MEMBER(aes, $enabled_ciphers) -test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS rijndael.lo" -AC_DEFINE_UNQUOTED(USE_AES, $found, - [Defined if this module should be included]) +if test "$found" = "1" ; then + GCRYPT_CIPHERS="$GCRYPT_CIPHERS rijndael.lo" + AC_DEFINE(USE_AES, 1, [Defined if this module should be included]) +fi LIST_MEMBER(twofish, $enabled_ciphers) -test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS twofish.lo" -AC_DEFINE_UNQUOTED(USE_TWOFISH, $found, - [Defined if this module should be included]) +if test "$found" = "1" ; then + GCRYPT_CIPHERS="$GCRYPT_CIPHERS twofish.lo" + AC_DEFINE(USE_TWOFISH, 1, [Defined if this module should be included]) +fi LIST_MEMBER(serpent, $enabled_ciphers) -test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS serpent.lo" -AC_DEFINE_UNQUOTED(USE_SERPENT, $found, - [Defined if this module should be included]) +if test "$found" = "1" ; then + GCRYPT_CIPHERS="$GCRYPT_CIPHERS serpent.lo" + AC_DEFINE(USE_SERPENT, 1, [Defined if this module should be included]) +fi LIST_MEMBER(rfc2268, $enabled_ciphers) -test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS rfc2268.lo" -AC_DEFINE_UNQUOTED(USE_RFC2268, $found, - [Defined if this module should be included]) +if test "$found" = "1" ; then + GCRYPT_CIPHERS="$GCRYPT_CIPHERS rfc2268.lo" + AC_DEFINE(USE_RFC2268, 1, [Defined if this module should be included]) +fi LIST_MEMBER(seed, $enabled_ciphers) -test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS seed.lo" -AC_DEFINE_UNQUOTED(USE_SEED, $found, - [Defined if this module should be included]) +if test "$found" = "1" ; then + GCRYPT_CIPHERS="$GCRYPT_CIPHERS seed.lo" + AC_DEFINE(USE_SEED, 1, [Defined if this module should be included]) +fi LIST_MEMBER(camellia, $enabled_ciphers) -test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS camellia.lo camellia-glue.lo" -AC_DEFINE_UNQUOTED(USE_CAMELLIA, $found, - [Defined if this module should be included]) +if test "$found" = "1" ; then + GCRYPT_CIPHERS="$GCRYPT_CIPHERS camellia.lo camellia-glue.lo" + AC_DEFINE(USE_CAMELLIA, 1, [Defined if this module should be included]) +fi LIST_MEMBER(dsa, $enabled_pubkey_ciphers) -test "$found" = "1" && GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS dsa.lo" -AC_DEFINE_UNQUOTED(USE_DSA, $found, - [Defined if this module should be included]) +if test "$found" = "1" ; then + GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS dsa.lo" + AC_DEFINE(USE_DSA, 1, [Defined if this module should be included]) +fi LIST_MEMBER(rsa, $enabled_pubkey_ciphers) -test "$found" = "1" && GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS rsa.lo" -AC_DEFINE_UNQUOTED(USE_RSA, $found, - [Defined if this module should be included]) +if test "$found" = "1" ; then + GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS rsa.lo" + AC_DEFINE(USE_RSA, 1, [Defined if this module should be included]) +fi LIST_MEMBER(elgamal, $enabled_pubkey_ciphers) -test "$found" = "1" \ - && GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS elgamal.lo" -AC_DEFINE_UNQUOTED(USE_ELGAMAL, $found, - [Defined if this module should be included]) +if test "$found" = "1" ; then + GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS elgamal.lo" + AC_DEFINE(USE_ELGAMAL, 1, [Defined if this module should be included]) +fi LIST_MEMBER(ecc, $enabled_pubkey_ciphers) -test "$found" = "1" \ - && GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS ecc.lo" -AC_DEFINE_UNQUOTED(USE_ECC, $found, - [Defined if this module should be included]) +if test "$found" = "1" ; then + GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS ecc.lo" + AC_DEFINE(USE_ECC, 1, [Defined if this module should be included]) +fi LIST_MEMBER(crc, $enabled_digests) -test "$found" = "1" && GCRYPT_DIGESTS="$GCRYPT_DIGESTS crc.lo" -AC_DEFINE_UNQUOTED(USE_CRC, $found, - [Defined if this module should be included]) +if test "$found" = "1" ; then + GCRYPT_DIGESTS="$GCRYPT_DIGESTS crc.lo" + AC_DEFINE(USE_CRC, 1, [Defined if this module should be included]) +fi LIST_MEMBER(md4, $enabled_digests) -test "$found" = "1" && GCRYPT_DIGESTS="$GCRYPT_DIGESTS md4.lo" -AC_DEFINE_UNQUOTED(USE_MD4, $found, - [Defined if this module should be included]) +if test "$found" = "1" ; then + GCRYPT_DIGESTS="$GCRYPT_DIGESTS md4.lo" + AC_DEFINE(USE_MD4, 1, [Defined if this module should be included]) +fi LIST_MEMBER(md5, $enabled_digests) -test "$found" = "1" && GCRYPT_DIGESTS="$GCRYPT_DIGESTS md5.lo" -AC_DEFINE_UNQUOTED(USE_MD5, $found, - [Defined if this module should be included]) +if test "$found" = "1" ; then + GCRYPT_DIGESTS="$GCRYPT_DIGESTS md5.lo" + AC_DEFINE(USE_MD5, 1, [Defined if this module should be included]) +fi LIST_MEMBER(sha256, $enabled_digests) -test "$found" = "1" && GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha256.lo" -AC_DEFINE_UNQUOTED(USE_SHA256, $found, - [Defined if this module should be included]) +if test "$found" = "1" ; then + GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha256.lo" + AC_DEFINE(USE_SHA256, 1, [Defined if this module should be included]) +fi LIST_MEMBER(sha512, $enabled_digests) -test "$found" = "1" && GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha512.lo" -AC_DEFINE_UNQUOTED(USE_SHA512, $found, - [Defined if this module should be included]) +if test "$found" = "1" ; then + GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha512.lo" + AC_DEFINE(USE_SHA512, 1, [Defined if this module should be included]) +fi LIST_MEMBER(tiger, $enabled_digests) -test "$found" = "1" && GCRYPT_DIGESTS="$GCRYPT_DIGESTS tiger.lo" -AC_DEFINE_UNQUOTED(USE_TIGER, $found, - [Defined if this module should be included]) +if test "$found" = "1" ; then + GCRYPT_DIGESTS="$GCRYPT_DIGESTS tiger.lo" + AC_DEFINE(USE_TIGER, 1, [Defined if this module should be included]) +fi LIST_MEMBER(whirlpool, $enabled_digests) -test "$found" = "1" && GCRYPT_DIGESTS="$GCRYPT_DIGESTS whirlpool.lo" -AC_DEFINE_UNQUOTED(USE_WHIRLPOOL, $found, - [Defined if this module should be included]) +if test "$found" = "1" ; then + GCRYPT_DIGESTS="$GCRYPT_DIGESTS whirlpool.lo" + AC_DEFINE(USE_WHIRLPOOL, 1, [Defined if this module should be included]) +fi # rmd160 and sha1 should be included always. GCRYPT_DIGESTS="$GCRYPT_DIGESTS rmd160.lo sha1.lo" -AC_DEFINE_UNQUOTED(USE_RMD160, 1, [Defined if this module should be included]) -AC_DEFINE_UNQUOTED(USE_SHA1, 1, [Defined if this module should be included]) +AC_DEFINE(USE_RMD160, 1, [Defined if this module should be included]) +AC_DEFINE(USE_SHA1, 1, [Defined if this module should be included]) LIST_MEMBER(linux, $random_modules) -test "$found" = "1" && GCRYPT_RANDOM="$GCRYPT_RANDOM rndlinux.lo" -AC_DEFINE_UNQUOTED(USE_RNDLINUX, $found, - [Defined if the /dev/random based RNG should be used.]) - +if test "$found" = "1" ; then + GCRYPT_RANDOM="$GCRYPT_RANDOM rndlinux.lo" + AC_DEFINE(USE_RNDLINUX, 1, [Defined if the /dev/random RNG should be used.]) +fi LIST_MEMBER(unix, $random_modules) -test "$found" = "1" && GCRYPT_RANDOM="$GCRYPT_RANDOM rndunix.lo" -AC_DEFINE_UNQUOTED(USE_RNDUNIX, $found, - [Defined if the default Unix RNG should be used.]) -if test "$found" = "1"; then +if test "$found" = "1" ; then + GCRYPT_RANDOM="$GCRYPT_RANDOM rndunix.lo" + AC_DEFINE(USE_RNDUNIX, 1, [Defined if the default Unix RNG should be used.]) print_egd_notice=yes fi LIST_MEMBER(egd, $random_modules) -test "$found" = "1" && GCRYPT_RANDOM="$GCRYPT_RANDOM rndegd.lo" -AC_DEFINE_UNQUOTED(USE_RNDEGD, $found, - [Defined if the EGD based RNG should be used.]) +if test "$found" = "1" ; then + GCRYPT_RANDOM="$GCRYPT_RANDOM rndegd.lo" + AC_DEFINE(USE_RNDEGD, 1, [Defined if the EGD based RNG should be used.]) +fi LIST_MEMBER(w32, $random_modules) -test "$found" = "1" && GCRYPT_RANDOM="$GCRYPT_RANDOM rndw32.lo" -AC_DEFINE_UNQUOTED(USE_RNDW32, $found, - [Defined if the Windows specific RNG should be used.]) +if test "$found" = "1" ; then + GCRYPT_RANDOM="$GCRYPT_RANDOM rndw32.lo" + AC_DEFINE(USE_RNDW32, 1, + [Defined if the Windows specific RNG should be used.]) +fi AC_SUBST([GCRYPT_CIPHERS]) AC_SUBST([GCRYPT_PUBKEY_CIPHERS]) diff --git a/src/ChangeLog b/src/ChangeLog index 5be65475..25faf359 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2008-04-18 Werner Koch <wk@g10code.com> + + * missing-string.c (vasprintf): Remove. It is not used. Reported + by Simon Josefsson. + 2008-03-11 Werner Koch <wk@g10code.com> * gcrypt.h.in (gcry_ac_em_t, gcry_ac_scheme_t): Remove trailing diff --git a/src/missing-string.c b/src/missing-string.c index 5e43b2a8..a5e56c3f 100644 --- a/src/missing-string.c +++ b/src/missing-string.c @@ -53,100 +53,3 @@ strcasecmp( const char *a, const char *b ) } #endif - -#ifdef __MINGW32__ -/* - * Like vsprintf but provides a pointer to malloc'd storage, which - * must be freed by the caller (gcry_free). Taken from libiberty as - * found in gcc-2.95.2 and a little bit modernized. - * FIXME: Write a new CRT for W32. - */ -int -vasprintf ( char **result, const char *format, va_list args) -{ - const char *p = format; - /* Add one to make sure that it is never zero, which might cause malloc - to return NULL. */ - int total_width = strlen (format) + 1; - va_list ap; - - /* this is not really portable but works under Windows */ - memcpy ( &ap, &args, sizeof (va_list)); - - while (*p != '\0') - { - if (*p++ == '%') - { - while (strchr ("-+ #0", *p)) - ++p; - if (*p == '*') - { - ++p; - total_width += abs (va_arg (ap, int)); - } - else - { - char *endp; - total_width += strtoul (p, &endp, 10); - p = endp; - } - if (*p == '.') - { - ++p; - if (*p == '*') - { - ++p; - total_width += abs (va_arg (ap, int)); - } - else - { - char *endp; - total_width += strtoul (p, &endp, 10); - p = endp; - } - } - while (strchr ("hlL", *p)) - ++p; - /* Should be big enough for any format specifier except %s - and floats. */ - total_width += 30; - switch (*p) - { - case 'd': - case 'i': - case 'o': - case 'u': - case 'x': - case 'X': - case 'c': - (void) va_arg (ap, int); - break; - case 'f': - case 'e': - case 'E': - case 'g': - case 'G': - (void) va_arg (ap, double); - /* Since an ieee double can have an exponent of 307, we'll - make the buffer wide enough to cover the gross case. */ - total_width += 307; - - case 's': - total_width += strlen (va_arg (ap, char *)); - break; - case 'p': - case 'n': - (void) va_arg (ap, char *); - break; - } - } - } - *result = gcry_malloc (total_width); - if (*result != NULL) - return vsprintf (*result, format, args); - else - return 0; -} - -#endif /*__MINGW32__*/ - diff --git a/tests/basic.c b/tests/basic.c index 85f7ef5b..abaebfee 100644 --- a/tests/basic.c +++ b/tests/basic.c @@ -1063,9 +1063,10 @@ check_one_md (int algo, const char *data, int len, const char *expect) { /* hash one million times a "a" */ char aaa[1000]; + /* Write in odd size chunks so that we test the buffering. */ memset (aaa, 'a', 1000); for (i = 0; i < 1000; i++) - gcry_md_write (hd, aaa, 1000); + gcry_md_write (hd, aaa, 1000); } else gcry_md_write (hd, data, len); @@ -1096,6 +1097,7 @@ check_one_md (int algo, const char *data, int len, const char *expect) gcry_md_close (hd2); } + static void check_digests (void) { @@ -1261,13 +1263,14 @@ check_digests (void) if (verbose) fprintf (stderr, "Starting hash checks.\n"); - for (i = 0; algos[i].md; i++) + for (i = 0; i < 1 && algos[i].md; i++) { if (verbose) fprintf (stderr, " checking %s [%i] for length %zi\n", gcry_md_algo_name (algos[i].md), algos[i].md, - strlen(algos[i].data)); + !strcmp (algos[i].data, "!")? + 1000000 : strlen(algos[i].data)); check_one_md (algos[i].md, algos[i].data, strlen (algos[i].data), algos[i].expect); diff --git a/tests/pubkey.c b/tests/pubkey.c index ac68a21e..f3e65158 100644 --- a/tests/pubkey.c +++ b/tests/pubkey.c @@ -355,7 +355,7 @@ main (int argc, char **argv) gcry_control (GCRYCTL_DISABLE_SECMEM, 0); if (!gcry_check_version (GCRYPT_VERSION)) - /*die ("version mismatch\n")*/; + die ("version mismatch\n"); gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); if (debug) gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1u , 0); |