* bithelp.h, des.c, random.c, rndlinux.c, sha1.c, blowfish.c, elgamal.c,

rijndael.c, rndunix.c, sha256.c, cast5.c, idea-stub.c, rmd160.c, rndw32.c,
sha512.c, md5.c, rmd160test.c, rsa.c, tiger.c: Edit all preprocessor
instructions to remove whitespace before the '#'.  This is not required by
C89, but there are some compilers out there that don't like it.
This commit is contained in:
David Shaw 2003-05-24 18:31:33 +00:00
parent e152598106
commit 29e6411a7b
20 changed files with 179 additions and 196 deletions

View File

@ -1,3 +1,12 @@
2003-05-24 David Shaw <dshaw@jabberwocky.com>
* bithelp.h, des.c, random.c, rndlinux.c, sha1.c, blowfish.c,
elgamal.c, rijndael.c, rndunix.c, sha256.c, cast5.c, idea-stub.c,
rmd160.c, rndw32.c, sha512.c, md5.c, rmd160test.c, rsa.c, tiger.c:
Edit all preprocessor instructions to remove whitespace before the
'#'. This is not required by C89, but there are some compilers
out there that don't like it.
2003-05-15 David Shaw <dshaw@jabberwocky.com> 2003-05-15 David Shaw <dshaw@jabberwocky.com>
* cipher.c (setup_cipher_table): #ifdef IDEA. * cipher.c (setup_cipher_table): #ifdef IDEA.

View File

@ -34,7 +34,7 @@ rol( u32 x, int n)
return x; return x;
} }
#else #else
#define rol(x,n) ( ((x) << (n)) | ((x) >> (32-(n))) ) #define rol(x,n) ( ((x) << (n)) | ((x) >> (32-(n))) )
#endif #endif

View File

@ -253,27 +253,27 @@ function_F( BLOWFISH_context *bc, u32 x )
{ {
u16 a, b, c, d; u16 a, b, c, d;
#ifdef BIG_ENDIAN_HOST #ifdef BIG_ENDIAN_HOST
a = ((byte*)&x)[0]; a = ((byte*)&x)[0];
b = ((byte*)&x)[1]; b = ((byte*)&x)[1];
c = ((byte*)&x)[2]; c = ((byte*)&x)[2];
d = ((byte*)&x)[3]; d = ((byte*)&x)[3];
#else #else
a = ((byte*)&x)[3]; a = ((byte*)&x)[3];
b = ((byte*)&x)[2]; b = ((byte*)&x)[2];
c = ((byte*)&x)[1]; c = ((byte*)&x)[1];
d = ((byte*)&x)[0]; d = ((byte*)&x)[0];
#endif #endif
return ((bc->s0[a] + bc->s1[b]) ^ bc->s2[c] ) + bc->s3[d]; return ((bc->s0[a] + bc->s1[b]) ^ bc->s2[c] ) + bc->s3[d];
} }
#endif #endif
#ifdef BIG_ENDIAN_HOST #ifdef BIG_ENDIAN_HOST
#define F(x) ((( s0[((byte*)&x)[0]] + s1[((byte*)&x)[1]]) \ #define F(x) ((( s0[((byte*)&x)[0]] + s1[((byte*)&x)[1]]) \
^ s2[((byte*)&x)[2]]) + s3[((byte*)&x)[3]] ) ^ s2[((byte*)&x)[2]]) + s3[((byte*)&x)[3]] )
#else #else
#define F(x) ((( s0[((byte*)&x)[3]] + s1[((byte*)&x)[2]]) \ #define F(x) ((( s0[((byte*)&x)[3]] + s1[((byte*)&x)[2]]) \
^ s2[((byte*)&x)[1]]) + s3[((byte*)&x)[0]] ) ^ s2[((byte*)&x)[1]]) + s3[((byte*)&x)[0]] )
#endif #endif
#define R(l,r,i) do { l ^= p[i]; r ^= F(l); } while(0) #define R(l,r,i) do { l ^= p[i]; r ^= F(l); } while(0)
@ -293,7 +293,7 @@ burn_stack (int bytes)
static void static void
do_encrypt( BLOWFISH_context *bc, u32 *ret_xl, u32 *ret_xr ) do_encrypt( BLOWFISH_context *bc, u32 *ret_xl, u32 *ret_xr )
{ {
#if BLOWFISH_ROUNDS == 16 #if BLOWFISH_ROUNDS == 16
u32 xl, xr, *s0, *s1, *s2, *s3, *p; u32 xl, xr, *s0, *s1, *s2, *s3, *p;
xl = *ret_xl; xl = *ret_xl;
@ -327,7 +327,7 @@ do_encrypt( BLOWFISH_context *bc, u32 *ret_xl, u32 *ret_xr )
*ret_xl = xr; *ret_xl = xr;
*ret_xr = xl; *ret_xr = xl;
#else #else
u32 xl, xr, temp, *p; u32 xl, xr, temp, *p;
int i; int i;
@ -351,14 +351,14 @@ do_encrypt( BLOWFISH_context *bc, u32 *ret_xl, u32 *ret_xr )
*ret_xl = xl; *ret_xl = xl;
*ret_xr = xr; *ret_xr = xr;
#endif #endif
} }
static void static void
decrypt( BLOWFISH_context *bc, u32 *ret_xl, u32 *ret_xr ) decrypt( BLOWFISH_context *bc, u32 *ret_xl, u32 *ret_xr )
{ {
#if BLOWFISH_ROUNDS == 16 #if BLOWFISH_ROUNDS == 16
u32 xl, xr, *s0, *s1, *s2, *s3, *p; u32 xl, xr, *s0, *s1, *s2, *s3, *p;
xl = *ret_xl; xl = *ret_xl;
@ -392,7 +392,7 @@ decrypt( BLOWFISH_context *bc, u32 *ret_xl, u32 *ret_xr )
*ret_xl = xr; *ret_xl = xr;
*ret_xr = xl; *ret_xr = xl;
#else #else
u32 xl, xr, temp, *p; u32 xl, xr, temp, *p;
int i; int i;
@ -417,7 +417,7 @@ decrypt( BLOWFISH_context *bc, u32 *ret_xl, u32 *ret_xr )
*ret_xl = xl; *ret_xl = xl;
*ret_xr = xr; *ret_xr = xr;
#endif #endif
} }
#undef F #undef F
@ -534,17 +534,17 @@ do_bf_setkey( BLOWFISH_context *c, byte *key, unsigned keylen )
} }
for(i=j=0; i < BLOWFISH_ROUNDS+2; i++ ) { for(i=j=0; i < BLOWFISH_ROUNDS+2; i++ ) {
#ifdef BIG_ENDIAN_HOST #ifdef BIG_ENDIAN_HOST
((byte*)&data)[0] = key[j]; ((byte*)&data)[0] = key[j];
((byte*)&data)[1] = key[(j+1)%keylen]; ((byte*)&data)[1] = key[(j+1)%keylen];
((byte*)&data)[2] = key[(j+2)%keylen]; ((byte*)&data)[2] = key[(j+2)%keylen];
((byte*)&data)[3] = key[(j+3)%keylen]; ((byte*)&data)[3] = key[(j+3)%keylen];
#else #else
((byte*)&data)[3] = key[j]; ((byte*)&data)[3] = key[j];
((byte*)&data)[2] = key[(j+1)%keylen]; ((byte*)&data)[2] = key[(j+1)%keylen];
((byte*)&data)[1] = key[(j+2)%keylen]; ((byte*)&data)[1] = key[(j+2)%keylen];
((byte*)&data)[0] = key[(j+3)%keylen]; ((byte*)&data)[0] = key[(j+3)%keylen];
#endif #endif
c->p[i] ^= data; c->p[i] ^= data;
j = (j+4) % keylen; j = (j+4) % keylen;
} }
@ -630,4 +630,3 @@ blowfish_get_info( int algo, size_t *keylen,
return "BLOWFISH"; return "BLOWFISH";
return NULL; return NULL;
} }

