]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Update.
authorSimon Josefsson <simon@josefsson.org>
Sat, 22 Oct 2005 16:48:36 +0000 (16:48 +0000)
committerSimon Josefsson <simon@josefsson.org>
Sat, 22 Oct 2005 16:48:36 +0000 (16:48 +0000)
gl/arcfour.c
gl/arcfour.h
gl/arctwo.h
gl/m4/gc.m4
gl/m4/gnulib-comp.m4
gl/md4.c
gl/md4.h

index 186961dd0879eeac78b885d233d11243b2f65d3b..89387b0fc7db6765f5fb8c114fe2ecbbce5599a0 100644 (file)
@@ -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;
index 3925abb2156830c2ef80398d0fa6165f8dca2d61..dee819021fa0d559d28e8cff07e553cd511cbf80 100644 (file)
 # define ARCFOUR_H
 
 # include <stddef.h>
+# include <stdint.h>
 
 #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
index 11eca57a391f7492c0f2f0838bc90a334f84acec..c7c3e511b30f37e70b55671e55e0bd9cf7bce605 100644 (file)
@@ -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,
index 41e569d5bce3af3e303ae2b6b2cf4ac63dfc4a0e..d91147738c2471838463e67a1d51df2a5f385a3a 100644 (file)
@@ -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
index 09081fecd70dce2e2424daabdecc2585dd017902..058c390d1a85ecb00688405a0402f9455e50c3c1 100644 (file)
@@ -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
index 7ddb6e710f3f9b92d97a46a575e831a3e3b4cd3f..53f346817ea3d838f05e37cf2c8ea538a66633f2 100644 (file)
--- 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;
     }
index f9417ef8e9356b38f2ff41da8323f553cac5b508..d94907e6c3193e8a918c14d08bac5d53772d2a6f 100644 (file)
--- a/gl/md4.h
+++ b/gl/md4.h
@@ -22,7 +22,7 @@
 # include <stdio.h>
 # include <stdint.h>
 
-#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];
 };