## -*-makefile-*-
##
-## $Id: Makefile.m4,v 1.43 2000/10/08 16:01:26 mdw Exp $
+## $Id: Makefile.m4,v 1.44 2000/10/15 17:49:00 mdw Exp $
##
## Makefile for Catacomb
##
##----- Revision history ----------------------------------------------------
##
## $Log: Makefile.m4,v $
+## Revision 1.44 2000/10/15 17:49:00 mdw
+## New SHA variants with longer outputs.
+##
## Revision 1.43 2000/10/08 16:01:26 mdw
## Add binary poly arithmetic. Tidy table generation stuff. Distribute
## calc prototypes.
define(`cipher_modes', `_(ecb) _(cbc) _(cfb) _(ofb) _(counter)')
define(`hashes', `dnl
-_(md5) _(md4) _(sha) _(tiger) dnl
+_(md5) _(md4) _(tiger) dnl
+_(sha) _(sha256) _(sha384) _(sha512) dnl
_(rmd128) _(rmd160) _(rmd256) _(rmd320)')
define(`hash_modes', `_(mgf) _(hmac)')
--- /dev/null
+/* -*-c-*-
+ *
+ * $Id: sha256.c,v 1.1 2000/10/15 17:48:14 mdw Exp $
+ *
+ * Implementation of the SHA-256 hash function
+ *
+ * (c) 2000 Straylight/Edgeware
+ */
+
+/*----- Licensing notice --------------------------------------------------*
+ *
+ * This file is part of Catacomb.
+ *
+ * Catacomb is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * Catacomb is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with Catacomb; if not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ */
+
+/*----- Revision history --------------------------------------------------*
+ *
+ * $Log: sha256.c,v $
+ * Revision 1.1 2000/10/15 17:48:14 mdw
+ * New SHA variants with longer outputs.
+ *
+ */
+
+/*----- Header files ------------------------------------------------------*/
+
+#include <mLib/bits.h>
+
+#include "ghash.h"
+#include "ghash-def.h"
+#include "hash.h"
+#include "sha256.h"
+
+/*----- Main code ---------------------------------------------------------*/
+
+/* --- @sha256_compress@ --- *
+ *
+ * Arguments: @sha256_ctx *ctx@ = pointer to context block
+ * @const void *sbuf@ = pointer to buffer of appropriate size
+ *
+ * Returns: ---
+ *
+ * Use: SHA-256 compression function.
+ */
+
+void sha256_compress(sha256_ctx *ctx, const void *sbuf)
+{
+ uint32 a, b, c, d, e, f, g, h;
+ uint32 buf[64];
+
+ /* --- Fetch the chaining variables --- */
+
+ a = ctx->a;
+ b = ctx->b;
+ c = ctx->c;
+ d = ctx->d;
+ e = ctx->e;
+ f = ctx->f;
+ g = ctx->g;
+ h = ctx->h;
+
+ /* --- Definitions for round functions --- */
+
+#define CH(x, y, z) (((x) & (y)) | (~(x) & (z)))
+#define MAJ(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z)))
+
+#define S0(x) (ROR32((x), 2) ^ ROR32((x), 13) ^ ROR32((x), 22))
+#define S1(x) (ROR32((x), 6) ^ ROR32((x), 11) ^ ROR32((x), 25))
+#define s0(x) (ROR32((x), 7) ^ ROR32((x), 18) ^ LSR32((x), 3))
+#define s1(x) (ROR32((x), 17) ^ ROR32((x), 19) ^ LSR32((x), 10))
+
+#define T(a, b, c, d, e, f, g, h, i, k) do { \
+ uint32 t1 = h + S1(e) + CH(e, f, g) + k + buf[i]; \
+ uint32 t2 = S0(a) + MAJ(a, b, c); \
+ d += t1; h = t1 + t2; \
+} while (0)
+
+ /* --- Fetch and expand the buffer contents --- */
+
+ {
+ int i;
+ const octet *p;
+
+ for (i = 0, p = sbuf; i < 16; i++, p += 4)
+ buf[i] = LOAD32(p);
+ for (i = 16; i < 64; i++)
+ buf[i] = s1(buf[i - 2]) + buf[i - 7] + s0(buf[i - 15]) + buf[i - 16];
+ }
+
+ /* --- The main compression function --- */
+
+ T(a, b, c, d, e, f, g, h, 0, 0x428a2f98);
+ T(h, a, b, c, d, e, f, g, 1, 0x71374491);
+ T(g, h, a, b, c, d, e, f, 2, 0xb5c0fbcf);
+ T(f, g, h, a, b, c, d, e, 3, 0xe9b5dba5);
+ T(e, f, g, h, a, b, c, d, 4, 0x3956c25b);
+ T(d, e, f, g, h, a, b, c, 5, 0x59f111f1);
+ T(c, d, e, f, g, h, a, b, 6, 0x923f82a4);
+ T(b, c, d, e, f, g, h, a, 7, 0xab1c5ed5);
+ T(a, b, c, d, e, f, g, h, 8, 0xd807aa98);
+ T(h, a, b, c, d, e, f, g, 9, 0x12835b01);
+ T(g, h, a, b, c, d, e, f, 10, 0x243185be);
+ T(f, g, h, a, b, c, d, e, 11, 0x550c7dc3);
+ T(e, f, g, h, a, b, c, d, 12, 0x72be5d74);
+ T(d, e, f, g, h, a, b, c, 13, 0x80deb1fe);
+ T(c, d, e, f, g, h, a, b, 14, 0x9bdc06a7);
+ T(b, c, d, e, f, g, h, a, 15, 0xc19bf174);
+ T(a, b, c, d, e, f, g, h, 16, 0xe49b69c1);
+ T(h, a, b, c, d, e, f, g, 17, 0xefbe4786);
+ T(g, h, a, b, c, d, e, f, 18, 0x0fc19dc6);
+ T(f, g, h, a, b, c, d, e, 19, 0x240ca1cc);
+ T(e, f, g, h, a, b, c, d, 20, 0x2de92c6f);
+ T(d, e, f, g, h, a, b, c, 21, 0x4a7484aa);
+ T(c, d, e, f, g, h, a, b, 22, 0x5cb0a9dc);
+ T(b, c, d, e, f, g, h, a, 23, 0x76f988da);
+ T(a, b, c, d, e, f, g, h, 24, 0x983e5152);
+ T(h, a, b, c, d, e, f, g, 25, 0xa831c66d);
+ T(g, h, a, b, c, d, e, f, 26, 0xb00327c8);
+ T(f, g, h, a, b, c, d, e, 27, 0xbf597fc7);
+ T(e, f, g, h, a, b, c, d, 28, 0xc6e00bf3);
+ T(d, e, f, g, h, a, b, c, 29, 0xd5a79147);
+ T(c, d, e, f, g, h, a, b, 30, 0x06ca6351);
+ T(b, c, d, e, f, g, h, a, 31, 0x14292967);
+ T(a, b, c, d, e, f, g, h, 32, 0x27b70a85);
+ T(h, a, b, c, d, e, f, g, 33, 0x2e1b2138);
+ T(g, h, a, b, c, d, e, f, 34, 0x4d2c6dfc);
+ T(f, g, h, a, b, c, d, e, 35, 0x53380d13);
+ T(e, f, g, h, a, b, c, d, 36, 0x650a7354);
+ T(d, e, f, g, h, a, b, c, 37, 0x766a0abb);
+ T(c, d, e, f, g, h, a, b, 38, 0x81c2c92e);
+ T(b, c, d, e, f, g, h, a, 39, 0x92722c85);
+ T(a, b, c, d, e, f, g, h, 40, 0xa2bfe8a1);
+ T(h, a, b, c, d, e, f, g, 41, 0xa81a664b);
+ T(g, h, a, b, c, d, e, f, 42, 0xc24b8b70);
+ T(f, g, h, a, b, c, d, e, 43, 0xc76c51a3);
+ T(e, f, g, h, a, b, c, d, 44, 0xd192e819);
+ T(d, e, f, g, h, a, b, c, 45, 0xd6990624);
+ T(c, d, e, f, g, h, a, b, 46, 0xf40e3585);
+ T(b, c, d, e, f, g, h, a, 47, 0x106aa070);
+ T(a, b, c, d, e, f, g, h, 48, 0x19a4c116);
+ T(h, a, b, c, d, e, f, g, 49, 0x1e376c08);
+ T(g, h, a, b, c, d, e, f, 50, 0x2748774c);
+ T(f, g, h, a, b, c, d, e, 51, 0x34b0bcb5);
+ T(e, f, g, h, a, b, c, d, 52, 0x391c0cb3);
+ T(d, e, f, g, h, a, b, c, 53, 0x4ed8aa4a);
+ T(c, d, e, f, g, h, a, b, 54, 0x5b9cca4f);
+ T(b, c, d, e, f, g, h, a, 55, 0x682e6ff3);
+ T(a, b, c, d, e, f, g, h, 56, 0x748f82ee);
+ T(h, a, b, c, d, e, f, g, 57, 0x78a5636f);
+ T(g, h, a, b, c, d, e, f, 58, 0x84c87814);
+ T(f, g, h, a, b, c, d, e, 59, 0x8cc70208);
+ T(e, f, g, h, a, b, c, d, 60, 0x90befffa);
+ T(d, e, f, g, h, a, b, c, 61, 0xa4506ceb);
+ T(c, d, e, f, g, h, a, b, 62, 0xbef9a3f7);
+ T(b, c, d, e, f, g, h, a, 63, 0xc67178f2);
+
+ /* --- Update the chaining variables --- */
+
+ ctx->a += a;
+ ctx->b += b;
+ ctx->c += c;
+ ctx->d += d;
+ ctx->e += e;
+ ctx->f += f;
+ ctx->g += g;
+ ctx->h += h;
+}
+
+/* --- @sha256_init@ --- *
+ *
+ * Arguments: @sha256_ctx *ctx@ = pointer to context block to initialize
+ *
+ * Returns: ---
+ *
+ * Use: Initializes a context block ready for hashing.
+ */
+
+void sha256_init(sha256_ctx *ctx)
+{
+ ctx->a = 0x6a09e667;
+ ctx->b = 0xbb67ae85;
+ ctx->c = 0x3c6ef372;
+ ctx->d = 0xa54ff53a;
+ ctx->e = 0x510e527f;
+ ctx->f = 0x9b05688c;
+ ctx->g = 0x1f83d9ab;
+ ctx->h = 0x5be0cd19;
+ ctx->off = 0;
+ ctx->nl = ctx->nh = 0;
+}
+
+/* --- @sha256_set@ --- *
+ *
+ * Arguments: @sha256_ctx *ctx@ = pointer to context block
+ * @const void *buf@ = pointer to state buffer
+ * @unsigned long count@ = current count of bytes processed
+ *
+ * Returns: ---
+ *
+ * Use: Initializes a context block from a given state. This is
+ * useful in cases where the initial hash state is meant to be
+ * secret, e.g., for NMAC and HMAC support.
+ */
+
+void sha256_set(sha256_ctx *ctx, const void *buf, unsigned long count)
+{
+ const octet *p = buf;
+ ctx->a = LOAD32(p + 0);
+ ctx->b = LOAD32(p + 4);
+ ctx->c = LOAD32(p + 8);
+ ctx->d = LOAD32(p + 12);
+ ctx->e = LOAD32(p + 16);
+ ctx->f = LOAD32(p + 20);
+ ctx->g = LOAD32(p + 24);
+ ctx->h = LOAD32(p + 28);
+ ctx->off = 0;
+ ctx->nl = U32(count);
+ ctx->nh = U32(((count & ~MASK32) >> 16) >> 16);
+}
+
+/* --- @sha256_hash@ --- *
+ *
+ * Arguments: @sha256_ctx *ctx@ = pointer to context block
+ * @const void *buf@ = buffer of data to hash
+ * @size_t sz@ = size of buffer to hash
+ *
+ * Returns: ---
+ *
+ * Use: Hashes a buffer of data. The buffer may be of any size and
+ * alignment.
+ */
+
+void sha256_hash(sha256_ctx *ctx, const void *buf, size_t sz)
+{
+ HASH_BUFFER(SHA256, sha256, ctx, buf, sz);
+}
+
+/* --- @sha256_done@ --- *
+ *
+ * Arguments: @sha256_ctx *ctx@ = pointer to context block
+ * @void *hash@ = pointer to output buffer
+ *
+ * Returns: ---
+ *
+ * Use: Returns the hash of the data read so far.
+ */
+
+void sha256_done(sha256_ctx *ctx, void *hash)
+{
+ octet *p = hash;
+ HASH_PAD(SHA256, sha256, ctx, 0x80, 0, 8);
+ STORE32(ctx->buf + SHA256_BUFSZ - 8, (ctx->nl >> 29) | (ctx->nh << 3));
+ STORE32(ctx->buf + SHA256_BUFSZ - 4, ctx->nl << 3);
+ sha256_compress(ctx, ctx->buf);
+ STORE32(p + 0, ctx->a);
+ STORE32(p + 4, ctx->b);
+ STORE32(p + 8, ctx->c);
+ STORE32(p + 12, ctx->d);
+ STORE32(p + 16, ctx->e);
+ STORE32(p + 20, ctx->f);
+ STORE32(p + 24, ctx->g);
+ STORE32(p + 28, ctx->h);
+}
+
+/* --- @sha256_state@ --- *
+ *
+ * Arguments: @sha256_ctx *ctx@ = pointer to context
+ * @void *state@ = pointer to buffer for current state
+ *
+ * Returns: Number of bytes written to the hash function so far.
+ *
+ * Use: Returns the current state of the hash function such that
+ * it can be passed to @sha256_set@.
+ */
+
+unsigned long sha256_state(sha256_ctx *ctx, void *state)
+{
+ octet *p = state;
+ STORE32(p + 0, ctx->a);
+ STORE32(p + 4, ctx->b);
+ STORE32(p + 8, ctx->c);
+ STORE32(p + 12, ctx->d);
+ STORE32(p + 16, ctx->e);
+ STORE32(p + 20, ctx->f);
+ STORE32(p + 24, ctx->g);
+ STORE32(p + 28, ctx->h);
+ return (ctx->nl | ((ctx->nh << 16) << 16));
+}
+
+/* --- Generic interface --- */
+
+GHASH_DEF(SHA256, sha256)
+
+/* --- Test code --- */
+
+HASH_TEST(SHA256, sha256)
+
+/*----- That's all, folks -------------------------------------------------*/
--- /dev/null
+/* -*-c-*-
+ *
+ * $Id: sha256.h,v 1.1 2000/10/15 17:48:15 mdw Exp $
+ *
+ * Implementation of the SHA-256 hash function
+ *
+ * (c) 2000 Straylight/Edgeware
+ */
+
+/*----- Licensing notice --------------------------------------------------*
+ *
+ * This file is part of Catacomb.
+ *
+ * Catacomb is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * Catacomb is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with Catacomb; if not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ */
+
+/*----- Revision history --------------------------------------------------*
+ *
+ * $Log: sha256.h,v $
+ * Revision 1.1 2000/10/15 17:48:15 mdw
+ * New SHA variants with longer outputs.
+ *
+ */
+
+/*----- Notes on the SHA-256 hash function ----------------------------------*
+ *
+ * SHA-1 (Secure Hash Algorithm) was designed by the NSA, for use with the
+ * Digital Signature Algorithm. This is an evolution with a larger output
+ * size, intended to provide security commensurate with 128-bit AES. At the
+ * time of writing, SHA-256 is very new, and can't be trusted too far.
+ */
+
+#ifndef CATACOMB_SHA256_H
+#define CATACOMB_SHA256_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/*----- Header files ------------------------------------------------------*/
+
+#include <mLib/bits.h>
+
+#ifndef CATACOMB_GHASH_H
+# include "ghash.h"
+#endif
+
+/*----- Magic numbers -----------------------------------------------------*/
+
+#define SHA256_BUFSZ 64
+#define SHA256_HASHSZ 32
+
+/*----- Data structures ---------------------------------------------------*/
+
+typedef struct sha256_ctx {
+ uint32 a, b, c, d, e, f, g, h; /* Chaining variables */
+ uint32 nl, nh; /* Byte count so far */
+ unsigned off; /* Offset into buffer */
+ octet buf[SHA256_BUFSZ]; /* Accumulation buffer */
+} sha256_ctx;
+
+/*----- Functions provided ------------------------------------------------*/
+
+/* --- @sha256_compress@ --- *
+ *
+ * Arguments: @sha256_ctx *ctx@ = pointer to context block
+ * @const void *sbuf@ = pointer to buffer of appropriate size
+ *
+ * Returns: ---
+ *
+ * Use: SHA-256 compression function.
+ */
+
+extern void sha256_compress(sha256_ctx */*ctx*/, const void */*sbuf*/);
+
+/* --- @sha256_init@ --- *
+ *
+ * Arguments: @sha256_ctx *ctx@ = pointer to context block to initialize
+ *
+ * Returns: ---
+ *
+ * Use: Initializes a context block ready for hashing.
+ */
+
+extern void sha256_init(sha256_ctx */*ctx*/);
+
+/* --- @sha256_set@ --- *
+ *
+ * Arguments: @sha256_ctx *ctx@ = pointer to context block
+ * @const void *buf@ = pointer to state buffer
+ * @unsigned long count@ = current count of bytes processed
+ *
+ * Returns: ---
+ *
+ * Use: Initializes a context block from a given state. This is
+ * useful in cases where the initial hash state is meant to be
+ * secret, e.g., for NMAC and HMAC support.
+ */
+
+extern void sha256_set(sha256_ctx */*ctx*/, const void */*buf*/,
+ unsigned long /*count*/);
+
+/* --- @sha256_hash@ --- *
+ *
+ * Arguments: @sha256_ctx *ctx@ = pointer to context block
+ * @const void *buf@ = buffer of data to hash
+ * @size_t sz@ = size of buffer to hash
+ *
+ * Returns: ---
+ *
+ * Use: Hashes a buffer of data. The buffer may be of any size and
+ * alignment.
+ */
+
+extern void sha256_hash(sha256_ctx */*ctx*/,
+ const void */*buf*/, size_t /*sz*/);
+
+/* --- @sha256_done@ --- *
+ *
+ * Arguments: @sha256_ctx *ctx@ = pointer to context block
+ * @void *hash@ = pointer to output buffer
+ *
+ * Returns: ---
+ *
+ * Use: Returns the hash of the data read so far.
+ */
+
+extern void sha256_done(sha256_ctx */*ctx*/, void */*hash*/);
+
+/* --- @sha256_state@ --- *
+ *
+ * Arguments: @sha256_ctx *ctx@ = pointer to context
+ * @void *state@ = pointer to buffer for current state
+ *
+ * Returns: Number of bytes written to the hash function so far.
+ *
+ * Use: Returns the current state of the hash function such that
+ * it can be passed to @sha256_set@.
+ */
+
+extern unsigned long sha256_state(sha256_ctx */*ctx*/, void */*state*/);
+
+/*----- Generic hash interface --------------------------------------------*/
+
+extern const gchash sha256;
+
+/*----- That's all, folks -------------------------------------------------*/
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
--- /dev/null
+/* -*-c-*-
+ *
+ * $Id: sha384.c,v 1.1 2000/10/15 17:48:15 mdw Exp $
+ *
+ * Stub code for SHA-384
+ */
+
+#include "ghash.h"
+#include "ghash-def.h"
+#include "hash.h"
+#include "sha384.h"
+
+GHASH_DEF(SHA384, sha384)
+HASH_TEST(SHA384, sha384)
--- /dev/null
+/* -*-c-*-
+ *
+ * $Id: sha384.h,v 1.1 2000/10/15 17:48:15 mdw Exp $
+ *
+ * Stub header for SHA-384
+ */
+
+#ifndef CATACOMB_SHA384_H
+#define CATACOMB_SHA384_H
+
+#include "sha512.h"
+
+#endif
--- /dev/null
+/* -*-c-*-
+ *
+ * $Id: sha512.c,v 1.1 2000/10/15 17:48:15 mdw Exp $
+ *
+ * Implementation of the SHA-512 hash function
+ *
+ * (c) 2000 Straylight/Edgeware
+ */
+
+/*----- Licensing notice --------------------------------------------------*
+ *
+ * This file is part of Catacomb.
+ *
+ * Catacomb is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * Catacomb is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with Catacomb; if not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ */
+
+/*----- Revision history --------------------------------------------------*
+ *
+ * $Log: sha512.c,v $
+ * Revision 1.1 2000/10/15 17:48:15 mdw
+ * New SHA variants with longer outputs.
+ *
+ */
+
+/*----- Header files ------------------------------------------------------*/
+
+#include <mLib/bits.h>
+
+#include "ghash.h"
+#include "ghash-def.h"
+#include "hash.h"
+#include "sha512.h"
+
+/*----- Main code ---------------------------------------------------------*/
+
+/* --- @sha512_compress@, @sha384_compress@ --- *
+ *
+ * Arguments: @sha512_ctx *ctx@ = pointer to context block
+ * @const void *sbuf@ = pointer to buffer of appropriate size
+ *
+ * Returns: ---
+ *
+ * Use: SHA-512 compression function.
+ */
+
+void sha512_compress(sha512_ctx *ctx, const void *sbuf)
+{
+ kludge64 a, b, c, d, e, f, g, h;
+ kludge64 buf[80];
+ int i;
+
+ static const kludge64 K[80] = {
+ X64(428a2f98, d728ae22), X64(71374491, 23ef65cd),
+ X64(b5c0fbcf, ec4d3b2f), X64(e9b5dba5, 8189dbbc),
+ X64(3956c25b, f348b538), X64(59f111f1, b605d019),
+ X64(923f82a4, af194f9b), X64(ab1c5ed5, da6d8118),
+ X64(d807aa98, a3030242), X64(12835b01, 45706fbe),
+ X64(243185be, 4ee4b28c), X64(550c7dc3, d5ffb4e2),
+ X64(72be5d74, f27b896f), X64(80deb1fe, 3b1696b1),
+ X64(9bdc06a7, 25c71235), X64(c19bf174, cf692694),
+ X64(e49b69c1, 9ef14ad2), X64(efbe4786, 384f25e3),
+ X64(0fc19dc6, 8b8cd5b5), X64(240ca1cc, 77ac9c65),
+ X64(2de92c6f, 592b0275), X64(4a7484aa, 6ea6e483),
+ X64(5cb0a9dc, bd41fbd4), X64(76f988da, 831153b5),
+ X64(983e5152, ee66dfab), X64(a831c66d, 2db43210),
+ X64(b00327c8, 98fb213f), X64(bf597fc7, beef0ee4),
+ X64(c6e00bf3, 3da88fc2), X64(d5a79147, 930aa725),
+ X64(06ca6351, e003826f), X64(14292967, 0a0e6e70),
+ X64(27b70a85, 46d22ffc), X64(2e1b2138, 5c26c926),
+ X64(4d2c6dfc, 5ac42aed), X64(53380d13, 9d95b3df),
+ X64(650a7354, 8baf63de), X64(766a0abb, 3c77b2a8),
+ X64(81c2c92e, 47edaee6), X64(92722c85, 1482353b),
+ X64(a2bfe8a1, 4cf10364), X64(a81a664b, bc423001),
+ X64(c24b8b70, d0f89791), X64(c76c51a3, 0654be30),
+ X64(d192e819, d6ef5218), X64(d6990624, 5565a910),
+ X64(f40e3585, 5771202a), X64(106aa070, 32bbd1b8),
+ X64(19a4c116, b8d2d0c8), X64(1e376c08, 5141ab53),
+ X64(2748774c, df8eeb99), X64(34b0bcb5, e19b48a8),
+ X64(391c0cb3, c5c95a63), X64(4ed8aa4a, e3418acb),
+ X64(5b9cca4f, 7763e373), X64(682e6ff3, d6b2b8a3),
+ X64(748f82ee, 5defb2fc), X64(78a5636f, 43172f60),
+ X64(84c87814, a1f0ab72), X64(8cc70208, 1a6439ec),
+ X64(90befffa, 23631e28), X64(a4506ceb, de82bde9),
+ X64(bef9a3f7, b2c67915), X64(c67178f2, e372532b),
+ X64(ca273ece, ea26619c), X64(d186b8c7, 21c0c207),
+ X64(eada7dd6, cde0eb1e), X64(f57d4f7f, ee6ed178),
+ X64(06f067aa, 72176fba), X64(0a637dc5, a2c898a6),
+ X64(113f9804, bef90dae), X64(1b710b35, 131c471b),
+ X64(28db77f5, 23047d84), X64(32caab7b, 40c72493),
+ X64(3c9ebe0a, 15c9bebc), X64(431d67c4, 9c100d4c),
+ X64(4cc5d4be, cb3e42b6), X64(597f299c, fc657e2a),
+ X64(5fcb6fab, 3ad6faec), X64(6c44198c, 4a475817)
+ };
+
+ /* --- Fetch the chaining variables --- */
+
+ a = ctx->a;
+ b = ctx->b;
+ c = ctx->c;
+ d = ctx->d;
+ e = ctx->e;
+ f = ctx->f;
+ g = ctx->g;
+ h = ctx->h;
+
+ /* --- Definitions for round functions --- */
+
+#define CH(d, x, y, z) do { \
+ kludge64 _x; AND64((d), (x), (y)); CPL64(_x, (x)); \
+ AND64(_x, _x, (z)); OR64((d), (d), _x); \
+} while (0)
+
+#define MAJ(d, x, y, z) do { \
+ kludge64 _x; AND64((d), (x), (y)); AND64(_x, (x), (z)); \
+ OR64((d), (d), _x); AND64(_x, (y), (z)); OR64((d), (d), _x); \
+} while (0)
+
+#define SIGMA(d, x, i, j, k, last, what) do { \
+ kludge64 _x; ROR64_((d), (x), (i)); ROR64_(_x, (x), (j)); \
+ XOR64((d), (d), _x); last##64_(_x, (x), (k)); XOR64((d), (d), _x); \
+} while (0)
+
+#define S0(d, x) SIGMA(d, x, 28, 34, 39, ROR, S0);
+#define S1(d, x) SIGMA(d, x, 14, 18, 41, ROR, S1);
+#define s0(d, x) SIGMA(d, x, 1, 8, 7, LSR, s0);
+#define s1(d, x) SIGMA(d, x, 19, 61, 6, LSR, s1);
+
+#define T(a, b, c, d, e, f, g, h, i) do { \
+ kludge64 t1, t2, x; \
+ ADD64(t1, buf[i], K[i]); ADD64(t1, t1, h); \
+ S1(x, e); ADD64(t1, t1, x); CH(x, e, f, g); ADD64(t1, t1, x); \
+ S0(t2, a); MAJ(x, a, b, c); ADD64(t2, t2, x); \
+ ADD64(d, d, t1); ADD64(h, t1, t2); \
+} while (0)
+
+ /* --- Fetch and expand the buffer contents --- */
+
+ {
+ const octet *p;
+
+ for (i = 0, p = sbuf; i < 16; i++, p += 8)
+ LOAD64_(buf[i], p);
+ for (i = 16; i < 80; i++) {
+ kludge64 x;
+ buf[i] = buf[i - 7]; s1(x, buf[i - 2]); ADD64(buf[i], buf[i], x);
+ s0(x, buf[i - 15]); ADD64(buf[i], buf[i], x);
+ ADD64(buf[i], buf[i], buf[i - 16]);
+ }
+ }
+
+ /* --- The main compression function --- */
+
+ for (i = 0; i < 80; i += 8) {
+ T(a, b, c, d, e, f, g, h, i + 0);
+ T(h, a, b, c, d, e, f, g, i + 1);
+ T(g, h, a, b, c, d, e, f, i + 2);
+ T(f, g, h, a, b, c, d, e, i + 3);
+ T(e, f, g, h, a, b, c, d, i + 4);
+ T(d, e, f, g, h, a, b, c, i + 5);
+ T(c, d, e, f, g, h, a, b, i + 6);
+ T(b, c, d, e, f, g, h, a, i + 7);
+ }
+
+ /* --- Update the chaining variables --- */
+
+ ADD64(ctx->a, ctx->a, a);
+ ADD64(ctx->b, ctx->b, b);
+ ADD64(ctx->c, ctx->c, c);
+ ADD64(ctx->d, ctx->d, d);
+ ADD64(ctx->e, ctx->e, e);
+ ADD64(ctx->f, ctx->f, f);
+ ADD64(ctx->g, ctx->g, g);
+ ADD64(ctx->h, ctx->h, h);
+}
+
+/* --- @sha512_init@, @sha384_init@ --- *
+ *
+ * Arguments: @sha512_ctx *ctx@ = pointer to context block to initialize
+ *
+ * Returns: ---
+ *
+ * Use: Initializes a context block ready for hashing.
+ */
+
+void sha512_init(sha512_ctx *ctx)
+{
+ SET64(ctx->a, 0x6a09e667, 0xf3bcc908);
+ SET64(ctx->b, 0xbb67ae85, 0x84caa73b);
+ SET64(ctx->c, 0x3c6ef372, 0xfe94f82b);
+ SET64(ctx->d, 0xa54ff53a, 0x5f1d36f1);
+ SET64(ctx->e, 0x510e527f, 0xade682d1);
+ SET64(ctx->f, 0x9b05688c, 0x2b3e6c1f);
+ SET64(ctx->g, 0x1f83d9ab, 0xfb41bd6b);
+ SET64(ctx->h, 0x5be0cd19, 0x137e2179);
+ ctx->off = 0;
+ ctx->nh = ctx->nl = 0;
+}
+
+void sha384_init(sha512_ctx *ctx)
+{
+ SET64(ctx->a, 0xcbbb9d5d, 0xc1059ed8);
+ SET64(ctx->b, 0x629a292a, 0x367cd507);
+ SET64(ctx->c, 0x9159015a, 0x3070dd17);
+ SET64(ctx->d, 0x152fecd8, 0xf70e5939);
+ SET64(ctx->e, 0x67332667, 0xffc00b31);
+ SET64(ctx->f, 0x8eb44a87, 0x68581511);
+ SET64(ctx->g, 0xdb0c2e0d, 0x64f98fa7);
+ SET64(ctx->h, 0x47b5481d, 0xbefa4fa4);
+ ctx->off = 0;
+ ctx->nh = ctx->nl = 0;
+}
+
+/* --- @sha512_set@, @sha384_set@ --- *
+ *
+ * Arguments: @sha512_ctx *ctx@ = pointer to context block
+ * @const void *buf@ = pointer to state buffer
+ * @unsigned long count@ = current count of bytes processed
+ *
+ * Returns: ---
+ *
+ * Use: Initializes a context block from a given state. This is
+ * useful in cases where the initial hash state is meant to be
+ * secret, e.g., for NMAC and HMAC support.
+ */
+
+void sha512_set(sha512_ctx *ctx, const void *buf, unsigned long count)
+{
+ const octet *p = buf;
+ LOAD64_(ctx->a, p + 0);
+ LOAD64_(ctx->b, p + 8);
+ LOAD64_(ctx->c, p + 16);
+ LOAD64_(ctx->d, p + 24);
+ LOAD64_(ctx->e, p + 32);
+ LOAD64_(ctx->f, p + 40);
+ LOAD64_(ctx->g, p + 48);
+ LOAD64_(ctx->h, p + 56);
+ ctx->off = 0;
+ ctx->nl = U32(count);
+ ctx->nh = U32(((count & ~MASK32) >> 16) >> 16);
+}
+
+/* --- @sha512_hash@, @sha384_hash@ --- *
+ *
+ * Arguments: @sha512_ctx *ctx@ = pointer to context block
+ * @const void *buf@ = buffer of data to hash
+ * @size_t sz@ = size of buffer to hash
+ *
+ * Returns: ---
+ *
+ * Use: Hashes a buffer of data. The buffer may be of any size and
+ * alignment.
+ */
+
+void sha512_hash(sha512_ctx *ctx, const void *buf, size_t sz)
+{
+ HASH_BUFFER(SHA512, sha512, ctx, buf, sz);
+}
+
+/* --- @sha512_done@, @sha384_done@ --- *
+ *
+ * Arguments: @sha512_ctx *ctx@ = pointer to context block
+ * @void *hash@ = pointer to output buffer
+ *
+ * Returns: ---
+ *
+ * Use: Returns the hash of the data read so far.
+ */
+
+static void final(sha512_ctx *ctx)
+{
+ HASH_PAD(SHA512, sha512, ctx, 0x80, 0, 16);
+ memset(ctx->buf + SHA512_BUFSZ - 16, 0, 8);
+ STORE32(ctx->buf + SHA512_BUFSZ - 8, (ctx->nl >> 29) | (ctx->nh << 3));
+ STORE32(ctx->buf + SHA512_BUFSZ - 4, ctx->nl << 3);
+ sha512_compress(ctx, ctx->buf);
+}
+
+void sha512_done(sha512_ctx *ctx, void *hash)
+{
+ octet *p = hash;
+ final(ctx);
+ STORE64_(p + 0, ctx->a);
+ STORE64_(p + 8, ctx->b);
+ STORE64_(p + 16, ctx->c);
+ STORE64_(p + 24, ctx->d);
+ STORE64_(p + 32, ctx->e);
+ STORE64_(p + 40, ctx->f);
+ STORE64_(p + 48, ctx->g);
+ STORE64_(p + 56, ctx->h);
+}
+
+void sha384_done(sha384_ctx *ctx, void *hash)
+{
+ octet *p = hash;
+ final(ctx);
+ STORE64_(p + 0, ctx->a);
+ STORE64_(p + 8, ctx->b);
+ STORE64_(p + 16, ctx->c);
+ STORE64_(p + 24, ctx->d);
+ STORE64_(p + 32, ctx->e);
+ STORE64_(p + 40, ctx->f);
+}
+
+/* --- @sha512_state@, @sha384_state@ --- *
+ *
+ * Arguments: @sha512_ctx *ctx@ = pointer to context
+ * @void *state@ = pointer to buffer for current state
+ *
+ * Returns: Number of bytes written to the hash function so far.
+ *
+ * Use: Returns the current state of the hash function such that
+ * it can be passed to @sha512_set@.
+ */
+
+unsigned long sha512_state(sha512_ctx *ctx, void *state)
+{
+ octet *p = state;
+ STORE64_(p + 0, ctx->a);
+ STORE64_(p + 8, ctx->b);
+ STORE64_(p + 16, ctx->c);
+ STORE64_(p + 24, ctx->d);
+ STORE64_(p + 32, ctx->e);
+ STORE64_(p + 40, ctx->f);
+ STORE64_(p + 48, ctx->g);
+ STORE64_(p + 56, ctx->h);
+ return (ctx->nl | ((ctx->nh << 16) << 16));
+}
+
+/* --- Generic interface --- */
+
+GHASH_DEF(SHA512, sha512)
+
+/* --- Test code --- */
+
+HASH_TEST(SHA512, sha512)
+
+/*----- That's all, folks -------------------------------------------------*/
--- /dev/null
+/* -*-c-*-
+ *
+ * $Id: sha512.h,v 1.1 2000/10/15 17:48:15 mdw Exp $
+ *
+ * Implementation of the SHA-512 hash function
+ *
+ * (c) 2000 Straylight/Edgeware
+ */
+
+/*----- Licensing notice --------------------------------------------------*
+ *
+ * This file is part of Catacomb.
+ *
+ * Catacomb is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * Catacomb is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with Catacomb; if not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ */
+
+/*----- Revision history --------------------------------------------------*
+ *
+ * $Log: sha512.h,v $
+ * Revision 1.1 2000/10/15 17:48:15 mdw
+ * New SHA variants with longer outputs.
+ *
+ */
+
+/*----- Notes on the SHA-512 hash function ----------------------------------*
+ *
+ * SHA-1 (Secure Hash Algorithm) was designed by the NSA, for use with the
+ * Digital Signature Algorithm. This is an evolution with a larger output
+ * size, intended to provide security commensurate with 256-bit AES. At the
+ * time of writing, SHA-512 is very new, and can't be trusted too far. There
+ * is also a truncated version, SHA-384, which provides security commensurate
+ * with 192-bit AES.
+ */
+
+#ifndef CATACOMB_SHA512_H
+#define CATACOMB_SHA512_H
+#define CATACOMB_SHA384_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/*----- Header files ------------------------------------------------------*/
+
+#include <mLib/bits.h>
+
+#ifndef CATACOMB_GHASH_H
+# include "ghash.h"
+#endif
+
+/*----- Magic numbers -----------------------------------------------------*/
+
+#define SHA512_BUFSZ 128
+#define SHA512_HASHSZ 64
+
+#define SHA384_BUFSZ 128
+#define SHA384_HASHSZ 48
+
+/*----- Data structures ---------------------------------------------------*/
+
+typedef struct sha512_ctx {
+ kludge64 a, b, c, d, e, f, g, h; /* Chaining variables */
+ uint32 nh, nl; /* Byte count so far */
+ unsigned off; /* Offset into buffer */
+ octet buf[SHA512_BUFSZ]; /* Accumulation buffer */
+} sha512_ctx, sha384_ctx;
+
+/*----- Functions provided ------------------------------------------------*/
+
+/* --- @sha512_compress@, @sha384_compress@ --- *
+ *
+ * Arguments: @sha512_ctx *ctx@ = pointer to context block
+ * @const void *sbuf@ = pointer to buffer of appropriate size
+ *
+ * Returns: ---
+ *
+ * Use: SHA-512 compression function.
+ */
+
+extern void sha512_compress(sha512_ctx */*ctx*/, const void */*sbuf*/);
+#define sha384_compress sha512_compress
+
+/* --- @sha512_init@, @sha384_init@ --- *
+ *
+ * Arguments: @sha512_ctx *ctx@ = pointer to context block to initialize
+ *
+ * Returns: ---
+ *
+ * Use: Initializes a context block ready for hashing.
+ */
+
+extern void sha512_init(sha512_ctx */*ctx*/);
+extern void sha384_init(sha512_ctx */*ctx*/);
+
+/* --- @sha512_set@, @sha384_set@ --- *
+ *
+ * Arguments: @sha512_ctx *ctx@ = pointer to context block
+ * @const void *buf@ = pointer to state buffer
+ * @unsigned long count@ = current count of bytes processed
+ *
+ * Returns: ---
+ *
+ * Use: Initializes a context block from a given state. This is
+ * useful in cases where the initial hash state is meant to be
+ * secret, e.g., for NMAC and HMAC support.
+ */
+
+extern void sha512_set(sha512_ctx */*ctx*/, const void */*buf*/,
+ unsigned long /*count*/);
+#define sha384_set sha512_set
+
+/* --- @sha512_hash@, @sha384_hash@ --- *
+ *
+ * Arguments: @sha512_ctx *ctx@ = pointer to context block
+ * @const void *buf@ = buffer of data to hash
+ * @size_t sz@ = size of buffer to hash
+ *
+ * Returns: ---
+ *
+ * Use: Hashes a buffer of data. The buffer may be of any size and
+ * alignment.
+ */
+
+extern void sha512_hash(sha512_ctx */*ctx*/,
+ const void */*buf*/, size_t /*sz*/);
+#define sha384_hash sha512_hash
+
+/* --- @sha512_done@, @sha384_done@ --- *
+ *
+ * Arguments: @sha512_ctx *ctx@ = pointer to context block
+ * @void *hash@ = pointer to output buffer
+ *
+ * Returns: ---
+ *
+ * Use: Returns the hash of the data read so far.
+ */
+
+extern void sha512_done(sha512_ctx */*ctx*/, void */*hash*/);
+extern void sha384_done(sha512_ctx */*ctx*/, void */*hash*/);
+
+/* --- @sha512_state@, @sha384_state@ --- *
+ *
+ * Arguments: @sha512_ctx *ctx@ = pointer to context
+ * @void *state@ = pointer to buffer for current state
+ *
+ * Returns: Number of bytes written to the hash function so far.
+ *
+ * Use: Returns the current state of the hash function such that
+ * it can be passed to @sha512_set@.
+ */
+
+extern unsigned long sha512_state(sha512_ctx */*ctx*/, void */*state*/);
+#define sha384_state sha512_state
+
+/*----- Generic hash interface --------------------------------------------*/
+
+extern const gchash sha512;
+extern const gchash sha384;
+
+/*----- That's all, folks -------------------------------------------------*/
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif
--- /dev/null
+# $Id: sha256,v 1.1 2000/10/15 17:48:16 mdw Exp $
+#
+# Test vectors for SHA-256
+
+# --- Basic hash function ---
+
+sha256 {
+
+ # --- Test vectors from the definition ---
+
+ "abc"
+ ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad;
+ "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
+ 248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1;
+
+ # --- Other tests to trap regression ---
+
+ ""
+ e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855;
+ "a"
+ ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb;
+ "message digest"
+ f7846f55cf23e14eebeab5b4e1550cad5b509e3348fbc4efa3a1413d393cb650;
+ "abcdefghijklmnopqrstuvwxyz"
+ 71c480df93d6ae2f1efad1447c66c9525e316218cf51fc8d9ed832f2daf18b73;
+ "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
+ 248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1;
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
+ db4bfcbd4da0cd85a60c3c37d3fbd8805c77f15fc6b1fdfe614ee0a7c8fdb4c0;
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890"
+ f371bc4a311f2b009eef952dd83ca80e2b60026c8e935592d0f9c308453c813e;
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+"
+ 4804a2a4759acebe127b62ba651ae601a756ca0b509e4987498224acaffb0d98;
+}
+
+# --- HMAC mode ---
+#
+# Autogenerated, unofficial.
+
+sha256-hmac {
+ "Hi There"
+ 0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b
+ 198a607eb44bfbc69903a0f1cf2bbdc5ba0aa3f3d9ae3c1c7a3b1696a0b68cf7;
+
+ "what do ya want for nothing?"
+ 4a656665
+ 5bdcc146bf60754e6a042426089575c75a003f089d2739839dec58b964ec3843;
+
+ "ÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ"
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ cdcb1220d1ecccea91e53aba3092f962e549fe6ce9ed7fdc43191fbde45c30b0;
+
+ "ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ"
+ 0102030405060708090a0b0c0d0e0f10111213141516171819
+ 82558a389a443c0ea4cc819899f2083a85f0faa3e578f8077a2e3ff46729665b;
+
+ "Test With Truncation"
+ 0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c
+ 7546af01841fc09b1ab9c3749a5f1c17d4f589668a587b2700a9c97c1193cf42;
+
+ "Test Using Larger Than Block-Size Key - Hash Key First"
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 6953025ed96f0c09f80a96f78e6538dbe2e7b820e3dd970e7ddd39091b32352f;
+
+ "Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data"
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 6355ac22e890d0a3c8481a5ca4825bc884d3e7a1ff98a2fc2ac7d8e064c3b2e6;
+}
--- /dev/null
+# $Id: sha384,v 1.1 2000/10/15 17:48:16 mdw Exp $
+#
+# Test vectors for SHA-384
+
+# --- Basic hash function ---
+
+sha384 {
+
+ # --- Test vectors from the definition ---
+
+ "abc"
+ cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7;
+ "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"
+ 09330c33f71147e83d192fc782cd1b4753111b173b3b05d22fa08086e3b0f712fcc7c71a557e2db966c3e9fa91746039;
+
+ # --- Other tests to trap regression ---
+
+ ""
+ 38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b;
+ "a"
+ 54a59b9f22b0b80880d8427e548b7c23abd873486e1f035dce9cd697e85175033caa88e6d57bc35efae0b5afd3145f31;
+ "message digest"
+ 473ed35167ec1f5d8e550368a3db39be54639f828868e9454c239fc8b52e3c61dbd0d8b4de1390c256dcbb5d5fd99cd5;
+ "abcdefghijklmnopqrstuvwxyz"
+ feb67349df3db6f5924815d6c3dc133f091809213731fe5c7b5f4999e463479ff2877f5f2936fa63bb43784b12f3ebb4;
+ "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
+ 3391fdddfc8dc7393707a65b1b4709397cf8b1d162af05abfe8f450de5f36bc6b0455a8520bc4e6f5fe95b1fe3c8452b;
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
+ 1761336e3f7cbfe51deb137f026f89e01a448e3b1fafa64039c1464ee8732f11a5341a6f41e0c202294736ed64db1a84;
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890"
+ b12932b0627d1c060942f5447764155655bd4da0c9afa6dd9b9ef53129af1b8fb0195996d2de9ca0df9d821ffee67026;
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+"
+ f77d169c73427bd30cceff74f822a0209657dfb78c07980509bf8452a3c5d671b7198081898d0a0034e0f7151211fa0f;
+}
+
+# --- HMAC mode ---
+#
+# Autogenerated, unofficial.
+
+sha384-hmac {
+ "Hi There"
+ 0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b
+ 7d87b0fbf4ce50df1fb20c8b686aec32f561ad652a83d4400162bb74edebe45370165bd1523f5b475d25c5b001234b4e;
+
+ "what do ya want for nothing?"
+ 4a656665
+ b0ce1937a8ac0fc573d37b106e76f7629c03ea7ca3b34808d27e1e2823bcab8a1401a4931fd28619c07e03bb86eed6a8;
+
+ "ÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ"
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ e69bd8e862b4f010e4144db3a91c86b8fa565b3697da308c068df51ef3db7dd95ea2e17397a4e6361ea0d493dcdf2348;
+
+ "ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ"
+ 0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f2122232425262728292a2b2c2d2e2f30313233343536373839
+ 1ad20db6df12cc62a9444b4dd9a3181138c7912caed0ac7abb840c2a1388227e57689b24ea64a1a42b6fbbff910eb15c;
+
+ "Test With Truncation"
+ 0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c
+ ca4339d50d33a135f9693a1ec9417353b81953c131903a74666d5b2cf8bf56bd891d5a16c7bcb00c0fd0b202632d71d8;
+
+ "Test Using Larger Than Block-Size Key - Hash Key First"
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ ed3fb5125f5219412bdf7b09997d302e9ebfeb3aa5360fafe6082a896c1a88b01fea01e5f39ebe353e5e66684ad5bad4;
+
+ "Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data Bearing In Mind That This Hash Has An Extraordinarily Large Block Size So The Standard Test Won't Work"
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 375766e947a41e6d1b622ec31f6a33bf495879bfb58405f5f6c6901826a484727dda4175f3ad40fb630c65540bf34683;
+}
--- /dev/null
+# $Id: sha512,v 1.1 2000/10/15 17:48:16 mdw Exp $
+#
+# Test vectors for SHA-512
+
+# --- Basic hash function ---
+
+sha512 {
+
+ # --- Test vectors from the definition ---
+
+ "abc"
+ ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f;
+ "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"
+ 8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909;
+
+ # --- Other tests to trap regression ---
+
+ ""
+ cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e;
+ "a"
+ 1f40fc92da241694750979ee6cf582f2d5d7d28e18335de05abc54d0560e0f5302860c652bf08d560252aa5e74210546f369fbbbce8c12cfc7957b2652fe9a75;
+ "message digest"
+ 107dbf389d9e9f71a3a95f6c055b9251bc5268c2be16d6c13492ea45b0199f3309e16455ab1e96118e8a905d5597b72038ddb372a89826046de66687bb420e7c;
+ "abcdefghijklmnopqrstuvwxyz"
+ 4dbff86cc2ca1bae1e16468a05cb9881c97f1753bce3619034898faa1aabe429955a1bf8ec483d7421fe3c1646613a59ed5441fb0f321389f77f48a879c7b1f1;
+ "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
+ 204a8fc6dda82f0a0ced7beb8e08a41657c16ef468b228a8279be331a703c33596fd15c13b1b07f9aa1d3bea57789ca031ad85c7a71dd70354ec631238ca3445;
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
+ 1e07be23c26a86ea37ea810c8ec7809352515a970e9253c26f536cfc7a9996c45c8370583e0a78fa4a90041d71a4ceab7423f19c71b9d5a3e01249f0bebd5894;
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890"
+ 72ec1ef1124a45b047e8b7c75a932195135bb61de24ec0d1914042246e0aec3a2354e093d76f3048b456764346900cb130d2a4fd5dd16abb5e30bcb850dee843;
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
+"
+ 4def32cfb1107a104eae530fe04326a57e839a0bd9675f6770ff18d0b3b3ee2d4343bf99e9d54adc272617d49d0f61eab4b4bc177f9d2bac086cd2d902b5780e;
+}
+
+# --- HMAC mode ---
+#
+# Autogenerated, unofficial.
+
+sha512-hmac {
+ "Hi There"
+ 0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0bb0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b
+ bb969b8e6b99529a2e09757ef582257aed4f66cb62f1b32150b969eaa7dd683d46a776726cbf0f614f784cfa0759e84ba1d0baf07a1391ed998da6ea2fd7ff53;
+
+ "what do ya want for nothing?"
+ 4a656665
+ 164b7a7bfcf819e2e395fbe73b56e0a387bd64222e831fd610270cd7ea2505549758bf75c05a994a6d034f65f8f0e6fdcaeab1a34d4a6b4b636e070a38bce737;
+
+ "ÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ"
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 2ee7acd783624ca9398710f3ee05ae41b9f9b0510c87e49e586cc9bf961733d8623c7b55cebefccf02d5581acc1c9d5fb1ff68a1de45509fbe4da9a433922655;
+
+ "ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ"
+ 0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f2122232425262728292a2b2c2d2e2f30313233343536373839
+ 005a43d33fe40a285dc0947121984509698d4533519662c5eda2f8fac7a6b69f78ce84b61b1427d8dc88046aa1f35c6513b467185de195deb4dee3367b55d38d;
+
+ "Test With Truncation"
+ 0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c
+ 54701368cc706f527661ec9617d506ab255890b7c0cd8318f2efcf2b1bfbac560a77c369bdc01220d652e79747c0fa465da176e34b0de91cf075db0a12ac0ab5;
+
+ "Test Using Larger Than Block-Size Key - Hash Key First"
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ ae52fbcfb432b5963d1fa0b38a584554752d41f5b4de82483ec1f32de676ae708fc20ffa3bc6525f3d4115eda6b145bf123ed5acf6cbb0ee7f7bf625402609fd;
+
+ "Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data Bearing In Mind That This Hash Has An Extraordinarily Large Block Size So The Standard Test Won't Work"
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ 062d5553721e9512a061feaa8a236a5c2c5a45f25ed3ebe9c7337f3bc26b65d8ba3e1bd061b53fe45ac03800aeee4b48c6f2f3bd955c32991bd2bfaf2b1c05a3;
+
+}
+