View File

@ -345,7 +345,7 @@ rol(int n, u32 x)
return x; return x;
} }
#else #else
#define rol(n,x) ( ((x) << (n)) | ((x) >> (32-(n))) ) #define rol(n,x) ( ((x) << (n)) | ((x) >> (32-(n))) )
#endif #endif
#define F1(D,m,r) ( (I = ((m) + (D))), (I=rol((r),I)), \ #define F1(D,m,r) ( (I = ((m) + (D))), (I=rol((r),I)), \
@ -495,7 +495,7 @@ selftest(void)
if( memcmp( buffer, plain, 8 ) ) if( memcmp( buffer, plain, 8 ) )
return "2"; return "2";
#if 0 /* full maintenance test */ #if 0 /* full maintenance test */
{ {
int i; int i;
byte a0[16] = { 0x01,0x23,0x45,0x67,0x12,0x34,0x56,0x78, byte a0[16] = { 0x01,0x23,0x45,0x67,0x12,0x34,0x56,0x78,
@ -519,7 +519,7 @@ selftest(void)
return "3"; return "3";
} }
#endif #endif
return NULL; return NULL;
} }
@ -528,8 +528,8 @@ static void
key_schedule( u32 *x, u32 *z, u32 *k ) key_schedule( u32 *x, u32 *z, u32 *k )
{ {
#define xi(i) ((x[(i)/4] >> (8*(3-((i)%4)))) & 0xff) #define xi(i) ((x[(i)/4] >> (8*(3-((i)%4)))) & 0xff)
#define zi(i) ((z[(i)/4] >> (8*(3-((i)%4)))) & 0xff) #define zi(i) ((z[(i)/4] >> (8*(3-((i)%4)))) & 0xff)
z[0] = x[0] ^ s5[xi(13)]^s6[xi(15)]^s7[xi(12)]^s8[xi(14)]^s7[xi( 8)]; z[0] = x[0] ^ s5[xi(13)]^s6[xi(15)]^s7[xi(12)]^s8[xi(14)]^s7[xi( 8)];
z[1] = x[2] ^ s5[zi( 0)]^s6[zi( 2)]^s7[zi( 1)]^s8[zi( 3)]^s8[xi(10)]; z[1] = x[2] ^ s5[zi( 0)]^s6[zi( 2)]^s7[zi( 1)]^s8[zi( 3)]^s8[xi(10)];
@ -567,8 +567,8 @@ key_schedule( u32 *x, u32 *z, u32 *k )
k[14]= s5[xi(12)]^s6[xi(13)]^s7[xi( 3)]^s8[xi( 2)]^s7[xi( 8)]; k[14]= s5[xi(12)]^s6[xi(13)]^s7[xi( 3)]^s8[xi( 2)]^s7[xi( 8)];
k[15]= s5[xi(14)]^s6[xi(15)]^s7[xi( 1)]^s8[xi( 0)]^s8[xi(13)]; k[15]= s5[xi(14)]^s6[xi(15)]^s7[xi( 1)]^s8[xi( 0)]^s8[xi(13)];
#undef xi #undef xi
#undef zi #undef zi
} }
@ -610,8 +610,8 @@ do_cast_setkey( CAST5_context *c, byte *key, unsigned keylen )
memset(&z,0, sizeof z); memset(&z,0, sizeof z);
memset(&k,0, sizeof k); memset(&k,0, sizeof k);
#undef xi #undef xi
#undef zi #undef zi
return 0; return 0;
} }
@ -652,4 +652,3 @@ cast5_get_info( int algo, size_t *keylen,
return "CAST5"; return "CAST5";
return NULL; return NULL;
} }

View File

@ -141,9 +141,9 @@ working_memcmp( const char *a, const char *b, size_t n )
/* Some defines/checks to support standalone modules */ /* Some defines/checks to support standalone modules */
#ifndef CIPHER_ALGO_3DES #ifndef CIPHER_ALGO_3DES
#define CIPHER_ALGO_3DES 2 #define CIPHER_ALGO_3DES 2
#elif CIPHER_ALGO_3DES != 2 #elif CIPHER_ALGO_3DES != 2
#error CIPHER_ALGO_3DES is defined to a wrong value. #error CIPHER_ALGO_3DES is defined to a wrong value.
#endif #endif
@ -1022,4 +1022,3 @@ des_get_info( int algo, size_t *keylen,
} }
return NULL; return NULL;
} }

View File

