bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: problem in lib/sha256.h


From: Jim Meyering
Subject: Re: problem in lib/sha256.h
Date: Thu, 31 Jul 2008 15:36:35 +0200

"Paulie Pena IV" <address@hidden> wrote:
> There seems to be an error in the sha256.h file.  It declares
> SHA224_DIGEST_SIZE = 24, but 224 bits is not 24 bytes, it is 28 bytes.
>  The comments in that file also say that it should be 28 bytes.

A bug, indeed.  Thank you!
Here's how I'm fixing it:

>From ef5ee4cd9f0fbaf722f363dab1145ec5aaa62d95 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Thu, 31 Jul 2008 15:35:25 +0200
Subject: [PATCH] sha256.h: correct definition on SHA224_DIGEST_SIZE

* lib/sha256.h (SHA224_DIGEST_SIZE): Define to 28, not 24.
Reported by Paulie Pena IV <address@hidden>.
Define as 224 / 8, rather than as a literal.
(SHA256_DIGEST_SIZE): Define as 256/8 rather than equivalent literal.
* lib/sha512.h (SHA384_DIGEST_SIZE): Likewise, define as equiv: 384/8.
(SHA512_DIGEST_SIZE): Likewise, define as equivalent quotient: 512/8.
---
 ChangeLog    |   10 ++++++++++
 lib/sha256.h |    4 ++--
 lib/sha512.h |    4 ++--
 3 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a84039a..23563dc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2008-07-31  Jim Meyering  <address@hidden>
+
+       sha256.h: correct definition on SHA224_DIGEST_SIZE
+       * lib/sha256.h (SHA224_DIGEST_SIZE): Define to 28, not 24.
+       Reported by Paulie Pena IV <address@hidden>.
+       Define as 224 / 8, rather than as a literal.
+       (SHA256_DIGEST_SIZE): Define as 256/8 rather than equivalent literal.
+       * lib/sha512.h (SHA384_DIGEST_SIZE): Likewise, define as equiv: 384/8.
+       (SHA512_DIGEST_SIZE): Likewise, define as equivalent quotient: 512/8.
+
 2008-07-28  Jim Meyering  <address@hidden>

        bootstrap: work also when there are no .po files in po/
diff --git a/lib/sha256.h b/lib/sha256.h
index 3aa1ce9..a63b201 100644
--- a/lib/sha256.h
+++ b/lib/sha256.h
@@ -31,8 +31,8 @@ struct sha256_ctx
   uint32_t buffer[32];
 };

-enum { SHA224_DIGEST_SIZE = 24 };
-enum { SHA256_DIGEST_SIZE = 32 };
+enum { SHA224_DIGEST_SIZE = 224 / 8 };
+enum { SHA256_DIGEST_SIZE = 256 / 8 };

 /* Initialize structure containing state of computation. */
 extern void sha256_init_ctx (struct sha256_ctx *ctx);
diff --git a/lib/sha512.h b/lib/sha512.h
index 84fe559..ed12d54 100644
--- a/lib/sha512.h
+++ b/lib/sha512.h
@@ -32,8 +32,8 @@ struct sha512_ctx
   u64 buffer[32];
 };

-enum { SHA384_DIGEST_SIZE = 48 };
-enum { SHA512_DIGEST_SIZE = 64 };
+enum { SHA384_DIGEST_SIZE = 384 / 8 };
+enum { SHA512_DIGEST_SIZE = 512 / 8 };

 /* Initialize structure containing state of computation. */
 extern void sha512_init_ctx (struct sha512_ctx *ctx);
--
1.6.0.rc1.2.gc4577




reply via email to

[Prev in Thread] Current Thread [Next in Thread]