bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

md5, sha1, sha256, sha512 minor cleanups


From: Paul Eggert
Subject: md5, sha1, sha256, sha512 minor cleanups
Date: Wed, 11 Jan 2006 23:25:35 -0800
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)

coreutils CVS didn't build with Sun's C compiler due to an unprotected
use of __attribute__ in one of the sha* libraries, so I looked for all
the unnecessary differences between md5 and sha* and removed the ones
I found, installing the following change, along with importing the
stdint module from gnulib.

2006-01-11  Paul Eggert  <address@hidden>

        * lib/.cvsignore: Add stdint.h.
        * lib/Makefile.am (BUILT_SOURCES, EXTRA_DIST, stdint.h, 
MOSTLYCLEANFILES):
        Add gnulib snippet.
        * lib/md5.c: Fix commentary typos.
        (alignof, UNALIGNED_P): No need for a GCC-specific version.
        * lib/md5.h (__attribute__): Remove; unused.
        * lib/sha1.c, lib/sha256.c, lib/sha256.c:
        Fix commentary to match md5 better.
        * lib/sha1.h (struct sha1_ctx): Use a word buffer, not a byte buffer,
        so that we don't need to worry about alignment.  All uses changed.
        This merges the 2005-10-28 md5 change into sha1.
        * lib/sha256.h (struct sha256_ctx): Likewise.
        * lib/sha512.h (struct sha512_ctx): Likewise.
        * lib/sha256.h: Include stdint.h rather than md5.h.
        * lib/sha512.h: Include stdint.h uniformly, since we now have the
        stdint module.
        * lib/stdint_.h: New file, from gnulib.
        * m4/prereq.m4 (gl_PREREQ): Require gl_STDINT_H.
        * m4/stdint_.h.m4: New file, from gnulib.

Index: lib/.cvsignore
===================================================================
RCS file: /fetish/cu/lib/.cvsignore,v
retrieving revision 1.27
diff -p -u -r1.27 .cvsignore
--- lib/.cvsignore      22 Sep 2005 05:47:40 -0000      1.27
+++ lib/.cvsignore      12 Jan 2006 07:10:47 -0000
@@ -14,6 +14,7 @@ ref-del.sed
 search.h
 stat.c
 stdbool.h
+stdint.h
 sysexit.h
 t-fpending
 unlocked-io.h
Index: lib/Makefile.am
===================================================================
RCS file: /fetish/cu/lib/Makefile.am,v
retrieving revision 1.241
diff -p -u -r1.241 Makefile.am
--- lib/Makefile.am     14 Dec 2005 20:37:06 -0000      1.241
+++ lib/Makefile.am     12 Jan 2006 07:10:47 -0000
@@ -130,6 +130,16 @@ stdbool.h: stdbool_.h
        sed -e 's/@''HAVE__BOOL''@/$(HAVE__BOOL)/g' < $(srcdir)/stdbool_.h > 
address@hidden
        mv address@hidden $@
 
+BUILT_SOURCES += $(STDINT_H)
+EXTRA_DIST += stdint_.h
+
+# We need the following in order to create <stdint.h> when the system
+# doesn't have one that works with the given compiler.
+stdint.h: stdint_.h
+       sed -e 
's/@''HAVE_LONG_64BIT''@/$(HAVE_LONG_64BIT)/g;s/@''HAVE_LONG_LONG_64BIT@/$(HAVE_LONG_LONG_64BIT)/g'
 < $(srcdir)/stdint_.h > address@hidden
+       mv address@hidden $@
+MOSTLYCLEANFILES += stdint.h stdint.h-t
+
 BUILT_SOURCES += $(ALLOCA_H)
 EXTRA_DIST += alloca_.h
 