@ -356,7 +356,7 @@ do_encrypt(MPI a, MPI b, MPI input, ELG_public_key *pkey )
*/ */
mpi_powm( b, pkey->y, k, pkey->p ); mpi_powm( b, pkey->y, k, pkey->p );
mpi_mulm( b, b, input, pkey->p ); mpi_mulm( b, b, input, pkey->p );
#if 0 #if 0
if( DBG_CIPHER ) { if( DBG_CIPHER ) {
log_mpidump("elg encrypted y= ", pkey->y); log_mpidump("elg encrypted y= ", pkey->y);
log_mpidump("elg encrypted p= ", pkey->p); log_mpidump("elg encrypted p= ", pkey->p);
@ -365,7 +365,7 @@ do_encrypt(MPI a, MPI b, MPI input, ELG_public_key *pkey )
log_mpidump("elg encrypted a= ", a); log_mpidump("elg encrypted a= ", a);
log_mpidump("elg encrypted b= ", b); log_mpidump("elg encrypted b= ", b);
} }
#endif #endif
mpi_free(k); mpi_free(k);
} }
@ -381,7 +381,7 @@ decrypt(MPI output, MPI a, MPI b, ELG_secret_key *skey )
mpi_powm( t1, a, skey->x, skey->p ); mpi_powm( t1, a, skey->x, skey->p );
mpi_invm( t1, t1, skey->p ); mpi_invm( t1, t1, skey->p );
mpi_mulm( output, b, t1, skey->p ); mpi_mulm( output, b, t1, skey->p );
#if 0 #if 0
if( DBG_CIPHER ) { if( DBG_CIPHER ) {
log_mpidump("elg decrypted x= ", skey->x); log_mpidump("elg decrypted x= ", skey->x);
log_mpidump("elg decrypted p= ", skey->p); log_mpidump("elg decrypted p= ", skey->p);
@ -389,7 +389,7 @@ decrypt(MPI output, MPI a, MPI b, ELG_secret_key *skey )
log_mpidump("elg decrypted b= ", b); log_mpidump("elg decrypted b= ", b);
log_mpidump("elg decrypted M= ", output); log_mpidump("elg decrypted M= ", output);
} }
#endif #endif
mpi_free(t1); mpi_free(t1);
} }
@ -424,7 +424,7 @@ sign(MPI a, MPI b, MPI input, ELG_secret_key *skey )
mpi_invm(inv, k, p_1 ); mpi_invm(inv, k, p_1 );
mpi_mulm(b, t, inv, p_1 ); mpi_mulm(b, t, inv, p_1 );
#if 0 #if 0
if( DBG_CIPHER ) { if( DBG_CIPHER ) {
log_mpidump("elg sign p= ", skey->p); log_mpidump("elg sign p= ", skey->p);
log_mpidump("elg sign g= ", skey->g); log_mpidump("elg sign g= ", skey->g);
@ -435,7 +435,7 @@ sign(MPI a, MPI b, MPI input, ELG_secret_key *skey )
log_mpidump("elg sign a= ", a); log_mpidump("elg sign a= ", a);
log_mpidump("elg sign b= ", b); log_mpidump("elg sign b= ", b);
} }
#endif #endif
mpi_free(k); mpi_free(k);
mpi_free(t); mpi_free(t);
mpi_free(inv); mpi_free(inv);
@ -461,7 +461,7 @@ verify(MPI a, MPI b, MPI input, ELG_public_key *pkey )
t1 = mpi_alloc( mpi_get_nlimbs(a) ); t1 = mpi_alloc( mpi_get_nlimbs(a) );
t2 = mpi_alloc( mpi_get_nlimbs(a) ); t2 = mpi_alloc( mpi_get_nlimbs(a) );
#if 0 #if 0
/* t1 = (y^a mod p) * (a^b mod p) mod p */ /* t1 = (y^a mod p) * (a^b mod p) mod p */
mpi_powm( t1, pkey->y, a, pkey->p ); mpi_powm( t1, pkey->y, a, pkey->p );
mpi_powm( t2, a, b, pkey->p ); mpi_powm( t2, a, b, pkey->p );
@ -471,7 +471,7 @@ verify(MPI a, MPI b, MPI input, ELG_public_key *pkey )
mpi_powm( t2, pkey->g, input, pkey->p ); mpi_powm( t2, pkey->g, input, pkey->p );
rc = !mpi_cmp( t1, t2 ); rc = !mpi_cmp( t1, t2 );
#elif 0 #elif 0
/* t1 = (y^a mod p) * (a^b mod p) mod p */ /* t1 = (y^a mod p) * (a^b mod p) mod p */
base[0] = pkey->y; exp[0] = a; base[0] = pkey->y; exp[0] = a;
base[1] = a; exp[1] = b; base[1] = a; exp[1] = b;
@ -482,7 +482,7 @@ verify(MPI a, MPI b, MPI input, ELG_public_key *pkey )
mpi_powm( t2, pkey->g, input, pkey->p ); mpi_powm( t2, pkey->g, input, pkey->p );
rc = !mpi_cmp( t1, t2 ); rc = !mpi_cmp( t1, t2 );
#else #else
/* t1 = g ^ - input * y ^ a * a ^ b mod p */ /* t1 = g ^ - input * y ^ a * a ^ b mod p */
mpi_invm(t2, pkey->g, pkey->p ); mpi_invm(t2, pkey->g, pkey->p );
base[0] = t2 ; exp[0] = input; base[0] = t2 ; exp[0] = input;
@ -492,7 +492,7 @@ verify(MPI a, MPI b, MPI input, ELG_public_key *pkey )
mpi_mulpowm( t1, base, exp, pkey->p ); mpi_mulpowm( t1, base, exp, pkey->p );
rc = !mpi_cmp_ui( t1, 1 ); rc = !mpi_cmp_ui( t1, 1 );
#endif #endif
mpi_free(t1); mpi_free(t1);
mpi_free(t2); mpi_free(t2);
@ -662,5 +662,3 @@ elg_get_info( int algo, int *npkey, int *nskey, int *nenc, int *nsig,
default: *use = 0; return NULL; default: *use = 0; return NULL;
} }
} }

View File

@ -39,16 +39,16 @@
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#ifdef HAVE_DL_DLOPEN #ifdef HAVE_DL_DLOPEN
#include <dlfcn.h> #include <dlfcn.h>
#endif #endif
#ifdef __MINGW32__ #ifdef __MINGW32__
#include <windows.h> #include <windows.h>
#endif #endif
#include "util.h" #include "util.h"
#include "algorithms.h" #include "algorithms.h"
#ifndef RTLD_NOW #ifndef RTLD_NOW
#define RTLD_NOW 1 #define RTLD_NOW 1
#endif #endif
@ -193,4 +193,3 @@ idea_get_info( int algo, size_t *keylen,
return rstr; return rstr;
return NULL; return NULL;
} }

View File

@ -100,7 +100,7 @@ transform( MD5_CONTEXT *ctx, byte *data )
u32 D = ctx->D; u32 D = ctx->D;
u32 *cwp = correct_words; u32 *cwp = correct_words;
#ifdef BIG_ENDIAN_HOST #ifdef BIG_ENDIAN_HOST
{ int i; { int i;
byte *p2, *p1; byte *p2, *p1;
for(i=0, p1=data, p2=(byte*)correct_words; i < 16; i++, p2 += 4 ) { for(i=0, p1=data, p2=(byte*)correct_words; i < 16; i++, p2 += 4 ) {
@ -110,9 +110,9 @@ transform( MD5_CONTEXT *ctx, byte *data )
p2[0] = *p1++; p2[0] = *p1++;
} }
} }
#else #else
memcpy( correct_words, data, 64 ); memcpy( correct_words, data, 64 );
#endif #endif
#define OP(a, b, c, d, s, T) \ #define OP(a, b, c, d, s, T) \
@ -311,17 +311,17 @@ md5_final( MD5_CONTEXT *hd )
burn_stack (80+6*sizeof(void*)); burn_stack (80+6*sizeof(void*));
p = hd->buf; p = hd->buf;
#ifdef BIG_ENDIAN_HOST #ifdef BIG_ENDIAN_HOST
#define X(a) do { *p++ = hd-> a ; *p++ = hd-> a >> 8; \ #define X(a) do { *p++ = hd-> a ; *p++ = hd-> a >> 8; \
*p++ = hd-> a >> 16; *p++ = hd-> a >> 24; } while(0) *p++ = hd-> a >> 16; *p++ = hd-> a >> 24; } while(0)
#else /* little endian */ #else /* little endian */
#define X(a) do { *(u32*)p = hd-> a ; p += 4; } while(0) #define X(a) do { *(u32*)p = hd-> a ; p += 4; } while(0)
#endif #endif
X(A); X(A);
X(B); X(B);
X(C); X(C);
X(D); X(D);
#undef X #undef X
} }
@ -364,4 +364,3 @@ md5_get_info( int algo, size_t *contextsize,
return "MD5"; return "MD5";
} }

View File

