Jim Meyering <[EMAIL PROTECTED]> writes:

> Simon Josefsson <[EMAIL PROTECTED]> wrote:
>
>> Jim Meyering <[EMAIL PROTECTED]> writes:
>>
>>> FYI, I've just created the sha256 and sha512 modules and
>>> moved the remaining sha*-related files from coreutils/{lib,m4}
>>> into coreutils/gl/{lib,m4}.
>>>
>>>     http://git.sv.gnu.org/gitweb/?p=coreutils.git;a=commitdiff;h=f33599c1441
>>
>> Looks fine.  Would you consider adding define's for the digest size in
>> the *.h files?  Something like:
>>
>> #define SHA256_DIGEST_SIZE 32
>>
>> #define SHA384_DIGEST_SIZE 48
>>
>> #define SHA512_DIGEST_SIZE 64
>>
>> The define's are useful when declaring local variables statically to
>> hold the output digest.
>
> Sure.  Please send a patch.
> SHA224, too, I suppose?
> I have a preference for using enum symbols, if that works for you.
>
> enum { SHA512_DIGEST_SIZE = 64 };

Sure.  See below.  I was unsure whether to put both declarations in the
same enum or not.  I'm not sure what the preferred style is.

/Simon

2008-03-03  Simon Josefsson  <[EMAIL PROTECTED]>

        * sha256.h: Add SHA224_DIGEST_SIZE, SHA256_DIGEST_SIZE.

        * sha512.h: Add SHA384_DIGEST_SIZE, SHA512_DIGEST_SIZE.

diff --git a/gl/lib/sha256.h b/gl/lib/sha256.h
index 9fd83c9..c35d6c1 100644
--- a/gl/lib/sha256.h
+++ b/gl/lib/sha256.h
@@ -31,6 +31,8 @@ struct sha256_ctx
   uint32_t buffer[32];
 };
 
+enum { SHA224_DIGEST_SIZE = 24 };
+enum { SHA256_DIGEST_SIZE = 32 };
 
 /* Initialize structure containing state of computation. */
 extern void sha256_init_ctx (struct sha256_ctx *ctx);
diff --git a/gl/lib/sha512.h b/gl/lib/sha512.h
index 7ee3ac4..84fe559 100644
--- a/gl/lib/sha512.h
+++ b/gl/lib/sha512.h
@@ -32,6 +32,8 @@ struct sha512_ctx
   u64 buffer[32];
 };
 
+enum { SHA384_DIGEST_SIZE = 48 };
+enum { SHA512_DIGEST_SIZE = 64 };
 
 /* Initialize structure containing state of computation. */
 extern void sha512_init_ctx (struct sha512_ctx *ctx);


Reply via email to