This is the mail archive of the
glibc-cvs@sourceware.org
mailing list for the glibc project.
GNU C Library master sources branch, master, updated. glibc-2.14-65-gfeea494
- From: drepper at sourceware dot org
- To: glibc-cvs at sourceware dot org
- Date: 2 Jul 2011 17:04:08 -0000
- Subject: GNU C Library master sources branch, master, updated. glibc-2.14-65-gfeea494
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".
The branch, master has been updated
via feea4948bca7e442edad3f995696f33450549e80 (commit)
from fcfc776bc6242fdefde0efd7b0c315fbeca08555 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=feea4948bca7e442edad3f995696f33450549e80
commit feea4948bca7e442edad3f995696f33450549e80
Author: Ulrich Drepper <drepper@gmail.com>
Date: Sat Jul 2 13:03:53 2011 -0400
Fix last patch for big-endian machines
diff --git a/crypt/sha256.c b/crypt/sha256.c
index 0ca3355..1a3aca6 100644
--- a/crypt/sha256.c
+++ b/crypt/sha256.c
@@ -224,9 +224,11 @@ __sha256_finish_ctx (ctx, resbuf)
#ifdef _STRING_ARCH_unaligned
*(uint64_t *) &ctx->buffer[bytes + pad] = SWAP64 (ctx->total64 << 3);
#else
- *(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));
+ *(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));
#endif
/* Process last bytes. */
diff --git a/crypt/sha256.h b/crypt/sha256.h
index fcf6148..0457bfa 100644
--- a/crypt/sha256.h
+++ b/crypt/sha256.h
@@ -24,6 +24,7 @@
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
+#include <endian.h>
/* Structure to save state of computation between the single steps. */
@@ -34,6 +35,8 @@ struct sha256_ctx
union
{
uint64_t total64;
+#define TOTAL64_low (1 - (BYTE_ORDER == LITTLE_ENDIAN))
+#define TOTAL64_high (BYTE_ORDER == LITTLE_ENDIAN)
uint32_t total[2];
};
uint32_t buflen;
diff --git a/crypt/sha512.c b/crypt/sha512.c
index 16b4877..60a7ca5 100644
--- a/crypt/sha512.c
+++ b/crypt/sha512.c
@@ -124,9 +124,9 @@ sha512_process_block (const void *buffer, size_t len, struct sha512_ctx *ctx)
#ifdef USE_TOTAL128
ctx->total128 += len;
#else
- ctx->total[0] += len;
- if (ctx->total[0] < len)
- ++ctx->total[1];
+ ctx->total[TOTAL128_low] += len;
+ if (ctx->total[TOTAL128_low] < len)
+ ++ctx->total[TOTAL128_high];
#endif
/* Process all bytes in the buffer with 128 bytes in each round of
@@ -244,18 +244,20 @@ __sha512_finish_ctx (ctx, resbuf)
#ifdef USE_TOTAL128
ctx->total128 += bytes;
#else
- ctx->total[0] += bytes;
- if (ctx->total[0] < bytes)
- ++ctx->total[1];
+ ctx->total[TOTAL128_low] += bytes;
+ if (ctx->total[TOTAL128_low] < bytes)
+ ++ctx->total[TOTAL128_high];
#endif
pad = bytes >= 112 ? 128 + 112 - bytes : 112 - bytes;
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[0] << 3);
- *(uint64_t *) &ctx->buffer[bytes + pad] = SWAP ((ctx->total[1] << 3) |
- (ctx->total[0] >> 61));
+ *(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));
/* Process last bytes. */
sha512_process_block (ctx->buffer, bytes + pad + 16, ctx);
diff --git a/crypt/sha512.h b/crypt/sha512.h
index 90e55dc..d98a2fc 100644
--- a/crypt/sha512.h
+++ b/crypt/sha512.h
@@ -24,9 +24,8 @@
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
-#ifdef _LIBC
-# include <bits/wordsize.h>
-#endif
+#include <endian.h>
+#include <bits/wordsize.h>
/* Structure to save state of computation between the single steps. */
@@ -40,6 +39,13 @@ struct sha512_ctx
# define USE_TOTAL128
unsigned int total128 __attribute__ ((__mode__ (TI)));
#endif
+#if BYTE_ORDER == LITTLE_ENDIAN
+# define TOTAL128_low 0
+# define TOTAL128_high 1
+#else
+# define TOTAL128_low 1
+# define TOTAL128_high 0
+#endif
uint64_t total[2];
};
uint64_t buflen;
-----------------------------------------------------------------------
Summary of changes:
crypt/sha256.c | 8 +++++---
crypt/sha256.h | 3 +++
crypt/sha512.c | 20 +++++++++++---------
crypt/sha512.h | 12 +++++++++---
4 files changed, 28 insertions(+), 15 deletions(-)
hooks/post-receive
--
GNU C Library master sources