@ -39,19 +39,19 @@
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#ifdef HAVE_GETHRTIME #ifdef HAVE_GETHRTIME
#include <sys/times.h> #include <sys/times.h>
#endif #endif
#ifdef HAVE_GETTIMEOFDAY #ifdef HAVE_GETTIMEOFDAY
#include <sys/times.h> #include <sys/times.h>
#endif #endif
#ifdef HAVE_TIMES #ifdef HAVE_TIMES
#include <sys/times.h> #include <sys/times.h>
#endif #endif
#ifdef HAVE_GETRUSAGE #ifdef HAVE_GETRUSAGE
#include <sys/resource.h> #include <sys/resource.h>
#endif #endif
#ifdef __MINGW32__ #ifdef __MINGW32__
#include <process.h> #include <process.h>
#endif #endif
#include "util.h" #include "util.h"
#include "rmd.h" #include "rmd.h"
@ -62,16 +62,16 @@
#include "algorithms.h" #include "algorithms.h"
#ifndef RAND_MAX /* for SunOS */ #ifndef RAND_MAX /* for SunOS */
#define RAND_MAX 32767 #define RAND_MAX 32767
#endif #endif
#if SIZEOF_UNSIGNED_LONG == 8 #if SIZEOF_UNSIGNED_LONG == 8
#define ADD_VALUE 0xa5a5a5a5a5a5a5a5 #define ADD_VALUE 0xa5a5a5a5a5a5a5a5
#elif SIZEOF_UNSIGNED_LONG == 4 #elif SIZEOF_UNSIGNED_LONG == 4
#define ADD_VALUE 0xa5a5a5a5 #define ADD_VALUE 0xa5a5a5a5
#else #else
#error weird size for an unsigned long #error weird size for an unsigned long
#endif #endif
#define BLOCKLEN 64 /* hash this amount of bytes */ #define BLOCKLEN 64 /* hash this amount of bytes */
@ -84,7 +84,7 @@
#define POOLBLOCKS 30 #define POOLBLOCKS 30
#define POOLSIZE (POOLBLOCKS*DIGESTLEN) #define POOLSIZE (POOLBLOCKS*DIGESTLEN)
#if (POOLSIZE % SIZEOF_UNSIGNED_LONG) #if (POOLSIZE % SIZEOF_UNSIGNED_LONG)
#error Please make sure that poolsize is a multiple of ulong #error Please make sure that poolsize is a multiple of ulong
#endif #endif
#define POOLWORDS (POOLSIZE / SIZEOF_UNSIGNED_LONG) #define POOLWORDS (POOLSIZE / SIZEOF_UNSIGNED_LONG)
@ -315,7 +315,7 @@ mix_pool(byte *pool)
rmd160_init( &md ); rmd160_init( &md );
#if DIGESTLEN != 20 #if DIGESTLEN != 20
#error must have a digest length of 20 for ripe-md-160 #error must have a digest length of 20 for ripe-md-160
#endif #endif
/* loop over the pool */ /* loop over the pool */
pend = pool + POOLSIZE; pend = pool + POOLSIZE;
@ -632,40 +632,40 @@ fast_random_poll()
} }
/* fall back to the generic function */ /* fall back to the generic function */
#if defined(HAVE_GETHRTIME) && !defined(HAVE_BROKEN_GETHRTIME) #if defined(HAVE_GETHRTIME) && !defined(HAVE_BROKEN_GETHRTIME)
{ hrtime_t tv; { hrtime_t tv;
/* On some Solaris and HPUX system gethrtime raises an SIGILL, but we /* On some Solaris and HPUX system gethrtime raises an SIGILL, but we
* checked this with configure */ * checked this with configure */
tv = gethrtime(); tv = gethrtime();
add_randomness( &tv, sizeof(tv), 1 ); add_randomness( &tv, sizeof(tv), 1 );
} }
#elif defined (HAVE_GETTIMEOFDAY) #elif defined (HAVE_GETTIMEOFDAY)
{ struct timeval tv; { struct timeval tv;
if( gettimeofday( &tv, NULL ) ) if( gettimeofday( &tv, NULL ) )
BUG(); BUG();
add_randomness( &tv.tv_sec, sizeof(tv.tv_sec), 1 ); add_randomness( &tv.tv_sec, sizeof(tv.tv_sec), 1 );
add_randomness( &tv.tv_usec, sizeof(tv.tv_usec), 1 ); add_randomness( &tv.tv_usec, sizeof(tv.tv_usec), 1 );
} }
#elif defined (HAVE_CLOCK_GETTIME) #elif defined (HAVE_CLOCK_GETTIME)
{ struct timespec tv; { struct timespec tv;
if( clock_gettime( CLOCK_REALTIME, &tv ) == -1 ) if( clock_gettime( CLOCK_REALTIME, &tv ) == -1 )
BUG(); BUG();
add_randomness( &tv.tv_sec, sizeof(tv.tv_sec), 1 ); add_randomness( &tv.tv_sec, sizeof(tv.tv_sec), 1 );
add_randomness( &tv.tv_nsec, sizeof(tv.tv_nsec), 1 ); add_randomness( &tv.tv_nsec, sizeof(tv.tv_nsec), 1 );
} }
#elif defined (HAVE_TIMES) #elif defined (HAVE_TIMES)
{ struct tms buf; { struct tms buf;
if( times( &buf ) == -1 ) if( times( &buf ) == -1 )
BUG(); BUG();
add_randomness( &buf, sizeof buf, 1 ); add_randomness( &buf, sizeof buf, 1 );
} }
#endif #endif
#ifdef HAVE_GETRUSAGE #ifdef HAVE_GETRUSAGE
#ifndef RUSAGE_SELF #ifndef RUSAGE_SELF
#ifdef __GCC__ #ifdef __GCC__
#warning There is no RUSAGE_SELF on this system #warning There is no RUSAGE_SELF on this system
#endif #endif
#else #else
{ struct rusage buf; { struct rusage buf;
/* QNX/Neutrino does return ENOSYS - so we just ignore it and /* QNX/Neutrino does return ENOSYS - so we just ignore it and
* add whatever is in buf. In a chroot environment it might not * add whatever is in buf. In a chroot environment it might not
@ -677,8 +677,8 @@ fast_random_poll()
add_randomness( &buf, sizeof buf, 1 ); add_randomness( &buf, sizeof buf, 1 );
wipememory( &buf, sizeof buf ); wipememory( &buf, sizeof buf );
} }
#endif #endif
#endif #endif
/* time and clock are available on all systems - so /* time and clock are available on all systems - so
* we better do it just in case one of the above functions * we better do it just in case one of the above functions
* didn't work */ * didn't work */
@ -727,25 +727,23 @@ gather_faked( void (*add)(const void*, size_t, int), int requester,
"it run - it is in no way a strong RNG!\n\n" "it run - it is in no way a strong RNG!\n\n"
"DON'T USE ANY DATA GENERATED BY THIS PROGRAM!!\n\n")); "DON'T USE ANY DATA GENERATED BY THIS PROGRAM!!\n\n"));
initialized=1; initialized=1;
#ifdef HAVE_RAND #ifdef HAVE_RAND
srand(make_timestamp()*getpid()); srand(make_timestamp()*getpid());
#else #else
srandom(make_timestamp()*getpid()); srandom(make_timestamp()*getpid());
#endif #endif
} }
p = buffer = m_alloc( length ); p = buffer = m_alloc( length );
n = length; n = length;
#ifdef HAVE_RAND #ifdef HAVE_RAND
while( n-- ) while( n-- )
*p++ = ((unsigned)(1 + (int) (256.0*rand()/(RAND_MAX+1.0)))-1); *p++ = ((unsigned)(1 + (int) (256.0*rand()/(RAND_MAX+1.0)))-1);
#else #else
while( n-- ) while( n-- )
*p++ = ((unsigned)(1 + (int) (256.0*random()/(RAND_MAX+1.0)))-1); *p++ = ((unsigned)(1 + (int) (256.0*random()/(RAND_MAX+1.0)))-1);
#endif #endif
add_randomness( buffer, length, requester ); add_randomness( buffer, length, requester );
m_free(buffer); m_free(buffer);
return 0; /* okay */ return 0; /* okay */
} }

