+2011-07-19 Ulrich Drepper <drepper@gmail.com>
+
+ * crypt/sha512.h (struct sha512_ctx): Move buffer into union and add
+ buffer64.
+ * crypt/sha512.c (__sha512_finish_ctx): Use buffer64 for writes instead
+ of casting of buffer.
+ * crypt/sha256.h (struct sha256_ctx): Move buffer into union and add
+ buffer32 and buffer64.
+ * crypt/sha256.c (__sha256_finish_ctx): Use buffer32 or buffer64 for
+ writes instead of casting of buffer.
+ * crypt/md5.h (struct md5_ctx): Move buffer into union and add
+ buffer32.
+ * crypt/md5.c (md5_finish_ctx): Use buffer32 for writes instead of
+ casting of buffer.
+
2011-07-19 Andreas Schwab <schwab@redhat.com>
* string/strxfrm_l.c (STRXFRM): Fix alloca accounting.
/* 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,2011
Free Software Foundation, Inc.
This file is part of the GNU C Library.
memcpy (&ctx->buffer[bytes], fillbuf, pad);
/* Put the 64-bit file length in *bits* at the end of the buffer. */
- *(md5_uint32 *) &ctx->buffer[bytes + pad] = SWAP (ctx->total[0] << 3);
- *(md5_uint32 *) &ctx->buffer[bytes + pad + 4] = SWAP ((ctx->total[1] << 3) |
- (ctx->total[0] >> 29));
+ ctx->buffer32[(bytes + pad) / 4] = SWAP (ctx->total[0] << 3);
+ ctx->buffer32[(bytes + pad + 4) / 4] = SWAP ((ctx->total[1] << 3) |
+ (ctx->total[0] >> 29));
/* Process last bytes. */
md5_process_block (ctx->buffer, bytes + pad + 8, ctx);
}
while (sum < BLOCKSIZE && n != 0);
if (n == 0 && ferror (stream))
- return 1;
+ return 1;
/* If end of file is reached, end the loop. */
if (n == 0)
#define OP(a, b, c, d, s, T) \
do \
- { \
+ { \
a += FF (b, c, d) + (*cwp++ = SWAP (*words)) + T; \
++words; \
CYCLIC (a, s); \
a += b; \
- } \
+ } \
while (0)
/* It is unfortunate that C does not provide an operator for
/* 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,2011
Free Software Foundation, Inc.
This file is part of the GNU C Library.
typedef unsigned long md5_uint32;
# else
/* The following line is intended to evoke an error.
- Using #error is not portable enough. */
+ Using #error is not portable enough. */
"Cannot determine unsigned 32-bit data type."
# endif
# endif
md5_uint32 total[2];
md5_uint32 buflen;
- char buffer[128] __attribute__ ((__aligned__ (__alignof__ (md5_uint32))));
+ union
+ {
+ char buffer[128];
+ md5_uint32 buffer32[32];
+ };
};
/*
/* Put the 64-bit file length in *bits* at the end of the buffer. */
#ifdef _STRING_ARCH_unaligned
- *(uint64_t *) &ctx->buffer[bytes + pad] = SWAP64 (ctx->total64 << 3);
+ ctx->buffer64[(bytes + pad) / 8] = SWAP64 (ctx->total64 << 3);
#else
- *(uint32_t *) &ctx->buffer[bytes + pad + 4]
- = SWAP (ctx->total[TOTAL64_low] << 3);
- *(uint32_t *) &ctx->buffer[bytes + pad]
- = SWAP ((ctx->total[TOTAL64_high] << 3) |
- (ctx->total[TOTAL64_low] >> 29));
+ ctx->buffer32[(bytes + pad + 4) / 4] = SWAP (ctx->total[TOTAL64_low] << 3);
+ ctx->buffer32[(bytes + pad) / 4] = SWAP ((ctx->total[TOTAL64_high] << 3) |
+ (ctx->total[TOTAL64_low] >> 29));
#endif
/* Process last bytes. */
uint32_t total[2];
};
uint32_t buflen;
- char buffer[128] __attribute__ ((__aligned__ (__alignof__ (uint32_t))));
+ union
+ {
+ char buffer[128];
+ uint32_t buffer32[32];
+ uint64_t buffer64[16];
+ };
};
/* Initialize structure containing state of computation.
memcpy (&ctx->buffer[bytes], fillbuf, pad);
/* Put the 128-bit file length in *bits* at the end of the buffer. */
- *(uint64_t *) &ctx->buffer[bytes + pad + 8]
- = SWAP (ctx->total[TOTAL128_low] << 3);
- *(uint64_t *) &ctx->buffer[bytes + pad]
- = SWAP ((ctx->total[TOTAL128_high] << 3) |
- (ctx->total[TOTAL128_low] >> 61));
+ ctx->buffer64[(bytes + pad + 8) / 8] = SWAP (ctx->total[TOTAL128_low] << 3);
+ ctx->buffer64[(bytes + pad) / 8] = SWAP ((ctx->total[TOTAL128_high] << 3) |
+ (ctx->total[TOTAL128_low] >> 61));
/* Process last bytes. */
sha512_process_block (ctx->buffer, bytes + pad + 16, ctx);
uint64_t total[2];
};
uint64_t buflen;
- char buffer[256] __attribute__ ((__aligned__ (__alignof__ (uint64_t))));
+ union
+ {
+ char buffer[256];
+ uint64_t buffer64[32];
+ };
};
/* Initialize structure containing state of computation.