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 12:30:03 -0400
committerUlrich Drepper <drepper@gmail.com>2011-07-02 12:30:03 -0400
commitfcfc776bc6242fdefde0efd7b0c315fbeca08555 (patch)
treec46c6b25047a2ed2f6baea7b76985f1d7bec3c4c /crypt/sha512.c
parent99231d9abe0fd74c7957d25b08c1d1ede4cae5a0 (diff)
downloadglibc-fcfc776bc6242fdefde0efd7b0c315fbeca08555.tar.gz
glibc-fcfc776bc6242fdefde0efd7b0c315fbeca08555.tar.xz
glibc-fcfc776bc6242fdefde0efd7b0c315fbeca08555.zip
Optimize long-word additions in SHA implementation
Diffstat (limited to 'crypt/sha512.c')
-rw-r--r--crypt/sha512.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/crypt/sha512.c b/crypt/sha512.c
index 02127476fe..16b4877551 100644
--- a/crypt/sha512.c
+++ b/crypt/sha512.c
@@ -1,6 +1,6 @@
 /* Functions to compute SHA512 message digest of files or memory blocks.
    according to the definition of SHA512 in FIPS 180-2.
-   Copyright (C) 2007 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2011 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -121,9 +121,13 @@ sha512_process_block (const void *buffer, size_t len, struct sha512_ctx *ctx)
   /* First increment the byte count.  FIPS 180-2 specifies the possible
      length of the file up to 2^128 bits.  Here we only compute the
      number of bytes.  Do a double word increment.  */
+#ifdef USE_TOTAL128
+  ctx->total128 += len;
+#else
   ctx->total[0] += len;
   if (ctx->total[0] < len)
     ++ctx->total[1];
+#endif
 
   /* Process all bytes in the buffer with 128 bytes in each round of
      the loop.  */
@@ -237,9 +241,13 @@ __sha512_finish_ctx (ctx, resbuf)
   size_t pad;
 
   /* Now count remaining bytes.  */
+#ifdef USE_TOTAL128
+  ctx->total128 += bytes;
+#else
   ctx->total[0] += bytes;
   if (ctx->total[0] < bytes)
     ++ctx->total[1];
+#endif
 
   pad = bytes >= 112 ? 128 + 112 - bytes : 112 - bytes;
   memcpy (&ctx->buffer[bytes], fillbuf, pad);