View File

@ -1764,7 +1764,7 @@ do_setkey (RIJNDAEL_context *ctx, const byte *key, const unsigned keylen)
for (i = 0; i < keylen; i++) { for (i = 0; i < keylen; i++) {
k[i >> 2][i & 3] = key[i]; k[i >> 2][i & 3] = key[i];
} }
#define W (ctx->keySched) #define W (ctx->keySched)
for (j = KC-1; j >= 0; j--) { for (j = KC-1; j >= 0; j--) {
*((u32*)tk[j]) = *((u32*)k[j]); *((u32*)tk[j]) = *((u32*)k[j]);
@ -1819,7 +1819,7 @@ do_setkey (RIJNDAEL_context *ctx, const byte *key, const unsigned keylen)
} }
} }
#undef W #undef W
return 0; return 0;
} }
@ -1844,7 +1844,7 @@ prepare_decryption( RIJNDAEL_context *ctx )
*((u32*)ctx->keySched2[r][2]) = *((u32*)ctx->keySched[r][2]); *((u32*)ctx->keySched2[r][2]) = *((u32*)ctx->keySched[r][2]);
*((u32*)ctx->keySched2[r][3]) = *((u32*)ctx->keySched[r][3]); *((u32*)ctx->keySched2[r][3]) = *((u32*)ctx->keySched[r][3]);
} }
#define W (ctx->keySched2) #define W (ctx->keySched2)
for (r = 1; r < ctx->ROUNDS; r++) { for (r = 1; r < ctx->ROUNDS; r++) {
w = W[r][0]; w = W[r][0];
*((u32*)w) = *((u32*)U1[w[0]]) ^ *((u32*)U2[w[1]]) *((u32*)w) = *((u32*)U1[w[0]]) ^ *((u32*)U2[w[1]])
@ -1862,7 +1862,7 @@ prepare_decryption( RIJNDAEL_context *ctx )
*((u32*)w) = *((u32*)U1[w[0]]) ^ *((u32*)U2[w[1]]) *((u32*)w) = *((u32*)U1[w[0]]) ^ *((u32*)U2[w[1]])
^ *((u32*)U3[w[2]]) ^ *((u32*)U4[w[3]]); ^ *((u32*)U3[w[2]]) ^ *((u32*)U4[w[3]]);
} }
#undef W #undef W
} }
@ -1874,7 +1874,7 @@ do_encrypt (const RIJNDAEL_context *ctx, byte *b, const byte *a)
int r; int r;
byte temp[4][4]; byte temp[4][4];
int ROUNDS = ctx->ROUNDS; int ROUNDS = ctx->ROUNDS;
#define rk (ctx->keySched) #define rk (ctx->keySched)
*((u32*)temp[0]) = *((u32*)(a )) ^ *((u32*)rk[0][0]); *((u32*)temp[0]) = *((u32*)(a )) ^ *((u32*)rk[0][0]);
*((u32*)temp[1]) = *((u32*)(a+ 4)) ^ *((u32*)rk[0][1]); *((u32*)temp[1]) = *((u32*)(a+ 4)) ^ *((u32*)rk[0][1]);
@ -1944,7 +1944,7 @@ do_encrypt (const RIJNDAEL_context *ctx, byte *b, const byte *a)
*((u32*)(b+ 4)) ^= *((u32*)rk[ROUNDS][1]); *((u32*)(b+ 4)) ^= *((u32*)rk[ROUNDS][1]);
*((u32*)(b+ 8)) ^= *((u32*)rk[ROUNDS][2]); *((u32*)(b+ 8)) ^= *((u32*)rk[ROUNDS][2]);
*((u32*)(b+12)) ^= *((u32*)rk[ROUNDS][3]); *((u32*)(b+12)) ^= *((u32*)rk[ROUNDS][3]);
#undef rk #undef rk
} }
static void static void
@ -1959,7 +1959,7 @@ rijndael_encrypt (const RIJNDAEL_context *ctx, byte *b, const byte *a)
static void static void
do_decrypt (RIJNDAEL_context *ctx, byte *b, const byte *a) do_decrypt (RIJNDAEL_context *ctx, byte *b, const byte *a)
{ {
#define rk (ctx->keySched2) #define rk (ctx->keySched2)
int ROUNDS = ctx->ROUNDS; int ROUNDS = ctx->ROUNDS;
int r; int r;
byte temp[4][4]; byte temp[4][4];
@ -2038,7 +2038,7 @@ do_decrypt (RIJNDAEL_context *ctx, byte *b, const byte *a)
*((u32*)(b+ 4)) ^= *((u32*)rk[0][1]); *((u32*)(b+ 4)) ^= *((u32*)rk[0][1]);
*((u32*)(b+ 8)) ^= *((u32*)rk[0][2]); *((u32*)(b+ 8)) ^= *((u32*)rk[0][2]);
*((u32*)(b+12)) ^= *((u32*)rk[0][3]); *((u32*)(b+12)) ^= *((u32*)rk[0][3]);
#undef rk #undef rk
} }
static void static void
@ -2223,12 +2223,3 @@ gnupgext_enum_func ( int what, int *sequence, int *class, int *vers )
return ret; return ret;
} }
#endif #endif

View File

