Module Name: src
Committed By: joerg
Date: Thu Jun 25 14:05:18 UTC 2009
Modified Files:
src/common/lib/libc/hash/sha2: sha2.c
Log Message:
Fix initialisation of SHA224.
To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/common/lib/libc/hash/sha2/sha2.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/common/lib/libc/hash/sha2/sha2.c
diff -u src/common/lib/libc/hash/sha2/sha2.c:1.17 src/common/lib/libc/hash/sha2/sha2.c:1.18
--- src/common/lib/libc/hash/sha2/sha2.c:1.17 Fri Jun 19 05:09:09 2009
+++ src/common/lib/libc/hash/sha2/sha2.c Thu Jun 25 14:05:18 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: sha2.c,v 1.17 2009/06/19 05:09:09 tsutsui Exp $ */
+/* $NetBSD: sha2.c,v 1.18 2009/06/25 14:05:18 joerg Exp $ */
/* $KAME: sha2.c,v 1.9 2003/07/20 00:28:38 itojun Exp $ */
/*
@@ -43,7 +43,7 @@
#include <sys/cdefs.h>
#if defined(_KERNEL) || defined(_STANDALONE)
-__KERNEL_RCSID(0, "$NetBSD: sha2.c,v 1.17 2009/06/19 05:09:09 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sha2.c,v 1.18 2009/06/25 14:05:18 joerg Exp $");
#include <sys/param.h> /* XXX: to pull <machine/macros.h> for vax memset(9) */
#include <lib/libkern/libkern.h>
@@ -51,7 +51,7 @@
#else
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: sha2.c,v 1.17 2009/06/19 05:09:09 tsutsui Exp $");
+__RCSID("$NetBSD: sha2.c,v 1.18 2009/06/25 14:05:18 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
@@ -624,9 +624,10 @@
if (context == NULL)
return 1;
+ /* The state and buffer size are driven by SHA256, not by SHA224. */
memcpy(context->state, sha224_initial_hash_value,
- (size_t)(SHA224_DIGEST_LENGTH));
- memset(context->buffer, 0, (size_t)(SHA224_BLOCK_LENGTH));
+ (size_t)(SHA256_DIGEST_LENGTH));
+ memset(context->buffer, 0, (size_t)(SHA256_BLOCK_LENGTH));
context->bitcount = 0;
return 1;