]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
Revert changes to sha256.c
authorNiels Möller <nisse@lysator.liu.se>
Wed, 30 Oct 2024 09:20:34 +0000 (10:20 +0100)
committerNiels Möller <nisse@lysator.liu.se>
Sun, 22 Jun 2025 19:11:04 +0000 (21:11 +0200)
sha2-internal.h
sha256.c

index 58e99b227b26e6a30367f1f360bae35e24441f58..93080bee67a633a3ae7edae02b001421173a34c5 100644 (file)
@@ -36,9 +36,6 @@
 
 #include "nettle-types.h"
 
-extern const uint32_t _nettle_sha224_iv[_SHA256_DIGEST_LENGTH];
-extern const uint32_t _nettle_sha256_iv[_SHA256_DIGEST_LENGTH];
-
 /* Internal compression function. STATE points to 8 uint32_t words,
    DATA points to 64 bytes of input data, possibly unaligned, and K
    points to the table of constants. */
index d25729477688718cc4ff099693824c871aa98da3..a2a5d4236cbd1ba2cbe193fe72f3b90a0b833b36 100644 (file)
--- a/sha256.c
+++ b/sha256.c
@@ -79,17 +79,19 @@ sha256_compress(uint32_t *state, const uint8_t *input)
 
 #define COMPRESS(ctx, data) (sha256_compress((ctx)->state, (data)))
 
-/* Initial values, also generated by the shadata program. */
-const uint32_t _nettle_sha256_iv[_SHA256_DIGEST_LENGTH] =
+/* Initialize the SHA values */
+
+void
+sha256_init(struct sha256_ctx *ctx)
+{
+  /* Initial values, also generated by the shadata program. */
+  static const uint32_t H0[_SHA256_DIGEST_LENGTH] =
   {
     0x6a09e667UL, 0xbb67ae85UL, 0x3c6ef372UL, 0xa54ff53aUL, 
     0x510e527fUL, 0x9b05688cUL, 0x1f83d9abUL, 0x5be0cd19UL, 
   };
 
-void
-sha256_init(struct sha256_ctx *ctx)
-{
-  memcpy(ctx->state, _nettle_sha256_iv, sizeof(ctx->state));
+  memcpy(ctx->state, H0, sizeof(H0));
 
   /* Initialize bit count */
   ctx->count = 0;
@@ -154,19 +156,19 @@ sha256_digest(struct sha256_ctx *ctx,
   sha256_init(ctx);
 }
 
-/* SHA224 variant. */
+/* sha224 variant. */
 
-/* Initial values. Low 32 bits of the initial values for sha384. */
-const uint32_t _nettle_sha224_iv[_SHA256_DIGEST_LENGTH] =
+void
+sha224_init(struct sha256_ctx *ctx)
+{
+  /* Initial values. Low 32 bits of the initial values for sha384. */
+  static const uint32_t H0[_SHA256_DIGEST_LENGTH] =
   {
     0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
     0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4,
   };
 
-void
-sha224_init(struct sha256_ctx *ctx)
-{
-  memcpy(ctx->state, _nettle_sha224_iv, sizeof(ctx->state));
+  memcpy(ctx->state, H0, sizeof(H0));
 
   /* Initialize bit count */
   ctx->count = 0;