Index: lib/md5.c
===================================================================
RCS file: /fetish/cu/lib/md5.c,v
retrieving revision 1.27
diff -p -u -r1.27 md5.c
--- lib/md5.c   11 Jan 2006 10:07:13 -0000      1.27
+++ lib/md5.c   12 Jan 2006 07:10:48 -0000
@@ -1,6 +1,6 @@
 /* Functions to compute MD5 message digest of files or memory blocks.
    according to the definition of MD5 in RFC 1321 from April 1992.
-   Copyright (C) 1995,1996,1997,1999,2000,2001,2005
+   Copyright (C) 1995,1996,1997,1999,2000,2001,2005,2006
        Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -86,7 +86,7 @@ md5_init_ctx (struct md5_ctx *ctx)
    must be in little endian byte order.
 
    IMPORTANT: On some systems it is required that RESBUF is correctly
-   aligned for a 32 bits value.  */
+   aligned for a 32-bit value.  */
 void *
 md5_read_ctx (const struct md5_ctx *ctx, void *resbuf)
 {
@@ -102,7 +102,7 @@ md5_read_ctx (const struct md5_ctx *ctx,
    prolog according to the standard and write the result to RESBUF.
 
    IMPORTANT: On some systems it is required that RESBUF is correctly
-   aligned for a 32 bits value.  */
+   aligned for a 32-bit value.  */
 void *
 md5_finish_ctx (struct md5_ctx *ctx, void *resbuf)
 {
@@ -245,14 +245,8 @@ md5_process_bytes (const void *buffer, s
   if (len >= 64)
     {
 #if !_STRING_ARCH_unaligned
-/* To check alignment gcc has an appropriate operator.  Other
-   compilers don't.  */
-# if __GNUC__ >= 2
-#  define UNALIGNED_P(p) (((uintptr_t) p) % __alignof__ (uint32_t) != 0)
-# else
-#  define alignof(type) offsetof (struct { char c; type x; }, x)
-#  define UNALIGNED_P(p) (((size_t) p) % alignof (uint32_t) != 0)
-# endif
+# define alignof(type) offsetof (struct { char c; type x; }, x)
+# define UNALIGNED_P(p) (((size_t) p) % alignof (uint32_t) != 0)
       if (UNALIGNED_P (buffer))
        while (len > 64)
          {
Index: lib/md5.h
===================================================================
RCS file: /fetish/cu/lib/md5.h,v
retrieving revision 1.20
diff -p -u -r1.20 md5.h
--- lib/md5.h   10 Jan 2006 17:47:57 -0000      1.20
+++ lib/md5.h   12 Jan 2006 07:10:48 -0000
@@ -1,6 +1,6 @@
 /* Declaration of functions and data types used for MD5 sum computing
    library functions.
-   Copyright (C) 1995-1997,1999,2000,2001,2004,2005
+   Copyright (C) 1995-1997,1999,2000,2001,2004,2005,2006
       Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -44,12 +44,6 @@
 # endif
 #endif
 
-#ifndef __attribute__
-# if ! __GNUC_PREREQ (2,8) || __STRICT_ANSI__
-#  define __attribute__(x)
-# endif
-#endif
-
 #ifndef _LIBC
 # define __md5_buffer md5_buffer
 # define __md5_finish_ctx md5_finish_ctx
Index: lib/sha1.c
===================================================================
RCS file: /fetish/cu/lib/sha1.c,v
retrieving revision 1.10
diff -p -u -r1.10 sha1.c
--- lib/sha1.c  10 Jan 2006 17:47:57 -0000      1.10
+++ lib/sha1.c  12 Jan 2006 07:10:48 -0000
@@ -1,7 +1,8 @@
 /* sha1.c - Functions to compute SHA1 message digest of files or
    memory blocks according to the NIST specification FIPS-180-1.
 
-   Copyright (C) 2000, 2001, 2003, 2004, 2005 Free Software Foundation, Inc.
+   Copyright (C) 2000, 2001, 2003, 2004, 2005, 2006 Free Software
+   Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by the
@@ -35,9 +36,6 @@
 # include "unlocked-io.h"
 #endif
 
-/* SWAP does an endian swap on architectures that are little-endian,
-   as SHA1 needs some data in a big-endian form.  */
-
 #ifdef WORDS_BIGENDIAN
 # define SWAP(n) (n)
 #else
@@ -55,11 +53,9 @@
 static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ...  */ };
 
 
-/*
-  Takes a pointer to a 160 bit block of data (five 32 bit ints) and
-  intializes it to the start constants of the SHA1 algorithm.  This
-  must be called before using hash in the call to sha1_hash.
-*/
+/* Take a pointer to a 160 bit block of data (five 32 bit ints) and
+   initialize it to the start constants of the SHA1 algorithm.  This
+   must be called before using hash in the call to sha1_hash.  */
 void
 sha1_init_ctx (struct sha1_ctx *ctx)
 {
@@ -100,23 +96,21 @@ sha1_finish_ctx (struct sha1_ctx *ctx, v
 {
   /* Take yet unprocessed bytes into account.  */
   uint32_t bytes = ctx->buflen;
-  size_t pad;
+  size_t size = (bytes < 56) ? 64 / 4 : 64 * 2 / 4;
 
   /* Now count remaining bytes.  */
   ctx->total[0] += bytes;
   if (ctx->total[0] < bytes)
     ++ctx->total[1];
 
-  pad = bytes >= 56 ? 64 + 56 - bytes : 56 - bytes;
-  memcpy (&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 + 4] = SWAP (ctx->total[0] << 3);
-  *(uint32_t *) &ctx->buffer[bytes + pad] = SWAP ((ctx->total[1] << 3) |
-                                                   (ctx->total[0] >> 29));
+  ctx->buffer[size - 2] = SWAP ((ctx->total[1] << 3) | (ctx->total[0] >> 29));
+  ctx->buffer[size - 1] = SWAP (ctx->total[0] << 3);
+
+  memcpy (&((char *) ctx->buffer)[bytes], fillbuf, (size - 2) * 4 - bytes);
 
   /* Process last bytes.  */
-  sha1_process_block (ctx->buffer, bytes + pad + 8, ctx);
+  sha1_process_block (ctx->buffer, size * 4, ctx);
 
   return sha1_read_ctx (ctx, resbuf);
 }
@@ -216,7 +210,7 @@ sha1_process_bytes (const void *buffer, 
       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)
@@ -225,7 +219,8 @@ sha1_process_bytes (const void *buffer, 
 
          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);
        }
 
@@ -260,13 +255,13 @@ sha1_process_bytes (const void *buffer, 
     {
       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)
        {
          sha1_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: lib/sha1.h
===================================================================
RCS file: /fetish/cu/lib/sha1.h,v
retrieving revision 1.6
diff -p -u -r1.6 sha1.h
--- lib/sha1.h  10 Jan 2006 17:47:57 -0000      1.6
+++ lib/sha1.h  12 Jan 2006 07:10:48 -0000
@@ -1,6 +1,6 @@
 /* Declarations of functions and data types used for SHA1 sum
    library functions.
-   Copyright (C) 2000, 2001, 2003, 2005 Free Software Foundation, Inc.
+   Copyright (C) 2000, 2001, 2003, 2005, 2006 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by the
@@ -33,7 +33,7 @@ struct sha1_ctx
 
   uint32_t total[2];
   uint32_t buflen;
-  char buffer[128] __attribute__ ((__aligned__ (__alignof__ (uint32_t))));
+  uint32_t buffer[32];
 };
 
 
Index: lib/sha256.c
===================================================================
RCS file: /fetish/cu/lib/sha256.c,v
retrieving revision 1.4
diff -p -u -r1.4 sha256.c
--- lib/sha256.c        10 Jan 2006 20:05:53 -0000      1.4
+++ lib/sha256.c        12 Jan 2006 07:10:48 -0000
@@ -34,26 +34,20 @@
 # include "unlocked-io.h"
 #endif
 
-/*
-  Not-swap is a macro that does an endian swap on architectures that are
-  big-endian, as SHA256 needs some data in a little-endian format
-*/
-
 #ifdef WORDS_BIGENDIAN
-# define NOTSWAP(n) (n)
+# define SWAP(n) (n)
 #else
-# define NOTSWAP(n)                                                         \
+# define SWAP(n) \
     (((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24))
 #endif
 
 #define BLOCKSIZE 4096
-/* Ensure that BLOCKSIZE is a multiple of 64.  */
 #if BLOCKSIZE % 64 != 0
 # error "invalid BLOCKSIZE"
 #endif
 
 /* This array contains the bytes used to pad the buffer to the next
-   64-byte boundary.   */
+   64-byte boundary.  */
 static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ...  */ };
 
 
@@ -104,8 +98,8 @@ sha256_read_ctx (const struct sha256_ctx
 {
   int i;
 
-  for ( i=0 ; i<8 ; i++ )
-    ((uint32_t *) resbuf)[i] = NOTSWAP (ctx->state[i]);
+  for (i = 0; i < 8; i++)
+    ((uint32_t *) resbuf)[i] = SWAP (ctx->state[i]);
 
   return resbuf;
 }
@@ -115,8 +109,8 @@ sha224_read_ctx (const struct sha256_ctx
 {
   int i;
 
-  for ( i=0 ; i<7 ; i++ )
-    ((uint32_t *) resbuf)[i] = NOTSWAP (ctx->state[i]);
+  for (i = 0; i < 7; i++)
+    ((uint32_t *) resbuf)[i] = SWAP (ctx->state[i]);
 
   return resbuf;
 }
@@ -131,23 +125,21 @@ sha256_conclude_ctx (struct sha256_ctx *
 {
   /* Take yet unprocessed bytes into account.  */
   uint32_t bytes = ctx->buflen;
-  size_t pad;
+  size_t size = (bytes < 56) ? 64 / 4 : 64 * 2 / 4;
 
   /* Now count remaining bytes.  */
   ctx->total[0] += bytes;
   if (ctx->total[0] < bytes)
     ++ctx->total[1];
 
-  pad = bytes >= 56 ? 64 + 56 - bytes : 56 - bytes;
-  memcpy (&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 + 4] = NOTSWAP (ctx->total[0] << 3);
-  *(uint32_t *) &ctx->buffer[bytes + pad] = NOTSWAP ((ctx->total[1] << 3) |
-                                                   (ctx->total[0] >> 29));
+  ctx->buffer[size - 2] = SWAP ((ctx->total[1] << 3) | (ctx->total[0] >> 29));
+  ctx->buffer[size - 1] = SWAP (ctx->total[0] << 3);
+
+  memcpy (&((char *) ctx->buffer)[bytes], fillbuf, (size - 2) * 4 - bytes);
 
   /* Process last bytes.  */
-  sha256_process_block (ctx->buffer, bytes + pad + 8, ctx);
+  sha256_process_block (ctx->buffer, size * 4, ctx);
 }
 
 void *
@@ -338,7 +330,7 @@ sha256_process_bytes (const void *buffer
       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)
@@ -347,7 +339,8 @@ sha256_process_bytes (const void *buffer
 
          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);
        }
 
@@ -382,13 +375,13 @@ sha256_process_bytes (const void *buffer
     {
       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)
        {
          sha256_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;
     }
@@ -474,7 +467,7 @@ sha256_process_block (const void *buffer
       /* FIXME: see sha1.c for a better implementation.  */
       for (t = 0; t < 16; t++)
        {
-         x[t] = NOTSWAP (*words);
+         x[t] = SWAP (*words);
          words++;
        }
 
Index: lib/sha256.h
===================================================================
RCS file: /fetish/cu/lib/sha256.h,v
retrieving revision 1.2
diff -p -u -r1.2 sha256.h
--- lib/sha256.h        10 Jan 2006 17:47:57 -0000      1.2
+++ lib/sha256.h        12 Jan 2006 07:10:48 -0000
@@ -20,7 +20,7 @@
 # define SHA256_H 1
 
 # include <stdio.h>
-# include "md5.h"
+# include <stdint.h>
 
 /* Structure to save state of computation between the single steps.  */
 struct sha256_ctx
@@ -29,7 +29,7 @@ struct sha256_ctx
 
   uint32_t total[2];
   uint32_t buflen;
-  char buffer[128];
+  uint32_t buffer[32];
 };
 
 
Index: lib/sha512.c
===================================================================
RCS file: /fetish/cu/lib/sha512.c,v
retrieving revision 1.3
diff -p -u -r1.3 sha512.c
--- lib/sha512.c        10 Jan 2006 17:47:57 -0000      1.3
+++ lib/sha512.c        12 Jan 2006 07:10:48 -0000
@@ -34,28 +34,22 @@
 # include "unlocked-io.h"
 #endif
 
-/*
-  Not-swap is a macro that does an endian swap on architectures that are
-  big-endian, as SHA512 needs some data in a little-endian format
-*/
-
 #ifdef WORDS_BIGENDIAN
-# define NOTSWAP(n) (n)
+# define SWAP(n) (n)
 #else
-# define NOTSWAP(n)                                                         \
+# define SWAP(n) \
     (((n) << 56) | (((n) & 0xff00) << 40) | (((n) & 0xff0000UL) << 24) \
-  | (((n) & 0xff000000UL) << 8) | (((n) >> 8) & 0xff000000UL) \
-  | (((n) >> 24) & 0xff0000UL) | (((n) >> 40) & 0xff00UL) | ((n) >> 56))
+     | (((n) & 0xff000000UL) << 8) | (((n) >> 8) & 0xff000000UL) \
+     | (((n) >> 24) & 0xff0000UL) | (((n) >> 40) & 0xff00UL) | ((n) >> 56))
 #endif
 
 #define BLOCKSIZE 4096
-/* Ensure that BLOCKSIZE is a multiple of 128.  */
 #if BLOCKSIZE % 128 != 0
 # error "invalid BLOCKSIZE"
 #endif
 
 /* This array contains the bytes used to pad the buffer to the next
-   64-byte boundary.  */
+   128-byte boundary.  */
 static const unsigned char fillbuf[128] = { 0x80, 0 /* , 0, 0, ...  */ };
 
 
@@ -106,8 +100,8 @@ sha512_read_ctx (const struct sha512_ctx
 {
   int i;
 
-  for ( i=0 ; i<8 ; i++ )
-    ((uint64_t *) resbuf)[i] = NOTSWAP (ctx->state[i]);
+  for (i = 0; i < 8; i++)
+    ((uint64_t *) resbuf)[i] = SWAP (ctx->state[i]);
 
   return resbuf;
 }
@@ -117,8 +111,8 @@ sha384_read_ctx (const struct sha512_ctx
 {
   int i;
 
-  for ( i=0 ; i<6 ; i++ )
-    ((uint64_t *) resbuf)[i] = NOTSWAP (ctx->state[i]);
+  for (i = 0; i < 6; i++)
+    ((uint64_t *) resbuf)[i] = SWAP (ctx->state[i]);
 
   return resbuf;
 }
@@ -133,23 +127,21 @@ sha512_conclude_ctx (struct sha512_ctx *
 {
   /* Take yet unprocessed bytes into account.  */
   uint64_t bytes = ctx->buflen;
-  size_t pad;
+  size_t size = (bytes < 112) ? 128 / 8 : 128 * 2 / 8;
 
   /* Now count remaining bytes.  */
   ctx->total[0] += bytes;
   if (ctx->total[0] < bytes)
     ++ctx->total[1];
 
-  pad = bytes >= 112 ? 128 + 112 - bytes : 112 - bytes;
-  memcpy (&ctx->buffer[bytes], fillbuf, pad);
-
   /* Put the 64-bit file length in *bits* at the end of the buffer.  */
-  *(uint64_t *) &ctx->buffer[bytes + pad + 8] = NOTSWAP (ctx->total[0] << 3);
-  *(uint64_t *) &ctx->buffer[bytes + pad] = NOTSWAP ((ctx->total[1] << 3) |
-                                                   (ctx->total[0] >> 61));
+  ctx->buffer[size - 2] = SWAP ((ctx->total[1] << 3) | (ctx->total[0] >> 61));
+  ctx->buffer[size - 1] = SWAP (ctx->total[0] << 3);
+
+  memcpy (&((char *) ctx->buffer)[bytes], fillbuf, (size - 2) * 8 - bytes);
 
   /* Process last bytes.  */
-  sha512_process_block (ctx->buffer, bytes + pad + 16, ctx);
+  sha512_process_block (ctx->buffer, size * 8, ctx);
 }
 
 void *
@@ -340,7 +332,7 @@ sha512_process_bytes (const void *buffer
       size_t left_over = ctx->buflen;
       size_t add = 256 - left_over > len ? len : 256 - left_over;
 
-      memcpy (&ctx->buffer[left_over], buffer, add);
+      memcpy (&((char *) ctx->buffer)[left_over], buffer, add);
       ctx->buflen += add;
 
       if (ctx->buflen > 128)
@@ -349,7 +341,8 @@ sha512_process_bytes (const void *buffer
 
          ctx->buflen &= 127;
          /* The regions in the following copy operation cannot overlap.  */
-         memcpy (ctx->buffer, &ctx->buffer[(left_over + add) & ~127],
+         memcpy (ctx->buffer,
+                 &((char *) ctx->buffer)[(left_over + add) & ~127],
                  ctx->buflen);
        }
 
@@ -384,13 +377,13 @@ sha512_process_bytes (const void *buffer
     {
       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 >= 128)
        {
          sha512_process_block (ctx->buffer, 128, ctx);
          left_over -= 128;
-         memcpy (ctx->buffer, &ctx->buffer[128], left_over);
+         memcpy (ctx->buffer, &ctx->buffer[16], left_over);
        }
       ctx->buflen = left_over;
     }
@@ -469,7 +462,7 @@ sha512_process_block (const void *buffer
       /* FIXME: see sha1.c for a better implementation.  */
       for (t = 0; t < 16; t++)
        {
-         x[t] = NOTSWAP (*words);
+         x[t] = SWAP (*words);
          words++;
        }
 
Index: lib/sha512.h
===================================================================
RCS file: /fetish/cu/lib/sha512.h,v
retrieving revision 1.3
diff -p -u -r1.3 sha512.h
--- lib/sha512.h        10 Jan 2006 17:47:57 -0000      1.3
+++ lib/sha512.h        12 Jan 2006 07:10:48 -0000
@@ -20,13 +20,7 @@
 # define SHA512_H 1
 
 # include <stdio.h>
-
-# if HAVE_INTTYPES_H
-#  include <inttypes.h>
-# endif
-# if HAVE_STDINT_H || _LIBC
-#  include <stdint.h>
-# endif
+# include <stdint.h>
 
 /* Structure to save state of computation between the single steps.  */
 struct sha512_ctx
@@ -35,7 +29,7 @@ struct sha512_ctx
 
   uint64_t total[2];
   uint64_t buflen;
-  char buffer[256];
+  uint64_t buffer[32];
 };
 
 
Index: m4/prereq.m4
===================================================================
RCS file: /fetish/cu/m4/prereq.m4,v
retrieving revision 1.122
diff -p -u -r1.122 prereq.m4
--- m4/prereq.m4        20 Nov 2005 08:26:38 -0000      1.122
+++ m4/prereq.m4        12 Jan 2006 07:10:48 -0000
@@ -1,4 +1,4 @@
-#serial 62
+#serial 63
 
 dnl We use gl_ for non Autoconf macros.
 m4_pattern_forbid([^gl_[ABCDEFGHIJKLMNOPQRSTUVXYZ]])dnl
@@ -138,6 +138,7 @@ AC_DEFUN([gl_PREREQ],
   AC_REQUIRE([gl_SHA512])
   AC_REQUIRE([gl_STAT_MACROS])
   AC_REQUIRE([gl_STAT_TIME])
+  AC_REQUIRE([gl_STDINT_H])
   AC_REQUIRE([gl_STDIO_SAFER])
   AC_REQUIRE([gl_STDLIB_SAFER])
   AC_REQUIRE([gl_STRCASE])







reply via email to

[Prev in Thread] Current Thread [Next in Thread]