-/* $OpenBSD: sha256.c,v 1.12 2023/03/26 16:40:07 jsing Exp $ */
+/* $OpenBSD: sha256.c,v 1.13 2023/03/26 17:06:14 jsing Exp $ */
/* ====================================================================
* Copyright (c) 2004 The OpenSSL Project. All rights reserved
* according to the OpenSSL license [found in ../../LICENSE].
SHA224_Init(SHA256_CTX *c)
{
memset (c, 0, sizeof(*c));
+
c->h[0] = 0xc1059ed8UL;
c->h[1] = 0x367cd507UL;
c->h[2] = 0x3070dd17UL;
c->h[5] = 0x68581511UL;
c->h[6] = 0x64f98fa7UL;
c->h[7] = 0xbefa4fa4UL;
+
c->md_len = SHA224_DIGEST_LENGTH;
+
return 1;
}
SHA256_Init(SHA256_CTX *c)
{
memset (c, 0, sizeof(*c));
+
c->h[0] = 0x6a09e667UL;
c->h[1] = 0xbb67ae85UL;
c->h[2] = 0x3c6ef372UL;
c->h[5] = 0x9b05688cUL;
c->h[6] = 0x1f83d9abUL;
c->h[7] = 0x5be0cd19UL;
+
c->md_len = SHA256_DIGEST_LENGTH;
+
return 1;
}
if (md == NULL)
md = m;
+
SHA224_Init(&c);
SHA256_Update(&c, d, n);
SHA256_Final(md, &c);
+
explicit_bzero(&c, sizeof(c));
+
return (md);
}
if (md == NULL)
md = m;
+
SHA256_Init(&c);
SHA256_Update(&c, d, n);
SHA256_Final(md, &c);
+
explicit_bzero(&c, sizeof(c));
+
return (md);
}
#define HASH_FINAL SHA256_Final
#define HASH_BLOCK_DATA_ORDER sha256_block_data_order
#ifndef SHA256_ASM
- static
+static
#endif
- void sha256_block_data_order (SHA256_CTX *ctx, const void *in, size_t num);
+void sha256_block_data_order (SHA256_CTX *ctx, const void *in, size_t num);
#include "md32_common.h"
ctx->h[5] += f;
ctx->h[6] += g;
ctx->h[7] += h;
-
}
}
-/* $OpenBSD: sha512.c,v 1.17 2023/03/26 16:40:07 jsing Exp $ */
+/* $OpenBSD: sha512.c,v 1.18 2023/03/26 17:06:14 jsing Exp $ */
/* ====================================================================
* Copyright (c) 2004 The OpenSSL Project. All rights reserved
* according to the OpenSSL license [found in ../../LICENSE].
int
SHA384_Update(SHA512_CTX *c, const void *data, size_t len)
{
- return SHA512_Update (c, data, len);
+ return SHA512_Update(c, data, len);
}
void
memcpy(c->u.p, data, sizeof(c->u.p)),
data = c->u.p;
#endif
- sha512_block_data_order (c, data, 1);
+ sha512_block_data_order(c, data, 1);
}
unsigned char *
if (md == NULL)
md = m;
+
SHA384_Init(&c);
SHA512_Update(&c, d, n);
SHA512_Final(md, &c);
+
explicit_bzero(&c, sizeof(c));
+
return (md);
}
if (md == NULL)
md = m;
+
SHA512_Init(&c);
SHA512_Update(&c, d, n);
SHA512_Final(md, &c);
+
explicit_bzero(&c, sizeof(c));
+
return (md);
}