#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. */
#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;
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;