Module Name: othersrc
Committed By: agc
Date: Sat Aug 17 18:29:35 UTC 2013
Modified Files:
othersrc/external/bsd/multigest/bin: 10.expected 11.expected
12.expected 19.expected 2.expected 20.expected 4.expected
5.expected 6.expected 7.expected 9.expected Makefile
othersrc/external/bsd/multigest/dist: blake2.c blake2.h keccak.c
keccak.h main.c multigest.c multigest.h
Added Files:
othersrc/external/bsd/multigest/dist: Makefile
Log Message:
multigest changes:
+ fix a bug whereby large multiple digests overflowed the context space
because they weren't taking into account the current algorithm's context
space needs
+ add my own copyright where substantial work has been done
+ move to a portable, lightweight RFC1738-inspired encoding for VCS identifiers
(we can't be assured that any of the vis(3) routines are going to be
available)
+ re-do all the regression test results to avoid the RCS Ids being expanded
in checked-in regression tests
+ make keccak sources thread-safe by moving the initialisation space into the
keccak context space
+ print details of expected and calculated digests during check if the
digests do NOT match (from Thomas Klausner, the original behaviour was
from debugging tests - thanks!)
To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 othersrc/external/bsd/multigest/bin/10.expected \
othersrc/external/bsd/multigest/bin/11.expected \
othersrc/external/bsd/multigest/bin/12.expected \
othersrc/external/bsd/multigest/bin/19.expected \
othersrc/external/bsd/multigest/bin/2.expected \
othersrc/external/bsd/multigest/bin/20.expected \
othersrc/external/bsd/multigest/bin/4.expected \
othersrc/external/bsd/multigest/bin/5.expected \
othersrc/external/bsd/multigest/bin/6.expected \
othersrc/external/bsd/multigest/bin/7.expected \
othersrc/external/bsd/multigest/bin/9.expected \
othersrc/external/bsd/multigest/bin/Makefile
cvs rdiff -u -r0 -r1.1 othersrc/external/bsd/multigest/dist/Makefile
cvs rdiff -u -r1.1.1.1 -r1.2 othersrc/external/bsd/multigest/dist/blake2.c \
othersrc/external/bsd/multigest/dist/blake2.h \
othersrc/external/bsd/multigest/dist/keccak.c \
othersrc/external/bsd/multigest/dist/keccak.h \
othersrc/external/bsd/multigest/dist/main.c \
othersrc/external/bsd/multigest/dist/multigest.c \
othersrc/external/bsd/multigest/dist/multigest.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: othersrc/external/bsd/multigest/bin/10.expected
diff -u othersrc/external/bsd/multigest/bin/10.expected:1.1.1.1 othersrc/external/bsd/multigest/bin/10.expected:1.2
--- othersrc/external/bsd/multigest/bin/10.expected:1.1.1.1 Fri Aug 16 06:47:53 2013
+++ othersrc/external/bsd/multigest/bin/10.expected Sat Aug 17 18:29:35 2013
@@ -1,2 +0,0 @@
-provided digest: '93af9cbe145da570b71c7a57b84dcdb19419a8bc6c8dfad8fc17a935d626fd38b8d7ff164ffdf08e1ecbb1bb9d0982fb5f3a57c82294befe985e279a0f27e1f193af9cbe145da570b71c7a57b84dcdb19419a8bc6c8dfad8fc17a935d626fd38b8d7ff164ffdf08e1ecbb1bb9d0982fb5f3a57c82294befe985e279a0f27e1f193af9cbe145da570b71c7a57b84dcdb19419a8bc6c8dfad8fc17a935d626fd38b8d7ff164ffdf08e1ecbb1bb9d0982fb5f3a57c82294befe985e279a0f27e1f193af9cbe145da570b71c7a57b84dcdb19419a8bc6c8dfad8fc17a935d626fd38b8d7ff164ffdf08e1ecbb1bb9d0982fb5f3a57c82294befe985e279a0f27e1f193af9cbe145da570b71c7a57b84dcdb19419a8bc6c8dfad8fc17a935d626fd38b8d7ff164ffdf08e1ecbb1bb9d0982fb5f3a57c82294befe985e279a0f27e1f193af9cbe145da570b71c7a57b84dcdb19419a8bc6c8dfad8fc17a935d626fd38b8d7ff164ffdf08e1ecbb1bb9d0982fb5f3a57c82294befe985e279a0f27e1f193af9cbe145da570b71c7a57b84dcdb19419a8bc6c8dfad8fc17a935d626fd38b8d7ff164ffdf08e1ecbb1bb9d0982fb5f3a57c82294befe985e279a0f27e1f193af9cbe145da570b71c7a57b84dcdb19419a8bc6c8dfad8fc17a935d626fd38b8d7ff164
ffdf08e1ecbb1bb9d0982fb5f3a57c82294befe985e279a0f27e1f193af9cbe145da570b71c7a57b84dcdb19419a8bc6c8dfad8fc17a935d626fd38b8d7ff164ffdf08e1ecbb1bb9d0982fb5f3a57c82294befe985e279a0f27e1f193af9cbe145da570b71c7a57b84dcdb19419a8bc6c8dfad8fc17a935d626fd38b8d7ff164ffdf08e1ecbb1bb9d0982fb5f3a57c82294befe985e279a0f27e1f193af9cbe145da570b71c7a57b84dcdb19419a8bc6c8dfad8fc17a935d626fd38b8d7ff164ffdf08e1ecbb1bb9d0982fb5f3a57c82294befe985e279a0f27e1f1'
-calculated digest: '93af9cbe145da570b71c7a57b84dcdb19419a8bc6c8dfad8fc17a935d626fd38b8d7ff164ffdf08e1ecbb1bb9d0982fb5f3a57c82294befe985e279a0f27e1f193af9cbe145da570b71c7a57b84dcdb19419a8bc6c8dfad8fc17a935d626fd38b8d7ff164ffdf08e1ecbb1bb9d0982fb5f3a57c82294befe985e279a0f27e1f193af9cbe145da570b71c7a57b84dcdb19419a8bc6c8dfad8fc17a935d626fd38b8d7ff164ffdf08e1ecbb1bb9d0982fb5f3a57c82294befe985e279a0f27e1f193af9cbe145da570b71c7a57b84dcdb19419a8bc6c8dfad8fc17a935d626fd38b8d7ff164ffdf08e1ecbb1bb9d0982fb5f3a57c82294befe985e279a0f27e1f193af9cbe145da570b71c7a57b84dcdb19419a8bc6c8dfad8fc17a935d626fd38b8d7ff164ffdf08e1ecbb1bb9d0982fb5f3a57c82294befe985e279a0f27e1f193af9cbe145da570b71c7a57b84dcdb19419a8bc6c8dfad8fc17a935d626fd38b8d7ff164ffdf08e1ecbb1bb9d0982fb5f3a57c82294befe985e279a0f27e1f193af9cbe145da570b71c7a57b84dcdb19419a8bc6c8dfad8fc17a935d626fd38b8d7ff164ffdf08e1ecbb1bb9d0982fb5f3a57c82294befe985e279a0f27e1f193af9cbe145da570b71c7a57b84dcdb19419a8bc6c8dfad8fc17a935d626fd38b8d7ff164
ffdf08e1ecbb1bb9d0982fb5f3a57c82294befe985e279a0f27e1f193af9cbe145da570b71c7a57b84dcdb19419a8bc6c8dfad8fc17a935d626fd38b8d7ff164ffdf08e1ecbb1bb9d0982fb5f3a57c82294befe985e279a0f27e1f193af9cbe145da570b71c7a57b84dcdb19419a8bc6c8dfad8fc17a935d626fd38b8d7ff164ffdf08e1ecbb1bb9d0982fb5f3a57c82294befe985e279a0f27e1f193af9cbe145da570b71c7a57b84dcdb19419a8bc6c8dfad8fc17a935d626fd38b8d7ff164ffdf08e1ecbb1bb9d0982fb5f3a57c82294befe985e279a0f27e1f1'
Index: othersrc/external/bsd/multigest/bin/11.expected
diff -u othersrc/external/bsd/multigest/bin/11.expected:1.1.1.1 othersrc/external/bsd/multigest/bin/11.expected:1.2
--- othersrc/external/bsd/multigest/bin/11.expected:1.1.1.1 Fri Aug 16 06:47:53 2013
+++ othersrc/external/bsd/multigest/bin/11.expected Sat Aug 17 18:29:35 2013
@@ -1 +1 @@
-CRC32C,MD5,RMD160,SHA1,SHA256,SHA512 (2.in) (,\$(Id|NetBSD)[^\n]*\$,$NetBSD: 11.expected,v 1.1.1.1 2013/08/16 06:47:53 agc Exp $) = 279934d7b43c46ba05e28788df71eaea4777912ffaad8f20db6708582703a0ef4bc79a61c34a91bc114f266e7a71dc51811df9dc994bce4de69170c9835bc89fbf57f3a6aa9168b776bd3ef2ba6bcf6e6934a12380b10272ae73679ca92644bdf34583700776b58728501c15ee8300feb6ddba910c462618bce2221a0445036a2d46e676ef32988283372710701eb39fa7a59821b740bf07a3d364a5
+CRC32C,MD5,RMD160,SHA1,SHA256,SHA512 (2.in) (,\%24(Id|NetBSD)[^%0a]*\%24,%24NetBSD%24) = 279934d7b43c46ba05e28788df71eaea4777912ffaad8f20db6708582703a0ef4bc79a61c34a91bc114f266e7a71dc51811df9dc994bce4de69170c9835bc89fbf57f3a6aa9168b776bd3ef2ba6bcf6e6934a12380b10272ae73679ca92644bdf34583700776b58728501c15ee8300feb6ddba910c462618bce2221a0445036a2d46e676ef32988283372710701eb39fa7a59821b740bf07a3d364a5
Index: othersrc/external/bsd/multigest/bin/12.expected
diff -u othersrc/external/bsd/multigest/bin/12.expected:1.1.1.1 othersrc/external/bsd/multigest/bin/12.expected:1.2
--- othersrc/external/bsd/multigest/bin/12.expected:1.1.1.1 Fri Aug 16 06:47:53 2013
+++ othersrc/external/bsd/multigest/bin/12.expected Sat Aug 17 18:29:35 2013
@@ -1,2 +0,0 @@
-provided digest: '279934d7b43c46ba05e28788df71eaea4777912ffaad8f20db6708582703a0ef4bc79a61c34a91bc114f266e7a71dc51811df9dc994bce4de69170c9835bc89fbf57f3a6aa9168b776bd3ef2ba6bcf6e6934a12380b10272ae73679ca92644bdf34583700776b58728501c15ee8300feb6ddba910c462618bce2221a0445036a2d46e676ef32988283372710701eb39fa7a59821b740bf07a3d364a5'
-calculated digest: '279934d7b43c46ba05e28788df71eaea4777912ffaad8f20db6708582703a0ef4bc79a61c34a91bc114f266e7a71dc51811df9dc994bce4de69170c9835bc89fbf57f3a6aa9168b776bd3ef2ba6bcf6e6934a12380b10272ae73679ca92644bdf34583700776b58728501c15ee8300feb6ddba910c462618bce2221a0445036a2d46e676ef32988283372710701eb39fa7a59821b740bf07a3d364a5'
Index: othersrc/external/bsd/multigest/bin/19.expected
diff -u othersrc/external/bsd/multigest/bin/19.expected:1.1.1.1 othersrc/external/bsd/multigest/bin/19.expected:1.2
--- othersrc/external/bsd/multigest/bin/19.expected:1.1.1.1 Fri Aug 16 06:47:53 2013
+++ othersrc/external/bsd/multigest/bin/19.expected Sat Aug 17 18:29:35 2013
@@ -1 +1 @@
-SIZE (2.in) () = 00000000000016f5
+SIZE (2.in) () = 00000000000016ef
Index: othersrc/external/bsd/multigest/bin/2.expected
diff -u othersrc/external/bsd/multigest/bin/2.expected:1.1.1.1 othersrc/external/bsd/multigest/bin/2.expected:1.2
--- othersrc/external/bsd/multigest/bin/2.expected:1.1.1.1 Fri Aug 16 06:47:53 2013
+++ othersrc/external/bsd/multigest/bin/2.expected Sat Aug 17 18:29:35 2013
@@ -1 +1 @@
-SHA1 (2.in) (,\$(Id|NetBSD)[^\n]*\$,$NetBSD: 2.expected,v 1.1.1.1 2013/08/16 06:47:53 agc Exp $) = 114f266e7a71dc51811df9dc994bce4de69170c9
+SHA1 (2.in) (,\%24(Id|NetBSD)[^%0a]*\%24,%24NetBSD%24) = 114f266e7a71dc51811df9dc994bce4de69170c9
Index: othersrc/external/bsd/multigest/bin/20.expected
diff -u othersrc/external/bsd/multigest/bin/20.expected:1.1.1.1 othersrc/external/bsd/multigest/bin/20.expected:1.2
--- othersrc/external/bsd/multigest/bin/20.expected:1.1.1.1 Fri Aug 16 06:47:53 2013
+++ othersrc/external/bsd/multigest/bin/20.expected Sat Aug 17 18:29:35 2013
@@ -1 +1 @@
-BLAKE2,CRC32C,MD5,RMD160,SHA1,SHA256,SHA3-224,SHA3-256,SHA3-384,SHA3-512,SHA512,SIZE,TIGER2,TIGER,WHIRLPOOL (2.in) (,\$(Id|NetBSD)[^\n]*\$,$NetBSD: 20.expected,v 1.1.1.1 2013/08/16 06:47:53 agc Exp $) = 5388c3a6ac094bd49d82ca1404d111cbf1cbb64cd6a7cd47b7b366b1b89447988a96f2064d9e7d48746fee39128f33bfd3e537085d48088f7ddc6da8d4b2e7df279934d7b43c46ba05e28788df71eaea4777912ffaad8f20db6708582703a0ef4bc79a61c34a91bc114f266e7a71dc51811df9dc994bce4de69170c9835bc89fbf57f3a6aa9168b776bd3ef2ba6bcf6e6934a12380b10272ae73679c1cd5c98e369f050cdef21f260e4930e2d4fb50dbd89ebe73b45867f8c8db407d733900b40499f5103018696d773bb246a23d465d8fa2ef5a8b7ecf29fd303cf644be9d1c638bb8aaf5f7ba48eadd3e7fd86f6fa3f4fd378e7d39626077a56b343e5beffe6dc1de78b33a4dfa349259f3a560d4eaef508b4ce9cf1d84199b0a3db8dd0d4f5fe5d9e52beb40d660890296b1275cf75b49544ff76e0db804eca97aa9fc2e7c4de96a3fb8af2069a92644bdf34583700776b58728501c15ee8300feb6ddba910c462618bce2221a0445036a2d46e676ef32988283372710701eb39fa7a59821b740bf07a3d364a500
000000000016955be276d25e1bb131e9f3089052492cfa3da484855759a53238eb28030a6a3e9511e2d1dbee6e37c0dd3f93c55b149acf4d77b962c86eb1303d186bf2fdc8f011511b0f720f3171850aec1a462e2067218ee672d0b66950cf7ee6078df0593a9fd22109984cc31b2fd327b223f1a7c634
+BLAKE2,CRC32C,MD5,RMD160,SHA1,SHA256,SHA3-224,SHA3-256,SHA3-384,SHA3-512,SHA512,SIZE,TIGER2,TIGER,WHIRLPOOL (2.in) (,\%24(Id|NetBSD)[^%0a]*\%24,%24NetBSD%24) = 5388c3a6ac094bd49d82ca1404d111cbf1cbb64cd6a7cd47b7b366b1b89447988a96f2064d9e7d48746fee39128f33bfd3e537085d48088f7ddc6da8d4b2e7df279934d7b43c46ba05e28788df71eaea4777912ffaad8f20db6708582703a0ef4bc79a61c34a91bc114f266e7a71dc51811df9dc994bce4de69170c9835bc89fbf57f3a6aa9168b776bd3ef2ba6bcf6e6934a12380b10272ae73679c1cd5c98e369f050cdef21f260e4930e2d4fb50dbd89ebe73b45867f8c8db407d733900b40499f5103018696d773bb246a23d465d8fa2ef5a8b7ecf29fd303cf644be9d1c638bb8aaf5f7ba48eadd3e7fd86f6fa3f4fd378e7d39626077a56b343e5beffe6dc1de78b33a4dfa349259f3a560d4eaef508b4ce9cf1d84199b0a3db8dd0d4f5fe5d9e52beb40d660890296b1275cf75b49544ff76e0db804eca97aa9fc2e7c4de96a3fb8af2069a92644bdf34583700776b58728501c15ee8300feb6ddba910c462618bce2221a0445036a2d46e676ef32988283372710701eb39fa7a59821b740bf07a3d364a500000000000016955be276d25e1bb131e9f3089052492
cfa3da484855759a53238eb28030a6a3e9511e2d1dbee6e37c0dd3f93c55b149acf4d77b962c86eb1303d186bf2fdc8f011511b0f720f3171850aec1a462e2067218ee672d0b66950cf7ee6078df0593a9fd22109984cc31b2fd327b223f1a7c634
Index: othersrc/external/bsd/multigest/bin/4.expected
diff -u othersrc/external/bsd/multigest/bin/4.expected:1.1.1.1 othersrc/external/bsd/multigest/bin/4.expected:1.2
--- othersrc/external/bsd/multigest/bin/4.expected:1.1.1.1 Fri Aug 16 06:47:53 2013
+++ othersrc/external/bsd/multigest/bin/4.expected Sat Aug 17 18:29:35 2013
@@ -1 +1 @@
-SHA1 (2.in) (,\$(Id|NetBSD)[^\n]*\$,$NetBSD: 4.expected,v 1.1.1.1 2013/08/16 06:47:53 agc Exp $) = 114f266e7a71dc51811df9dc994bce4de69170c9
+SHA1 (2.in) (,\%24(Id|NetBSD)[^%0a]*\%24,%24NetBSD%24) = 114f266e7a71dc51811df9dc994bce4de69170c9
Index: othersrc/external/bsd/multigest/bin/5.expected
diff -u othersrc/external/bsd/multigest/bin/5.expected:1.1.1.1 othersrc/external/bsd/multigest/bin/5.expected:1.2
--- othersrc/external/bsd/multigest/bin/5.expected:1.1.1.1 Fri Aug 16 06:47:53 2013
+++ othersrc/external/bsd/multigest/bin/5.expected Sat Aug 17 18:29:35 2013
@@ -1 +1 @@
-SHA256 (2.in) (,\$(Id|NetBSD)[^\n]*\$,$NetBSD: 5.expected,v 1.1.1.1 2013/08/16 06:47:53 agc Exp $) = 835bc89fbf57f3a6aa9168b776bd3ef2ba6bcf6e6934a12380b10272ae73679c
+SHA256 (2.in) (,\%24(Id|NetBSD)[^%0a]*\%24,%24NetBSD%24) = 835bc89fbf57f3a6aa9168b776bd3ef2ba6bcf6e6934a12380b10272ae73679c
Index: othersrc/external/bsd/multigest/bin/6.expected
diff -u othersrc/external/bsd/multigest/bin/6.expected:1.1.1.1 othersrc/external/bsd/multigest/bin/6.expected:1.2
--- othersrc/external/bsd/multigest/bin/6.expected:1.1.1.1 Fri Aug 16 06:47:53 2013
+++ othersrc/external/bsd/multigest/bin/6.expected Sat Aug 17 18:29:35 2013
@@ -1 +1 @@
-SHA1,SHA256 (2.in) (,\$(Id|NetBSD)[^\n]*\$,$NetBSD: 6.expected,v 1.1.1.1 2013/08/16 06:47:53 agc Exp $) = 114f266e7a71dc51811df9dc994bce4de69170c9835bc89fbf57f3a6aa9168b776bd3ef2ba6bcf6e6934a12380b10272ae73679c
+SHA1,SHA256 (2.in) (,\%24(Id|NetBSD)[^%0a]*\%24,%24NetBSD%24) = 114f266e7a71dc51811df9dc994bce4de69170c9835bc89fbf57f3a6aa9168b776bd3ef2ba6bcf6e6934a12380b10272ae73679c
Index: othersrc/external/bsd/multigest/bin/7.expected
diff -u othersrc/external/bsd/multigest/bin/7.expected:1.1.1.1 othersrc/external/bsd/multigest/bin/7.expected:1.2
--- othersrc/external/bsd/multigest/bin/7.expected:1.1.1.1 Fri Aug 16 06:47:53 2013
+++ othersrc/external/bsd/multigest/bin/7.expected Sat Aug 17 18:29:35 2013
@@ -1 +1 @@
-CRC32C,SHA1,SHA256 (2.in) (,\$(Id|NetBSD)[^\n]*\$,$NetBSD: 7.expected,v 1.1.1.1 2013/08/16 06:47:53 agc Exp $) = 279934d7114f266e7a71dc51811df9dc994bce4de69170c9835bc89fbf57f3a6aa9168b776bd3ef2ba6bcf6e6934a12380b10272ae73679c
+CRC32C,SHA1,SHA256 (2.in) (,\%24(Id|NetBSD)[^%0a]*\%24,%24NetBSD%24) = 279934d7114f266e7a71dc51811df9dc994bce4de69170c9835bc89fbf57f3a6aa9168b776bd3ef2ba6bcf6e6934a12380b10272ae73679c
Index: othersrc/external/bsd/multigest/bin/9.expected
diff -u othersrc/external/bsd/multigest/bin/9.expected:1.1.1.1 othersrc/external/bsd/multigest/bin/9.expected:1.2
--- othersrc/external/bsd/multigest/bin/9.expected:1.1.1.1 Fri Aug 16 06:47:53 2013
+++ othersrc/external/bsd/multigest/bin/9.expected Sat Aug 17 18:29:35 2013
@@ -1,2 +0,0 @@
-provided digest: 'b0197d624ecf7547d2d486a20c9d05c25f6e6729'
-calculated digest: 'b0197d624ecf7547d2d486a20c9d05c25f6e6729'
Index: othersrc/external/bsd/multigest/bin/Makefile
diff -u othersrc/external/bsd/multigest/bin/Makefile:1.1.1.1 othersrc/external/bsd/multigest/bin/Makefile:1.2
--- othersrc/external/bsd/multigest/bin/Makefile:1.1.1.1 Fri Aug 16 06:47:53 2013
+++ othersrc/external/bsd/multigest/bin/Makefile Sat Aug 17 18:29:35 2013
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.1.1.1 2013/08/16 06:47:53 agc Exp $
+# $NetBSD: Makefile,v 1.2 2013/08/17 18:29:35 agc Exp $
.include <bsd.own.mk>
@@ -31,9 +31,8 @@ t: ${PROG}
diff 2.expected 2.out
rm -f 2.out
env LD_LIBRARY_PATH=${LIB_MULTIGEST_DIR} ./${PROG} -r < 2.in > 3.out
- digest sha1 < 2.in.normalised > 3.norm.out
- diff 3.norm.out 3.out
- rm -f 3.norm.out 3.out
+ diff 3.expected 3.out
+ rm -f 3.out
env LD_LIBRARY_PATH=${LIB_MULTIGEST_DIR} ./${PROG} -o 4.out -r 2.in
diff 4.expected 4.out
rm -f 4.out
Index: othersrc/external/bsd/multigest/dist/blake2.c
diff -u othersrc/external/bsd/multigest/dist/blake2.c:1.1.1.1 othersrc/external/bsd/multigest/dist/blake2.c:1.2
--- othersrc/external/bsd/multigest/dist/blake2.c:1.1.1.1 Fri Aug 16 06:47:53 2013
+++ othersrc/external/bsd/multigest/dist/blake2.c Sat Aug 17 18:29:35 2013
@@ -1,3 +1,27 @@
+/*-
+ * Copyright (c) 2013 Alistair Crooks <[email protected]>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
#include <stdint.h>
#include <string.h>
#include <stdio.h>
Index: othersrc/external/bsd/multigest/dist/blake2.h
diff -u othersrc/external/bsd/multigest/dist/blake2.h:1.1.1.1 othersrc/external/bsd/multigest/dist/blake2.h:1.2
--- othersrc/external/bsd/multigest/dist/blake2.h:1.1.1.1 Fri Aug 16 06:47:53 2013
+++ othersrc/external/bsd/multigest/dist/blake2.h Sat Aug 17 18:29:35 2013
@@ -1,3 +1,27 @@
+/*-
+ * Copyright (c) 2013 Alistair Crooks <[email protected]>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
#ifndef BLAKE2_H_
#define BLAKE2_H_ 20130814
Index: othersrc/external/bsd/multigest/dist/keccak.c
diff -u othersrc/external/bsd/multigest/dist/keccak.c:1.1.1.1 othersrc/external/bsd/multigest/dist/keccak.c:1.2
--- othersrc/external/bsd/multigest/dist/keccak.c:1.1.1.1 Fri Aug 16 06:47:53 2013
+++ othersrc/external/bsd/multigest/dist/keccak.c Sat Aug 17 18:29:35 2013
@@ -1,3 +1,27 @@
+/*-
+ * Copyright (c) 2013 Alistair Crooks <[email protected]>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
/*
The Keccak sponge function, designed by Guido Bertoni, Joan Daemen,
Michaël Peeters and Gilles Van Assche. For more information, feedback or
@@ -18,11 +42,6 @@ http://creativecommons.org/publicdomain/
#include "keccak.h"
-#define nrRounds 24
-static uint64_t KeccakRoundConstants[nrRounds];
-#define nrLanes 25
-static unsigned int KeccakRhoOffsets[nrLanes];
-
static void
fromBytesToWords(uint64_t *stateAsWords, const uint8_t *state)
{
@@ -74,13 +93,13 @@ theta(uint64_t *A)
}
static void
-rho(uint64_t *A)
+rho(KECCAK_CTX *ctx, uint64_t *A)
{
unsigned int x, y;
for(x=0; x<5; x++) {
for(y=0; y<5; y++) {
- A[INDEX(x, y)] = ROL64(A[INDEX(x, y)], KeccakRhoOffsets[INDEX(x, y)]);
+ A[INDEX(x, y)] = ROL64(A[INDEX(x, y)], ctx->KeccakRhoOffsets[INDEX(x, y)]);
}
}
}
@@ -120,50 +139,50 @@ chi(uint64_t *A)
}
static void
-iota(uint64_t *A, unsigned int indexRound)
+iota(KECCAK_CTX *ctx, uint64_t *A, unsigned int indexRound)
{
- A[INDEX(0, 0)] ^= KeccakRoundConstants[indexRound];
+ A[INDEX(0, 0)] ^= ctx->KeccakRoundConstants[indexRound];
}
static void
-KeccakPermutationOnWords(uint64_t *state)
+KeccakPermutationOnWords(KECCAK_CTX *ctx, uint64_t *st)
{
unsigned int i;
- for(i=0; i<nrRounds; i++) {
- theta(state);
- rho(state);
- pi(state);
- chi(state);
- iota(state, i);
+ for(i=0; i<KeccaknrRounds; i++) {
+ theta(st);
+ rho(ctx, st);
+ pi(st);
+ chi(st);
+ iota(ctx, st, i);
}
}
static void
-keccak_permutation(uint8_t *state)
+keccak_permutation(KECCAK_CTX *ctx)
{
const int indian = 1;
uint64_t stateAsWords[KeccakPermutationSize/64];
if (*(const char *)(const void *)&indian) {
/* little endian */
- KeccakPermutationOnWords((uint64_t*)(void *)state);
+ KeccakPermutationOnWords(ctx, (uint64_t*)(void *)ctx->state);
} else {
- fromBytesToWords(stateAsWords, state);
- KeccakPermutationOnWords(stateAsWords);
- fromWordsToBytes(state, stateAsWords);
+ fromBytesToWords(stateAsWords, ctx->state);
+ KeccakPermutationOnWords(ctx, stateAsWords);
+ fromWordsToBytes(ctx->state, stateAsWords);
}
}
static void
-KeccakPermutationAfterXor(uint8_t *state, const uint8_t *data, unsigned int dataLengthInBytes)
+KeccakPermutationAfterXor(KECCAK_CTX *ctx, uint8_t *state, const uint8_t *data, unsigned int dataLengthInBytes)
{
unsigned int i;
for(i=0; i<dataLengthInBytes; i++) {
state[i] ^= data[i];
}
- keccak_permutation(state);
+ keccak_permutation(ctx);
}
static int
@@ -181,32 +200,32 @@ LFSR86540(uint8_t *LFSR)
}
static void
-keccak_initialise_RoundConstants(void)
+keccak_initialise_RoundConstants(KECCAK_CTX *ctx)
{
uint8_t LFSRstate = 0x01;
unsigned int i, j, bitPosition;
- for(i=0; i<nrRounds; i++) {
- KeccakRoundConstants[i] = 0;
+ for(i=0; i<KeccaknrRounds; i++) {
+ ctx->KeccakRoundConstants[i] = 0;
for(j=0; j<7; j++) {
bitPosition = (1<<j)-1; //2^j-1
if (LFSR86540(&LFSRstate)) {
- KeccakRoundConstants[i] ^= (uint64_t)1<<bitPosition;
+ ctx->KeccakRoundConstants[i] ^= (uint64_t)1<<bitPosition;
}
}
}
}
static void
-keccak_initialise_RhoOffsets(void)
+keccak_initialise_RhoOffsets(KECCAK_CTX *ctx)
{
unsigned int x, y, t, newX, newY;
- KeccakRhoOffsets[INDEX(0, 0)] = 0;
+ ctx->KeccakRhoOffsets[INDEX(0, 0)] = 0;
x = 1;
y = 0;
for(t=0; t<24; t++) {
- KeccakRhoOffsets[INDEX(x, y)] = ((t+1)*(t+2)/2) % 64;
+ ctx->KeccakRhoOffsets[INDEX(x, y)] = ((t+1)*(t+2)/2) % 64;
newX = (0*x+1*y) % 5;
newY = (2*x+3*y) % 5;
x = newX;
@@ -215,10 +234,10 @@ keccak_initialise_RhoOffsets(void)
}
static void
-keccak_initialize(void)
+keccak_initialize(KECCAK_CTX *ctx)
{
- keccak_initialise_RoundConstants();
- keccak_initialise_RhoOffsets();
+ keccak_initialise_RoundConstants(ctx);
+ keccak_initialise_RhoOffsets(ctx);
}
static void
@@ -228,9 +247,9 @@ keccak_initialise_state(uint8_t *state)
}
static void
-KeccakAbsorb(uint8_t *state, const uint8_t *data, unsigned int laneCount)
+KeccakAbsorb(KECCAK_CTX *ctx, uint8_t *state, const uint8_t *data, unsigned int laneCount)
{
- KeccakPermutationAfterXor(state, data, laneCount*8);
+ KeccakPermutationAfterXor(ctx, state, data, laneCount*8);
}
static void
@@ -240,7 +259,7 @@ keccak_extract(const uint8_t *state, uin
}
static int
-init_sponge(KECCAK_CTX *state, unsigned int rate, unsigned int capacity)
+init_sponge(KECCAK_CTX *ctx, unsigned int rate, unsigned int capacity)
{
if (rate+capacity != 1600) {
return 1;
@@ -248,64 +267,64 @@ init_sponge(KECCAK_CTX *state, unsigned
if ((rate == 0) || (rate >= 1600) || ((rate % 64) != 0)) {
return 1;
}
- keccak_initialize();
- state->rate = rate;
- state->capacity = capacity;
- state->fixedOutputLength = 0;
- keccak_initialise_state(state->state);
- memset(state->dataQueue, 0, KeccakMaximumRateInBytes);
- state->bitsInQueue = 0;
- state->squeezing = 0;
- state->bitsAvailableForSqueezing = 0;
+ keccak_initialize(ctx);
+ ctx->rate = rate;
+ ctx->capacity = capacity;
+ ctx->fixedOutputLength = 0;
+ keccak_initialise_state(ctx->state);
+ memset(ctx->dataQueue, 0, KeccakMaximumRateInBytes);
+ ctx->bitsInQueue = 0;
+ ctx->squeezing = 0;
+ ctx->bitsAvailableForSqueezing = 0;
return 0;
}
static void
-absorb_queue(KECCAK_CTX *state)
+absorb_queue(KECCAK_CTX *ctx)
{
// state->bitsInQueue is assumed to be equal to state->rate
- KeccakAbsorb(state->state, state->dataQueue, state->rate/64);
- state->bitsInQueue = 0;
+ KeccakAbsorb(ctx, ctx->state, ctx->dataQueue, ctx->rate/64);
+ ctx->bitsInQueue = 0;
}
static int
-absorb(KECCAK_CTX *state, const uint8_t *data, uint64_t databitlen)
+absorb(KECCAK_CTX *ctx, const uint8_t *data, uint64_t databitlen)
{
uint64_t i, j, wholeBlocks;
unsigned int partialBlock, partialByte;
const uint8_t *curData;
- if ((state->bitsInQueue % 8) != 0) {
+ if ((ctx->bitsInQueue % 8) != 0) {
return 1; // Only the last call may contain a partial byte
}
- if (state->squeezing) {
+ if (ctx->squeezing) {
return 1; // Too late for additional input
}
for (i = 0; i < databitlen ; ) {
- if ((state->bitsInQueue == 0) && (databitlen >= state->rate) && (i <= (databitlen-state->rate))) {
- wholeBlocks = (databitlen-i)/state->rate;
+ if ((ctx->bitsInQueue == 0) && (databitlen >= ctx->rate) && (i <= (databitlen-ctx->rate))) {
+ wholeBlocks = (databitlen-i)/ctx->rate;
curData = &data[(long)i/8];
- for(j=0; j<wholeBlocks; j++, curData+=state->rate/8) {
- KeccakAbsorb(state->state, curData, state->rate/64);
+ for(j=0; j<wholeBlocks; j++, curData+=ctx->rate/8) {
+ KeccakAbsorb(ctx, ctx->state, curData, ctx->rate/64);
}
- i += wholeBlocks*state->rate;
+ i += wholeBlocks*ctx->rate;
} else {
partialBlock = (unsigned int)(databitlen - i);
- if (partialBlock+state->bitsInQueue > state->rate) {
- partialBlock = state->rate-state->bitsInQueue;
+ if (partialBlock+ctx->bitsInQueue > ctx->rate) {
+ partialBlock = ctx->rate-ctx->bitsInQueue;
}
partialByte = partialBlock % 8;
partialBlock -= partialByte;
- memcpy(state->dataQueue+state->bitsInQueue/8, &data[(unsigned long)i/8], partialBlock/8);
- state->bitsInQueue += partialBlock;
+ memcpy(ctx->dataQueue+ctx->bitsInQueue/8, &data[(unsigned long)i/8], partialBlock/8);
+ ctx->bitsInQueue += partialBlock;
i += partialBlock;
- if (state->bitsInQueue == state->rate) {
- absorb_queue(state);
+ if (ctx->bitsInQueue == ctx->rate) {
+ absorb_queue(ctx);
}
if (partialByte > 0) {
uint8_t mask = (1 << partialByte)-1;
- state->dataQueue[state->bitsInQueue/8] = data[(unsigned long)i/8] & mask;
- state->bitsInQueue += partialByte;
+ ctx->dataQueue[ctx->bitsInQueue/8] = data[(unsigned long)i/8] & mask;
+ ctx->bitsInQueue += partialByte;
i += partialByte;
}
}
@@ -314,50 +333,50 @@ absorb(KECCAK_CTX *state, const uint8_t
}
static void
-PadAndSwitchToSqueezingPhase(KECCAK_CTX *state)
+PadAndSwitchToSqueezingPhase(KECCAK_CTX *ctx)
{
// Note: the bits are numbered from 0=LSB to 7=MSB
- if (state->bitsInQueue + 1 == state->rate) {
- state->dataQueue[state->bitsInQueue/8 ] |= 1 << (state->bitsInQueue % 8);
- absorb_queue(state);
- memset(state->dataQueue, 0, state->rate/8);
+ if (ctx->bitsInQueue + 1 == ctx->rate) {
+ ctx->dataQueue[ctx->bitsInQueue/8 ] |= 1 << (ctx->bitsInQueue % 8);
+ absorb_queue(ctx);
+ memset(ctx->dataQueue, 0, ctx->rate/8);
} else {
- memset(state->dataQueue + (state->bitsInQueue+7)/8, 0, state->rate/8 - (state->bitsInQueue+7)/8);
- state->dataQueue[state->bitsInQueue/8 ] |= 1 << (state->bitsInQueue % 8);
+ memset(ctx->dataQueue + (ctx->bitsInQueue+7)/8, 0, ctx->rate/8 - (ctx->bitsInQueue+7)/8);
+ ctx->dataQueue[ctx->bitsInQueue/8 ] |= 1 << (ctx->bitsInQueue % 8);
}
- state->dataQueue[(state->rate-1)/8] |= 1 << ((state->rate-1) % 8);
- absorb_queue(state);
- keccak_extract(state->state, state->dataQueue, state->rate/64);
- state->bitsAvailableForSqueezing = state->rate;
- state->squeezing = 1;
+ ctx->dataQueue[(ctx->rate-1)/8] |= 1 << ((ctx->rate-1) % 8);
+ absorb_queue(ctx);
+ keccak_extract(ctx->state, ctx->dataQueue, ctx->rate/64);
+ ctx->bitsAvailableForSqueezing = ctx->rate;
+ ctx->squeezing = 1;
}
static int
-squeeze(KECCAK_CTX *state, uint8_t *output, uint64_t outputLength)
+squeeze(KECCAK_CTX *ctx, uint8_t *output, uint64_t outputLength)
{
uint64_t i;
unsigned int partialBlock;
- if (!state->squeezing) {
- PadAndSwitchToSqueezingPhase(state);
+ if (!ctx->squeezing) {
+ PadAndSwitchToSqueezingPhase(ctx);
}
if ((outputLength % 8) != 0) {
return 1; // Only multiple of 8 bits are allowed, truncation can be done at user level
}
for (i = 0; i < outputLength ; i += partialBlock) {
- if (state->bitsAvailableForSqueezing == 0) {
- keccak_permutation(state->state);
- keccak_extract(state->state, state->dataQueue, state->rate/64);
- state->bitsAvailableForSqueezing = state->rate;
+ if (ctx->bitsAvailableForSqueezing == 0) {
+ keccak_permutation(ctx);
+ keccak_extract(ctx->state, ctx->dataQueue, ctx->rate/64);
+ ctx->bitsAvailableForSqueezing = ctx->rate;
}
- partialBlock = state->bitsAvailableForSqueezing;
+ partialBlock = ctx->bitsAvailableForSqueezing;
if ((uint64_t)partialBlock > outputLength - i) {
partialBlock = (unsigned int)(outputLength - i);
}
memcpy(&output[(unsigned long)i/8],
- state->dataQueue+(state->rate-state->bitsAvailableForSqueezing)/8,
+ ctx->dataQueue+(ctx->rate-ctx->bitsAvailableForSqueezing)/8,
partialBlock/8);
- state->bitsAvailableForSqueezing -= partialBlock;
+ ctx->bitsAvailableForSqueezing -= partialBlock;
}
return 0;
}
@@ -365,52 +384,52 @@ squeeze(KECCAK_CTX *state, uint8_t *outp
/***************************************************************/
HashReturn
-KECCAK_Init(KECCAK_CTX *state, int hashbitlen)
+KECCAK_Init(KECCAK_CTX *ctx, int hashbitlen)
{
switch(hashbitlen) {
case 0: // Default parameters, arbitrary length output
- init_sponge((KECCAK_CTX*)state, 1024, 576);
+ init_sponge((KECCAK_CTX*)ctx, 1024, 576);
break;
case 224:
- init_sponge((KECCAK_CTX*)state, 1152, 448);
+ init_sponge((KECCAK_CTX*)ctx, 1152, 448);
break;
case 256:
- init_sponge((KECCAK_CTX*)state, 1088, 512);
+ init_sponge((KECCAK_CTX*)ctx, 1088, 512);
break;
case 384:
- init_sponge((KECCAK_CTX*)state, 832, 768);
+ init_sponge((KECCAK_CTX*)ctx, 832, 768);
break;
case 512:
- init_sponge((KECCAK_CTX*)state, 576, 1024);
+ init_sponge((KECCAK_CTX*)ctx, 576, 1024);
break;
default:
return BAD_HASHLEN;
}
- state->fixedOutputLength = hashbitlen;
+ ctx->fixedOutputLength = hashbitlen;
return SUCCESS;
}
HashReturn
-KECCAK_Update(KECCAK_CTX *state, const uint8_t *data, uint64_t databitlen)
+KECCAK_Update(KECCAK_CTX *ctx, const uint8_t *data, uint64_t databitlen)
{
HashReturn ret;
if ((databitlen % 8) == 0) {
- return absorb((KECCAK_CTX*)state, data, databitlen);
+ return absorb((KECCAK_CTX*)ctx, data, databitlen);
}
- ret = absorb((KECCAK_CTX*)state, data, databitlen - (databitlen % 8));
+ ret = absorb((KECCAK_CTX*)ctx, data, databitlen - (databitlen % 8));
if (ret == SUCCESS) {
uint8_t lastByte;
// Align the last partial byte to the least significant bits
lastByte = data[(unsigned long)databitlen/8] >> (8 - (databitlen % 8));
- return absorb((KECCAK_CTX*)state, &lastByte, databitlen % 8);
+ return absorb((KECCAK_CTX*)ctx, &lastByte, databitlen % 8);
}
return ret;
}
HashReturn
-KECCAK_Final(KECCAK_CTX *state, uint8_t *hashval)
+KECCAK_Final(KECCAK_CTX *ctx, uint8_t *hashval)
{
- return squeeze(state, hashval, state->fixedOutputLength);
+ return squeeze(ctx, hashval, ctx->fixedOutputLength);
}
Index: othersrc/external/bsd/multigest/dist/keccak.h
diff -u othersrc/external/bsd/multigest/dist/keccak.h:1.1.1.1 othersrc/external/bsd/multigest/dist/keccak.h:1.2
--- othersrc/external/bsd/multigest/dist/keccak.h:1.1.1.1 Fri Aug 16 06:47:54 2013
+++ othersrc/external/bsd/multigest/dist/keccak.h Sat Aug 17 18:29:35 2013
@@ -1,3 +1,27 @@
+/*-
+ * Copyright (c) 2013 Alistair Crooks <[email protected]>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
/*
The Keccak sponge function, designed by Guido Bertoni, Joan Daemen,
Michaël Peeters and Gilles Van Assche. For more information, feedback or
@@ -20,6 +44,9 @@ http://creativecommons.org/publicdomain/
#define KeccakMaximumRate 1536
#define KeccakMaximumRateInBytes (KeccakMaximumRate/8)
+#define KeccaknrRounds 24
+#define KeccaknrLanes 25
+
#if defined(__GNUC__)
#define ALIGN __attribute__ ((aligned(32)))
#elif defined(_MSC_VER)
@@ -29,14 +56,16 @@ http://creativecommons.org/publicdomain/
#endif
ALIGN typedef struct KECCAK_CTX {
- ALIGN uint8_t state[KeccakPermutationSizeInBytes];
- ALIGN uint8_t dataQueue[KeccakMaximumRateInBytes];
- unsigned int rate;
- unsigned int capacity;
- unsigned int bitsInQueue;
- unsigned int fixedOutputLength;
- int squeezing;
- unsigned int bitsAvailableForSqueezing;
+ ALIGN uint8_t state[KeccakPermutationSizeInBytes];
+ ALIGN uint8_t dataQueue[KeccakMaximumRateInBytes];
+ uint32_t rate;
+ uint32_t capacity;
+ uint32_t bitsInQueue;
+ uint32_t fixedOutputLength;
+ int32_t squeezing;
+ uint32_t bitsAvailableForSqueezing;
+ uint64_t KeccakRoundConstants[KeccaknrRounds];
+ uint32_t KeccakRhoOffsets[KeccaknrLanes];
} KECCAK_CTX;
typedef enum { SUCCESS = 0, FAIL = 1, BAD_HASHLEN = 2 } HashReturn;
@@ -53,9 +82,9 @@ typedef enum { SUCCESS = 0, FAIL = 1, BA
__BEGIN_DECLS
-HashReturn KECCAK_Init(KECCAK_CTX *state, int hashbitlen);
-HashReturn KECCAK_Update(KECCAK_CTX *state, const uint8_t *data, uint64_t databitlen);
-HashReturn KECCAK_Final(KECCAK_CTX *state, uint8_t *hashval);
+HashReturn KECCAK_Init(KECCAK_CTX */*ctx*/, int /*hashbitlen*/);
+HashReturn KECCAK_Update(KECCAK_CTX */*ctx*/, const uint8_t */*data*/, uint64_t /*databitlen*/);
+HashReturn KECCAK_Final(KECCAK_CTX */*ctx*/, uint8_t */*hashval*/);
__END_DECLS
Index: othersrc/external/bsd/multigest/dist/main.c
diff -u othersrc/external/bsd/multigest/dist/main.c:1.1.1.1 othersrc/external/bsd/multigest/dist/main.c:1.2
--- othersrc/external/bsd/multigest/dist/main.c:1.1.1.1 Fri Aug 16 06:47:53 2013
+++ othersrc/external/bsd/multigest/dist/main.c Sat Aug 17 18:29:35 2013
@@ -73,8 +73,7 @@ getsubst(const char *arg, char *from, si
}
len = (size_t)(sep - arg) - 1;
len = MIN(fromsize - 1, len);
- memcpy(from, arg + 1, len);
- from[len] = 0x0;
+ multigest_unpcstring(arg + 1, len, from, fromsize);
for (sub = ++sep ; *sep && *sep != *arg ; sep++) {
if (*sep == '\\') {
sep += 1;
@@ -82,8 +81,7 @@ getsubst(const char *arg, char *from, si
}
len = (size_t)(sep - sub);
len = MIN(tosize - 1, len);
- memcpy(to, sub, len);
- to[len] = 0x0;
+ multigest_unpcstring(sub, len, to, tosize);
return 1;
}
@@ -94,10 +92,10 @@ read_check(const char *check)
struct stat st;
regmatch_t match[10];
regex_t r;
- uint8_t raw[4096];
+ uint8_t raw[8192];
FILE *fp;
char *provided;
- char calc[4096];
+ char calc[8192];
char from[128];
char to[128];
char *file;
@@ -131,8 +129,8 @@ read_check(const char *check)
getsubst(subs, from, sizeof(from), to, sizeof(to));
multigest_file(file, alg, raw, from, to);
multigest_format_hex(raw, alg, calc, sizeof(calc));
- if ((ret = memcmp(calc, provided, match[4].rm_eo - match[4].rm_so)) == 0) {
- fprintf(stdout, "provided digest: '%s'\ncalculated digest: '%s'\n", provided, calc);
+ if ((ret = memcmp(calc, provided, match[4].rm_eo - match[4].rm_so)) != 0) {
+ fprintf(stderr, "multigest: provided digest: '%s', calculated digest: '%s'\n", provided, calc);
}
regfree(&r);
free(in);
@@ -146,7 +144,7 @@ main(int argc, char **argv)
const char *check;
const char *alg;
const char *sub;
- uint8_t raw[4096];
+ uint8_t raw[8192];
char from[128];
char to[128];
int ok;
Index: othersrc/external/bsd/multigest/dist/multigest.c
diff -u othersrc/external/bsd/multigest/dist/multigest.c:1.1.1.1 othersrc/external/bsd/multigest/dist/multigest.c:1.2
--- othersrc/external/bsd/multigest/dist/multigest.c:1.1.1.1 Fri Aug 16 06:47:53 2013
+++ othersrc/external/bsd/multigest/dist/multigest.c Sat Aug 17 18:29:35 2013
@@ -51,6 +51,10 @@
#define __arraycount(__x) (sizeof(__x) / sizeof(__x[0]))
#endif
+#ifndef USE_ARG
+#define USE_ARG(x) /*LINTED*/(void)&(x)
+#endif
+
#define MB(x) ((x) * 1024 * 1024)
/*
@@ -234,6 +238,7 @@ wrap_size_update(void *v, const char *da
{
uint64_t n;
+ USE_ARG(data);
memcpy(&n, v, sizeof(n));
n += len;
memcpy(v, &n, sizeof(n));
@@ -371,15 +376,17 @@ findalg(const char *algname)
return NULL;
}
-/* make a string visible */
+/* percent encode (pseudo-RFC1738) a string */
static void
-pstring(FILE *fp, const char *s)
+pcstring(FILE *fp, const char *s)
{
+ static const char *pcencodes = "%$\r\n\t ";
+
for ( ; *s ; s++) {
- if (*s == '\n') {
- fprintf(fp, "\\n");
- } else {
+ if (strchr(pcencodes, *s) == NULL) {
fprintf(fp, "%c", *s);
+ } else {
+ fprintf(fp, "%%%02hhx", *s);
}
}
}
@@ -411,7 +418,7 @@ multigest_init(multigest_t *multigest, c
(alg = findalg(algname)) == NULL) {
break;
}
- if (ctxoff >= multigest->ctxsize) {
+ if (ctxoff + alg->ctxsize >= multigest->ctxsize) {
if ((newv = realloc(multigest->ctx, multigest->ctxsize + 4096)) == NULL) {
return 0;
}
@@ -583,6 +590,30 @@ multigest_free(multigest_t *s)
}
}
+/* percent decode (pseudo-RFC1738) a string */
+void
+multigest_unpcstring(const char *in, size_t isize, char *out, size_t osize)
+{
+ static const char *hexes = "0123456789abcdef";
+ const char *p[2];
+ const char *i;
+ char *o;
+
+ for (i = in, o = out ; (size_t)(o - out) < osize - 1 && (size_t)(i - in) < isize && *i ; o++) {
+ if (*i == '%') {
+ if ((p[0] = strchr(hexes, i[1])) == NULL ||
+ (p[1] = strchr(hexes, i[2])) == NULL) {
+ break;
+ }
+ *o = ((p[0] - hexes) * 16) + (p[1] - hexes);
+ i += 3;
+ } else {
+ *o = *i++;
+ }
+ }
+ *o = 0x0;
+}
+
/* print as hex string */
int
multigest_format_hex(uint8_t *raw, const char *algname, char *out, size_t size)
@@ -629,7 +660,7 @@ multigest_print_hex(uint8_t *raw, const
}
fprintf(fp, " (%s) (", f);
if (sub) {
- pstring(fp, sub);
+ pcstring(fp, sub);
}
fprintf(fp, ") = ");
}
Index: othersrc/external/bsd/multigest/dist/multigest.h
diff -u othersrc/external/bsd/multigest/dist/multigest.h:1.1.1.1 othersrc/external/bsd/multigest/dist/multigest.h:1.2
--- othersrc/external/bsd/multigest/dist/multigest.h:1.1.1.1 Fri Aug 16 06:47:53 2013
+++ othersrc/external/bsd/multigest/dist/multigest.h Sat Aug 17 18:29:35 2013
@@ -86,6 +86,7 @@ int multigest_data(const char */*data*/,
int multigest_file(const char */*f*/, const char */*alg*/, uint8_t */*raw*/, const char */*pat*/, const char */*repl*/);
/* output */
+void multigest_unpcstring(const char */*in*/, size_t /*isize*/, char */*out*/, size_t /*osize*/);
uint32_t multigest_get_rawsize(multigest_t */*multigest*/);
int multigest_format_hex(uint8_t */*raw*/, const char */*algname*/, char */*out*/, size_t /*size*/);
int multigest_print_hex(uint8_t */*raw*/, const char */*algname*/, const char */*outname*/, const char */*f*/, const char */*sub*/);
Added files:
Index: othersrc/external/bsd/multigest/dist/Makefile
diff -u /dev/null othersrc/external/bsd/multigest/dist/Makefile:1.1
--- /dev/null Sat Aug 17 18:29:35 2013
+++ othersrc/external/bsd/multigest/dist/Makefile Sat Aug 17 18:29:35 2013
@@ -0,0 +1,20 @@
+# $NetBSD: Makefile,v 1.1 2013/08/17 18:29:35 agc Exp $
+
+.include <bsd.own.mk>
+
+PROG=m
+SRCS= blake2.c crc32c.c keccak.c main.c md5c.c multigest.c rmd160.c sha1.c sha2.c tiger.c whirlpool.c
+CPPFLAGS+=-I.
+
+CPPFLAGS+=-g -O0
+LDFLAGS+=-g -O0
+
+WARNS=6
+MAN=multigest.1
+
+.include <bsd.prog.mk>
+
+t: ${PROG}
+ ./${PROG} -o 20.out -a blake2,crc32c,md5,rmd160,sha1,sha256,sha3-224,sha3-256,sha3-384,sha3-512,sha512,size,tiger2,tiger,whirlpool -r ${.CURDIR}/../bin/2.in
+ diff 20.expected 20.out
+ rm -f 20.out