From: Simon Josefsson Date: Sat, 22 Oct 2005 16:48:36 +0000 (+0000) Subject: Update. X-Git-Tag: gnutls_1_2_9~86 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=46fbc43120da3da0e3456e4948621cbdfe2ee8ef;p=thirdparty%2Fgnutls.git Update. --- diff --git a/gl/arcfour.c b/gl/arcfour.c index 186961dd08..89387b0fc7 100644 --- a/gl/arcfour.c +++ b/gl/arcfour.c @@ -36,16 +36,16 @@ void arcfour_stream (arcfour_context * context, const char *inbuf, char *outbuf, size_t length) { - size_t i = context->idx_i; - size_t j = context->idx_j; + uint8_t i = context->idx_i; + uint8_t j = context->idx_j; char *sbox = context->sbox; for (; length > 0; length--) { char t; - i = (i + 1) % ARCFOUR_SBOX_SIZE; - j = (j + sbox[i]) % ARCFOUR_SBOX_SIZE; + i++; + j += sbox[i]; t = sbox[i]; sbox[i] = sbox[j]; sbox[j] = t; diff --git a/gl/arcfour.h b/gl/arcfour.h index 3925abb215..dee819021f 100644 --- a/gl/arcfour.h +++ b/gl/arcfour.h @@ -25,13 +25,14 @@ # define ARCFOUR_H # include +# include #define ARCFOUR_SBOX_SIZE 256 typedef struct { - size_t idx_i, idx_j; char sbox[ARCFOUR_SBOX_SIZE]; + uint8_t idx_i, idx_j; } arcfour_context; /* Apply ARCFOUR stream to INBUF placing the result in OUTBUF, both of diff --git a/gl/arctwo.h b/gl/arctwo.h index 11eca57a39..c7c3e511b3 100644 --- a/gl/arctwo.h +++ b/gl/arctwo.h @@ -42,7 +42,7 @@ arctwo_setkey_ekb (arctwo_context *context, size_t keylen, const char *key, size_t effective_keylen); #define arctwo_setkey(context,keylen,key) \ - arctwo_setkey_ekb (context, keylen, key, 8 * keylen) + arctwo_setkey_ekb (context, keylen, key, 8 * (keylen)) /* Encrypt INBUF of size LENGTH into OUTBUF. LENGTH must be a multiple of ARCTWO_BLOCK_SIZE. CONTEXT hold the encryption key, diff --git a/gl/m4/gc.m4 b/gl/m4/gc.m4 index 41e569d5bc..d91147738c 100644 --- a/gl/m4/gc.m4 +++ b/gl/m4/gc.m4 @@ -51,33 +51,30 @@ AC_DEFUN([gl_GC], AC_ARG_ENABLE(random-device, AC_HELP_STRING([--enable-random-device], [device with (strong) randomness (for Nettle)]), - NAME_OF_RANDOM_DEVICE=$enableval) + test "$enableval" != "no" && NAME_OF_RANDOM_DEVICE=$enableval) AC_MSG_RESULT($NAME_OF_RANDOM_DEVICE) AC_MSG_CHECKING([device with pseudo random data...]) AC_ARG_ENABLE(pseudo-random-device, AC_HELP_STRING([--enable-pseudo-random-device], [device with pseudo randomness (for Nettle)]), - NAME_OF_PSEUDO_RANDOM_DEVICE=$enableval) + test "$enableval" != "no" && NAME_OF_PSEUDO_RANDOM_DEVICE=$enableval) AC_MSG_RESULT($NAME_OF_PSEUDO_RANDOM_DEVICE) AC_MSG_CHECKING([device with unpredictable data for nonces...]) AC_ARG_ENABLE(nonce-device, AC_HELP_STRING([--enable-nonce-device], [device with unpredictable nonces (for Nettle)]), - NAME_OF_NONCE_DEVICE=$enableval) + test "$enableval" != "no" && NAME_OF_NONCE_DEVICE=$enableval) AC_MSG_RESULT($NAME_OF_NONCE_DEVICE) if test "$cross_compiling" != yes; then - AC_CHECK_FILE($NAME_OF_RANDOM_DEVICE,, AC_MSG_ERROR([[ - *** Device for (strong) random data $NAME_OF_RANDOM_DEVICE does not exist - ]])) - AC_CHECK_FILE($NAME_OF_PSEUDO_RANDOM_DEVICE,, AC_MSG_ERROR([[ - *** Device for pseudo-random data $NAME_OF_PSEUDO_RANDOM_DEVICE does not exist - ]])) - AC_CHECK_FILE($NAME_OF_NONCE_DEVICE,, AC_MSG_ERROR([[ - *** Device for unpredictable nonces $NAME_OF_NONCE_DEVICE does not exist - ]])) + AC_CHECK_FILE($NAME_OF_RANDOM_DEVICE,, + AC_MSG_ERROR([[device for (strong) random data `$NAME_OF_RANDOM_DEVICE' does not exist]])) + AC_CHECK_FILE($NAME_OF_PSEUDO_RANDOM_DEVICE,, + AC_MSG_ERROR([[device for pseudo-random data `$NAME_OF_PSEUDO_RANDOM_DEVICE' does not exist]])) + AC_CHECK_FILE($NAME_OF_NONCE_DEVICE,, + AC_MSG_ERROR([[device for unpredictable nonces `$NAME_OF_NONCE_DEVICE' does not exist]])) else AC_MSG_NOTICE([[Cross compiling, assuming random devices exists...]]) fi diff --git a/gl/m4/gnulib-comp.m4 b/gl/m4/gnulib-comp.m4 index 09081fecd7..058c390d1a 100644 --- a/gl/m4/gnulib-comp.m4 +++ b/gl/m4/gnulib-comp.m4 @@ -25,7 +25,7 @@ AC_DEFUN([gl_EARLY], # "Check for header files, types and library functions". AC_DEFUN([gl_INIT], [ -AM_CONDITIONAL(GL_COND_LIBTOOL, true) +AM_CONDITIONAL([GL_COND_LIBTOOL], [true]) gl_FUNC_ALLOCA gl_GC gl_GC_ARCFOUR diff --git a/gl/md4.c b/gl/md4.c index 7ddb6e710f..53f346817e 100644 --- a/gl/md4.c +++ b/gl/md4.c @@ -100,12 +100,12 @@ md4_finish_ctx (struct md4_ctx *ctx, void *resbuf) ++ctx->total[1]; pad = bytes >= 56 ? 64 + 56 - bytes : 56 - bytes; - memcpy (&ctx->buffer[bytes], fillbuf, pad); + memcpy (&((char*)ctx->buffer)[bytes], fillbuf, pad); /* Put the 64-bit file length in *bits* at the end of the buffer. */ - *(uint32_t *) &ctx->buffer[bytes + pad] = SWAP (ctx->total[0] << 3); - *(uint32_t *) &ctx->buffer[bytes + pad + 4] = SWAP ((ctx->total[1] << 3) | - (ctx->total[0] >> 29)); + ctx->buffer[(bytes + pad) / 4] = SWAP (ctx->total[0] << 3); + ctx->buffer[(bytes + pad) / 4 + 1] = SWAP ((ctx->total[1] << 3) | + (ctx->total[0] >> 29)); /* Process last bytes. */ md4_process_block (ctx->buffer, bytes + pad + 8, ctx); @@ -208,7 +208,7 @@ md4_process_bytes (const void *buffer, size_t len, struct md4_ctx *ctx) size_t left_over = ctx->buflen; size_t add = 128 - left_over > len ? len : 128 - left_over; - memcpy (&ctx->buffer[left_over], buffer, add); + memcpy (&((char*)ctx->buffer)[left_over], buffer, add); ctx->buflen += add; if (ctx->buflen > 64) @@ -217,7 +217,7 @@ md4_process_bytes (const void *buffer, size_t len, struct md4_ctx *ctx) ctx->buflen &= 63; /* The regions in the following copy operation cannot overlap. */ - memcpy (ctx->buffer, &ctx->buffer[(left_over + add) & ~63], + memcpy (ctx->buffer, &((char*)ctx->buffer)[(left_over + add) & ~63], ctx->buflen); } @@ -258,13 +258,13 @@ md4_process_bytes (const void *buffer, size_t len, struct md4_ctx *ctx) { size_t left_over = ctx->buflen; - memcpy (&ctx->buffer[left_over], buffer, len); + memcpy (&((char*)ctx->buffer)[left_over], buffer, len); left_over += len; if (left_over >= 64) { md4_process_block (ctx->buffer, 64, ctx); left_over -= 64; - memcpy (ctx->buffer, &ctx->buffer[64], left_over); + memcpy (ctx->buffer, &ctx->buffer[16], left_over); } ctx->buflen = left_over; } diff --git a/gl/md4.h b/gl/md4.h index f9417ef8e9..d94907e6c3 100644 --- a/gl/md4.h +++ b/gl/md4.h @@ -22,7 +22,7 @@ # include # include -#define MD4_DIGEST_SIZE 16 +# define MD4_DIGEST_SIZE 16 /* Structure to save state of computation between the single steps. */ struct md4_ctx @@ -34,7 +34,7 @@ struct md4_ctx uint32_t total[2]; uint32_t buflen; - char buffer[128] __attribute__ ((__aligned__ (__alignof__ (uint32_t)))); + uint32_t buffer[128]; };