@ -175,7 +175,7 @@ static void
transform( RMD160_CONTEXT *hd, byte *data ) transform( RMD160_CONTEXT *hd, byte *data )
{ {
u32 a,b,c,d,e,aa,bb,cc,dd,ee,t; u32 a,b,c,d,e,aa,bb,cc,dd,ee,t;
#ifdef BIG_ENDIAN_HOST #ifdef BIG_ENDIAN_HOST
u32 x[16]; u32 x[16];
{ int i; { int i;
byte *p2, *p1; byte *p2, *p1;
@ -186,10 +186,10 @@ transform( RMD160_CONTEXT *hd, byte *data )
p2[0] = *p1++; p2[0] = *p1++;
} }
} }
#else #else
#if 0 #if 0
u32 *x =(u32*)data; u32 *x =(u32*)data;
#else #else
/* this version is better because it is always aligned; /* this version is better because it is always aligned;
* The performance penalty on a 586-100 is about 6% which * The performance penalty on a 586-100 is about 6% which
* is acceptable - because the data is more local it might * is acceptable - because the data is more local it might
@ -199,8 +199,8 @@ transform( RMD160_CONTEXT *hd, byte *data )
* [measured with a 4MB data and "gpgm --print-md rmd160"] */ * [measured with a 4MB data and "gpgm --print-md rmd160"] */
u32 x[16]; u32 x[16];
memcpy( x, data, 64 ); memcpy( x, data, 64 );
#endif #endif
#endif #endif
#define K0 0x00000000 #define K0 0x00000000
@ -454,13 +454,13 @@ rmd160_mixblock( RMD160_CONTEXT *hd, char *buffer )
{ {
char *p = buffer; char *p = buffer;
transform( hd, buffer ); transform( hd, buffer );
#define X(a) do { *(u32*)p = hd->h##a ; p += 4; } while(0) #define X(a) do { *(u32*)p = hd->h##a ; p += 4; } while(0)
X(0); X(0);
X(1); X(1);
X(2); X(2);
X(3); X(3);
X(4); X(4);
#undef X #undef X
} }
@ -514,18 +514,18 @@ rmd160_final( RMD160_CONTEXT *hd )
burn_stack (108+5*sizeof(void*)); burn_stack (108+5*sizeof(void*));
p = hd->buf; p = hd->buf;
#ifdef BIG_ENDIAN_HOST #ifdef BIG_ENDIAN_HOST
#define X(a) do { *p++ = hd->h##a ; *p++ = hd->h##a >> 8; \ #define X(a) do { *p++ = hd->h##a ; *p++ = hd->h##a >> 8; \
*p++ = hd->h##a >> 16; *p++ = hd->h##a >> 24; } while(0) *p++ = hd->h##a >> 16; *p++ = hd->h##a >> 24; } while(0)
#else /* little endian */ #else /* little endian */
#define X(a) do { *(u32*)p = hd->h##a ; p += 4; } while(0) #define X(a) do { *(u32*)p = hd->h##a ; p += 4; } while(0)
#endif #endif
X(0); X(0);
X(1); X(1);
X(2); X(2);
X(3); X(3);
X(4); X(4);
#undef X #undef X
} }
static byte * static byte *
@ -585,4 +585,3 @@ rmd160_get_info( int algo, size_t *contextsize,
return "RIPEMD160"; return "RIPEMD160";
} }

View File

@ -45,13 +45,13 @@ main(int argc, char **argv)
usage(); usage();
rmdhd = rmd160_open(0); rmdhd = rmd160_open(0);
#if 1 #if 1
while( (n = fread( buf, 1, 100, stdin )) > 0 ) while( (n = fread( buf, 1, 100, stdin )) > 0 )
rmd160_write(rmdhd, buf, n); rmd160_write(rmdhd, buf, n);
#else #else
for(i=0; i < 1000000; i++ ) for(i=0; i < 1000000; i++ )
rmd160_putchar(rmdhd, 'a'); rmd160_putchar(rmdhd, 'a');
#endif #endif
p = rmd160_final(rmdhd); p = rmd160_final(rmdhd);
for(i=0; i < 20; i++, p++ ) for(i=0; i < 20; i++, p++ )
printf("%02x", *p ); printf("%02x", *p );
@ -60,4 +60,3 @@ main(int argc, char **argv)
rmd160_close(rmdhd); rmd160_close(rmdhd);
return 0; return 0;
} }

View File

