summaryrefslogtreecommitdiff
path: root/cipher/sha1.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2008-04-22 10:25:35 +0000
committerWerner Koch <wk@gnupg.org>2008-04-22 10:25:35 +0000
commitc9a31c6d9334def7502bfd76f9953c89b0df51b7 (patch)
tree601b7280f1db4e816976994568796b224d4faf0c /cipher/sha1.c
parent8559c656de0c2de6013c7d705bc8fe175a6a7abb (diff)
downloadlibgcrypt-c9a31c6d9334def7502bfd76f9953c89b0df51b7.tar.gz
Preapring a release candidate
Diffstat (limited to 'cipher/sha1.c')
-rw-r--r--cipher/sha1.c139
1 files changed, 5 insertions, 134 deletions
diff --git a/cipher/sha1.c b/cipher/sha1.c
index fe80aba8..2c1bda20 100644
--- a/cipher/sha1.c
+++ b/cipher/sha1.c
@@ -45,22 +45,13 @@
/* 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 __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
@@ -112,7 +103,6 @@ sha1_init (void *context)
/*
* 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)
@@ -240,125 +230,6 @@ transform (SHA1_CONTEXT *hd, const unsigned char *data, size_t nblocks)
}
-#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.
*/