about summary refs log tree commit diff
path: root/crypt/sha512.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@gmail.com>2011-07-02 13:03:53 -0400
committerUlrich Drepper <drepper@gmail.com>2011-07-02 13:03:53 -0400
commitfeea4948bca7e442edad3f995696f33450549e80 (patch)
treef0d06f3188f1179aa50dd5281234ed4167422db4 /crypt/sha512.c
parentfcfc776bc6242fdefde0efd7b0c315fbeca08555 (diff)
downloadglibc-feea4948bca7e442edad3f995696f33450549e80.tar.gz
glibc-feea4948bca7e442edad3f995696f33450549e80.tar.xz
glibc-feea4948bca7e442edad3f995696f33450549e80.zip
Fix last patch for big-endian machines
Diffstat (limited to 'crypt/sha512.c')
-rw-r--r--crypt/sha512.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/crypt/sha512.c b/crypt/sha512.c
index 16b4877551..60a7ca53b9 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);