@ -31,15 +31,15 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#ifdef HAVE_GETTIMEOFDAY #ifdef HAVE_GETTIMEOFDAY
#include <sys/times.h> #include <sys/times.h>
#endif #endif
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#if 0 #if 0
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <asm/types.h> #include <asm/types.h>
#include <linux/random.h> #include <linux/random.h>
#endif #endif
#include "types.h" #include "types.h"
#include "util.h" #include "util.h"
@ -114,11 +114,11 @@ rndlinux_gather_random( void (*add)(const void*, size_t, int), int requester,
fd = fd_urandom; fd = fd_urandom;
} }
#if 0 #if 0
#ifdef HAVE_DEV_RANDOM_IOCTL #ifdef HAVE_DEV_RANDOM_IOCTL
g10_log_info("entropy count of %d is %lu\n", fd, get_entropy_count(fd) ); g10_log_info("entropy count of %d is %lu\n", fd, get_entropy_count(fd) );
#endif #endif
#endif #endif
while( length ) { while( length ) {
fd_set rfds; fd_set rfds;
struct timeval tv; struct timeval tv;

View File

@ -328,9 +328,9 @@ typedef struct {
pid_t pid_t
waitpid(pid_t pid, int *statptr, int options) waitpid(pid_t pid, int *statptr, int options)
{ {
#ifdef HAVE_WAIT4 #ifdef HAVE_WAIT4
return wait4(pid, statptr, options, NULL); return wait4(pid, statptr, options, NULL);
#else #else
/* If wait4 is also not available, try wait3 for SVR3 variants */ /* If wait4 is also not available, try wait3 for SVR3 variants */
/* Less ideal because can't actually request a specific pid */ /* Less ideal because can't actually request a specific pid */
/* For that reason, first check to see if pid is for an */ /* For that reason, first check to see if pid is for an */
@ -346,7 +346,7 @@ waitpid(pid_t pid, int *statptr, int options)
(tmp_pid != -1) && (tmp_pid != 0) && (pid != -1)) (tmp_pid != -1) && (tmp_pid != 0) && (pid != -1))
; ;
return tmp_pid; return tmp_pid;
#endif #endif
} }
#endif #endif
@ -494,11 +494,11 @@ slow_poll(FILE *dbgfp, int dbgall, size_t *nbytes )
int moreSources; int moreSources;
struct timeval tv; struct timeval tv;
fd_set fds; fd_set fds;
#if defined( __hpux ) #if defined( __hpux )
size_t maxFD = 0; size_t maxFD = 0;
#else #else
int maxFD = 0; int maxFD = 0;
#endif /* OS-specific brokenness */ #endif /* OS-specific brokenness */
int bufPos, i, usefulness = 0; int bufPos, i, usefulness = 0;
@ -521,9 +521,9 @@ slow_poll(FILE *dbgfp, int dbgall, size_t *nbytes )
dataSources[i].pipeFD = fileno(dataSources[i].pipe); dataSources[i].pipeFD = fileno(dataSources[i].pipe);
if (dataSources[i].pipeFD > maxFD) if (dataSources[i].pipeFD > maxFD)
maxFD = dataSources[i].pipeFD; maxFD = dataSources[i].pipeFD;
#ifdef O_NONBLOCK /* Ohhh what a hack (used for Atari) */ #ifdef O_NONBLOCK /* Ohhh what a hack (used for Atari) */
fcntl(dataSources[i].pipeFD, F_SETFL, O_NONBLOCK); fcntl(dataSources[i].pipeFD, F_SETFL, O_NONBLOCK);
#endif #endif
FD_SET(dataSources[i].pipeFD, &fds); FD_SET(dataSources[i].pipeFD, &fds);
dataSources[i].length = 0; dataSources[i].length = 0;
@ -550,11 +550,11 @@ slow_poll(FILE *dbgfp, int dbgall, size_t *nbytes )
tv.tv_sec = 10; tv.tv_sec = 10;
tv.tv_usec = 0; tv.tv_usec = 0;
#if defined( __hpux ) && ( OS_VERSION == 9 ) #if defined( __hpux ) && ( OS_VERSION == 9 )
if (select(maxFD + 1, (int *)&fds, NULL, NULL, &tv) == -1) if (select(maxFD + 1, (int *)&fds, NULL, NULL, &tv) == -1)
#else /* */ #else /* */
if (select(maxFD + 1, &fds, NULL, NULL, &tv) == -1) if (select(maxFD + 1, &fds, NULL, NULL, &tv) == -1)
#endif /* __hpux */ #endif /* __hpux */
break; break;
/* One of the sources has data available, read it into the buffer */ /* One of the sources has data available, read it into the buffer */
@ -684,27 +684,27 @@ start_gatherer( int pipefd )
* return an error, so the read data won't be added to the randomness * return an error, so the read data won't be added to the randomness
* pool. There are two types of SIGC(H)LD naming, the SysV SIGCLD and * pool. There are two types of SIGC(H)LD naming, the SysV SIGCLD and
* the BSD/Posix SIGCHLD, so we need to handle either possibility */ * the BSD/Posix SIGCHLD, so we need to handle either possibility */
#ifdef SIGCLD #ifdef SIGCLD
signal(SIGCLD, SIG_DFL); signal(SIGCLD, SIG_DFL);
#else #else
signal(SIGCHLD, SIG_DFL); signal(SIGCHLD, SIG_DFL);
#endif #endif
fflush (stderr); fflush (stderr);
/* Arrghh!! It's Stuart code!! */ /* Arrghh!! It's Stuart code!! */
/* (close all files but the ones we need) */ /* (close all files but the ones we need) */
{ int nmax, n1, i; { int nmax, n1, i;
#ifdef _SC_OPEN_MAX #ifdef _SC_OPEN_MAX
if( (nmax=sysconf( _SC_OPEN_MAX )) < 0 ) { if( (nmax=sysconf( _SC_OPEN_MAX )) < 0 ) {
#ifdef _POSIX_OPEN_MAX #ifdef _POSIX_OPEN_MAX
nmax = _POSIX_OPEN_MAX; nmax = _POSIX_OPEN_MAX;
#else #else
nmax = 20; /* assume a reasonable value */ nmax = 20; /* assume a reasonable value */
#endif #endif
} }
#else #else
nmax = 20; /* assume a reasonable value */ nmax = 20; /* assume a reasonable value */
#endif #endif
{ {
int fd; int fd;
if ((fd = open ("/dev/null", O_RDWR)) != -1) { if ((fd = open ("/dev/null", O_RDWR)) != -1) {

View File

@ -433,7 +433,7 @@ slow_gatherer_windowsNT( void (*add)(const void*, size_t, int), int requester )
CloseHandle (hDevice); CloseHandle (hDevice);
} }
#if 0 /* we don't need this in GnuPG */ #if 0 /* we don't need this in GnuPG */
/* Wait for any async keyset driver binding to complete. You may be /* Wait for any async keyset driver binding to complete. You may be
* wondering what this call is doing here... the reason it's necessary is * wondering what this call is doing here... the reason it's necessary is
* because RegQueryValueEx() will hang indefinitely if the async driver * because RegQueryValueEx() will hang indefinitely if the async driver
@ -453,7 +453,7 @@ slow_gatherer_windowsNT( void (*add)(const void*, size_t, int), int requester )
* this, we have to wait until any async driver bind has completed * this, we have to wait until any async driver bind has completed
* before we can call RegQueryValueEx() */ * before we can call RegQueryValueEx() */
waitSemaphore (SEMAPHORE_DRIVERBIND); waitSemaphore (SEMAPHORE_DRIVERBIND);
#endif #endif
/* Get information from the system performance counters. This can take /* Get information from the system performance counters. This can take
* a few seconds to do. In some environments the call to * a few seconds to do. In some environments the call to
@ -587,7 +587,7 @@ rndw32_gather_random_fast( void (*add)(const void*, size_t, int), int requester
* events in input queue, and milliseconds since Windows was started */ * events in input queue, and milliseconds since Windows was started */
{ byte buffer[20*sizeof(ulong)], *bufptr; { byte buffer[20*sizeof(ulong)], *bufptr;
bufptr = buffer; bufptr = buffer;
#define ADD(f) do { ulong along = (ulong)(f); \ #define ADD(f) do { ulong along = (ulong)(f); \
memcpy (bufptr, &along, sizeof (along) ); \ memcpy (bufptr, &along, sizeof (along) ); \
bufptr += sizeof (along); } while (0) bufptr += sizeof (along); } while (0)
ADD ( GetActiveWindow ()); ADD ( GetActiveWindow ());
@ -611,7 +611,7 @@ rndw32_gather_random_fast( void (*add)(const void*, size_t, int), int requester
assert ( bufptr-buffer < sizeof (buffer) ); assert ( bufptr-buffer < sizeof (buffer) );
(*add) ( buffer, bufptr-buffer, requester ); (*add) ( buffer, bufptr-buffer, requester );
#undef ADD #undef ADD
} }
/* Get multiword system information: Current caret position, current /* Get multiword system information: Current caret position, current
@ -699,5 +699,4 @@ rndw32_gather_random_fast( void (*add)(const void*, size_t, int), int requester
return 0; return 0;
} }
#endif /*USE_RNDW32*/ #endif /*USE_RNDW32*/

View File

@ -301,9 +301,9 @@ stronger_key_check ( RSA_secret_key *skey )
static void static void
secret(MPI output, MPI input, RSA_secret_key *skey ) secret(MPI output, MPI input, RSA_secret_key *skey )
{ {
#if 0 #if 0
mpi_powm( output, input, skey->d, skey->n ); mpi_powm( output, input, skey->d, skey->n );
#else #else
MPI m1 = mpi_alloc_secure( mpi_get_nlimbs(skey->n)+1 ); MPI m1 = mpi_alloc_secure( mpi_get_nlimbs(skey->n)+1 );
MPI m2 = mpi_alloc_secure( mpi_get_nlimbs(skey->n)+1 ); MPI m2 = mpi_alloc_secure( mpi_get_nlimbs(skey->n)+1 );
MPI h = mpi_alloc_secure( mpi_get_nlimbs(skey->n)+1 ); MPI h = mpi_alloc_secure( mpi_get_nlimbs(skey->n)+1 );
@ -329,7 +329,7 @@ secret(MPI output, MPI input, RSA_secret_key *skey )
mpi_free ( h ); mpi_free ( h );
mpi_free ( m1 ); mpi_free ( m1 );
mpi_free ( m2 ); mpi_free ( m2 );
#endif #endif
} }
@ -489,6 +489,3 @@ rsa_get_info( int algo,
default:*r_usage = 0; return NULL; default:*r_usage = 0; return NULL;
} }
} }

View File

@ -90,9 +90,9 @@ transform( SHA1_CONTEXT *hd, byte *data )
d = hd->h3; d = hd->h3;
e = hd->h4; e = hd->h4;
#ifdef BIG_ENDIAN_HOST #ifdef BIG_ENDIAN_HOST
memcpy( x, data, 64 ); memcpy( x, data, 64 );
#else #else
{ int i; { int i;
byte *p2; byte *p2;
for(i=0, p2=(byte*)x; i < 16; i++, p2 += 4 ) { for(i=0, p2=(byte*)x; i < 16; i++, p2 += 4 ) {
@ -102,7 +102,7 @@ transform( SHA1_CONTEXT *hd, byte *data )
p2[0] = *data++; p2[0] = *data++;
} }
} }
#endif #endif
#define K1 0x5A827999L #define K1 0x5A827999L
@ -304,19 +304,18 @@ sha1_final(SHA1_CONTEXT *hd)
burn_stack (88+4*sizeof(void*)); burn_stack (88+4*sizeof(void*));
p = hd->buf; p = hd->buf;
#ifdef BIG_ENDIAN_HOST #ifdef BIG_ENDIAN_HOST
#define X(a) do { *(u32*)p = hd->h##a ; p += 4; } while(0) #define X(a) do { *(u32*)p = hd->h##a ; p += 4; } while(0)
#else /* little endian */ #else /* little endian */
#define X(a) do { *p++ = hd->h##a >> 24; *p++ = hd->h##a >> 16; \ #define X(a) do { *p++ = hd->h##a >> 24; *p++ = hd->h##a >> 16; \
*p++ = hd->h##a >> 8; *p++ = hd->h##a; } while(0) *p++ = hd->h##a >> 8; *p++ = hd->h##a; } while(0)
#endif #endif
X(0); X(0);
X(1); X(1);
X(2); X(2);
X(3); X(3);
X(4); X(4);
#undef X #undef X
} }
static byte * static byte *

