aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2024-08-24 20:13:01 +0200
committerMattias Andrée <maandree@kth.se>2024-08-24 20:13:01 +0200
commitfebb5279f7bf3c86ec872c1b2ed1e024f73e64c5 (patch)
treeea6918fc1dcb29e11ce9399b8300a124cc0342cf
parentAdd support for Keccak, SHA3, SHAKE, and RawSHAKE via libkeccak>=1.3 (this version introduced zerocopy) (diff)
downloadlibhashsum-febb5279f7bf3c86ec872c1b2ed1e024f73e64c5.tar.gz
libhashsum-febb5279f7bf3c86ec872c1b2ed1e024f73e64c5.tar.bz2
libhashsum-febb5279f7bf3c86ec872c1b2ed1e024f73e64c5.tar.xz
Add BLAKE via libblake>=1.1 (this version introduced libblake_init())
Signed-off-by: Mattias Andrée <maandree@kth.se>
-rw-r--r--Makefile34
-rw-r--r--README3
-rw-r--r--blake224.c76
-rw-r--r--blake256.c76
-rw-r--r--blake384.c126
-rw-r--r--blake512.c195
-rw-r--r--common.h16
-rw-r--r--config.mk21
-rw-r--r--keccak_224.c6
-rw-r--r--keccak_256.c6
-rw-r--r--keccak_384.c6
-rw-r--r--keccak_512.c18
-rw-r--r--libhashsum.h169
-rw-r--r--libhashsum_init_blake224_hasher.c98
-rw-r--r--libhashsum_init_blake256_hasher.c98
-rw-r--r--libhashsum_init_blake384_hasher.c98
-rw-r--r--libhashsum_init_blake512_hasher.c98
-rw-r--r--libhashsum_init_blake_hasher.c32
-rw-r--r--libhashsum_init_blakeb_hasher.c28
-rw-r--r--libhashsum_init_blakes_hasher.c28
-rw-r--r--libhashsum_init_hasher.c8
-rw-r--r--libhashsum_init_hasher_from_string.c8
-rw-r--r--md4.c8
-rw-r--r--md5.c8
l---------mk/blake224=no.mk1
-rw-r--r--mk/blake224=yes.mk4
l---------mk/blake256=no.mk1
-rw-r--r--mk/blake256=yes.mk4
l---------mk/blake384=no.mk1
-rw-r--r--mk/blake384=yes.mk4
l---------mk/blake512=no.mk1
-rw-r--r--mk/blake512=yes.mk4
-rw-r--r--ripemd-128.c8
-rw-r--r--ripemd-160.c8
-rw-r--r--ripemd-256.c14
-rw-r--r--ripemd-320.c14
-rw-r--r--sha0.c8
-rw-r--r--sha1.c8
-rw-r--r--sha3_224.c8
-rw-r--r--sha3_256.c6
-rw-r--r--sha3_384.c6
-rw-r--r--sha3_512.c18
-rw-r--r--sha_224.c8
-rw-r--r--sha_256.c8
-rw-r--r--sha_384.c8
-rw-r--r--sha_512.c20
46 files changed, 1401 insertions, 25 deletions
diff --git a/Makefile b/Makefile
index fd52be7..5c5fbe6 100644
--- a/Makefile
+++ b/Makefile
@@ -18,6 +18,10 @@ SUPPORT_KECCAK = $(DEFAULT_SUPPORT)
SUPPORT_SHA3 = $(DEFAULT_SUPPORT)
SUPPORT_SHAKE = $(DEFAULT_SUPPORT)
SUPPORT_RAWSHAKE = $(DEFAULT_SUPPORT)
+SUPPORT_BLAKE224 = $(DEFAULT_SUPPORT)
+SUPPORT_BLAKE256 = $(DEFAULT_SUPPORT)
+SUPPORT_BLAKE384 = $(DEFAULT_SUPPORT)
+SUPPORT_BLAKE512 = $(DEFAULT_SUPPORT)
CONFIGFILE = config.mk
@@ -39,6 +43,9 @@ LIB_NAME = hashsum
CPPFLAGS_LIBKECCAK_IF_SUPPORTED =
LDFLAGS_LIBKECCAK_IF_SUPPORTED =
+CPPFLAGS_LIBBLAKE_IF_SUPPORTED =
+LDFLAGS_LIBBLAKE_IF_SUPPORTED =
+
include mk/md2=$(SUPPORT_MD2).mk
include mk/md4=$(SUPPORT_MD4).mk
include mk/md5=$(SUPPORT_MD5).mk
@@ -52,6 +59,10 @@ include mk/keccak=$(SUPPORT_KECCAK).mk
include mk/sha3=$(SUPPORT_SHA3).mk
include mk/shake=$(SUPPORT_SHAKE).mk
include mk/rawshake=$(SUPPORT_RAWSHAKE).mk
+include mk/blake224=$(SUPPORT_SHA3).mk
+include mk/blake256=$(SUPPORT_SHA3).mk
+include mk/blake384=$(SUPPORT_SHA3).mk
+include mk/blake512=$(SUPPORT_SHA3).mk
CPPFLAGS_FULL =\
@@ -69,13 +80,19 @@ CPPFLAGS_FULL =\
$(CPPFLAGS_KECCAK)\
$(CPPFLAGS_SHA3)\
$(CPPFLAGS_SHAKE)\
- $(CPPFLAGS_RAWSHAKE)
+ $(CPPFLAGS_RAWSHAKE)\
+ $(CPPFLAGS_LIBBLAKE_IF_SUPPORTED)\
+ $(CPPFLAGS_BLAKE224)\
+ $(CPPFLAGS_BLAKE256)\
+ $(CPPFLAGS_BLAKE384)\
+ $(CPPFLAGS_BLAKE512)
LDFLAGS_FULL =\
$(LDFLAGS)\
$(LDFLAGS_SHA1)\
$(LDFLAGS_SHA2)\
- $(LDFLAGS_LIBKECCAK_IF_SUPPORTED)
+ $(LDFLAGS_LIBKECCAK_IF_SUPPORTED)\
+ $(LDFLAGS_LIBBLAKE_IF_SUPPORTED)
OBJ =\
@@ -115,6 +132,13 @@ OBJ =\
libhashsum_init_rawshake256_hasher.o\
libhashsum_init_rawshake512_hasher.o\
libhashsum_init_rawshake_hasher.o\
+ libhashsum_init_blake224_hasher.o\
+ libhashsum_init_blake256_hasher.o\
+ libhashsum_init_blakes_hasher.o\
+ libhashsum_init_blake384_hasher.o\
+ libhashsum_init_blake512_hasher.o\
+ libhashsum_init_blakeb_hasher.o\
+ libhashsum_init_blake_hasher.o\
libhashsum_reverse_byte__.o\
libhashsum_init_keccak__.o
@@ -145,7 +169,11 @@ TEST =\
sha3_224.t\
sha3_256.t\
sha3_384.t\
- sha3_512.t
+ sha3_512.t\
+ blake224.t\
+ blake256.t\
+ blake384.t\
+ blake512.t
LOBJ = $(OBJ:.o=.lo)
TOBJ = $(TEST:.t=.o)
diff --git a/README b/README
index b35360f..7e06f52 100644
--- a/README
+++ b/README
@@ -23,6 +23,9 @@ DESCRIPTION
SHAKE128, SHAKE256, SHAKE512, RawSHAKE128,
RawSHAKE256, RawSHAKE512
+ Via libblake>=1.1
+ BLAKE224, BLAKE256, BLAKE384, BLAKE512
+
libhashsum makes it easy to select at compile-time which
functions to compile support for.
diff --git a/blake224.c b/blake224.c
new file mode 100644
index 0000000..04d78f7
--- /dev/null
+++ b/blake224.c
@@ -0,0 +1,76 @@
+/* See LICENSE file for copyright and license details. */
+#ifdef SUPPORT_BLAKE224
+# define TEST
+# include "common.h"
+
+
+static struct testcase testcases[] = {
+ {1, 0, "", "7dc5313b1c04512a174bd6503b89607aecbee0903d40a8a569c94eed"},
+ {0, 1, "\xff", "6f464fcaa901babeb27cb94dea4aca966756a1759a24e3cae93f3a05"},
+ {0, 1, "\x7f", "6f464fcaa901babeb27cb94dea4aca966756a1759a24e3cae93f3a05"},
+ {0, 1, "\x01", "6f464fcaa901babeb27cb94dea4aca966756a1759a24e3cae93f3a05"},
+ {0, 1, "\xfe", "615b9bd1077a8270d4f647799ffaaf87c03d72efd37e4947fcf01cca"},
+ {0, 1, "\x7e", "615b9bd1077a8270d4f647799ffaaf87c03d72efd37e4947fcf01cca"},
+ {1, 1, "\x00", "615b9bd1077a8270d4f647799ffaaf87c03d72efd37e4947fcf01cca"},
+ {1, 2, "\x03", "6a829dca3a3d0d35762d7b0f9a2c8379c32415c87a8ad773fefec19f"},
+ {1, 3, "\x03", "5478a106aca2b539d5bd52db8b19717d436ca27c14ef99ed565bc4a7"},
+ {1, 4, "\x01", "2b10ebc335731de6148ce84ed05a2685b9c274105c6aaf1dd59ef000"},
+ {1, 5, "\x12", "a49e36fd01041a0a86eb12d7f110bf4ef798b686fff48e5abc6bc8b4"},
+ {1, 6, "\x0a", "57036a8ad47cb24e0f329ef991b571211f171bf86f546aa068577cb5"},
+ {1, 7, "\x19", "82417e4fdb2b426d125415b10fe7dae7e944291f8daeb049b80e93a0"},
+ {1, 8, "\xcc", "5e21c1e375c7bc822046fad96910c95031bd4262ada71b4c91052fea"},
+ {1, 9, "\x98\x00", "30df15eb42922a41c1ef59102115d2f656e94f39fd1eeca115a9a07a"},
+ {1, 10, "\x9d\x02", "5c6c22d948c98644057c9ad31107164ecda652f4c51abd8cc4652ee6"},
+ {1, 11, "\xaa\x01", "276babfb45f0da4ddce7012d009122cdb974702cce1fcc83e0b254af"},
+ {1, 12, "\x98\x0c", "5dd804d86cc32084c81caea4ee5b472b2ba6e8c17eb2ff982e9e885b"},
+ {1, 13, "\x50\x0c", "e3d122c703be5ebca4ecc1860a8f50cff518c3984d3605f3c98bb52b"},
+ {1, 14, "\x4d\x24", "35e05b766f7fcfb136e62cef59400b3e776f74e69a16912a9e7a9d78"},
+ {1, 15, "\xcb\x7b", "227804938f7d63d96a54778f71bfb7421dcf056ddd78ab8b739a7a2e"},
+ {1, 16, "\x41\xfb", "195707e8ce71fb91c2c82ccf78022609a598bd80c9a505ef035314db"},
+ {1, 17, "\x4f\xf4\x00", "86113100dd674ebf5d0c36b609d9ab8bbd8ecb5d54b0a5aaea9d5e1d"},
+ {1, 18, "\xfd\x04\x02", "608997b3ae1483e0298a08d816029d112124743cde703dd0350edbe9"},
+ {1, 19, "\x42\x4d\x00", "89f898843d7ab0bb50ac8f6d1139e18aca0ef1d4e95b089ec2172685"},
+ {1, 20, "\x3f\xde\x07", "280cee22ba45b2ff9dfa70462cd34c106a24842c6a247f74ade67158"},
+ {1, 21, "\x33\x57\x16", "780f1fb7fd80898a10e9c6d63d212372bf7f6b3cd6a6c231ee5daa9b"},
+ {1, 22, "\x05\x1e\x3e", "0296e4a199194d5b65aa40fb0ec33870e36daa3e2e962d2c5b6f3a99"},
+ {1, 23, "\x71\x7f\x31", "1e95aa999a1a68c1c5191d2365664415344ed1673cb6c12a849abf0a"},
+ {1, 24, "\x1f\x87\x7c", "4239b4afa926f2269b117059dc0310033c9c85acea1a031f97cd4e2a"},
+ {1, 25, "\xeb\x35\xcf\x01", "dfd3f804fbc9ad5805fc5b529c1d0564e96454710d0b21d561357ac5"},
+ {1, 26, "\xb4\x06\xc4\x01", "e1fd87c6396d42e19713290547cc324268c27b7fa40398ed3797b148"},
+ {1, 27, "\xce\xe8\x80\x02", "dfebe7b56e9247d4023cecda04c28e1fc4eb6049fa27a747f75d832d"},
+ {1, 28, "\xc5\x84\xdb\x0e", "79737f20528fac047c7ea52a2a295bd7ce15087773747cb450be6874"},
+ {1, 29, "\x53\x58\x7b\x13", "de42f62c6eeddc5bd80fdf52edcf64754d875bb2b214d5e715833270"},
+ {1, 30, "\x69\xa3\x05\x0d", "328a913d190fa087c58958a321138400e5a9e9a8983c9853c0b932ea"},
+ {1, 31, "\xc9\x37\x5e\x73", "efa18a9d2ada4755c260482989442f21b8c5b2e09155517e201d269e"},
+ {1, 32, "\xc1\xec\xfd\xfc", "9cd80af6d0181b831e1879959f287735c9cbf5d1e480e7341266d6f0"},
+ {1, 33, "\x8d\x73\xe8\xa2\x01", "2849a31c29e378fa9eef77ad80043e822c70cde973cb99a4a7f21a07"},
+ {1, 34, "\x06\xf2\x52\x20\x01", "d9315ee5d1e33178363ddfdd7d595e0ba4a6d82522500e27ed3075ae"},
+ {1, 35, "\x3e\xf6\xc3\x6f\x04", "40663b7856cfb2d57987a85dbd76c447dcf582481912c9a373924127"},
+ {1, 36, "\x01\x27\xa1\xd3\x02", "61a5fdead981d711d72d3dc5cfe7f8c40916ce16a42a97cb7b8a016e"},
+ {1, 37, "\x6a\x6a\xb6\xc2\x08", "a63d8d4a5239c7132031c1ca6527ebe3e7d6d647124fafdf5f123de2"},
+ {1, 38, "\xaf\x31\x75\xe1\x06", "3e7c863db3e16c2350a44e161a2aa3810764cf523c62ab71999a9d24"},
+ {1, 39, "\xb6\x66\x09\xed\x61", "e3b7ce19f60913cd5aa1d43bd92de285f72163e0f9453f4e5f21bf52"},
+ {1, 40, "\x21\xf1\x34\xac\x57", "9e908983741757ff632c01f2b2c4d7f1ec8e642d112c212ba9739fd1"},
+ {1, 41, "\x3d\xc2\xaa\xdf\xfc\x01", "4e1a8c57c3713217530a5f667b37f6bc23939d2fb43dea9745f50068"},
+ {1, 42, "\x92\x02\x73\x6d\x22\x02", "a3c9ece5a71fed7c2e58bfd0b67fcf286668c2bcc31826c1b4cd6d59"},
+ {1, 43, "\xf2\x19\xbd\x62\x98\x04", "f087f490d55044aa4d147f79d0f1e980fdba1d78cacb5999ff9e67ca"},
+ {1, 44, "\xf3\x51\x1e\xe2\xc4\x0d", "49da5bdbc1fe187a28cbd493f383108ff1c6bcd71b3fef2c742074a5"},
+ {1, 45, "\x3e\xca\xb6\xbf\x77\x04", "2143ed11184621cb64716a451688291bd0799574f2a28537885540be"},
+ {1, 46, "\xcd\x62\xf6\x88\xf4\x19", "0874dba67485be94b9f5a500fade53c94622573059a7fd78f50d0309"},
+ {1, 47, "\xc2\xcb\xaa\x33\xa9\x1f", "2e14b39f6de58b0fdd67b9c45eae6c3ff71a363defea06975410e25a"},
+ {1, 48, "\xc6\xf5\x0b\xb7\x4e\x29", "6d6d952053aead200de9daa856c2993a7a7fa4a15b3924fb77dbb384"},
+ {1, 49, "\x79\xf1\xb4\xcc\xc6\x2a\x00", "ad93ea3f245493cf2b660d6f5fe82b8bfb0d3394854e88c2704c98c2"}
+};
+
+
+#else
+# define TEST_UNSUPPORTED
+# include "common.h"
+#endif
+
+
+int
+main(void)
+{
+ TEST_MAIN("BLAKE224", BLAKE224);
+}
diff --git a/blake256.c b/blake256.c
new file mode 100644
index 0000000..4e3951b
--- /dev/null
+++ b/blake256.c
@@ -0,0 +1,76 @@
+/* See LICENSE file for copyright and license details. */
+#ifdef SUPPORT_BLAKE256
+# define TEST
+# include "common.h"
+
+
+static struct testcase testcases[] = {
+ {1, 0, "", "716f6e863f744b9ac22c97ec7b76ea5f5908bc5b2f67c61510bfc4751384ea7a"},
+ {0, 1, "\xff", "9151be4536b8f5a0550713425a55cfeadecf71cdb170c647d9bc2d5d56110cc8"},
+ {0, 1, "\x7f", "9151be4536b8f5a0550713425a55cfeadecf71cdb170c647d9bc2d5d56110cc8"},
+ {0, 1, "\x01", "9151be4536b8f5a0550713425a55cfeadecf71cdb170c647d9bc2d5d56110cc8"},
+ {0, 1, "\xfe", "81a10984912cd57c12e923b46142b2b434dfe1a0ef29c03de05555f9f2fee9b4"},
+ {0, 1, "\x7e", "81a10984912cd57c12e923b46142b2b434dfe1a0ef29c03de05555f9f2fee9b4"},
+ {1, 1, "\x00", "81a10984912cd57c12e923b46142b2b434dfe1a0ef29c03de05555f9f2fee9b4"},
+ {1, 2, "\x03", "eae1614ea36088a8fd69a4614c2d98fada81134baa991aebfb743cd297669b01"},
+ {1, 3, "\x03", "4ac92b8903f7076563a6309eb9bd386807d28fe721fc8128af86e88967739443"},
+ {1, 4, "\x01", "c575142b6e471398bf9fc90a5660bb97f24cb106443b76e22b58084e82667b5d"},
+ {1, 5, "\x12", "45bc790b0180778efe9fd0381528ba9e9ec4460685375e1283e519e338b4c55d"},
+ {1, 6, "\x0a", "673acd73e1ea3c418e7707cf543155e9dc0c52c6d4aa8a9b0559680b06992d48"},
+ {1, 7, "\x19", "46bf46a9db7079a34f1b2b4ceffc8236730c2b5ec2a9f0d105ab5b66be9f6fd8"},
+ {1, 8, "\xcc", "e104256a2bc501f459d03fac96b9014f593e22d30f4de525fa680c3aa189eb4f"},
+ {1, 9, "\x98\x00", "1088da8ca79a1498f7d4629654307d63715f26edf916c8fb8c09d2039d28c8bc"},
+ {1, 10, "\x9d\x02", "1b34cb31b73d6966f038cdd3d93fe973776f9f4bd5bd9b1008ae105edc53add3"},
+ {1, 11, "\xaa\x01", "6df64c36384f863cbed1ccf0a615c04b808b73f35131e3f95adfcb93e54e8df0"},
+ {1, 12, "\x98\x0c", "37e539c6dfb9c94bc392090a41ae4eca0fe3eff478ef401cf163a73486754ef4"},
+ {1, 13, "\x50\x0c", "10ec14653844b6cbda11d908680f27de195a00446b773eb64480168074fb9439"},
+ {1, 14, "\x4d\x24", "8f9d0cb5d596260935d8057c260c218091ba666ac14b1a46f2d918484cfbe173"},
+ {1, 15, "\xcb\x7b", "891837f7f166cd0603379a2803fe27fed35853f5c4b6feed0fc74b4502d6105c"},
+ {1, 16, "\x41\xfb", "8f341148be7e354fdf38b693d8c6b4e0bd57301a734f6fd35cd85b8491c3ddcd"},
+ {1, 17, "\x4f\xf4\x00", "ddfc63311a6e1996b257af4ec0750bcbe400d7d507eea84aee9fc44b88127236"},
+ {1, 18, "\xfd\x04\x02", "5b452b7b003fab1abe488ba0dca0a6f5945d797a94f52e93d6e921af1a157fc4"},
+ {1, 19, "\x42\x4d\x00", "6733ca84f1652ff5d5252d4affa42d3ebda3fbd21a9a8fc07297dad28df7273c"},
+ {1, 20, "\x3f\xde\x07", "1e5c24058d33f16a7cef6ad102e3a19b59e595598dd4ddc2c9b8182abbb89b84"},
+ {1, 21, "\x33\x57\x16", "29a77b3fa2b97407791da3fa792e40555a2cae9fa85d559ba633ac2e817d6b5e"},
+ {1, 22, "\x05\x1e\x3e", "3ef17d53fb61fe2f543a935820f244e25cc8c0ae30d9774ff22427a3fb820d7a"},
+ {1, 23, "\x71\x7f\x31", "b2224450512df4c070084e17f6c8a423c5e22a66a77f4eb5792418832dcb05a0"},
+ {1, 24, "\x1f\x87\x7c", "bc334d1069099f10c601883ac6f3e7e9787c6aa53171f76a21923cc5ad3ab937"},
+ {1, 25, "\xeb\x35\xcf\x01", "7360eb4415d316866b8a748fcd90b7a014c6d62a18218a48cdf681538dcac8ec"},
+ {1, 26, "\xb4\x06\xc4\x01", "9e4a8d15be6cfd06425f224035a90ccb5fc8bf92e4d315bc6efe3d9c93085943"},
+ {1, 27, "\xce\xe8\x80\x02", "643cf377e140bb1f5d2710927c84ab23b0c258b6c0ab47da4b592180086c24d2"},
+ {1, 28, "\xc5\x84\xdb\x0e", "94b4d7f4830fda2e6ba7346f38456d28346589dec8b7dc6e61e3ec3580243c5e"},
+ {1, 29, "\x53\x58\x7b\x13", "2d7508d69c7fb9bfacf35fafc118840b8ad42fabae5f27adc9d74154f2e3a78a"},
+ {1, 30, "\x69\xa3\x05\x0d", "eec86da7600c3953f088084364b37a3d2bb6522876b82f9cf9cfed764746d53d"},
+ {1, 31, "\xc9\x37\x5e\x73", "7ff30cb54acd2e019c3664c42f37002d67132098d313525e5bced93470d19a56"},
+ {1, 32, "\xc1\xec\xfd\xfc", "b672a16f53982bab1e77685b71c0a5f6703ffd46a1c834be69f614bd128d658e"},
+ {1, 33, "\x8d\x73\xe8\xa2\x01", "3b171d80684fcbb88067e7519e0af3ab3d378254d36633b3eb8585553717ecf0"},
+ {1, 34, "\x06\xf2\x52\x20\x01", "d71133d28291531730403dbc363bf3d5a4c3db80861b7c3afbc4c769fedfd3aa"},
+ {1, 35, "\x3e\xf6\xc3\x6f\x04", "2e9830df74711da1a21e815aa6ab37013ebded7de7088ae8d5fdb5174440fe0b"},
+ {1, 36, "\x01\x27\xa1\xd3\x02", "5ba9f0532fbd0b44f0f7efd9988aa2e062a813797c732242ea5239f571adfb0f"},
+ {1, 37, "\x6a\x6a\xb6\xc2\x08", "e03567eefd4e515a73999fac87deb90726bdc488f4be6aa8a974c7b4ee13fc65"},
+ {1, 38, "\xaf\x31\x75\xe1\x06", "238036d9eeb9b09d9c9703b484833cc88097f27e34b8a94bef9f5e121b6d5575"},
+ {1, 39, "\xb6\x66\x09\xed\x61", "284e01f8b5604db347cd9d4ab95cc8d62d3640aeaf7502a2439fe780c598ba39"},
+ {1, 40, "\x21\xf1\x34\xac\x57", "d9134b2899057a7d8d320cc99e3e116982bc99d3c69d260a7f1ed3da8be68d99"},
+ {1, 41, "\x3d\xc2\xaa\xdf\xfc\x01", "3e64d5852d9a09ea76007a7b159430c3715598017850ec288316e13b80fd61c7"},
+ {1, 42, "\x92\x02\x73\x6d\x22\x02", "95f5bcf07e8a6c02b26f9fe29a5deb7faa5c03ab0e6180239924f5d48c7125af"},
+ {1, 43, "\xf2\x19\xbd\x62\x98\x04", "0fcf4c343c9d94bf3dea22069a28d23ff953bde89cd0dee4d1a521d4a302f8a3"},
+ {1, 44, "\xf3\x51\x1e\xe2\xc4\x0d", "c32364fa782462bc3a3af38e03fb4f052bd238ab756eaabdd5f8000006446184"},
+ {1, 45, "\x3e\xca\xb6\xbf\x77\x04", "511150cbab4c6be4d59d926b093a2d10fb6d9fb06169f47af2f1d75c07463428"},
+ {1, 46, "\xcd\x62\xf6\x88\xf4\x19", "a08519ce60cfef0554e8cd1a4d3cbe82504fe97b8b933cfccff5faac85bc787b"},
+ {1, 47, "\xc2\xcb\xaa\x33\xa9\x1f", "cc8eb0c743b2440399632474ba84980bebc9f6eedbbce3e31fdc497e0ba32d9d"},
+ {1, 48, "\xc6\xf5\x0b\xb7\x4e\x29", "637923bd29a35aa3ecbbd2a50549fc32c14cf0fdcaf41c3194dd7414fd224815"},
+ {1, 49, "\x79\xf1\xb4\xcc\xc6\x2a\x00", "106cd7e18e3bd16353cf561411d87b609536856d57180155b60d7bc0a73b9d45"}
+};
+
+
+#else
+# define TEST_UNSUPPORTED
+# include "common.h"
+#endif
+
+
+int
+main(void)
+{
+ TEST_MAIN("BLAKE256", BLAKE256);
+}
diff --git a/blake384.c b/blake384.c
new file mode 100644
index 0000000..a333e09
--- /dev/null
+++ b/blake384.c
@@ -0,0 +1,126 @@
+/* See LICENSE file for copyright and license details. */
+#ifdef SUPPORT_BLAKE384
+# define TEST
+# include "common.h"
+
+
+static struct testcase testcases[] = {
+ {1, 0, "", "c6cbd89c926ab525c242e6621f2f5fa73aa4afe3d9e24aed727faaadd6af38b620bdb623dd2b4788b1c8086984af8706"},
+ {0, 1, "\xff", "212ddd52b932eec23b7f38b5b91d2e7e614e64cbce43fc7e1021fed58202a737859634072e6e1847bd0ab5f73e938bc4"},
+ {0, 1, "\x7f", "212ddd52b932eec23b7f38b5b91d2e7e614e64cbce43fc7e1021fed58202a737859634072e6e1847bd0ab5f73e938bc4"},
+ {0, 1, "\x01", "212ddd52b932eec23b7f38b5b91d2e7e614e64cbce43fc7e1021fed58202a737859634072e6e1847bd0ab5f73e938bc4"},
+ {0, 1, "\xfe", "1ffde9711b419d7c97dc142e7704d2ae61163f8a818c47938b978d6113949d8e7819b9699d497a3b289b8bb4415ffae7"},
+ {0, 1, "\x7e", "1ffde9711b419d7c97dc142e7704d2ae61163f8a818c47938b978d6113949d8e7819b9699d497a3b289b8bb4415ffae7"},
+ {0, 1, "\x00", "1ffde9711b419d7c97dc142e7704d2ae61163f8a818c47938b978d6113949d8e7819b9699d497a3b289b8bb4415ffae7"},
+ {1, 1, "\x00",
+ "1ffde9711b419d7c97dc142e7704d2ae61163f8a818c47938b978d6113949d8e7819b9699d497a3b289b8bb4415ffae7"},
+ {1, 2, "\x03",
+ "195d771c302bb1ca0c9ac55a782cbe877bc0bc28016f735de68d7cf5fc1d0a99cc69a32cb0174fd2a97d5fcf46aafded"},
+ {1, 3, "\x03",
+ "883b186d9372a04d585eb1eef1cd32ff8a7c061d5e396f05fd9d3d9d6033de757bfc3adf30b06d7fb02a875a2ac0db70"},
+ {1, 4, "\x01",
+ "91140c47ba7ef06fe6810acef4be65ad772576291778c6b5588b08fd48beeae4e70c3ac4abb9636a637e9a6359a19053"},
+ {1, 5, "\x12",
+ "f03566b78ead38d98f787c08f117817702d24d3bc8c663551393a1f2e6a079855434414789b34dd360df198eb00e67a2"},
+ {1, 6, "\x0a",
+ "68eeca6e6550ece0662882bd36605eeabea74230171225b708c1a375c90e4a59fec2eff42eba07441dc1f48d39665bd6"},
+ {1, 7, "\x19",
+ "70bb604b0893b22e2f4e2fc0e9cfd725648c9ff217df8eee219a7a1cab3039158ff1ae3c8b2106165f00e3dac9301adb"},
+ {1, 8, "\xcc",
+ "a77e65c0c03ecb831dbcdd50a3c2bce300d55eac002a9c197095518d8514c0b578e3ecb7415291f99ede91d49197dd05"},
+ {1, 9, "\x98\x00",
+ "fdf53e189982aead4849b6fba84b9e84a7f4c38a580840344e4017819f30901ca333b12954ea811049e023f073a69ae2"},
+ {1, 10, "\x9d\x02",
+ "0afc73af8a4f8645cfb30ceab03c256cabf8088d5452c66a766159428de6050484f39b31cb4eebbcb2a06a8a7b0e4626"},
+ {1, 11, "\xaa\x01",
+ "7939c08121bcbdd2d87069a3f8feedc3e1eeaa7a140574afd126441f4ed9e32b783ca02f33bb454aa6d05494d4c9028d"},
+ {1, 12, "\x98\x0c",
+ "a9045405bb39e7f6f89398160208d61f2f4ccbd5c688a6b67aa6eef78d00ef1ee8c6779b781b8603eaf585d475cd86d5"},
+ {1, 13, "\x50\x0c",
+ "bcbc3cff50f0bd0f03c9dcba0296f7bd7a9e111361335cdd8cb47cc02fe6bcff01d3244c6b7141b77b4cbfc88d6cd320"},
+ {1, 14, "\x4d\x24",
+ "9bc5c48e85de4ea136072a53b31d964668175c378a424af4503a454637cd55fa091b2e1a005a6f308f18f5f2b90900a3"},
+ {1, 15, "\xcb\x7b",
+ "4f1eea4e836e12d8521bce58831481e80fec26d40fbef756e571c9cf1e1072008a2475fbdda6b1dc6ff09238f2675329"},
+ {1, 16, "\x41\xfb",
+ "e80a87362c9d39e2074ac135e2514b0cdf0001bfd8c35888d7ca8bbc4e918a157386524d41579e7fcd9c3c9a4f7a991a"},
+ {1, 17, "\x4f\xf4\x00",
+ "28a0158d802b4e6ca90dbd9558140dada402b3fa3f556fc06ab9cd0e645a32eb1793d5ba321e8e6fcbaef6403ba5d4c3"},
+ {1, 18, "\xfd\x04\x02",
+ "cf58d202fc28371bca34f2698569a87d06633777c457312341ce3651259041feefd2fcabe1618ad24d4707292a2f2c63"},
+ {1, 19, "\x42\x4d\x00",
+ "b0f5ab250b2f65cb9a6b200f6bc39ba74db8a5282fdd9e8d1bf87c733da89005fac37f40dcdb9b095a70a018392c3018"},
+ {1, 20, "\x3f\xde\x07",
+ "ffd7f9bf50dcca42c961bbc4fff717ab586e01968d606407ec610aa3d2462987af054c694474c7b5878dd7af5124c1dc"},
+ {1, 21, "\x33\x57\x16",
+ "1f288d53346f74a9618c47f5a77a9e41aece4005037e3b6b908f6d0b4d8faaf148cc18ac1632b3362e1a78369edfc6f6"},
+ {1, 22, "\x05\x1e\x3e",
+ "d5dbcb933c5cba8c1b355b6152a947051a71ea0a9ad295ab308afa39fdce8a07e9e0192a187df0ff9e089718534a7c46"},
+ {1, 23, "\x71\x7f\x31",
+ "c6c62993fb330dd106932569300a97ab54837fe5927adcd0a418fa24e01148d80de54ddc63dc58705c62be1ea4b3ee32"},
+ {1, 24, "\x1f\x87\x7c",
+ "d67cfa1b09c8c050094ea018bb5ecd3ce0c02835325467a8fa79701f0ad6bbd4a34947bbaa2fc5f9379985ccd6a1dc0e"},
+ {1, 25, "\xeb\x35\xcf\x01",
+ "dfba2a0077e56cacb0df1be549dfe06c9828e1eef91b77d83acc0300c0c67db0e2594a4bd552c80f4a0d98fae44a860c"},
+ {1, 26, "\xb4\x06\xc4\x01",
+ "a20846d26c780b03d4d0fe15757d664111aaedc435af784ae85e1a1b25ca56c476b86351edc1ad3825667b86328678d3"},
+ {1, 27, "\xce\xe8\x80\x02",
+ "ee885ca24e330d26bde1b3ea640fd0af5ab1840697bd12d015fc515d219cdd2c13bb3429f374727ee632a1555fef1ca3"},
+ {1, 28, "\xc5\x84\xdb\x0e",
+ "243a3c6ad6fb97298c04200273cbe829c636daab73ea7abaaf1caff193e9dc9b7399ed859a46a6daba98ee9fd810cf00"},
+ {1, 29, "\x53\x58\x7b\x13",
+ "01c6579dd37e707e33ec4a0a768499f28be4e80ba4952e645faa07f09d507dec9e81ab2cf34c0318a34a0ac4af621655"},
+ {1, 30, "\x69\xa3\x05\x0d",
+ "081633892d928cd7debc78ce70b0a82f8595cf32e1998b0298490b8799b26f76ed428d13ca4da02e504efda5a3379dca"},
+ {1, 31, "\xc9\x37\x5e\x73",
+ "24a2d2af040b31fc238abfb935fb0f699eaf97291b75d5a7eaaf542e19c7e486554c166962943b762f2818172bbcdee5"},
+ {1, 32, "\xc1\xec\xfd\xfc",
+ "7a57c41d850b7ab51c6075aba299ff649fdaf08a4c37088ece73b21304b1072c21930cc34ac6b0fc5f27b95f4f389b26"},
+ {1, 33, "\x8d\x73\xe8\xa2\x01",
+ "e1480a83839ab8747935690f1922e0f05e8f67239f7dced9cfd39a1678ee10febb4f7580bd803c66ec5584ef102a12db"},
+ {1, 34, "\x06\xf2\x52\x20\x01",
+ "f386f8bdd36de67d43aeb976b2d57a9499b3796c1c37e6c7b133bf2545d7efcd21be6935425a5dfaa627ceec834400b6"},
+ {1, 35, "\x3e\xf6\xc3\x6f\x04",
+ "311c0aafbb8e6729641d9bb12d0434614f5be6e0d3d27933e1469b0c662430de7153b2aab9c4085758099e6064d2f883"},
+ {1, 36, "\x01\x27\xa1\xd3\x02",
+ "9933fe64ef4de19c78695186286831534f30721b82d031b9f938fb19b4c2cab1d4ac53f63f96a60cf172702f9305854e"},
+ {1, 37, "\x6a\x6a\xb6\xc2\x08",
+ "094b79964b193bf655f91f76f4d3589eab2a902587f730ec76251b98d9de4db846d81c29dba5eb20ede52db447f429a7"},
+ {1, 38, "\xaf\x31\x75\xe1\x06",
+ "e05997f725613d05ec2a3edab5b9af53de9eeaef986ad4ed1f83c6c4211bb0b1a6058d8eaed94d52299e2e32225e2545"},
+ {1, 39, "\xb6\x66\x09\xed\x61",
+ "c0b0e332a81821d4dd06a72ef108fae9060f2c826b3905db037ad75db15efac9c04d0f284aae722e407b41f132a75980"},
+ {1, 40, "\x21\xf1\x34\xac\x57",
+ "324155f4f5e346bfe0b08e9642bebe86505795be186146d30242273ebebb3d51e076b1105ab647c130e6efc0b75072a7"},
+ {1, 41, "\x3d\xc2\xaa\xdf\xfc\x01",
+ "4202b2a7fd50f9f64268a5cecaa979e68fb5e5b4f16050baa0eee6254640a243f8f775c44f26c0d950498c8f1bbb34cb"},
+ {1, 42, "\x92\x02\x73\x6d\x22\x02",
+ "18987d9b924db295acb2645618b772fa7d451ef841f207d525c2c501e472fafb44b3078537515ed39475743c7d2d04c2"},
+ {1, 43, "\xf2\x19\xbd\x62\x98\x04",
+ "b059cd3e9e615574d0f2bbe11522ed7c2243f070272880a5f58bd147985a24afbdf8be2cf139792b482b97bfc94d6788"},
+ {1, 44, "\xf3\x51\x1e\xe2\xc4\x0d",
+ "028c6ea676b4ab01cbdf0918a90e507429ca7b926763dc26ced6f7a851923b91fd4ac6054cc7432139af954c3abe5a94"},
+ {1, 45, "\x3e\xca\xb6\xbf\x77\x04",
+ "5f46d3abe50df2b402567f95468862ecfc91508019c85a190a3c3eb2f6a77e794835697987dc4bce0bd3ef2afb89a026"},
+ {1, 46, "\xcd\x62\xf6\x88\xf4\x19",
+ "444921bbc8e0dceb33e0b4660f2e09fc8a0d8254ae03327af448408b1dc9229c95253c3873f09a522f428899d23d6846"},
+ {1, 47, "\xc2\xcb\xaa\x33\xa9\x1f",
+ "b4a57910d5ef0113585fbe7f3a5ebd7a3e3ddc4e66bd42a8baed7c59134d3cdc36c70a4a39fa11449ff8adfe4da66cb8"},
+ {1, 48, "\xc6\xf5\x0b\xb7\x4e\x29",
+ "5ddb50068ca430bffae7e5a8bbcb2c59171743cce027c0ea937fa2b511848192af2aca98ead30b0850b4d2d1542decdb"},
+ {1, 49, "\x79\xf1\xb4\xcc\xc6\x2a\x00",
+ "7c80a8320015dfc5143d1c6d60a4b51c6943208005aa5176300ecdfa728d5bb53c9817b33c934eca94332716458572dc"}
+};
+
+
+#else
+# define TEST_UNSUPPORTED
+# include "common.h"
+#endif
+
+
+int
+main(void)
+{
+ TEST_MAIN("BLAKE384", BLAKE384);
+}
diff --git a/blake512.c b/blake512.c
new file mode 100644
index 0000000..85f13fd
--- /dev/null
+++ b/blake512.c
@@ -0,0 +1,195 @@
+/* See LICENSE file for copyright and license details. */
+#ifdef SUPPORT_BLAKE512
+# define TEST
+# include "common.h"
+
+
+static struct testcase testcases[] = {
+ {1, 0, "",
+ "a8cfbbd73726062df0c6864dda65defe58ef0cc52a5625090fa17601e1eecd1b"
+ "628e94f396ae402a00acc9eab77b4d4c2e852aaaa25a636d80af3fc7913ef5b8"},
+ {1, 0, "The quick brown fox jumps over the lazy dog",
+ "1f7e26f63b6ad25a0896fd978fd050a1766391d2fd0471a77afb975e5034b7ad"
+ "2d9ccf8dfb47abbbe656e1b82fbc634ba42ce186e8dc5e1ce09a885d41f43451"},
+ {1, 0, "The quick brown fox jumps over the lazy dof",
+ "a701c2a1f9baabd8b1db6b75aee096900276f0b86dc15d247ecc03937b370324"
+ "a16a4ffc0c3a85cd63229cfa15c15f4ba6d46ae2e849ed6335e9ff43b764198a"},
+ {0, 1, "\xff",
+ "69269d2195e03088f928a24a4539849727e47dc46d2596f12b2c88491776f20c"
+ "31b1526912aec62f29e6641221ca2a67e149857be5e6e08fc3f49ec5d7b7138c"},
+ {0, 1, "\x7f",
+ "69269d2195e03088f928a24a4539849727e47dc46d2596f12b2c88491776f20c"
+ "31b1526912aec62f29e6641221ca2a67e149857be5e6e08fc3f49ec5d7b7138c"},
+ {0, 1, "\x01",
+ "69269d2195e03088f928a24a4539849727e47dc46d2596f12b2c88491776f20c"
+ "31b1526912aec62f29e6641221ca2a67e149857be5e6e08fc3f49ec5d7b7138c"},
+ {0, 1, "\xfe",
+ "f0a9b5b755802205fd1a1f56e7a03d7573d46e8ba5037517281560fbe6db03c1"
+ "74b00597fb4e1427747c7382fe63c6692f05a5e0841e99883cb7c272c2a62191"},
+ {0, 1, "\x7e",
+ "f0a9b5b755802205fd1a1f56e7a03d7573d46e8ba5037517281560fbe6db03c1"
+ "74b00597fb4e1427747c7382fe63c6692f05a5e0841e99883cb7c272c2a62191"},
+ {0, 1, "\x00",
+ "f0a9b5b755802205fd1a1f56e7a03d7573d46e8ba5037517281560fbe6db03c1"
+ "74b00597fb4e1427747c7382fe63c6692f05a5e0841e99883cb7c272c2a62191"},
+ {1, 1, "\x00",
+ "f0a9b5b755802205fd1a1f56e7a03d7573d46e8ba5037517281560fbe6db03c1"
+ "74b00597fb4e1427747c7382fe63c6692f05a5e0841e99883cb7c272c2a62191"},
+ {1, 2, "\x03",
+ "777e21c87839badde651fc37334f6d7cdc8316914e7cb76dab2efab90c62ef30"
+ "7e590936349b85041542f00d94d870633957699e818db79e1e064b0991a9cd1a"},
+ {1, 3, "\x03",
+ "1ffb9a5c5c4c5a0cb91d806fc1398e8a49bdac2cfb549628c886bf388f5a6c6b"
+ "0854bc9c68155502016592c3f0cd54ded83276463a2aed864436950d99244958"},
+ {1, 4, "\x01",
+ "32ff282bc8a43dc777ab74582fc2354f4294c6d634b25c4f2f606c72e10ae41e"
+ "f7f9391f3533649ce73a0dc6b5d30497f655bb87ae45aeb03c50c96d4c5218ff"},
+ {1, 5, "\x12",
+ "783a1850bc31594e382e346351cc004572288f1a12d95b6b52fc47a071033efd"
+ "7ad6fc0424c93b97708da15cf0482bb0afa1b289545ae6cbbcd2970611dabb46"},
+ {1, 6, "\x0a",
+ "fc355cd7b2f3cec08f4fbf64f8d08394c04ea80e9a6c2920312f450183c53739"
+ "5a6202d2532ff35597a7c2ec719c4174f347a8cf795fd71d2933a7003ecb05d0"},
+ {1, 7, "\x19",
+ "85bb7f4b9119d4495805c6f5ad9d4eb5f9ee363c34741147483abd6dfd24336b"
+ "d1a5fa566578f861ffaa0ad6c617491a378477d6dd3d8025ff2b9ce6cdfd0b12"},
+ {1, 8, "\xcc",
+ "4f0ef594f20172d23504873f596984c64c1583c7b2abb8d8786aa2aeeae1c46c"
+ "744b61893d661b0733b76d1fe19257dd68e0ef05422ca25d058dfe6c33d68709"},
+ {1, 9, "\x98\x00",
+ "073cf7ed8216a6b27f882563986489d1c418874f2b797a9a0c5c95394f3a9dbe"
+ "b7eb3e2e6598fa5f49ad10e87f4add5f08057e5c1cd0b45004f22b63f91787ad"},
+ {1, 10, "\x9d\x02",
+ "48ec88684d8239091d13d3d1d582a1b7cb07f6b67d9e9f1759c117f8dc447d01"
+ "2d6802748f1c613763a88e88a996a177ec562ba15c7da086502334f0df97d1b7"},
+ {1, 11, "\xaa\x01",
+ "635213e9c8ffb6a535e6eaae9e9231d901e07607afaecd9122e3dfbacb0f11fb"
+ "388fcb91e68e1d7f05c70f1f8a5dd6549c93f87fb4f25fa31d6c6abb4b9a55c4"},
+ {1, 12, "\x98\x0c",
+ "75d769e87d7c935faf58cd93043019bae5162e6b54d3b8b4aa2ae5fda3705e72"
+ "1e669dce33e8d59db6db0ad2c4ba7dc5f931ecf67a3448024b1515800b777129"},
+ {1, 13, "\x50\x0c",
+ "8903efd089efa56634fa8d4bd953abcf30d72fca70ebad0ddfccbd4cda514c56"
+ "79dc763291dbb888a0bc7af7964a3be07f14c37ee696b51099bd91466429b22b"},
+ {1, 14, "\x4d\x24",
+ "9464762c5824a83eef9445571734261e57a453e30e12e9581c4b378a7ec8219b"
+ "b3f25b0d900aa8dd446f2788395e4216f539ec4d3f8d41090ae7951a43bdf2ed"},
+ {1, 15, "\xcb\x7b",
+ "ae69b3b57792c5909a8482a4006eccceeb14d1f76b15da66018586ae132adae8"
+ "641890921c13bdc2164be991b1e248d66b5e647a8e4b4eef73e33d3f06a33a5c"},
+ {1, 16, "\x41\xfb",
+ "20afd72afbb66a5a0efd8b4a627cc2c82a5e4b6c63b0c9a78735c188d248c758"
+ "8fb4ee566b3b6fdcc235a498f7263feb7ab1411582a7055e3ce7a8c976e61fcc"},
+ {1, 17, "\x4f\xf4\x00",
+ "802ad11445c31e09a51f1431a9b735a009f631e192c78de140a484bfba91d5c5"
+ "482a5539509f1b0fca92f4e5ab6040d1efdb7fe64f107b6cf5a5c79342c10491"},
+ {1, 18, "\xfd\x04\x02",
+ "0e1a3fdc9506b0fb96bd69a14149fa41484c035a4867cc8f9ae8704e7fbf5b24"
+ "168089c1ae654a46d6dd2375bea3c62df92b2cba320a09a642917c7c7790f199"},
+ {1, 19, "\x42\x4d\x00",
+ "dd05e2ca3219efe375f2bf8edb2f45c5c490fb5e06bddbb2a813e5e232c62f15"
+ "b70324db66f442be5d2a437b21df736ebbd3eba0b58591550b45ef9838703054"},
+ {1, 20, "\x3f\xde\x07",
+ "8dc0a2797160f1eb1e4fca864f99298e655572adce432a03e5ff3a5dc814bbd8"
+ "1e3b328bbf8191e9041c57780f27fbecc1618b3fd140da3b96e2d0f769b441a1"},
+ {1, 21, "\x33\x57\x16",
+ "b501b4abc63aed8c5841e691e7f5ff5b096637e19342fa44feb53ddf84f16eb8"
+ "bc92730c41f2b29131f3c6701f9b3bb6dcb5af7e8a4d900243e7b136a0d60ddb"},
+ {1, 22, "\x05\x1e\x3e",
+ "9d28c92c6b54f7f6888b6d210029eeafde05b7ab95e2a34d1f3979d3b62c8940"
+ "c4980a1a46cfead4a630cf8e5efb521b5e412059786f626d1054e62b0f2ed916"},
+ {1, 23, "\x71\x7f\x31",
+ "855c53190122aec182624cd98ec4f97b362bc74c01eef9e1d140ce79ab54e127"
+ "7e8b873df52585c420b8c6d99652b47e5de322225dc1792788e71aa2912861f8"},
+ {1, 24, "\x1f\x87\x7c",
+ "b1211367fd8a886674f74d92716e7585f9b6e933edc5ee7f974facdccc481cfa"
+ "42a0532375b94f2c0dd73d6189a815c2bafb5686d784be81fbb447b0f291272b"},
+ {1, 25, "\xeb\x35\xcf\x01",
+ "df4050f53c05fa145dd89bf9ac94dcfd81f96f984ca484dbbbf92259f7b8ae19"
+ "d2fec657853bb2673ddb0ee26f298d8c4923daaeedc2926e7daf2157c697b2ed"},
+ {1, 26, "\xb4\x06\xc4\x01",
+ "f507a52fb135565c74e5905fe9a43dcbfb29b39344faec39c15ad09b0a465fef"
+ "0be36183433d29243d74f119b8242bd94b0e6b37c2c1039d9d7c5af316fc46d4"},
+ {1, 27, "\xce\xe8\x80\x02",
+ "06228dc4e1b32e816c77273e5e5b66349e82f48c6c7f3eea8876efa5db32d9fc"
+ "f2e26dd3eeae7355877ca9e7b31c0924c521b5e729cf08c4175dab8a451e5ad8"},
+ {1, 28, "\xc5\x84\xdb\x0e",
+ "fbbbc6cb4832c6545236f9e36fc92f7a7709e38fdf7ea6cb100048409a3c5f36"
+ "e8a336360e7ab5ec26a8c13d8e663f08cac2b2519f40c61cd3284b9f320463da"},
+ {1, 29, "\x53\x58\x7b\x13",
+ "91f4c152a8f637247a1747e2ca4df130d3be99c2dc3a9f2991df7a60900b1093"
+ "1fe670d10dc7725dc30e068f3220575f033e8634dd58904ca3136a04158a42ed"},
+ {1, 30, "\x69\xa3\x05\x0d",
+ "5068d281c4eef98502d0d1de51b1f78764059fb599f036fd7f60c0fd4f50b634"
+ "205a196306ee78eabd3ce8eb8333a6da8bf0c7176d5230bcc6af48700fd7f343"},
+ {1, 31, "\xc9\x37\x5e\x73",
+ "3501607fa6b01de201a10bd1db756621cd2097e3476acf862e8b723d98bc4399"
+ "84f8de6bc8514ed800265ef21116cf36aba1f68f9f96befb9b48eafbe19bf805"},
+ {1, 32, "\xc1\xec\xfd\xfc",
+ "ccbcdbc1a30ebbcc4fc015fdb1caba6c0ad6719301b4bbad4b0efab1141174a1"
+ "5e2e8b8b8e5671c1864a0f75ecb20f76dac45159e67786d07d79a29b1827e5a4"},
+ {1, 33, "\x8d\x73\xe8\xa2\x01",
+ "1f41330d6ad6f6fafa54f7c1a698a03ebd96e74025d0e5476138589e02194c13"
+ "3fad988e47c81a0ed887943670d41e560327761f897d996dc59cb9025b095315"},
+ {1, 34, "\x06\xf2\x52\x20\x01",
+ "4d9fa2dc0049230afd0d72e6195a19523d3d8b4f1983d1108157b7085ae82a0f"
+ "90542351fc8d66437fc9a9bc6f98807313abdc2b4c6140b819b201df6c62b1da"},
+ {1, 35, "\x3e\xf6\xc3\x6f\x04",
+ "cc14844fa038671773c4201fdd7e106e951d77cef951d253e9da9f07f2bb3040"
+ "a2569834d6836b30b743d39bee94a7e7721672ca30fd94b1de23bdcb1c218ff5"},
+ {1, 36, "\x01\x27\xa1\xd3\x02",
+ "37f909daa8a5e503b8af6f0826ba02ac14a4e92221a551cbcf4128a4c867d101"
+ "d4f158232de31bc4d9ed298def8e202db9490a0da1d09cb665bdf18a14f8ff4a"},
+ {1, 37, "\x6a\x6a\xb6\xc2\x08",
+ "4b6c339182ec57c24832313bba724aa37b2d8833e04fc31a1a869c3da3ba1061"
+ "36bfda897cec7aedd28227c2b118fa417c2592a71216be6e3766b26f04b4ea4d"},
+ {1, 38, "\xaf\x31\x75\xe1\x06",
+ "04548a4bf2fd865da48c060262bf0f17dc084c9d4162a06f2f7aad1aed7244d7"
+ "422d257e54a9eef9c24c8827e88fa707c9d0ee1ac555b46b7ee8e5ecc6fa8f1d"},
+ {1, 39, "\xb6\x66\x09\xed\x61",
+ "a5b8b8de6cf9c14ced277140d219755a4af5c80e0dbd67721831b1284a501c50"
+ "92a669390ecf997e406c4c1a43b25903759d0ae5ac09390f5d2ed747ae1bd361"},
+ {1, 40, "\x21\xf1\x34\xac\x57",
+ "ec6eaabc2a128c38dfcddf9aaad5bb6fba397aac06a4b584b2dbdeb0cd7fdb1f"
+ "d248ef93c0686b73818b2b78c923c70eba63c096f33d842ada959f7674e4730c"},
+ {1, 41, "\x3d\xc2\xaa\xdf\xfc\x01",
+ "eb9dc2c740374e28d9247393afe2d713e843c289977ea48abda51fb2950c3967"
+ "aea50d48e7eba75b591140062e14495d416934f9817ec832988397c3a781dfeb"},
+ {1, 42, "\x92\x02\x73\x6d\x22\x02",
+ "0c5dfdfd3167a6ca86abf804e71342e893b0270b3ef2d4c81032482538c0f580"
+ "2817a16d6ec12f541ce947d5579c27b9b7a5ee424554f3fa2c78a2fa8340d444"},
+ {1, 43, "\xf2\x19\xbd\x62\x98\x04",
+ "40f191621e6a183a0bd3f10df6716ddf09339fba20b48dbbb09fb44b82f15be7"
+ "7ad595bfdd1f1245b930334ea7042e716626d5fb49bc275df0b60639d9aea618"},
+ {1, 44, "\xf3\x51\x1e\xe2\xc4\x0d",
+ "e76cefbc4621956af8d7d5121bd10bdddaeff359ff2b988425f22bba15c8ad4d"
+ "bbf70f7e8b5cf2ee044eb9625bf36ec9f910e01701bbc8541d8529a13a56cc98"},
+ {1, 45, "\x3e\xca\xb6\xbf\x77\x04",
+ "39b3d2f730b774e16504fd6e5b2eafca5f68c9d5022e62d3bca67793d3260f34"
+ "d1dd594b95ef5a735aa9b78ff0b6028b484c34a4bcd9adb4ec5a9736ecd434eb"},
+ {1, 46, "\xcd\x62\xf6\x88\xf4\x19",
+ "69b151653d645e84c6eb509665a89a075210f743f8c7218e6c98895c9436e9ee"
+ "dfa2094597b13533e1c3af6b21907ddf2f4c5c8379e64a71b66add2a170d5689"},
+ {1, 47, "\xc2\xcb\xaa\x33\xa9\x1f",
+ "eac8acd05f04461d8050b53dafa99b0516adfacc8dbd3adc7dacfc7adea4ad92"
+ "50fa9e10ad43602e15a762a333a2cdb1c040ede1de79ac51b484507b5ae16536"},
+ {1, 48, "\xc6\xf5\x0b\xb7\x4e\x29",
+ "b6e8a7380df1f007d7c271e7255bbca7714f25029ac1fd6fe92ef74cbcd9e99c"
+ "112f8ae1a45ccb566ce19d9678a122c612beff5f8eeeee3f3f402fd2781182d4"},
+ {1, 49, "\x79\xf1\xb4\xcc\xc6\x2a\x00",
+ "1cc9fe09100fbc45f20382353785aa753fbd19ea0ab655c0d8338e0d07154cca"
+ "a5659698a6627302c25dd54cdfde00c0ef06905abc55030563399ca8efae2c22"}
+};
+
+
+#else
+# define TEST_UNSUPPORTED
+# include "common.h"
+#endif
+
+
+int
+main(void)
+{
+ TEST_MAIN("BLAKE512", BLAKE512);
+}
diff --git a/common.h b/common.h
index 903a0e9..a13e9c8 100644
--- a/common.h
+++ b/common.h
@@ -15,6 +15,18 @@
#if defined(SUPPORT_KECCAK) || defined(SUPPORT_SHA3) || defined(SUPPORT_SHAKE) || defined(SUPPORT_RAWSHAKE)
# define LIBHASHSUM_INCLUDE_LIBKECCAK_STATE
#endif
+#if defined(SUPPORT_BLAKE224) || defined(SUPPORT_BLAKE256)
+# define SUPPORT_BLAKES
+#endif
+#if defined(SUPPORT_BLAKE384) || defined(SUPPORT_BLAKE512)
+# define SUPPORT_BLAKEB
+#endif
+#if defined(SUPPORT_BLAKES) || defined(SUPPORT_BLAKEB)
+# define SUPPORT_BLAKE
+#endif
+#if defined(SUPPORT_BLAKE)
+# define LIBHASHSUM_INCLUDE_LIBBLAKE_STATE
+#endif
#include "libhashsum.h"
#include <ctype.h>
@@ -179,8 +191,8 @@ run_tests(const char *name, enum libhashsum_algorithm algorithm, size_t hash_siz
*p++ = 'b';
*p++ = '"';
while (bits--) {
- *p++ = "01"[(extra_bit >> 7) & 1U];
- extra_bit <<= 1;
+ *p++ = "01"[extra_bit & 1U];
+ extra_bit >>= 1;
}
*p++ = '"';
*p = '\0';
diff --git a/config.mk b/config.mk
index 2e3e31a..b415389 100644
--- a/config.mk
+++ b/config.mk
@@ -17,6 +17,9 @@ CPPFLAGS_LIBSHA2 =
LDFLAGS_LIBKECCAK = -lkeccak
CPPFLAGS_LIBKECCAK =
+LDFLAGS_LIBBLAKE = -lblake
+CPPFLAGS_LIBBLAKE =
+
DEFAULT_SUPPORT = yes
# Shall either be "yes" or "no", the same applies below where this macro is used
@@ -50,10 +53,22 @@ SUPPORT_SHA2 = $(DEFAULT_SUPPORT)
# Includes SHA-224, SHA-256, SHA-384, SHA-512, SHA-512/224, and SHA-512/256, requires libsha2
SUPPORT_SHA3 = $(DEFAULT_SUPPORT)
-# Includes SHA3-224, SHA3-256, SHA3-384, and SHA3-512, requires libkeccak>=1.2
+# Includes SHA3-224, SHA3-256, SHA3-384, and SHA3-512, requires libkeccak>=1.3
SUPPORT_SHAKE = $(DEFAULT_SUPPORT)
-# Includes SHAKE224, SHAKE256, SHAKE384, and SHAKE512, requires libkeccak>=1.2
+# Includes SHAKE224, SHAKE256, SHAKE384, and SHAKE512, requires libkeccak>=1.3
SUPPORT_RAWSHAKE = $(DEFAULT_SUPPORT)
-# Includes RawSHAKE224, RawSHAKE256, RawSHAKE384, and RawSHAKE512, requires libkeccak>=1.2
+# Includes RawSHAKE224, RawSHAKE256, RawSHAKE384, and RawSHAKE512, requires libkeccak>=1.3
+
+SUPPORT_BLAKE224 = $(DEFAULT_SUPPORT)
+# Requires libblake>=1.1
+
+SUPPORT_BLAKE256 = $(DEFAULT_SUPPORT)
+# Requires libblake>=1.1
+
+SUPPORT_BLAKE384 = $(DEFAULT_SUPPORT)
+# Requires libblake>=1.1
+
+SUPPORT_BLAKE512 = $(DEFAULT_SUPPORT)
+# Requires libblake>=1.1
diff --git a/keccak_224.c b/keccak_224.c
index 64546ba..cfe1bc1 100644
--- a/keccak_224.c
+++ b/keccak_224.c
@@ -6,6 +6,12 @@
static struct testcase testcases[] = {
{1, 0, "", "f71837502ba8e10837bdd8d365adb85591895602fc552b48b7390abd"},
+ {0, 1, "\xff", "c4ab876a7f74504cb63158562f7a8f855dfde3c6f005a3f2e8feed0d"},
+ {0, 1, "\x7f", "c4ab876a7f74504cb63158562f7a8f855dfde3c6f005a3f2e8feed0d"},
+ {0, 1, "\x01", "c4ab876a7f74504cb63158562f7a8f855dfde3c6f005a3f2e8feed0d"},
+ {0, 1, "\xfe", "860e3ec314c5cbf19c1a4314e9ea8cb85cecd18bd850b42f5c6f2a07"},
+ {0, 1, "\x7e", "860e3ec314c5cbf19c1a4314e9ea8cb85cecd18bd850b42f5c6f2a07"},
+ {0, 1, "\x00", "860e3ec314c5cbf19c1a4314e9ea8cb85cecd18bd850b42f5c6f2a07"}
};
diff --git a/keccak_256.c b/keccak_256.c
index b232d1d..4ac5930 100644
--- a/keccak_256.c
+++ b/keccak_256.c
@@ -6,6 +6,12 @@
static struct testcase testcases[] = {
{1, 0, "", "c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"},
+ {0, 1, "\xff", "1f9e121db558ff4a6111d06e48b47aa9e8c968222397c5867ed627c82a5bcce4"},
+ {0, 1, "\x7f", "1f9e121db558ff4a6111d06e48b47aa9e8c968222397c5867ed627c82a5bcce4"},
+ {0, 1, "\x01", "1f9e121db558ff4a6111d06e48b47aa9e8c968222397c5867ed627c82a5bcce4"},
+ {0, 1, "\xfe", "c3e5cb55999eeff4e07b7effec77582d0a5a11a94fc268a872493099273992e1"},
+ {0, 1, "\x7e", "c3e5cb55999eeff4e07b7effec77582d0a5a11a94fc268a872493099273992e1"},
+ {0, 1, "\x00", "c3e5cb55999eeff4e07b7effec77582d0a5a11a94fc268a872493099273992e1"}
};
diff --git a/keccak_384.c b/keccak_384.c
index 3884526..d545f4a 100644
--- a/keccak_384.c
+++ b/keccak_384.c
@@ -6,6 +6,12 @@
static struct testcase testcases[] = {
{1, 0, "", "2c23146a63a29acf99e73b88f8c24eaa7dc60aa771780ccc006afbfa8fe2479b2dd2b21362337441ac12b515911957ff"},
+ {0, 1, "\xff", "087f1bc0629ee5a186d63b2aa285ad6c8ebc1efffa177ae68801867fa59bad0fe90cfed735b2a86659209b24e1fc4031"},
+ {0, 1, "\x7f", "087f1bc0629ee5a186d63b2aa285ad6c8ebc1efffa177ae68801867fa59bad0fe90cfed735b2a86659209b24e1fc4031"},
+ {0, 1, "\x01", "087f1bc0629ee5a186d63b2aa285ad6c8ebc1efffa177ae68801867fa59bad0fe90cfed735b2a86659209b24e1fc4031"},
+ {0, 1, "\xfe", "4c6d164043571a32e169a527ca3503ea391bf91f22287215df75ea243d53a0d042bc66efe2956d8606a24f39e255a081"},
+ {0, 1, "\x7e", "4c6d164043571a32e169a527ca3503ea391bf91f22287215df75ea243d53a0d042bc66efe2956d8606a24f39e255a081"},
+ {0, 1, "\x00", "4c6d164043571a32e169a527ca3503ea391bf91f22287215df75ea243d53a0d042bc66efe2956d8606a24f39e255a081"}
};
diff --git a/keccak_512.c b/keccak_512.c
index a617a52..fae3585 100644
--- a/keccak_512.c
+++ b/keccak_512.c
@@ -8,6 +8,24 @@ static struct testcase testcases[] = {
{1, 0, "",
"0eab42de4c3ceb9235fc91acffe746b29c29a8c366b7c60e4e67c466f36a4304"
"c00fa9caf9d87976ba469bcbe06713b435f091ef2769fb160cdab33d3670680e"},
+ {0, 1, "\xff",
+ "23309d222712996f6caacd52656a11467fc96d8b2666803b2f5ab9019be1f3b1"
+ "2044f09cdb3c38050ecab7d0f285a6f31ab1f559e645182ffc506289792e9ef9"},
+ {0, 1, "\x7f",
+ "23309d222712996f6caacd52656a11467fc96d8b2666803b2f5ab9019be1f3b1"
+ "2044f09cdb3c38050ecab7d0f285a6f31ab1f559e645182ffc506289792e9ef9"},
+ {0, 1, "\x01",
+ "23309d222712996f6caacd52656a11467fc96d8b2666803b2f5ab9019be1f3b1"
+ "2044f09cdb3c38050ecab7d0f285a6f31ab1f559e645182ffc506289792e9ef9"},
+ {0, 1, "\xfe",
+ "7d9025bb145a0814083e934baa80ede67322651de52062bf9eb93623c37efc74"
+ "c62240cf8539107f9210c1e1126f79cbaeda6b82b4a8ce6821589c403fa76b9a"},
+ {0, 1, "\x7e",
+ "7d9025bb145a0814083e934baa80ede67322651de52062bf9eb93623c37efc74"
+ "c62240cf8539107f9210c1e1126f79cbaeda6b82b4a8ce6821589c403fa76b9a"},
+ {0, 1, "\x00",
+ "7d9025bb145a0814083e934baa80ede67322651de52062bf9eb93623c37efc74"
+ "c62240cf8539107f9210c1e1126f79cbaeda6b82b4a8ce6821589c403fa76b9a"}
};
diff --git a/libhashsum.h b/libhashsum.h
index e7050c1..d85dadd 100644
--- a/libhashsum.h
+++ b/libhashsum.h
@@ -14,6 +14,9 @@
#ifdef LIBHASHSUM_INCLUDE_LIBKECCAK_STATE
# include <libkeccak.h>
#endif
+#ifdef LIBHASHSUM_INCLUDE_LIBBLAKE_STATE
+# include <libblake.h>
+#endif
#if defined(__GNUC__)
@@ -63,7 +66,11 @@ enum libhashsum_algorithm {
LIBHASHSUM_SHAKE512, /**< SHAKE512 */
LIBHASHSUM_RAWSHAKE128, /**< RawSHAKE128 */
LIBHASHSUM_RAWSHAKE256, /**< RawSHAKE256 */
- LIBHASHSUM_RAWSHAKE512 /**< RawSHAKE512 */
+ LIBHASHSUM_RAWSHAKE512, /**< RawSHAKE512 */
+ LIBHASHSUM_BLAKE224, /**< BLAKE224 */
+ LIBHASHSUM_BLAKE256, /**< BLAKE256 */
+ LIBHASHSUM_BLAKE384, /**< BLAKE384 */
+ LIBHASHSUM_BLAKE512 /**< BLAKE512 */
};
@@ -270,6 +277,34 @@ enum libhashsum_algorithm {
*/
#define LIBHASHSUM_RAWSHAKE_512_HASH_SIZE 64
+/**
+ * The value of `struct libhashsum_hasher.hash_size` for `LIBHASHSUM_BLAKE224`
+ *
+ * @since 1.0
+ */
+#define LIBHASHSUM_BLAKE224_HASH_SIZE 28
+
+/**
+ * The value of `struct libhashsum_hasher.hash_size` for `LIBHASHSUM_BLAKE256`
+ *
+ * @since 1.0
+ */
+#define LIBHASHSUM_BLAKE256_HASH_SIZE 32
+
+/**
+ * The value of `struct libhashsum_hasher.hash_size` for `LIBHASHSUM_BLAKE384`
+ *
+ * @since 1.0
+ */
+#define LIBHASHSUM_BLAKE384_HASH_SIZE 48
+
+/**
+ * The value of `struct libhashsum_hasher.hash_size` for `LIBHASHSUM_BLAKE512`
+ *
+ * @since 1.0
+ */
+#define LIBHASHSUM_BLAKE512_HASH_SIZE 64
+
/**
* Hash state
@@ -385,7 +420,29 @@ union libhashsum_state {
} keccak; /* size = [1020, 1065] */
#endif
- /* libblake: size = 56(s), 112(b), 48(2s), 96(2b), 144(2Xs), 276(2Xb) */
+#ifdef LIBHASHSUM_INCLUDE_LIBBLAKE_STATE
+ struct {
+ struct libblake_blake224_state s;
+ uint8_t buf[128];
+ } blake224; /* size = 184 */
+
+ struct {
+ struct libblake_blake256_state s;
+ uint8_t buf[128];
+ } blake256; /* size = 184 */
+
+ struct {
+ struct libblake_blake384_state s;
+ uint8_t buf[256];
+ } blake384; /* size = 368 */
+
+ struct {
+ struct libblake_blake512_state s;
+ uint8_t buf[256];
+ } blake512; /* size = 368 */
+#endif
+
+ /* libblake: 48(2s), 96(2b), 144(2Xs), 276(2Xb) */
char max_size[1648];
#define libhashsum_init_hasher libhashsum_init_hasher__1648
@@ -478,7 +535,7 @@ struct libhashsum_hasher {
* last bit
*
* @param this The object containing this function pointer
- * @param data The new input data, the function may rewrite it's content
+ * @param data The new input data
* @param bytes The number of bytes available in `data` for reading
* @param extra_bits Additional bits in `data` not covered by `bytes`
* @return 0 on success, -1 on failure
@@ -503,7 +560,7 @@ struct libhashsum_hasher {
* last bit
*
* @param this The object containing this function pointer
- * @param data The new input data, the function may rewrite it's content
+ * @param data The new input data, the function may rewrite its content
* @param bytes The number of bytes available in `data` for reading
* @param extra_bits Additional bits in `data` not covered by `bytes`
* @param size `bytes` plus any number of additional bytes available
@@ -1118,5 +1175,109 @@ int libhashsum_init_rawshake512_hasher(struct libhashsum_hasher *this, size_t ha
LIBHASHSUM_1_NONNULL_
int libhashsum_init_rawshake_hasher(struct libhashsum_hasher *this, size_t hcapbits, size_t hashbits);
+/**
+ * Create an initialised state for BLAKE224 (BLAKE, BLAKEs)
+ * hashing and return hash functions and details
+ *
+ * @param this The output parameter for the functions, details, and state
+ * @return 0 on success, -1 on failure
+ *
+ * @throws ENOSYS Support was excluded at compile time
+ *
+ * @since 1.0
+ */
+LIBHASHSUM_1_NONNULL_
+int libhashsum_init_blake224_hasher(struct libhashsum_hasher *this);
+
+/**
+ * Create an initialised state for BLAKE256 (BLAKE, BLAKEs)
+ * hashing and return hash functions and details
+ *
+ * @param this The output parameter for the functions, details, and state
+ * @return 0 on success, -1 on failure
+ *
+ * @throws ENOSYS Support was excluded at compile time
+ *
+ * @since 1.0
+ */
+LIBHASHSUM_1_NONNULL_
+int libhashsum_init_blake256_hasher(struct libhashsum_hasher *this);
+
+/**
+ * Create an initialised state for BLAKEs (BLAKE)
+ * hashing and return hash functions and details
+ *
+ * @param this The output parameter for the functions, details, and state
+ * @param hashbits Hash output size in bits
+ * @return 0 on success, -1 on failure
+ *
+ * @throws EINVAL `hashbits` is invalid (neither 224 nor 256)
+ * @throws ENOSYS Support was excluded at compile time
+ *
+ * @since 1.0
+ */
+LIBHASHSUM_1_NONNULL_
+int libhashsum_init_blakes_hasher(struct libhashsum_hasher *this, size_t hashbits);
+
+/**
+ * Create an initialised state for BLAKE384 (BLAKE, BLAKEb)
+ * hashing and return hash functions and details
+ *
+ * @param this The output parameter for the functions, details, and state
+ * @return 0 on success, -1 on failure
+ *
+ * @throws ENOSYS Support was excluded at compile time
+ *
+ * @since 1.0
+ */
+LIBHASHSUM_1_NONNULL_
+int libhashsum_init_blake384_hasher(struct libhashsum_hasher *this);
+
+/**
+ * Create an initialised state for BLAKE512 (BLAKE, BLAKEb)
+ * hashing and return hash functions and details
+ *
+ * @param this The output parameter for the functions, details, and state
+ * @return 0 on success, -1 on failure
+ *
+ * @throws ENOSYS Support was excluded at compile time
+ *
+ * @since 1.0
+ */
+LIBHASHSUM_1_NONNULL_
+int libhashsum_init_blake512_hasher(struct libhashsum_hasher *this);
+
+/**
+ * Create an initialised state for BLAKEb (BLAKE)
+ * hashing and return hash functions and details
+ *
+ * @param this The output parameter for the functions, details, and state
+ * @param hashbits Hash output size in bits
+ * @return 0 on success, -1 on failure
+ *
+ * @throws EINVAL `hashbits` is invalid (neither 384 nor 512)
+ * @throws ENOSYS Support was excluded at compile time
+ *
+ * @since 1.0
+ */
+LIBHASHSUM_1_NONNULL_
+int libhashsum_init_blakeb_hasher(struct libhashsum_hasher *this, size_t hashbits);
+
+/**
+ * Create an initialised state for BLAKE
+ * hashing and return hash functions and details
+ *
+ * @param this The output parameter for the functions, details, and state
+ * @param hashbits Hash output size in bits
+ * @return 0 on success, -1 on failure
+ *
+ * @throws EINVAL `hashbits` is invalid (neither 224, 256, 384, nor 512)
+ * @throws ENOSYS Support was excluded at compile time
+ *
+ * @since 1.0
+ */
+LIBHASHSUM_1_NONNULL_
+int libhashsum_init_blake_hasher(struct libhashsum_hasher *this, size_t hashbits);
+
#endif
diff --git a/libhashsum_init_blake224_hasher.c b/libhashsum_init_blake224_hasher.c
new file mode 100644
index 0000000..65d0ee1
--- /dev/null
+++ b/libhashsum_init_blake224_hasher.c
@@ -0,0 +1,98 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+#ifdef SUPPORT_BLAKE224
+
+
+LIBHASHSUM_1_NONNULL_
+static size_t
+process(struct libhashsum_hasher *this, const void *data, size_t bytes)
+{
+ return libblake_blake224_update(&this->state.blake224.s, data, bytes);
+}
+
+
+LIBHASHSUM_1_NONNULL_
+static int
+finalise_const(struct libhashsum_hasher *this, const void *data, size_t bytes, unsigned extra_bits)
+{
+ const uint8_t *m = data;
+ size_t r;
+
+ if (extra_bits > 7U) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ r = libblake_blake224_update(&this->state.blake224.s, data, bytes);
+ m = &m[r];
+ bytes -= r;
+
+ memcpy(this->state.blake224.buf, m, bytes + (size_t)(extra_bits > 0U));
+ if (extra_bits)
+ this->state.blake224.buf[bytes] = libhashsum_reverse_byte__(this->state.blake224.buf[bytes]);
+ libblake_blake224_digest(&this->state.blake224.s, this->state.blake224.buf, bytes,
+ extra_bits, NULL, this->state.blake224.buf);
+ memset(&this->state.blake224.s, 0, sizeof(this->state.blake224.s));
+ this->hash_output = this->state.blake224.buf;
+ return 0;
+}
+
+
+LIBHASHSUM_1_NONNULL_
+static int
+finalise(struct libhashsum_hasher *this, void *data, size_t bytes, unsigned extra_bits, size_t size)
+{
+ uint8_t *m = data;
+ size_t r;
+
+ if (extra_bits > 7U) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ r = libblake_blake224_update(&this->state.blake224.s, data, bytes);
+ m = &m[r];
+ bytes -= r;
+ size -= r;
+
+ if (size < libblake_blake224_digest_get_required_input_size(bytes, extra_bits, NULL)) {
+ memcpy(this->state.blake224.buf, m, bytes + (size_t)(extra_bits > 0U));
+ m = this->state.blake224.buf;
+ }
+ if (extra_bits)
+ m[bytes] = libhashsum_reverse_byte__(m[bytes]);
+ libblake_blake224_digest(&this->state.blake224.s, m, bytes, extra_bits, NULL, this->state.blake224.buf);
+ memset(&this->state.blake224.s, 0, sizeof(this->state.blake224.s));
+ this->hash_output = this->state.blake224.buf;
+ return 0;
+}
+
+
+int
+libhashsum_init_blake224_hasher(struct libhashsum_hasher *this)
+{
+ libblake_init();
+ this->algorithm = LIBHASHSUM_BLAKE224;
+ this->algorithm_string = "BLAKE224";
+ this->input_block_size = 64U;
+ this->hash_size = LIBHASHSUM_BLAKE224_HASH_SIZE;
+ this->hash_output = NULL;
+ this->supports_non_whole_bytes = 1;
+ this->process = &process;
+ this->finalise_const = &finalise_const;
+ this->finalise = &finalise;
+ this->destroy = NULL;
+ libblake_blake224_init2(&this->state.blake224.s, NULL);
+ return 0;
+}
+
+
+#else
+int
+libhashsum_init_blake224_hasher(struct libhashsum_hasher *this)
+{
+ (void) this;
+ errno = ENOSYS;
+ return -1;
+}
+#endif
diff --git a/libhashsum_init_blake256_hasher.c b/libhashsum_init_blake256_hasher.c
new file mode 100644
index 0000000..202dc37
--- /dev/null
+++ b/libhashsum_init_blake256_hasher.c
@@ -0,0 +1,98 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+#ifdef SUPPORT_BLAKE256
+
+
+LIBHASHSUM_1_NONNULL_
+static size_t
+process(struct libhashsum_hasher *this, const void *data, size_t bytes)
+{
+ return libblake_blake256_update(&this->state.blake256.s, data, bytes);
+}
+
+
+LIBHASHSUM_1_NONNULL_
+static int
+finalise_const(struct libhashsum_hasher *this, const void *data, size_t bytes, unsigned extra_bits)
+{
+ const uint8_t *m = data;
+ size_t r;
+
+ if (extra_bits > 7U) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ r = libblake_blake256_update(&this->state.blake256.s, data, bytes);
+ m = &m[r];
+ bytes -= r;
+
+ memcpy(this->state.blake256.buf, m, bytes + (size_t)(extra_bits > 0U));
+ if (extra_bits)
+ this->state.blake256.buf[bytes] = libhashsum_reverse_byte__(this->state.blake256.buf[bytes]);
+ libblake_blake256_digest(&this->state.blake256.s, this->state.blake256.buf, bytes,
+ extra_bits, NULL, this->state.blake256.buf);
+ memset(&this->state.blake256.s, 0, sizeof(this->state.blake256.s));
+ this->hash_output = this->state.blake256.buf;
+ return 0;
+}
+
+
+LIBHASHSUM_1_NONNULL_
+static int
+finalise(struct libhashsum_hasher *this, void *data, size_t bytes, unsigned extra_bits, size_t size)
+{
+ uint8_t *m = data;
+ size_t r;
+
+ if (extra_bits > 7U) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ r = libblake_blake256_update(&this->state.blake256.s, data, bytes);
+ m = &m[r];
+ bytes -= r;
+ size -= r;
+
+ if (size < libblake_blake256_digest_get_required_input_size(bytes, extra_bits, NULL)) {
+ memcpy(this->state.blake256.buf, m, bytes + (size_t)(extra_bits > 0U));
+ m = this->state.blake256.buf;
+ }
+ if (extra_bits)
+ m[bytes] = libhashsum_reverse_byte__(m[bytes]);
+ libblake_blake256_digest(&this->state.blake256.s, m, bytes, extra_bits, NULL, this->state.blake256.buf);
+ memset(&this->state.blake256.s, 0, sizeof(this->state.blake256.s));
+ this->hash_output = this->state.blake256.buf;
+ return 0;
+}
+
+
+int
+libhashsum_init_blake256_hasher(struct libhashsum_hasher *this)
+{
+ libblake_init();
+ this->algorithm = LIBHASHSUM_BLAKE256;
+ this->algorithm_string = "BLAKE256";
+ this->input_block_size = 64U;
+ this->hash_size = LIBHASHSUM_BLAKE256_HASH_SIZE;
+ this->hash_output = NULL;
+ this->supports_non_whole_bytes = 1;
+ this->process = &process;
+ this->finalise_const = &finalise_const;
+ this->finalise = &finalise;
+ this->destroy = NULL;
+ libblake_blake256_init2(&this->state.blake256.s, NULL);
+ return 0;
+}
+
+
+#else
+int
+libhashsum_init_blake256_hasher(struct libhashsum_hasher *this)
+{
+ (void) this;
+ errno = ENOSYS;
+ return -1;
+}
+#endif
diff --git a/libhashsum_init_blake384_hasher.c b/libhashsum_init_blake384_hasher.c
new file mode 100644
index 0000000..6f92c6c
--- /dev/null
+++ b/libhashsum_init_blake384_hasher.c
@@ -0,0 +1,98 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+#ifdef SUPPORT_BLAKE384
+
+
+LIBHASHSUM_1_NONNULL_
+static size_t
+process(struct libhashsum_hasher *this, const void *data, size_t bytes)
+{
+ return libblake_blake384_update(&this->state.blake384.s, data, bytes);
+}
+
+
+LIBHASHSUM_1_NONNULL_
+static int
+finalise_const(struct libhashsum_hasher *this, const void *data, size_t bytes, unsigned extra_bits)
+{
+ const uint8_t *m = data;
+ size_t r;
+
+ if (extra_bits > 7U) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ r = libblake_blake384_update(&this->state.blake384.s, data, bytes);
+ m = &m[r];
+ bytes -= r;
+
+ memcpy(this->state.blake384.buf, m, bytes + (size_t)(extra_bits > 0U));
+ if (extra_bits)
+ this->state.blake384.buf[bytes] = libhashsum_reverse_byte__(this->state.blake384.buf[bytes]);
+ libblake_blake384_digest(&this->state.blake384.s, this->state.blake384.buf, bytes,
+ extra_bits, NULL, this->state.blake384.buf);
+ memset(&this->state.blake384.s, 0, sizeof(this->state.blake384.s));
+ this->hash_output = this->state.blake384.buf;
+ return 0;
+}
+
+
+LIBHASHSUM_1_NONNULL_
+static int
+finalise(struct libhashsum_hasher *this, void *data, size_t bytes, unsigned extra_bits, size_t size)
+{
+ uint8_t *m = data;
+ size_t r;
+
+ if (extra_bits > 7U) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ r = libblake_blake384_update(&this->state.blake384.s, data, bytes);
+ m = &m[r];
+ bytes -= r;
+ size -= r;
+
+ if (size < libblake_blake384_digest_get_required_input_size(bytes, extra_bits, NULL)) {
+ memcpy(this->state.blake384.buf, m, bytes + (size_t)(extra_bits > 0U));
+ m = this->state.blake384.buf;
+ }
+ if (extra_bits)
+ m[bytes] = libhashsum_reverse_byte__(m[bytes]);
+ libblake_blake384_digest(&this->state.blake384.s, m, bytes, extra_bits, NULL, this->state.blake384.buf);
+ memset(&this->state.blake384.s, 0, sizeof(this->state.blake384.s));
+ this->hash_output = this->state.blake384.buf;
+ return 0;
+}
+
+
+int
+libhashsum_init_blake384_hasher(struct libhashsum_hasher *this)
+{
+ libblake_init();
+ this->algorithm = LIBHASHSUM_BLAKE384;
+ this->algorithm_string = "BLAKE384";
+ this->input_block_size = 128U;
+ this->hash_size = LIBHASHSUM_BLAKE384_HASH_SIZE;
+ this->hash_output = NULL;
+ this->supports_non_whole_bytes = 1;
+ this->process = &process;
+ this->finalise_const = &finalise_const;
+ this->finalise = &finalise;
+ this->destroy = NULL;
+ libblake_blake384_init2(&this->state.blake384.s, NULL);
+ return 0;
+}
+
+
+#else
+int
+libhashsum_init_blake384_hasher(struct libhashsum_hasher *this)
+{
+ (void) this;
+ errno = ENOSYS;
+ return -1;
+}
+#endif
diff --git a/libhashsum_init_blake512_hasher.c b/libhashsum_init_blake512_hasher.c
new file mode 100644
index 0000000..b1d2c13
--- /dev/null
+++ b/libhashsum_init_blake512_hasher.c
@@ -0,0 +1,98 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+#ifdef SUPPORT_BLAKE512
+
+
+LIBHASHSUM_1_NONNULL_
+static size_t
+process(struct libhashsum_hasher *this, const void *data, size_t bytes)
+{
+ return libblake_blake512_update(&this->state.blake512.s, data, bytes);
+}
+
+
+LIBHASHSUM_1_NONNULL_
+static int
+finalise_const(struct libhashsum_hasher *this, const void *data, size_t bytes, unsigned extra_bits)
+{
+ const uint8_t *m = data;
+ size_t r;
+
+ if (extra_bits > 7U) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ r = libblake_blake512_update(&this->state.blake512.s, data, bytes);
+ m = &m[r];
+ bytes -= r;
+
+ memcpy(this->state.blake512.buf, m, bytes + (size_t)(extra_bits > 0U));
+ if (extra_bits)
+ this->state.blake512.buf[bytes] = libhashsum_reverse_byte__(this->state.blake512.buf[bytes]);
+ libblake_blake512_digest(&this->state.blake512.s, this->state.blake512.buf, bytes,
+ extra_bits, NULL, this->state.blake512.buf);
+ memset(&this->state.blake512.s, 0, sizeof(this->state.blake512.s));
+ this->hash_output = this->state.blake512.buf;
+ return 0;
+}
+
+
+LIBHASHSUM_1_NONNULL_
+static int
+finalise(struct libhashsum_hasher *this, void *data, size_t bytes, unsigned extra_bits, size_t size)
+{
+ uint8_t *m = data;
+ size_t r;
+
+ if (extra_bits > 7U) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ r = libblake_blake512_update(&this->state.blake512.s, data, bytes);
+ m = &m[r];
+ bytes -= r;
+ size -= r;
+
+ if (size < libblake_blake512_digest_get_required_input_size(bytes, extra_bits, NULL)) {
+ memcpy(this->state.blake512.buf, m, bytes + (size_t)(extra_bits > 0U));
+ m = this->state.blake512.buf;
+ }
+ if (extra_bits)
+ m[bytes] = libhashsum_reverse_byte__(m[bytes]);
+ libblake_blake512_digest(&this->state.blake512.s, m, bytes, extra_bits, NULL, this->state.blake512.buf);
+ memset(&this->state.blake512.s, 0, sizeof(this->state.blake512.s));
+ this->hash_output = this->state.blake512.buf;
+ return 0;
+}
+
+
+int
+libhashsum_init_blake512_hasher(struct libhashsum_hasher *this)
+{
+ libblake_init();
+ this->algorithm = LIBHASHSUM_BLAKE512;
+ this->algorithm_string = "BLAKE512";
+ this->input_block_size = 128U;
+ this->hash_size = LIBHASHSUM_BLAKE512_HASH_SIZE;
+ this->hash_output = NULL;
+ this->supports_non_whole_bytes = 1;
+ this->process = &process;
+ this->finalise_const = &finalise_const;
+ this->finalise = &finalise;
+ this->destroy = NULL;
+ libblake_blake512_init2(&this->state.blake512.s, NULL);
+ return 0;
+}
+
+
+#else
+int
+libhashsum_init_blake512_hasher(struct libhashsum_hasher *this)
+{
+ (void) this;
+ errno = ENOSYS;
+ return -1;
+}
+#endif
diff --git a/libhashsum_init_blake_hasher.c b/libhashsum_init_blake_hasher.c
new file mode 100644
index 0000000..645ab95
--- /dev/null
+++ b/libhashsum_init_blake_hasher.c
@@ -0,0 +1,32 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+#ifdef SUPPORT_BLAKEB
+
+
+int
+libhashsum_init_blake_hasher(struct libhashsum_hasher *this, size_t hashbits)
+{
+ if (hashbits == 224U)
+ return libhashsum_init_blake224_hasher(this);
+ if (hashbits == 256U)
+ return libhashsum_init_blake256_hasher(this);
+ if (hashbits == 384U)
+ return libhashsum_init_blake384_hasher(this);
+ if (hashbits == 512U)
+ return libhashsum_init_blake512_hasher(this);
+
+ errno = EINVAL;
+ return -1;
+}
+
+
+#else
+int
+libhashsum_init_blake_hasher(struct libhashsum_hasher *this, size_t hashbits)
+{
+ (void) this;
+ (void) hashbits;
+ errno = ENOSYS;
+ return -1;
+}
+#endif
diff --git a/libhashsum_init_blakeb_hasher.c b/libhashsum_init_blakeb_hasher.c
new file mode 100644
index 0000000..417553b
--- /dev/null
+++ b/libhashsum_init_blakeb_hasher.c
@@ -0,0 +1,28 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+#ifdef SUPPORT_BLAKEB
+
+
+int
+libhashsum_init_blakeb_hasher(struct libhashsum_hasher *this, size_t hashbits)
+{
+ if (hashbits == 384U)
+ return libhashsum_init_blake384_hasher(this);
+ if (hashbits == 512U)
+ return libhashsum_init_blake512_hasher(this);
+
+ errno = EINVAL;
+ return -1;
+}
+
+
+#else
+int
+libhashsum_init_blakeb_hasher(struct libhashsum_hasher *this, size_t hashbits)
+{
+ (void) this;
+ (void) hashbits;
+ errno = ENOSYS;
+ return -1;
+}
+#endif
diff --git a/libhashsum_init_blakes_hasher.c b/libhashsum_init_blakes_hasher.c
new file mode 100644
index 0000000..f5e7c20
--- /dev/null
+++ b/libhashsum_init_blakes_hasher.c
@@ -0,0 +1,28 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+#ifdef SUPPORT_BLAKES
+
+
+int
+libhashsum_init_blakes_hasher(struct libhashsum_hasher *this, size_t hashbits)
+{
+ if (hashbits == 224U)
+ return libhashsum_init_blake224_hasher(this);
+ if (hashbits == 256U)
+ return libhashsum_init_blake256_hasher(this);
+
+ errno = EINVAL;
+ return -1;
+}
+
+
+#else
+int
+libhashsum_init_blakes_hasher(struct libhashsum_hasher *this, size_t hashbits)
+{
+ (void) this;
+ (void) hashbits;
+ errno = ENOSYS;
+ return -1;
+}
+#endif
diff --git a/libhashsum_init_hasher.c b/libhashsum_init_hasher.c
index 3d8a521..ab44ac1 100644
--- a/libhashsum_init_hasher.c
+++ b/libhashsum_init_hasher.c
@@ -64,6 +64,14 @@ libhashsum_init_hasher(struct libhashsum_hasher *this, enum libhashsum_algorithm
return libhashsum_init_rawshake256_hasher(this, 0);
case LIBHASHSUM_RAWSHAKE512:
return libhashsum_init_rawshake512_hasher(this, 0);
+ case LIBHASHSUM_BLAKE224:
+ return libhashsum_init_blake224_hasher(this);
+ case LIBHASHSUM_BLAKE256:
+ return libhashsum_init_blake256_hasher(this);
+ case LIBHASHSUM_BLAKE384:
+ return libhashsum_init_blake384_hasher(this);
+ case LIBHASHSUM_BLAKE512:
+ return libhashsum_init_blake512_hasher(this);
default:
case LIBHASHSUM_KECCAK:
errno = EINVAL;
diff --git a/libhashsum_init_hasher_from_string.c b/libhashsum_init_hasher_from_string.c
index 30526da..9a53864 100644
--- a/libhashsum_init_hasher_from_string.c
+++ b/libhashsum_init_hasher_from_string.c
@@ -180,6 +180,14 @@ libhashsum_init_hasher_from_string(struct libhashsum_hasher *this, const char *a
return with_n(&libhashsum_init_rawshake512_hasher, this, algorithm);
if (equiv(algorithm, "Keccak["))
return with_rcn(&libhashsum_init_keccak_hasher, this, algorithm);
+ if (equiv(algorithm, "BLAKE-224"))
+ return libhashsum_init_blake224_hasher(this);
+ if (equiv(algorithm, "BLAKE-256"))
+ return libhashsum_init_blake256_hasher(this);
+ if (equiv(algorithm, "BLAKE-384"))
+ return libhashsum_init_blake384_hasher(this);
+ if (equiv(algorithm, "BLAKE-512"))
+ return libhashsum_init_blake512_hasher(this);
errno = EINVAL;
return -1;
diff --git a/md4.c b/md4.c
index 065ca26..650c50c 100644
--- a/md4.c
+++ b/md4.c
@@ -15,7 +15,13 @@ static struct testcase testcases[] = {
{1, 0, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", "043f8582f241db351ce627e153e7f0e4"},
{1, 0, "12345678901234567890123456789012345678901234567890123456789012345678901234567890", "e33b4ddc9c38f2199c3e7b164fcc0536"},
{1, 0, "1234567890123456789012345678901234567890123456789012345678901234", "c30a2de7d6eb547b4ceb82d65e28c029"},
- {1000000UL, 0, "a", NULL}
+ {1000000UL, 0, "a", NULL},
+ {0, 1, "\xff", "15f8f7419944ac564526a3c65da2c5f3"},
+ {0, 1, "\x7f", "15f8f7419944ac564526a3c65da2c5f3"},
+ {0, 1, "\x01", "15f8f7419944ac564526a3c65da2c5f3"},
+ {0, 1, "\xfe", "8d62ecbf6ffbc49dec08bb4c537189bb"},
+ {0, 1, "\x7e", "8d62ecbf6ffbc49dec08bb4c537189bb"},
+ {0, 1, "\x00", "8d62ecbf6ffbc49dec08bb4c537189bb"}
};
diff --git a/md5.c b/md5.c
index a56ecfc..52a6b72 100644
--- a/md5.c
+++ b/md5.c
@@ -106,7 +106,13 @@ static struct testcase testcases[] = {
{2049UL, 0, "x", "01ee208262ef50b8ea672d0865ad58fa"},
{2050UL, 0, "x", "da23b925b41f6160146ade5dc7f65281"},
{2051UL, 0, "x", "2583da14d43398956e19e24a6f591748"},
- {2052UL, 0, "x", "2388049a9674713a2e82cd59d2cc9241"}
+ {2052UL, 0, "x", "2388049a9674713a2e82cd59d2cc9241"},
+ {0, 1, "\xff", "7e663710ae2348bf0deaca2c79311eae"},
+ {0, 1, "\x7f", "7e663710ae2348bf0deaca2c79311eae"},
+ {0, 1, "\x01", "7e663710ae2348bf0deaca2c79311eae"},
+ {0, 1, "\xfe", "1da635b1430f171c657206fd69fee0e8"},
+ {0, 1, "\x7e", "1da635b1430f171c657206fd69fee0e8"},
+ {0, 1, "\x00", "1da635b1430f171c657206fd69fee0e8"}
};
diff --git a/mk/blake224=no.mk b/mk/blake224=no.mk
new file mode 120000
index 0000000..54299a4
--- /dev/null
+++ b/mk/blake224=no.mk
@@ -0,0 +1 @@
+no \ No newline at end of file
diff --git a/mk/blake224=yes.mk b/mk/blake224=yes.mk
new file mode 100644
index 0000000..765741c
--- /dev/null
+++ b/mk/blake224=yes.mk
@@ -0,0 +1,4 @@
+CPPFLAGS_BLAKE224 = -DSUPPORT_BLAKE224
+
+CPPFLAGS_LIBBLAKE_IF_SUPPORTED = $(CPPFLAGS_LIBBLAKE)
+LDFLAGS_LIBBLAKE_IF_SUPPORTED = $(LDFLAGS_LIBBLAKE)
diff --git a/mk/blake256=no.mk b/mk/blake256=no.mk
new file mode 120000
index 0000000..54299a4
--- /dev/null
+++ b/mk/blake256=no.mk
@@ -0,0 +1 @@
+no \ No newline at end of file
diff --git a/mk/blake256=yes.mk b/mk/blake256=yes.mk
new file mode 100644
index 0000000..6098067
--- /dev/null
+++ b/mk/blake256=yes.mk
@@ -0,0 +1,4 @@
+CPPFLAGS_BLAKE256 = -DSUPPORT_BLAKE256
+
+CPPFLAGS_LIBBLAKE_IF_SUPPORTED = $(CPPFLAGS_LIBBLAKE)
+LDFLAGS_LIBBLAKE_IF_SUPPORTED = $(LDFLAGS_LIBBLAKE)
diff --git a/mk/blake384=no.mk b/mk/blake384=no.mk
new file mode 120000
index 0000000..54299a4
--- /dev/null
+++ b/mk/blake384=no.mk
@@ -0,0 +1 @@
+no \ No newline at end of file
diff --git a/mk/blake384=yes.mk b/mk/blake384=yes.mk
new file mode 100644
index 0000000..fb66021
--- /dev/null
+++ b/mk/blake384=yes.mk
@@ -0,0 +1,4 @@
+CPPFLAGS_BLAKE384 = -DSUPPORT_BLAKE384
+
+CPPFLAGS_LIBBLAKE_IF_SUPPORTED = $(CPPFLAGS_LIBBLAKE)
+LDFLAGS_LIBBLAKE_IF_SUPPORTED = $(LDFLAGS_LIBBLAKE)
diff --git a/mk/blake512=no.mk b/mk/blake512=no.mk
new file mode 120000
index 0000000..54299a4
--- /dev/null
+++ b/mk/blake512=no.mk
@@ -0,0 +1 @@
+no \ No newline at end of file
diff --git a/mk/blake512=yes.mk b/mk/blake512=yes.mk
new file mode 100644
index 0000000..df46eb7
--- /dev/null
+++ b/mk/blake512=yes.mk
@@ -0,0 +1,4 @@
+CPPFLAGS_BLAKE512 = -DSUPPORT_BLAKE512
+
+CPPFLAGS_LIBBLAKE_IF_SUPPORTED = $(CPPFLAGS_LIBBLAKE)
+LDFLAGS_LIBBLAKE_IF_SUPPORTED = $(LDFLAGS_LIBBLAKE)
diff --git a/ripemd-128.c b/ripemd-128.c
index 993c031..b44c494 100644
--- a/ripemd-128.c
+++ b/ripemd-128.c
@@ -13,7 +13,13 @@ static struct testcase testcases[] = {
{1, 0, "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", "a1aa0689d0fafa2ddc22e88b49133a06"},
{1, 0, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", "d1e959eb179c911faea4624c60c5c702"},
{8, 0, "1234567890", "3f45ef194732c2dbb2c4a2c769795fa3"},
- {1000000UL, 0, "a", "4a7f5723f954eba1216c9d8f6320431f"}
+ {1000000UL, 0, "a", "4a7f5723f954eba1216c9d8f6320431f"},
+ {0, 1, "\xff", "2b4535a3d10c346e06cacff50db484ca"},
+ {0, 1, "\x7f", "2b4535a3d10c346e06cacff50db484ca"},
+ {0, 1, "\x01", "2b4535a3d10c346e06cacff50db484ca"},
+ {0, 1, "\xfe", "431f5ff8e69c47afd0212863079ce205"},
+ {0, 1, "\x7e", "431f5ff8e69c47afd0212863079ce205"},
+ {0, 1, "\x00", "431f5ff8e69c47afd0212863079ce205"}
};
diff --git a/ripemd-160.c b/ripemd-160.c
index 9f3f4dd..d1a1ece 100644
--- a/ripemd-160.c
+++ b/ripemd-160.c
@@ -13,7 +13,13 @@ static struct testcase testcases[] = {
{1, 0, "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", "12a053384a9c0c88e405a06c27dcf49ada62eb2b"},
{1, 0, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", "b0e20b6e3116640286ed3a87a5713079b21f5189"},
{8, 0, "1234567890", "9b752e45573d4b39f4dbd3323cab82bf63326bfb"},
- {1000000UL, 0, "a", "52783243c1697bdbe16d37f97f68f08325dc1528"}
+ {1000000UL, 0, "a", "52783243c1697bdbe16d37f97f68f08325dc1528"},
+ {0, 1, "\xff", "4cd9629a69fdd5fa1520047fa19b4b10480041c2"},
+ {0, 1, "\x7f", "4cd9629a69fdd5fa1520047fa19b4b10480041c2"},
+ {0, 1, "\x01", "4cd9629a69fdd5fa1520047fa19b4b10480041c2"},
+ {0, 1, "\xfe", "63d03656713e6e8ea7b6be680328f9501f59f35e"},
+ {0, 1, "\x7e", "63d03656713e6e8ea7b6be680328f9501f59f35e"},
+ {0, 1, "\x00", "63d03656713e6e8ea7b6be680328f9501f59f35e"}
};
diff --git a/ripemd-256.c b/ripemd-256.c
index a892b2b..646dbba 100644
--- a/ripemd-256.c
+++ b/ripemd-256.c
@@ -22,7 +22,19 @@ static struct testcase testcases[] = {
{8, 0, "1234567890",
"06fdcc7a409548aaf91368c06a6275b553e3f099bf0ea4edfd6778df89a890dd"},
{1000000UL, 0, "a",
- "ac953744e10e31514c150d4d8d7b677342e33399788296e43ae4850ce4f97978"}
+ "ac953744e10e31514c150d4d8d7b677342e33399788296e43ae4850ce4f97978"},
+ {0, 1, "\xff",
+ "837e2738bee15d14b8a6f984b992bcd404e2df2e18f70e89c60647cd90fcfff4"},
+ {0, 1, "\x7f",
+ "837e2738bee15d14b8a6f984b992bcd404e2df2e18f70e89c60647cd90fcfff4"},
+ {0, 1, "\x01",
+ "837e2738bee15d14b8a6f984b992bcd404e2df2e18f70e89c60647cd90fcfff4"},
+ {0, 1, "\xfe",
+ "555d43ce2b77dbc1e292372ef850ff8c92ce2fa6fe778501daf37974948ccfcf"},
+ {0, 1, "\x7e",
+ "555d43ce2b77dbc1e292372ef850ff8c92ce2fa6fe778501daf37974948ccfcf"},
+ {0, 1, "\x00",
+ "555d43ce2b77dbc1e292372ef850ff8c92ce2fa6fe778501daf37974948ccfcf"}
};
diff --git a/ripemd-320.c b/ripemd-320.c
index 6d9b954..e7a5b27 100644
--- a/ripemd-320.c
+++ b/ripemd-320.c
@@ -22,7 +22,19 @@ static struct testcase testcases[] = {
{8, 0, "1234567890",
"557888af5f6d8ed62ab66945c6d2a0a47ecd5341e915eb8fea1d0524955f825dc717e4a008ab2d42"},
{1000000UL, 0, "a",
- "bdee37f4371e20646b8b0d862dda16292ae36f40965e8c8509e63d1dbddecc503e2b63eb9245bb66"}
+ "bdee37f4371e20646b8b0d862dda16292ae36f40965e8c8509e63d1dbddecc503e2b63eb9245bb66"},
+ {0, 1, "\xff",
+ "59eb0bae1fdf140b1d372eda1449048488cc9c9a584e758f33bae6df4ef6d8c472d79ec0e5bb86f9"},
+ {0, 1, "\x7f",
+ "59eb0bae1fdf140b1d372eda1449048488cc9c9a584e758f33bae6df4ef6d8c472d79ec0e5bb86f9"},
+ {0, 1, "\x01",
+ "59eb0bae1fdf140b1d372eda1449048488cc9c9a584e758f33bae6df4ef6d8c472d79ec0e5bb86f9"},
+ {0, 1, "\xfe",
+ "4805943473099cd2e8b2ae39e0f5585444216b852f92d1eb5b4c98f182ad9848a378ad7f8b6ef325"},
+ {0, 1, "\x7e",
+ "4805943473099cd2e8b2ae39e0f5585444216b852f92d1eb5b4c98f182ad9848a378ad7f8b6ef325"},
+ {0, 1, "\x00",
+ "4805943473099cd2e8b2ae39e0f5585444216b852f92d1eb5b4c98f182ad9848a378ad7f8b6ef325"}
};
diff --git a/sha0.c b/sha0.c
index 3627f61..ae530e0 100644
--- a/sha0.c
+++ b/sha0.c
@@ -5,7 +5,13 @@
static struct testcase testcases[] = {
- {1, 0, "abc", "0164b8a914cd2a5e74c4f7ff082c4d97f1edf880"}
+ {1, 0, "abc", "0164b8a914cd2a5e74c4f7ff082c4d97f1edf880"},
+ {0, 1, "\xff", "72eb6615d834148bbf63d5ddfe172a36a072a724"},
+ {0, 1, "\x7f", "72eb6615d834148bbf63d5ddfe172a36a072a724"},
+ {0, 1, "\x01", "72eb6615d834148bbf63d5ddfe172a36a072a724"},
+ {0, 1, "\xfe", "b8b0ca781d45a96d2e71f798e7e26b5c2bc8b5c8"},
+ {0, 1, "\x7e", "b8b0ca781d45a96d2e71f798e7e26b5c2bc8b5c8"},
+ {0, 1, "\x00", "b8b0ca781d45a96d2e71f798e7e26b5c2bc8b5c8"}
};
diff --git a/sha1.c b/sha1.c
index eca40ba..d7669df 100644
--- a/sha1.c
+++ b/sha1.c
@@ -27,7 +27,13 @@ static struct testcase testcases[] = {
{0, 4, "\x0d", "ba582f5967911beb91599684c2eb2baeefb78da7"},
{0, 5, "\x09", "3320540d1c28b96ddd03eee1b186a8f2ae883fbe"},
{0, 6, "\x08", "b372bd120957ebc3392cd060e131699d1fee6059"},
- {0, 7, "\x22", "04f31807151181ad0db278a1660526b0aeef64c2"}
+ {0, 7, "\x22", "04f31807151181ad0db278a1660526b0aeef64c2"},
+ {0, 1, "\xff", "59c4526aa2cc59f9a5f56b5579ba7108e7ccb61a"},
+ {0, 1, "\x7f", "59c4526aa2cc59f9a5f56b5579ba7108e7ccb61a"},
+ {0, 1, "\x01", "59c4526aa2cc59f9a5f56b5579ba7108e7ccb61a"},
+ {0, 1, "\xfe", "bb6b3e18f0115b57925241676f5b1ae88747b08a"},
+ {0, 1, "\x7e", "bb6b3e18f0115b57925241676f5b1ae88747b08a"},
+ {0, 1, "\x00", "bb6b3e18f0115b57925241676f5b1ae88747b08a"}
};
diff --git a/sha3_224.c b/sha3_224.c
index ccbf5cf..4f3891f 100644
--- a/sha3_224.c
+++ b/sha3_224.c
@@ -335,7 +335,13 @@ static struct testcase testcases[] = {
{1, 0, "chevalier slat's spindel representations", "a64779aca943a6aef1d2e7c9a0f4e997f4dabd1f77112a22121d3ed5"},
{1, 0, "archery lexicographical equine veered", "f0a3e0587af7723f0aa4719059d3f5107115a5b3667cd5209cc4d867"},
{1, 0, "splay washbasin opposing there", "312e7e3c6403ab1a086155fb9a52b22a3d0d257876afd2b93fb7272e"},
- {1, 0, "faktum desist thundered klen", "270ba05b764221ff5b5d94adfb4fdb1f36f07fe7c438904a5f3df071"}
+ {1, 0, "faktum desist thundered klen", "270ba05b764221ff5b5d94adfb4fdb1f36f07fe7c438904a5f3df071"},
+ {0, 1, "\xff", "6f2fc54a6b11a6da611ed734505b9cab89eecc1dc7dd2debd27bd1c9"},
+ {0, 1, "\x7f", "6f2fc54a6b11a6da611ed734505b9cab89eecc1dc7dd2debd27bd1c9"},
+ {0, 1, "\x01", "6f2fc54a6b11a6da611ed734505b9cab89eecc1dc7dd2debd27bd1c9"},
+ {0, 1, "\xfe", "82000b40579ecbbe7f57cc132656530861e408becb51070288cec752"},
+ {0, 1, "\x7e", "82000b40579ecbbe7f57cc132656530861e408becb51070288cec752"},
+ {0, 1, "\x00", "82000b40579ecbbe7f57cc132656530861e408becb51070288cec752"}
};
diff --git a/sha3_256.c b/sha3_256.c
index 40614f6..fd57a2d 100644
--- a/sha3_256.c
+++ b/sha3_256.c
@@ -6,6 +6,12 @@
static struct testcase testcases[] = {
{1, 0, "", "a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a"},
+ {0, 1, "\xff", "83f66216d2cc769e153bafce0181b61a471b4c6a213fc6f59a42985f976f33fe"},
+ {0, 1, "\x7f", "83f66216d2cc769e153bafce0181b61a471b4c6a213fc6f59a42985f976f33fe"},
+ {0, 1, "\x01", "83f66216d2cc769e153bafce0181b61a471b4c6a213fc6f59a42985f976f33fe"},
+ {0, 1, "\xfe", "1b2e61923578e35f3b4629e04a0ff3b73daa571ae01130d9c16ef7da7a4cfdc2"},
+ {0, 1, "\x7e", "1b2e61923578e35f3b4629e04a0ff3b73daa571ae01130d9c16ef7da7a4cfdc2"},
+ {0, 1, "\x00", "1b2e61923578e35f3b4629e04a0ff3b73daa571ae01130d9c16ef7da7a4cfdc2"}
};
diff --git a/sha3_384.c b/sha3_384.c
index 367c5ed..81bf084 100644
--- a/sha3_384.c
+++ b/sha3_384.c
@@ -6,6 +6,12 @@
static struct testcase testcases[] = {
{1, 0, "", "0c63a75b845e4f7d01107d852e4c2485c51a50aaaa94fc61995e71bbee983a2ac3713831264adb47fb6bd1e058d5f004"},
+ {0, 1, "\xff", "3fae4536cd205ee08ed88e0e6f1152717f5afe181f9afeb508507f7429fd5031558e844edb73cb19b129cfeb55082617"},
+ {0, 1, "\x7f", "3fae4536cd205ee08ed88e0e6f1152717f5afe181f9afeb508507f7429fd5031558e844edb73cb19b129cfeb55082617"},
+ {0, 1, "\x01", "3fae4536cd205ee08ed88e0e6f1152717f5afe181f9afeb508507f7429fd5031558e844edb73cb19b129cfeb55082617"},
+ {0, 1, "\xfe", "d880bd58197c5c3d596fb73eca0897c69599b306c9135d3a6765ac41e19faa6e51f10710a4e68cf3c0af0e7869d3219b"},
+ {0, 1, "\x7e", "d880bd58197c5c3d596fb73eca0897c69599b306c9135d3a6765ac41e19faa6e51f10710a4e68cf3c0af0e7869d3219b"},
+ {0, 1, "\x00", "d880bd58197c5c3d596fb73eca0897c69599b306c9135d3a6765ac41e19faa6e51f10710a4e68cf3c0af0e7869d3219b"}
};
diff --git a/sha3_512.c b/sha3_512.c
index cda82ed..b05f680 100644
--- a/sha3_512.c
+++ b/sha3_512.c
@@ -8,6 +8,24 @@ static struct testcase testcases[] = {
{1, 0, "",
"a69f73cca23a9ac5c8b567dc185a756e97c982164fe25859e0d1dcc1475c80a6"
"15b2123af1f5f94c11e3e9402c3ac558f500199d95b6d3e301758586281dcd26"},
+ {0, 1, "\xff",
+ "0580220015f6b256328efe4d4af7ebd85187c42fe52fdc82ecc6ff5cee7c8473"
+ "f4a1911073ab7598eb41c6095ecfa05c1e148f726c3d474d66d1e4bcc191923c"},
+ {0, 1, "\x7f",
+ "0580220015f6b256328efe4d4af7ebd85187c42fe52fdc82ecc6ff5cee7c8473"
+ "f4a1911073ab7598eb41c6095ecfa05c1e148f726c3d474d66d1e4bcc191923c"},
+ {0, 1, "\x01",
+ "0580220015f6b256328efe4d4af7ebd85187c42fe52fdc82ecc6ff5cee7c8473"
+ "f4a1911073ab7598eb41c6095ecfa05c1e148f726c3d474d66d1e4bcc191923c"},
+ {0, 1, "\xfe",
+ "57600f99901ad7c7232e520a20097cf37c48257b51b7a69a570b2bb9535a7253"
+ "b8240318cc0e5ab990b3f1b6e8e7e7b16d43936416abe2eb9f84fdbe0f41e0f2"},
+ {0, 1, "\x7e",
+ "57600f99901ad7c7232e520a20097cf37c48257b51b7a69a570b2bb9535a7253"
+ "b8240318cc0e5ab990b3f1b6e8e7e7b16d43936416abe2eb9f84fdbe0f41e0f2"},
+ {0, 1, "\x00",
+ "57600f99901ad7c7232e520a20097cf37c48257b51b7a69a570b2bb9535a7253"
+ "b8240318cc0e5ab990b3f1b6e8e7e7b16d43936416abe2eb9f84fdbe0f41e0f2"}
};
diff --git a/sha_224.c b/sha_224.c
index f0a9287..e84260a 100644
--- a/sha_224.c
+++ b/sha_224.c
@@ -27,7 +27,13 @@ static struct testcase testcases[] = {
{0, 4, "\x05", "b04c423c9091ff5bb32ea4b0063e98814633350c1bc2bd974f776fd2"},
{0, 5, "\x0d", "e3b048552c3c387bcab37f6eb06bb79b96a4aee5ff27f51531a9551c"},
{0, 6, "\x2b", "44b64a6dbd91d49df5af0c9f8e001b1378e1dc29c4b891350e5d7bd9"},
- {0, 7, "\x0c", "20f25c1fe299cf337ff7ff9cc4b5b5afac076759720174a29ba79db6"}
+ {0, 7, "\x0c", "20f25c1fe299cf337ff7ff9cc4b5b5afac076759720174a29ba79db6"},
+ {0, 1, "\xff", "0d05096bca2a4a77a2b47a05a59618d01174b37892376135c1b6e957"},
+ {0, 1, "\x7f", "0d05096bca2a4a77a2b47a05a59618d01174b37892376135c1b6e957"},
+ {0, 1, "\x01", "0d05096bca2a4a77a2b47a05a59618d01174b37892376135c1b6e957"},
+ {0, 1, "\xfe", "d3fe57cb76cdd24e9eb23e7e15684e039c75459beaae100f89712e9d"},
+ {0, 1, "\x7e", "d3fe57cb76cdd24e9eb23e7e15684e039c75459beaae100f89712e9d"},
+ {0, 1, "\x00", "d3fe57cb76cdd24e9eb23e7e15684e039c75459beaae100f89712e9d"}
};
diff --git a/sha_256.c b/sha_256.c
index 17dda3a..d7eb5dc 100644
--- a/sha_256.c
+++ b/sha_256.c
@@ -23,7 +23,13 @@ static struct testcase testcases[] = {
#endif
{1, 0, "abc", "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"},
{1, 0, "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
- "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1"}
+ "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1"},
+ {0, 1, "\xff", "b9debf7d52f36e6468a54817c1fa071166c3a63d384850e1575b42f702dc5aa1"},
+ {0, 1, "\x7f", "b9debf7d52f36e6468a54817c1fa071166c3a63d384850e1575b42f702dc5aa1"},
+ {0, 1, "\x01", "b9debf7d52f36e6468a54817c1fa071166c3a63d384850e1575b42f702dc5aa1"},
+ {0, 1, "\xfe", "bd4f9e98beb68c6ead3243b1b4c7fed75fa4feaab1f84795cbd8a98676a2a375"},
+ {0, 1, "\x7e", "bd4f9e98beb68c6ead3243b1b4c7fed75fa4feaab1f84795cbd8a98676a2a375"},
+ {0, 1, "\x00", "bd4f9e98beb68c6ead3243b1b4c7fed75fa4feaab1f84795cbd8a98676a2a375"}
};
diff --git a/sha_384.c b/sha_384.c
index 802ace0..f627608 100644
--- a/sha_384.c
+++ b/sha_384.c
@@ -34,7 +34,13 @@ static struct testcase testcases[] = {
{1, 0, "abc",
"cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7"},
{1, 0, "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu",
- "09330c33f71147e83d192fc782cd1b4753111b173b3b05d22fa08086e3b0f712fcc7c71a557e2db966c3e9fa91746039"}
+ "09330c33f71147e83d192fc782cd1b4753111b173b3b05d22fa08086e3b0f712fcc7c71a557e2db966c3e9fa91746039"},
+ {0, 1, "\xff", "9eef0094544d88a6e9ccdf9e31d039c5ca96682293ab1cc3afc6016486190f3d20c89d5a13ebc9d13ff011b411af9186"},
+ {0, 1, "\x7f", "9eef0094544d88a6e9ccdf9e31d039c5ca96682293ab1cc3afc6016486190f3d20c89d5a13ebc9d13ff011b411af9186"},
+ {0, 1, "\x01", "9eef0094544d88a6e9ccdf9e31d039c5ca96682293ab1cc3afc6016486190f3d20c89d5a13ebc9d13ff011b411af9186"},
+ {0, 1, "\xfe", "634aa63038a164ae6c7d48b319f2aca0a107908e548519204c6d72dbeac0fdc3c9246674f98e8fd30221ba986e737d61"},
+ {0, 1, "\x7e", "634aa63038a164ae6c7d48b319f2aca0a107908e548519204c6d72dbeac0fdc3c9246674f98e8fd30221ba986e737d61"},
+ {0, 1, "\x00", "634aa63038a164ae6c7d48b319f2aca0a107908e548519204c6d72dbeac0fdc3c9246674f98e8fd30221ba986e737d61"}
};
diff --git a/sha_512.c b/sha_512.c
index 01b9460..c370750 100644
--- a/sha_512.c
+++ b/sha_512.c
@@ -49,7 +49,25 @@ static struct testcase testcases[] = {
{1, 0, "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhi"
"jklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu",
"8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018"
- "501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909"}
+ "501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909"},
+ {0, 1, "\xff",
+ "5f72ee8494a425ba13fc8c48ac0a05cbaae7e932e471e948cb524333745aa432"
+ "c1851c0c43682b0e67d64626f8f45cf165f6b538a94c63be98224e969e75d7ed"},
+ {0, 1, "\x7f",
+ "5f72ee8494a425ba13fc8c48ac0a05cbaae7e932e471e948cb524333745aa432"
+ "c1851c0c43682b0e67d64626f8f45cf165f6b538a94c63be98224e969e75d7ed"},
+ {0, 1, "\x01",
+ "5f72ee8494a425ba13fc8c48ac0a05cbaae7e932e471e948cb524333745aa432"
+ "c1851c0c43682b0e67d64626f8f45cf165f6b538a94c63be98224e969e75d7ed"},
+ {0, 1, "\xfe",
+ "b4594eb12959fc2e6979b6783554299cc0369f44083a8b0955baefd8830cda22"
+ "894b0b46c0ed49490e391ad99af856cc1bd96f238c7f2a17cf37aeb7e793395a"},
+ {0, 1, "\x7e",
+ "b4594eb12959fc2e6979b6783554299cc0369f44083a8b0955baefd8830cda22"
+ "894b0b46c0ed49490e391ad99af856cc1bd96f238c7f2a17cf37aeb7e793395a"},
+ {0, 1, "\x00",
+ "b4594eb12959fc2e6979b6783554299cc0369f44083a8b0955baefd8830cda22"
+ "894b0b46c0ed49490e391ad99af856cc1bd96f238c7f2a17cf37aeb7e793395a"}
};