View File

@ -256,12 +256,12 @@ sha256_final(SHA256_CONTEXT *hd)
burn_stack (328); burn_stack (328);
p = hd->buf; p = hd->buf;
#ifdef BIG_ENDIAN_HOST #ifdef BIG_ENDIAN_HOST
#define X(a) do { *(u32*)p = hd->h##a ; p += 4; } while(0) #define X(a) do { *(u32*)p = hd->h##a ; p += 4; } while(0)
#else /* little endian */ #else /* little endian */
#define X(a) do { *p++ = hd->h##a >> 24; *p++ = hd->h##a >> 16; \ #define X(a) do { *p++ = hd->h##a >> 24; *p++ = hd->h##a >> 16; \
*p++ = hd->h##a >> 8; *p++ = hd->h##a; } while(0) *p++ = hd->h##a >> 8; *p++ = hd->h##a; } while(0)
#endif #endif
X(0); X(0);
X(1); X(1);
X(2); X(2);
@ -270,8 +270,7 @@ sha256_final(SHA256_CONTEXT *hd)
X(5); X(5);
X(6); X(6);
X(7); X(7);
#undef X #undef X
} }
static byte * static byte *

View File

@ -331,14 +331,14 @@ sha512_final(SHA512_CONTEXT *hd)
burn_stack (768); burn_stack (768);
p = hd->buf; p = hd->buf;
#ifdef BIG_ENDIAN_HOST #ifdef BIG_ENDIAN_HOST
#define X(a) do { *(u64*)p = hd->h##a ; p += 8; } while(0) #define X(a) do { *(u64*)p = hd->h##a ; p += 8; } while(0)
#else /* little endian */ #else /* little endian */
#define X(a) do { *p++ = hd->h##a >> 56; *p++ = hd->h##a >> 48; \ #define X(a) do { *p++ = hd->h##a >> 56; *p++ = hd->h##a >> 48; \
*p++ = hd->h##a >> 40; *p++ = hd->h##a >> 32; \ *p++ = hd->h##a >> 40; *p++ = hd->h##a >> 32; \
*p++ = hd->h##a >> 24; *p++ = hd->h##a >> 16; \ *p++ = hd->h##a >> 24; *p++ = hd->h##a >> 16; \
*p++ = hd->h##a >> 8; *p++ = hd->h##a; } while(0) *p++ = hd->h##a >> 8; *p++ = hd->h##a; } while(0)
#endif #endif
X(0); X(0);
X(1); X(1);
X(2); X(2);
@ -349,7 +349,7 @@ sha512_final(SHA512_CONTEXT *hd)
We just ignore them. */ We just ignore them. */
X(6); X(6);
X(7); X(7);
#undef X #undef X
} }
static byte * static byte *

View File

@ -723,8 +723,8 @@ transform( TIGER_CONTEXT *hd, byte *data )
{ {
u64 a,b,c,aa,bb,cc; u64 a,b,c,aa,bb,cc;
u64 x[8]; u64 x[8];
#ifdef BIG_ENDIAN_HOST #ifdef BIG_ENDIAN_HOST
#define MKWORD(d,n) \ #define MKWORD(d,n) \
( ((u64)(d)[8*(n)+7]) << 56 | ((u64)(d)[8*(n)+6]) << 48 \ ( ((u64)(d)[8*(n)+7]) << 56 | ((u64)(d)[8*(n)+6]) << 48 \
| ((u64)(d)[8*(n)+5]) << 40 | ((u64)(d)[8*(n)+4]) << 32 \ | ((u64)(d)[8*(n)+5]) << 40 | ((u64)(d)[8*(n)+4]) << 32 \
| ((u64)(d)[8*(n)+3]) << 24 | ((u64)(d)[8*(n)+2]) << 16 \ | ((u64)(d)[8*(n)+3]) << 24 | ((u64)(d)[8*(n)+2]) << 16 \
@ -737,10 +737,10 @@ transform( TIGER_CONTEXT *hd, byte *data )
x[5] = MKWORD(data, 5); x[5] = MKWORD(data, 5);
x[6] = MKWORD(data, 6); x[6] = MKWORD(data, 6);
x[7] = MKWORD(data, 7); x[7] = MKWORD(data, 7);
#undef MKWORD #undef MKWORD
#else #else
memcpy( &x[0], data, 64 ); memcpy( &x[0], data, 64 );
#endif #endif
/* save */ /* save */
a = aa = hd->a; a = aa = hd->a;
@ -857,18 +857,18 @@ tiger_final( TIGER_CONTEXT *hd )
burn_stack (21*8+11*sizeof(void*)); burn_stack (21*8+11*sizeof(void*));
p = hd->buf; p = hd->buf;
#ifdef BIG_ENDIAN_HOST #ifdef BIG_ENDIAN_HOST
#define X(a) do { *(u64*)p = hd-> a ; p += 8; } while(0) #define X(a) do { *(u64*)p = hd-> a ; p += 8; } while(0)
#else /* little endian */ #else /* little endian */
#define X(a) do { *p++ = hd-> a >> 56; *p++ = hd-> a >> 48; \ #define X(a) do { *p++ = hd-> a >> 56; *p++ = hd-> a >> 48; \
*p++ = hd-> a >> 40; *p++ = hd-> a >> 32; \ *p++ = hd-> a >> 40; *p++ = hd-> a >> 32; \
*p++ = hd-> a >> 24; *p++ = hd-> a >> 16; \ *p++ = hd-> a >> 24; *p++ = hd-> a >> 16; \
*p++ = hd-> a >> 8; *p++ = hd-> a; } while(0) *p++ = hd-> a >> 8; *p++ = hd-> a; } while(0)
#endif #endif
X(a); X(a);
X(b); X(b);
X(c); X(c);
#undef X #undef X
} }
static byte * static byte *