Squashed commit of the following:

commit 47c75c6e9397e240919207e50e5a611d3e2a2428
Merge: d7685c2 42085ee
Author: Jeffrey Walton <noloader@gmail.com>
Date:   Thu Sep 8 20:20:39 2016 -0400

    Attempting to fix binary file merge conflict

commit d7685c2d946beecc419ddb6901c24e972c7cf3ee
Author: Jeffrey Walton <noloader@gmail.com>
Date:   Thu Sep 8 16:39:23 2016 -0400

    Add vsClean.cmd to vs2010.zip

commit 4b96fdf1c551260da60eb021f324bcc3fcfec626
Author: Jeffrey Walton <noloader@gmail.com>
Date:   Thu Sep 8 16:15:38 2016 -0400

    Add Keccak to vs2010.zip

commit 3962db73b7113ee805b46a5bb4da64e204fe6bb0
Author: Jeffrey Walton <noloader@gmail.com>
Date:   Thu Sep 8 15:40:35 2016 -0400

    Fold hmqv.cpp and fhmqv.cpp into mqv.cpp. There's no need for three empty source files

commit 44401448cbb6c8125b0f1ab4419c5b174408ffd7
Author: Jeffrey Walton <noloader@gmail.com>
Date:   Thu Sep 8 15:39:23 2016 -0400

    Fold hmqv.cpp and fhmqv.cpp into mqv.cpp. There's no need for three empty source files

commit 847bfccb8d5c388e67745dc8c69768fa503c5135
Author: Jeffrey Walton <noloader@gmail.com>
Date:   Thu Sep 8 14:48:02 2016 -0400

    Whitespace cleanup

commit 46a37be6fef361704dcf852bc9a099ce0a1da4c8
Merge: aefb8f8 3697867
Author: Jeffrey Walton <noloader@gmail.com>
Date:   Thu Sep 8 14:43:01 2016 -0400

    Merge 'master' into 'keccak'

commit aefb8f8ff2b81b967089c53b457a92fc6f7544d6
Merge: 51a828b 3c91d93
Author: Jeffrey Walton <noloader@gmail.com>
Date:   Thu Sep 8 12:39:51 2016 -0400

    Merge 'master' into 'keccak'

commit 51a828b88e37a4d18abb00300cd5522bd0e110c5
Merge: 4152870 e7c7722
Author: Jeffrey Walton <noloader@gmail.com>
Date:   Thu Sep 8 10:41:36 2016 -0400

    Merge 'master' into 'keccak'

commit 415287041e69ddadf5ca1f6fc794b87e145fc2db
Merge: 357a0c5 83ac849
Author: Jeffrey Walton <noloader@gmail.com>
Date:   Thu Sep 8 10:34:45 2016 -0400

    Merge 'master' into 'keccak'

commit 357a0c510f75e4e58078b500dd469462e90f7650
Author: Jeffrey Walton <noloader@gmail.com>
Date:   Thu Sep 8 10:13:32 2016 -0400

    Removed deprecated warning from SHA3 classes

commit 5cf9ec10d53b895b5a583e265e4e1298ed402195
Merge: 10ce0ed c2d60cc
Author: Jeffrey Walton <noloader@gmail.com>
Date:   Thu Sep 8 09:43:15 2016 -0400

    Merge 'master' into 'keccak'

commit 10ce0ed4c5b8a1ea230062fd2dfdec0d87ec5b42
Author: Jeffrey Walton <noloader@gmail.com>
Date:   Thu Sep 8 09:37:40 2016 -0400

    Add Keccak implementation based on early SHA3. Change SHA3 to NIST FIPS 202 conforming implementation
This commit is contained in:
Jeffrey Walton 2016-09-08 20:24:25 -04:00
parent 42085eea41
commit 7f958575ea
28 changed files with 526 additions and 347 deletions

View File

@ -148,6 +148,8 @@ integer.cpp
integer.h
iterhash.cpp
iterhash.h
keccak.cpp
keccak.h
lubyrack.h
luc.cpp
luc.h
@ -380,7 +382,6 @@ TestData/xtrdh342.dat
TestVectors/Readme.txt
TestVectors/aes.txt
TestVectors/all.txt
TestVectors/all_fips_202.txt
TestVectors/blake2.txt
TestVectors/blake2b.txt
TestVectors/blake2s.txt
@ -396,18 +397,19 @@ TestVectors/esign.txt
TestVectors/gcm.txt
TestVectors/hkdf.txt
TestVectors/hmac.txt
TestVectors/keccak.txt
TestVectors/mars.txt
TestVectors/nr.txt
TestVectors/panama.txt
TestVectors/rsa_oaep.txt
TestVectors/rsa_pkcs1_1_5.txt
TestVectors/rsa_pss.txt
TestVectors/dsa_rfc6979.txt
TestVectors/rw.txt
TestVectors/salsa.txt
TestVectors/seal.txt
TestVectors/seed.txt
TestVectors/sha.txt
TestVectors/sha3.txt
TestVectors/sha3_fips_202.txt
TestVectors/sha3_224_fips_202.txt
TestVectors/sha3_256_fips_202.txt

View File

@ -443,7 +443,7 @@ TESTOBJS := $(TESTSRCS:.cpp=.o)
LIBOBJS := $(filter-out $(TESTOBJS),$(OBJS))
# List cryptlib.cpp first in an attempt to tame C++ static initialization problems
DLLSRCS := cryptlib.cpp cpu.cpp integer.cpp shacal2.cpp md5.cpp shark.cpp zinflate.cpp gf2n.cpp salsa.cpp xtr.cpp oaep.cpp hmqv.cpp polynomi.cpp rc2.cpp default.cpp wait.cpp wake.cpp twofish.cpp iterhash.cpp adler32.cpp elgamal.cpp marss.cpp blowfish.cpp ecp.cpp filters.cpp strciphr.cpp camellia.cpp ida.cpp zlib.cpp des.cpp crc.cpp algparam.cpp dessp.cpp tea.cpp eax.cpp network.cpp emsa2.cpp pkcspad.cpp squaretb.cpp idea.cpp authenc.cpp hmac.cpp zdeflate.cpp xtrcrypt.cpp queue.cpp mars.cpp rc5.cpp blake2.cpp hrtimer.cpp eprecomp.cpp hex.cpp dsa.cpp fhmqv.cpp sha.cpp fips140.cpp gzip.cpp seal.cpp files.cpp base32.cpp vmac.cpp tigertab.cpp sharkbox.cpp safer.cpp randpool.cpp esign.cpp arc4.cpp osrng.cpp skipjack.cpp seed.cpp sha3.cpp sosemanuk.cpp bfinit.cpp rabin.cpp 3way.cpp rw.cpp rdrand.cpp rsa.cpp rdtables.cpp gost.cpp socketft.cpp tftables.cpp nbtheory.cpp panama.cpp modes.cpp rijndael.cpp casts.cpp chacha.cpp gfpcrypt.cpp poly1305.cpp dll.cpp ec2n.cpp blumshub.cpp algebra.cpp basecode.cpp base64.cpp cbcmac.cpp rc6.cpp dh2.cpp gf256.cpp mqueue.cpp misc.cpp pssr.cpp channels.cpp tiger.cpp cast.cpp rng.cpp square.cpp asn.cpp whrlpool.cpp md4.cpp dh.cpp ccm.cpp md2.cpp mqv.cpp gf2_32.cpp ttmac.cpp luc.cpp trdlocal.cpp pubkey.cpp gcm.cpp ripemd.cpp eccrypto.cpp serpent.cpp cmac.cpp
DLLSRCS := cryptlib.cpp cpu.cpp integer.cpp shacal2.cpp md5.cpp shark.cpp zinflate.cpp gf2n.cpp salsa.cpp xtr.cpp oaep.cpp polynomi.cpp rc2.cpp default.cpp wait.cpp wake.cpp twofish.cpp iterhash.cpp adler32.cpp elgamal.cpp marss.cpp blowfish.cpp ecp.cpp filters.cpp strciphr.cpp camellia.cpp ida.cpp zlib.cpp des.cpp crc.cpp algparam.cpp dessp.cpp tea.cpp eax.cpp network.cpp emsa2.cpp pkcspad.cpp squaretb.cpp idea.cpp authenc.cpp hmac.cpp zdeflate.cpp xtrcrypt.cpp queue.cpp mars.cpp rc5.cpp blake2.cpp hrtimer.cpp eprecomp.cpp hex.cpp dsa.cpp sha.cpp fips140.cpp gzip.cpp seal.cpp files.cpp base32.cpp vmac.cpp tigertab.cpp sharkbox.cpp safer.cpp randpool.cpp esign.cpp arc4.cpp osrng.cpp skipjack.cpp seed.cpp sha3.cpp sosemanuk.cpp bfinit.cpp rabin.cpp 3way.cpp rw.cpp rdrand.cpp rsa.cpp rdtables.cpp gost.cpp socketft.cpp tftables.cpp nbtheory.cpp panama.cpp modes.cpp rijndael.cpp casts.cpp chacha.cpp gfpcrypt.cpp poly1305.cpp dll.cpp ec2n.cpp blumshub.cpp algebra.cpp basecode.cpp base64.cpp cbcmac.cpp rc6.cpp dh2.cpp gf256.cpp mqueue.cpp misc.cpp pssr.cpp channels.cpp tiger.cpp cast.cpp rng.cpp square.cpp asn.cpp whrlpool.cpp md4.cpp dh.cpp ccm.cpp md2.cpp mqv.cpp gf2_32.cpp ttmac.cpp luc.cpp trdlocal.cpp pubkey.cpp gcm.cpp ripemd.cpp eccrypto.cpp serpent.cpp cmac.cpp
DLLOBJS := $(DLLSRCS:.cpp=.export.o)
# Import lib testing

View File

@ -20,8 +20,8 @@ Test: TestVectors/rsa_pss.txt
Test: TestVectors/rw.txt
Test: TestVectors/seal.txt
Test: TestVectors/sha.txt
Test: TestVectors/sha3.txt
#Test: TestVectors/sha3_fips_202.txt
Test: TestVectors/keccak.txt
Test: TestVectors/sha3_fips_202.txt
Test: TestVectors/panama.txt
Test: TestVectors/aes.txt
Test: TestVectors/salsa.txt

View File

@ -1,38 +0,0 @@
AlgorithmType: FileList
Name: all.txt collection
Test: TestVectors/tea.txt
Test: TestVectors/wake.txt
Test: TestVectors/camellia.txt
Test: TestVectors/shacal2.txt
Test: TestVectors/ttmac.txt
Test: TestVectors/whrlpool.txt
Test: TestVectors/dlies.txt
Test: TestVectors/dsa.txt
Test: TestVectors/dsa_1363.txt
Test: TestVectors/dsa_rfc6979.txt
#Test: TestVectors/ecdsa_rfc6979.txt
Test: TestVectors/esign.txt
Test: TestVectors/hmac.txt
Test: TestVectors/nr.txt
Test: TestVectors/rsa_oaep.txt
Test: TestVectors/rsa_pkcs1_1_5.txt
Test: TestVectors/rsa_pss.txt
Test: TestVectors/rw.txt
Test: TestVectors/seal.txt
Test: TestVectors/sha.txt
#Test: TestVectors/sha3.txt
Test: TestVectors/sha3_fips_202.txt
Test: TestVectors/panama.txt
Test: TestVectors/aes.txt
Test: TestVectors/salsa.txt
Test: TestVectors/chacha.txt
Test: TestVectors/vmac.txt
Test: TestVectors/sosemanuk.txt
Test: TestVectors/ccm.txt
Test: TestVectors/gcm.txt
Test: TestVectors/cmac.txt
Test: TestVectors/eax.txt
Test: TestVectors/mars.txt
Test: TestVectors/blake2s.txt
Test: TestVectors/blake2b.txt
Test: TestVectors/hkdf.txt

View File

@ -1,5 +1,5 @@
AlgorithmType: MessageDigest
Name: SHA-3-224
Name: Keccak-224
Message: ""
Digest: f71837502ba8e108 37bdd8d365adb855 91895602fc552b48 b7390abd
Test: Verify
@ -23,7 +23,7 @@ Digest: 19f9167be2a04c43 abd0ed554788101b 9c339031acc8e146 8531303f
Test: Verify
AlgorithmType: MessageDigest
Name: SHA-3-256
Name: Keccak-256
Message: ""
Digest: c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470
Test: Verify
@ -47,7 +47,7 @@ Digest: fadae6b49f129bbb 812be8407b7b2894 f34aecf6dbd1f9b0 f0c7e9853098fc96
Test: Verify
AlgorithmType: MessageDigest
Name: SHA-3-384
Name: Keccak-384
Message: ""
Digest: 2c23146a63a29acf99e73b88f8c24eaa7dc60aa771780ccc006afbfa8fe2479b2dd2b21362337441ac12b515911957ff
Test: Verify
@ -71,7 +71,7 @@ Digest: 0c8324e1ebc18282 2c5e2a086cac07c2 fe00e3bce61d01ba 8ad6b71780e2dec5 fb89
Test: Verify
AlgorithmType: MessageDigest
Name: SHA-3-512
Name: Keccak-512
Message: ""
Digest: 0eab42de4c3ceb9235fc91acffe746b29c29a8c366b7c60e4e67c466f36a4304c00fa9caf9d87976ba469bcbe06713b435f091ef2769fb160cdab33d3670680e
Test: Verify

View File

@ -1,6 +1,6 @@
AlgorithmType: MessageDigest
Source: SHA-3 Hash Function Test Vectors for Hashing Byte-Oriented Messages (http://csrc.nist.gov/groups/STM/cavp/secure-hashing.html)
Name: SHA-3-224
Name: SHA3-224
Comment: length 0
Message: ""
Digest: 6b4e03423667dbb73b6e15454f0eb1abd4597f9a1b078e3f5b5a6bc7

View File

@ -1,6 +1,6 @@
AlgorithmType: MessageDigest
Source: SHA-3 Hash Function Test Vectors for Hashing Byte-Oriented Messages (http://csrc.nist.gov/groups/STM/cavp/secure-hashing.html)
Name: SHA-3-256
Name: SHA3-256
Comment: length 0
Message: ""
Digest: a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a

View File

@ -1,6 +1,6 @@
AlgorithmType: MessageDigest
Source: SHA-3 Hash Function Test Vectors for Hashing Byte-Oriented Messages (http://csrc.nist.gov/groups/STM/cavp/secure-hashing.html)
Name: SHA-3-384
Name: SHA3-384
Comment: length 0
Message: ""
Digest: 0c63a75b845e4f7d01107d852e4c2485c51a50aaaa94fc61995e71bbee983a2ac3713831264adb47fb6bd1e058d5f004

View File

@ -1,6 +1,6 @@
AlgorithmType: MessageDigest
Source: SHA-3 Hash Function Test Vectors for Hashing Byte-Oriented Messages (http://csrc.nist.gov/groups/STM/cavp/secure-hashing.html)
Name: SHA-3-512
Name: SHA3-512
Comment: length 0
Message: ""
Digest: a69f73cca23a9ac5c8b567dc185a756e97c982164fe25859e0d1dcc1475c80a615b2123af1f5f94c11e3e9402c3ac558f500199d95b6d3e301758586281dcd26

View File

@ -315,10 +315,10 @@ void BenchmarkAll(double t, double hertz)
BenchMarkByNameKeyLess<HashTransformation>("SHA-1");
BenchMarkByNameKeyLess<HashTransformation>("SHA-256");
BenchMarkByNameKeyLess<HashTransformation>("SHA-512");
BenchMarkByNameKeyLess<HashTransformation>("SHA-3-224");
BenchMarkByNameKeyLess<HashTransformation>("SHA-3-256");
BenchMarkByNameKeyLess<HashTransformation>("SHA-3-384");
BenchMarkByNameKeyLess<HashTransformation>("SHA-3-512");
BenchMarkByNameKeyLess<HashTransformation>("SHA3-224");
BenchMarkByNameKeyLess<HashTransformation>("SHA3-256");
BenchMarkByNameKeyLess<HashTransformation>("SHA3-384");
BenchMarkByNameKeyLess<HashTransformation>("SHA3-512");
BenchMarkByNameKeyLess<HashTransformation>("Tiger");
BenchMarkByNameKeyLess<HashTransformation>("Whirlpool");
BenchMarkByNameKeyLess<HashTransformation>("RIPEMD-160");

View File

@ -60,13 +60,6 @@
// # define CRYPTOPP_NO_UNALIGNED_DATA_ACCESS
#endif
// Define this to choose the FIPS 202 version of SHA3, and not the original version of SHA3. NIST selected Keccak as SHA3
// in January 2013. SHA3 was finalized in FIPS 202 in August 2015, and it was a modified version of the original selection.
// If CRYPTOPP_USE_FIPS_202_SHA3 is defined, then sha3_fips_202.txt test vectors will be used instead of sha3.txt.
// #ifndef CRYPTOPP_USE_FIPS_202_SHA3
// # define CRYPTOPP_USE_FIPS_202_SHA3
// #endif
// ***************** Less Important Settings ***************
// Library version

View File

@ -60,13 +60,6 @@
# define CRYPTOPP_NO_UNALIGNED_DATA_ACCESS
#endif
// Define this to choose the FIPS 202 version of SHA3, and not the original version of SHA3. NIST selected Keccak as SHA3
// in January 2013. SHA3 was finalized in FIPS 202 in August 2015, and it was a modified version of the original selection.
// If CRYPTOPP_USE_FIPS_202_SHA3 is defined, then sha3_fips_202.txt test vectors will be used instead of sha3.txt.
#ifndef CRYPTOPP_USE_FIPS_202_SHA3
# define CRYPTOPP_USE_FIPS_202_SHA3
#endif
// ***************** Less Important Settings ***************
// Library version

View File

@ -18,15 +18,15 @@
# build it using NASM, and then include the NASM object file rdrand_x86.obj or rdrand_x64.obj.
# If you use 'make sources' from Linux makefile, then add 'winpipes.cpp'
LIB_SRCS = cryptlib.cpp cpu.cpp integer.cpp shacal2.cpp md5.cpp shark.cpp zinflate.cpp gf2n.cpp salsa.cpp xtr.cpp oaep.cpp hmqv.cpp rc2.cpp default.cpp wait.cpp wake.cpp twofish.cpp iterhash.cpp adler32.cpp algparam.cpp marss.cpp blowfish.cpp ecp.cpp strciphr.cpp camellia.cpp dh2.cpp ida.cpp zlib.cpp elgamal.cpp crc.cpp dessp.cpp tea.cpp eax.cpp network.cpp fhmqv.cpp sha.cpp emsa2.cpp pkcspad.cpp squaretb.cpp idea.cpp authenc.cpp hmac.cpp xtrcrypt.cpp queue.cpp mars.cpp rc5.cpp md2.cpp hrtimer.cpp vmac.cpp eprecomp.cpp hex.cpp dsa.cpp fips140.cpp gzip.cpp seal.cpp blake2.cpp files.cpp base32.cpp sharkbox.cpp safer.cpp randpool.cpp sosemanuk.cpp arc4.cpp osrng.cpp skipjack.cpp seed.cpp sha3.cpp filters.cpp bfinit.cpp rabin.cpp 3way.cpp rw.cpp rdtables.cpp rsa.cpp tftables.cpp gost.cpp socketft.cpp nbtheory.cpp panama.cpp modes.cpp rijndael.cpp casts.cpp algebra.cpp esign.cpp gfpcrypt.cpp dll.cpp ec2n.cpp polynomi.cpp blumshub.cpp des.cpp basecode.cpp zdeflate.cpp base64.cpp rc6.cpp gf256.cpp mqueue.cpp misc.cpp pssr.cpp channels.cpp rng.cpp tiger.cpp cast.cpp square.cpp asn.cpp chacha.cpp whrlpool.cpp md4.cpp dh.cpp ccm.cpp mqv.cpp tigertab.cpp gf2_32.cpp cbcmac.cpp ttmac.cpp luc.cpp trdlocal.cpp pubkey.cpp gcm.cpp ripemd.cpp rdrand.cpp eccrypto.cpp serpent.cpp cmac.cpp winpipes.cpp
LIB_SRCS = cryptlib.cpp cpu.cpp integer.cpp shacal2.cpp md5.cpp shark.cpp zinflate.cpp gf2n.cpp salsa.cpp xtr.cpp oaep.cpp rc2.cpp default.cpp wait.cpp wake.cpp twofish.cpp iterhash.cpp adler32.cpp algparam.cpp marss.cpp blowfish.cpp ecp.cpp strciphr.cpp camellia.cpp dh2.cpp ida.cpp zlib.cpp elgamal.cpp crc.cpp dessp.cpp tea.cpp eax.cpp network.cpp sha.cpp emsa2.cpp pkcspad.cpp squaretb.cpp idea.cpp authenc.cpp hmac.cpp xtrcrypt.cpp queue.cpp mars.cpp rc5.cpp md2.cpp hrtimer.cpp vmac.cpp eprecomp.cpp hex.cpp dsa.cpp fips140.cpp gzip.cpp seal.cpp blake2.cpp files.cpp base32.cpp sharkbox.cpp safer.cpp randpool.cpp sosemanuk.cpp arc4.cpp osrng.cpp skipjack.cpp seed.cpp sha3.cpp filters.cpp bfinit.cpp rabin.cpp 3way.cpp rw.cpp rdtables.cpp rsa.cpp tftables.cpp gost.cpp socketft.cpp nbtheory.cpp panama.cpp modes.cpp rijndael.cpp casts.cpp algebra.cpp esign.cpp gfpcrypt.cpp dll.cpp ec2n.cpp polynomi.cpp blumshub.cpp des.cpp basecode.cpp zdeflate.cpp base64.cpp rc6.cpp gf256.cpp mqueue.cpp misc.cpp pssr.cpp channels.cpp rng.cpp tiger.cpp cast.cpp square.cpp asn.cpp chacha.cpp whrlpool.cpp md4.cpp dh.cpp ccm.cpp mqv.cpp tigertab.cpp gf2_32.cpp cbcmac.cpp ttmac.cpp luc.cpp trdlocal.cpp pubkey.cpp gcm.cpp ripemd.cpp rdrand.cpp eccrypto.cpp serpent.cpp cmac.cpp winpipes.cpp
LIB_OBJS = cryptlib.obj cpu.obj integer.obj shacal2.obj md5.obj shark.obj zinflate.obj gf2n.obj salsa.obj xtr.obj oaep.obj hmqv.obj rc2.obj default.obj wait.obj wake.obj twofish.obj iterhash.obj adler32.obj algparam.obj marss.obj blowfish.obj ecp.obj strciphr.obj camellia.obj dh2.obj ida.obj zlib.obj elgamal.obj crc.obj dessp.obj tea.obj eax.obj network.obj fhmqv.obj sha.obj emsa2.obj pkcspad.obj squaretb.obj idea.obj authenc.obj hmac.obj xtrcrypt.obj queue.obj mars.obj rc5.obj md2.obj hrtimer.obj vmac.obj eprecomp.obj hex.obj dsa.obj fips140.obj gzip.obj seal.obj blake2.obj files.obj base32.obj sharkbox.obj safer.obj randpool.obj sosemanuk.obj arc4.obj osrng.obj skipjack.obj seed.obj sha3.obj filters.obj bfinit.obj rabin.obj 3way.obj rw.obj rdtables.obj rsa.obj tftables.obj gost.obj socketft.obj nbtheory.obj panama.obj modes.obj rijndael.obj casts.obj algebra.obj esign.obj gfpcrypt.obj dll.obj ec2n.obj polynomi.obj blumshub.obj des.obj basecode.obj zdeflate.obj base64.obj rc6.obj gf256.obj mqueue.obj misc.obj pssr.obj channels.obj rng.obj tiger.obj cast.obj square.obj asn.obj chacha.obj whrlpool.obj md4.obj dh.obj ccm.obj mqv.obj tigertab.obj gf2_32.obj cbcmac.obj ttmac.obj luc.obj trdlocal.obj pubkey.obj gcm.obj ripemd.obj rdrand.obj eccrypto.obj serpent.obj cmac.obj winpipes.obj
LIB_OBJS = cryptlib.obj cpu.obj integer.obj shacal2.obj md5.obj shark.obj zinflate.obj gf2n.obj salsa.obj xtr.obj oaep.obj rc2.obj default.obj wait.obj wake.obj twofish.obj iterhash.obj adler32.obj algparam.obj marss.obj blowfish.obj ecp.obj strciphr.obj camellia.obj dh2.obj ida.obj zlib.obj elgamal.obj crc.obj dessp.obj tea.obj eax.obj network.obj sha.obj emsa2.obj pkcspad.obj squaretb.obj idea.obj authenc.obj hmac.obj xtrcrypt.obj queue.obj mars.obj rc5.obj md2.obj hrtimer.obj vmac.obj eprecomp.obj hex.obj dsa.obj fips140.obj gzip.obj seal.obj blake2.obj files.obj base32.obj sharkbox.obj safer.obj randpool.obj sosemanuk.obj arc4.obj osrng.obj skipjack.obj seed.obj sha3.obj filters.obj bfinit.obj rabin.obj 3way.obj rw.obj rdtables.obj rsa.obj tftables.obj gost.obj socketft.obj nbtheory.obj panama.obj modes.obj rijndael.obj casts.obj algebra.obj esign.obj gfpcrypt.obj dll.obj ec2n.obj polynomi.obj blumshub.obj des.obj basecode.obj zdeflate.obj base64.obj rc6.obj gf256.obj mqueue.obj misc.obj pssr.obj channels.obj rng.obj tiger.obj cast.obj square.obj asn.obj chacha.obj whrlpool.obj md4.obj dh.obj ccm.obj mqv.obj tigertab.obj gf2_32.obj cbcmac.obj ttmac.obj luc.obj trdlocal.obj pubkey.obj gcm.obj ripemd.obj rdrand.obj eccrypto.obj serpent.obj cmac.obj winpipes.obj
TEST_SRCS = bench1.cpp bench2.cpp test.cpp validat1.cpp validat2.cpp validat3.cpp datatest.cpp regtest.cpp fipsalgt.cpp dlltest.cpp fipstest.cpp
TEST_OBJS = bench1.obj bench2.obj test.obj validat1.obj validat2.obj validat3.obj datatest.obj regtest.obj fipsalgt.obj dlltest.obj fipstest.obj
CXX = cl.exe
CXX = cl.exe
LD = link.exe
AR = lib.exe
RM = del.exe
@ -52,7 +52,7 @@ ARFLAGS = /nologo
LDLIBS =
!IF "$(PLATFORM)" == ""
!IF "$(PROCESSOR_ARCHITECTURE)" == "x86"
!IF "$(PROCESSOR_ARCHITECTURE)" == "x86"
PLATFORM = x86
!ELSEIF "$(PROCESSOR_ARCHITECTURE)" == "x64" || "$(PROCESSOR_ARCHITECTURE)" == "AMD64"
PLATFORM = x64

View File

@ -2406,58 +2406,6 @@ else
fi
fi
############################################
# Debug build, SHA3/FIPS 202
echo
echo "************************************" | tee -a "$TEST_RESULTS"
echo "Testing: Debug, USE_FIPS_202_SHA3" | tee -a "$TEST_RESULTS"
echo
"$MAKE" clean > /dev/null 2>&1
rm -f adhoc.cpp > /dev/null 2>&1
CXXFLAGS="$DEBUG_CXXFLAGS -DCRYPTOPP_USE_FIPS_202_SHA3 ${PLATFORM_CXXFLAGS[@]} $USER_CXXFLAGS ${DEPRECATED_CXXFLAGS[@]}"
CXX="$CXX" CXXFLAGS="$CXXFLAGS" "$MAKE" "${MAKEARGS[@]}" static dynamic cryptest.exe 2>&1 | tee -a "$TEST_RESULTS"
if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then
echo "ERROR: failed to make cryptest.exe" | tee -a "$TEST_RESULTS"
else
./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS"
if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then
echo "ERROR: failed to execute validation suite" | tee -a "$TEST_RESULTS"
fi
./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then
echo "ERROR: failed to execute test vectors" | tee -a "$TEST_RESULTS"
fi
fi
############################################
# Release build, SHA3/FIPS 202
echo
echo "************************************" | tee -a "$TEST_RESULTS"
echo "Testing: Release, USE_FIPS_202_SHA3" | tee -a "$TEST_RESULTS"
echo
"$MAKE" clean > /dev/null 2>&1
rm -f adhoc.cpp > /dev/null 2>&1
CXXFLAGS="$RELEASE_CXXFLAGS -DCRYPTOPP_USE_FIPS_202_SHA3 ${PLATFORM_CXXFLAGS[@]} $USER_CXXFLAGS ${DEPRECATED_CXXFLAGS[@]}"
CXX="$CXX" CXXFLAGS="$CXXFLAGS" "$MAKE" "${MAKEARGS[@]}" static dynamic cryptest.exe 2>&1 | tee -a "$TEST_RESULTS"
if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then
echo "ERROR: failed to make cryptest.exe" | tee -a "$TEST_RESULTS"
else
./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS"
if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then
echo "ERROR: failed to execute validation suite" | tee -a "$TEST_RESULTS"
fi
./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS"
if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then
echo "ERROR: failed to execute test vectors" | tee -a "$TEST_RESULTS"
fi
fi
############################################
# Build with LD-Gold
if [[ "$HAVE_LDGOLD" -ne "0" ]]; then

View File

@ -347,10 +347,6 @@ SOURCE=.\esign.cpp
# End Source File
# Begin Source File
SOURCE=.\fhmqv.cpp
# End Source File
# Begin Source File
SOURCE=.\files.cpp
# End Source File
# Begin Source File
@ -403,10 +399,6 @@ SOURCE=.\hmac.cpp
# End Source File
# Begin Source File
SOURCE=.\hmqv.cpp
# End Source File
# Begin Source File
SOURCE=.\hrtimer.cpp
# End Source File
# Begin Source File
@ -428,6 +420,10 @@ SOURCE=.\iterhash.cpp
# End Source File
# Begin Source File
SOURCE=.\keccak.cpp
# End Source File
# Begin Source File
SOURCE=.\luc.cpp
# End Source File
# Begin Source File
@ -945,6 +941,10 @@ SOURCE=.\iterhash.h
# End Source File
# Begin Source File
SOURCE=.\keccak.h
# End Source File
# Begin Source File
SOURCE=.\lubyrack.h
# End Source File
# Begin Source File

View File

@ -3058,80 +3058,6 @@
/>
</FileConfiguration>
</File>
<File
RelativePath="fhmqv.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="DLL-Import Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="DLL-Import Release|x64"
>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="DLL-Import Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="DLL-Import Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="files.cpp"
>
@ -4024,80 +3950,6 @@
/>
</FileConfiguration>
</File>
<File
RelativePath="hmqv.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="DLL-Import Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="DLL-Import Release|x64"
>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="DLL-Import Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="DLL-Import Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="hrtimer.cpp"
>
@ -4477,6 +4329,80 @@
/>
</FileConfiguration>
</File>
<File
RelativePath="keccak.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="DLL-Import Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="DLL-Import Release|x64"
>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="DLL-Import Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="DLL-Import Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="luc.cpp"
>
@ -9572,6 +9498,10 @@
RelativePath="iterhash.h"
>
</File>
<File
RelativePath="keccak.h"
>
</File>
<File
RelativePath="lubyrack.h"
>

View File

@ -235,7 +235,6 @@
<FILE FILENAME="emsa2.cpp" CONTAINERID="CCompiler" LOCALCOMMAND="" UNITNAME="emsa2" FORMNAME="" DESIGNCLASS=""/>
<FILE FILENAME="eprecomp.cpp" CONTAINERID="CCompiler" LOCALCOMMAND="" UNITNAME="eprecomp" FORMNAME="" DESIGNCLASS=""/>
<FILE FILENAME="esign.cpp" CONTAINERID="CCompiler" LOCALCOMMAND="" UNITNAME="esign" FORMNAME="" DESIGNCLASS=""/>
<FILE FILENAME="fhmqv.cpp" CONTAINERID="CCompiler" LOCALCOMMAND="" UNITNAME="fhmqv" FORMNAME="" DESIGNCLASS=""/>
<FILE FILENAME="files.cpp" CONTAINERID="CCompiler" LOCALCOMMAND="" UNITNAME="files" FORMNAME="" DESIGNCLASS=""/>
<FILE FILENAME="filters.cpp" CONTAINERID="CCompiler" LOCALCOMMAND="" UNITNAME="filters" FORMNAME="" DESIGNCLASS=""/>
<FILE FILENAME="fips140.cpp" CONTAINERID="CCompiler" LOCALCOMMAND="" UNITNAME="fips140" FORMNAME="" DESIGNCLASS=""/>
@ -249,7 +248,6 @@
<FILE FILENAME="gzip.cpp" CONTAINERID="CCompiler" LOCALCOMMAND="" UNITNAME="gzip" FORMNAME="" DESIGNCLASS=""/>
<FILE FILENAME="hex.cpp" CONTAINERID="CCompiler" LOCALCOMMAND="" UNITNAME="hex" FORMNAME="" DESIGNCLASS=""/>
<FILE FILENAME="hmac.cpp" CONTAINERID="CCompiler" LOCALCOMMAND="" UNITNAME="hmac" FORMNAME="" DESIGNCLASS=""/>
<FILE FILENAME="hmqv.cpp" CONTAINERID="CCompiler" LOCALCOMMAND="" UNITNAME="hmqv" FORMNAME="" DESIGNCLASS=""/>
<FILE FILENAME="hrtimer.cpp" CONTAINERID="CCompiler" LOCALCOMMAND="" UNITNAME="hrtimer" FORMNAME="" DESIGNCLASS=""/>
<FILE FILENAME="ida.cpp" CONTAINERID="CCompiler" LOCALCOMMAND="" UNITNAME="ida" FORMNAME="" DESIGNCLASS=""/>
<FILE FILENAME="idea.cpp" CONTAINERID="CCompiler" LOCALCOMMAND="" UNITNAME="idea" FORMNAME="" DESIGNCLASS=""/>

View File

@ -1,16 +0,0 @@
// fhmqv.cpp - written and placed in the public domain by Jeffrey Walton
// Shamelessly based upon Wei Dai's MQV source files
#include "pch.h"
#include "fhmqv.h"
NAMESPACE_BEGIN(CryptoPP)
#if !defined(NDEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING)
void TestInstantiations_FHMQV()
{
FHMQV fhmqv;
}
#endif
NAMESPACE_END

View File

@ -1,16 +0,0 @@
// hmqv.cpp - written and placed in the public domain by Uri Blumenthal
// Shamelessly based upon Jeffrey Walton's FHMQV and Wei Dai's MQV source files
#include "pch.h"
#include "hmqv.h"
NAMESPACE_BEGIN(CryptoPP)
#if !defined(NDEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING)
void TestInstantiations_HMQV()
{
HMQV hmqv;
}
#endif
NAMESPACE_END

291
keccak.cpp Normal file
View File

@ -0,0 +1,291 @@
// keccak.cpp - modified by Wei Dai from Ronny Van Keer's public domain sha3-simple.c
// all modifications here are placed in the public domain by Wei Dai
/*
The Keccak sponge function, designed by Guido Bertoni, Joan Daemen,
Michael Peeters and Gilles Van Assche. For more information, feedback or
questions, please refer to our website: http://keccak.noekeon.org/
Implementation by Ronny Van Keer,
hereby denoted as "the implementer".
To the extent possible under law, the implementer has waived all copyright
and related or neighboring rights to the source code in this file.
http://creativecommons.org/publicdomain/zero/1.0/
*/
#include "pch.h"
#include "keccak.h"
NAMESPACE_BEGIN(CryptoPP)
static const word64 KeccakF_RoundConstants[24] =
{
W64LIT(0x0000000000000001), W64LIT(0x0000000000008082), W64LIT(0x800000000000808a),
W64LIT(0x8000000080008000), W64LIT(0x000000000000808b), W64LIT(0x0000000080000001),
W64LIT(0x8000000080008081), W64LIT(0x8000000000008009), W64LIT(0x000000000000008a),
W64LIT(0x0000000000000088), W64LIT(0x0000000080008009), W64LIT(0x000000008000000a),
W64LIT(0x000000008000808b), W64LIT(0x800000000000008b), W64LIT(0x8000000000008089),
W64LIT(0x8000000000008003), W64LIT(0x8000000000008002), W64LIT(0x8000000000000080),
W64LIT(0x000000000000800a), W64LIT(0x800000008000000a), W64LIT(0x8000000080008081),
W64LIT(0x8000000000008080), W64LIT(0x0000000080000001), W64LIT(0x8000000080008008)
};
static void KeccakF1600(word64 *state)
{
{
word64 Aba, Abe, Abi, Abo, Abu;
word64 Aga, Age, Agi, Ago, Agu;
word64 Aka, Ake, Aki, Ako, Aku;
word64 Ama, Ame, Ami, Amo, Amu;
word64 Asa, Ase, Asi, Aso, Asu;
word64 BCa, BCe, BCi, BCo, BCu;
word64 Da, De, Di, Do, Du;
word64 Eba, Ebe, Ebi, Ebo, Ebu;
word64 Ega, Ege, Egi, Ego, Egu;
word64 Eka, Eke, Eki, Eko, Eku;
word64 Ema, Eme, Emi, Emo, Emu;
word64 Esa, Ese, Esi, Eso, Esu;
//copyFromState(A, state)
typedef BlockGetAndPut<word64, LittleEndian, true, true> Block;
Block::Get(state)(Aba)(Abe)(Abi)(Abo)(Abu)(Aga)(Age)(Agi)(Ago)(Agu)(Aka)(Ake)(Aki)(Ako)(Aku)(Ama)(Ame)(Ami)(Amo)(Amu)(Asa)(Ase)(Asi)(Aso)(Asu);
for( unsigned int round = 0; round < 24; round += 2 )
{
// prepareTheta
BCa = Aba^Aga^Aka^Ama^Asa;
BCe = Abe^Age^Ake^Ame^Ase;
BCi = Abi^Agi^Aki^Ami^Asi;
BCo = Abo^Ago^Ako^Amo^Aso;
BCu = Abu^Agu^Aku^Amu^Asu;
//thetaRhoPiChiIotaPrepareTheta(round , A, E)
Da = BCu^rotlFixed(BCe, 1);
De = BCa^rotlFixed(BCi, 1);
Di = BCe^rotlFixed(BCo, 1);
Do = BCi^rotlFixed(BCu, 1);
Du = BCo^rotlFixed(BCa, 1);
Aba ^= Da;
BCa = Aba;
Age ^= De;
BCe = rotlFixed(Age, 44);
Aki ^= Di;
BCi = rotlFixed(Aki, 43);
Amo ^= Do;
BCo = rotlFixed(Amo, 21);
Asu ^= Du;
BCu = rotlFixed(Asu, 14);
Eba = BCa ^((~BCe)& BCi );
Eba ^= (word64)KeccakF_RoundConstants[round];
Ebe = BCe ^((~BCi)& BCo );
Ebi = BCi ^((~BCo)& BCu );
Ebo = BCo ^((~BCu)& BCa );
Ebu = BCu ^((~BCa)& BCe );
Abo ^= Do;
BCa = rotlFixed(Abo, 28);
Agu ^= Du;
BCe = rotlFixed(Agu, 20);
Aka ^= Da;
BCi = rotlFixed(Aka, 3);
Ame ^= De;
BCo = rotlFixed(Ame, 45);
Asi ^= Di;
BCu = rotlFixed(Asi, 61);
Ega = BCa ^((~BCe)& BCi );
Ege = BCe ^((~BCi)& BCo );
Egi = BCi ^((~BCo)& BCu );
Ego = BCo ^((~BCu)& BCa );
Egu = BCu ^((~BCa)& BCe );
Abe ^= De;
BCa = rotlFixed(Abe, 1);
Agi ^= Di;
BCe = rotlFixed(Agi, 6);
Ako ^= Do;
BCi = rotlFixed(Ako, 25);
Amu ^= Du;
BCo = rotlFixed(Amu, 8);
Asa ^= Da;
BCu = rotlFixed(Asa, 18);
Eka = BCa ^((~BCe)& BCi );
Eke = BCe ^((~BCi)& BCo );
Eki = BCi ^((~BCo)& BCu );
Eko = BCo ^((~BCu)& BCa );
Eku = BCu ^((~BCa)& BCe );
Abu ^= Du;
BCa = rotlFixed(Abu, 27);
Aga ^= Da;
BCe = rotlFixed(Aga, 36);
Ake ^= De;
BCi = rotlFixed(Ake, 10);
Ami ^= Di;
BCo = rotlFixed(Ami, 15);
Aso ^= Do;
BCu = rotlFixed(Aso, 56);
Ema = BCa ^((~BCe)& BCi );
Eme = BCe ^((~BCi)& BCo );
Emi = BCi ^((~BCo)& BCu );
Emo = BCo ^((~BCu)& BCa );
Emu = BCu ^((~BCa)& BCe );
Abi ^= Di;
BCa = rotlFixed(Abi, 62);
Ago ^= Do;
BCe = rotlFixed(Ago, 55);
Aku ^= Du;
BCi = rotlFixed(Aku, 39);
Ama ^= Da;
BCo = rotlFixed(Ama, 41);
Ase ^= De;
BCu = rotlFixed(Ase, 2);
Esa = BCa ^((~BCe)& BCi );
Ese = BCe ^((~BCi)& BCo );
Esi = BCi ^((~BCo)& BCu );
Eso = BCo ^((~BCu)& BCa );
Esu = BCu ^((~BCa)& BCe );
// prepareTheta
BCa = Eba^Ega^Eka^Ema^Esa;
BCe = Ebe^Ege^Eke^Eme^Ese;
BCi = Ebi^Egi^Eki^Emi^Esi;
BCo = Ebo^Ego^Eko^Emo^Eso;
BCu = Ebu^Egu^Eku^Emu^Esu;
//thetaRhoPiChiIotaPrepareTheta(round+1, E, A)
Da = BCu^rotlFixed(BCe, 1);
De = BCa^rotlFixed(BCi, 1);
Di = BCe^rotlFixed(BCo, 1);
Do = BCi^rotlFixed(BCu, 1);
Du = BCo^rotlFixed(BCa, 1);
Eba ^= Da;
BCa = Eba;
Ege ^= De;
BCe = rotlFixed(Ege, 44);
Eki ^= Di;
BCi = rotlFixed(Eki, 43);
Emo ^= Do;
BCo = rotlFixed(Emo, 21);
Esu ^= Du;
BCu = rotlFixed(Esu, 14);
Aba = BCa ^((~BCe)& BCi );
Aba ^= (word64)KeccakF_RoundConstants[round+1];
Abe = BCe ^((~BCi)& BCo );
Abi = BCi ^((~BCo)& BCu );
Abo = BCo ^((~BCu)& BCa );
Abu = BCu ^((~BCa)& BCe );
Ebo ^= Do;
BCa = rotlFixed(Ebo, 28);
Egu ^= Du;
BCe = rotlFixed(Egu, 20);
Eka ^= Da;
BCi = rotlFixed(Eka, 3);
Eme ^= De;
BCo = rotlFixed(Eme, 45);
Esi ^= Di;
BCu = rotlFixed(Esi, 61);
Aga = BCa ^((~BCe)& BCi );
Age = BCe ^((~BCi)& BCo );
Agi = BCi ^((~BCo)& BCu );
Ago = BCo ^((~BCu)& BCa );
Agu = BCu ^((~BCa)& BCe );
Ebe ^= De;
BCa = rotlFixed(Ebe, 1);
Egi ^= Di;
BCe = rotlFixed(Egi, 6);
Eko ^= Do;
BCi = rotlFixed(Eko, 25);
Emu ^= Du;
BCo = rotlFixed(Emu, 8);
Esa ^= Da;
BCu = rotlFixed(Esa, 18);
Aka = BCa ^((~BCe)& BCi );
Ake = BCe ^((~BCi)& BCo );
Aki = BCi ^((~BCo)& BCu );
Ako = BCo ^((~BCu)& BCa );
Aku = BCu ^((~BCa)& BCe );
Ebu ^= Du;
BCa = rotlFixed(Ebu, 27);
Ega ^= Da;
BCe = rotlFixed(Ega, 36);
Eke ^= De;
BCi = rotlFixed(Eke, 10);
Emi ^= Di;
BCo = rotlFixed(Emi, 15);
Eso ^= Do;
BCu = rotlFixed(Eso, 56);
Ama = BCa ^((~BCe)& BCi );
Ame = BCe ^((~BCi)& BCo );
Ami = BCi ^((~BCo)& BCu );
Amo = BCo ^((~BCu)& BCa );
Amu = BCu ^((~BCa)& BCe );
Ebi ^= Di;
BCa = rotlFixed(Ebi, 62);
Ego ^= Do;
BCe = rotlFixed(Ego, 55);
Eku ^= Du;
BCi = rotlFixed(Eku, 39);
Ema ^= Da;
BCo = rotlFixed(Ema, 41);
Ese ^= De;
BCu = rotlFixed(Ese, 2);
Asa = BCa ^((~BCe)& BCi );
Ase = BCe ^((~BCi)& BCo );
Asi = BCi ^((~BCo)& BCu );
Aso = BCo ^((~BCu)& BCa );
Asu = BCu ^((~BCa)& BCe );
}
//copyToState(state, A)
Block::Put(NULL, state)(Aba)(Abe)(Abi)(Abo)(Abu)(Aga)(Age)(Agi)(Ago)(Agu)(Aka)(Ake)(Aki)(Ako)(Aku)(Ama)(Ame)(Ami)(Amo)(Amu)(Asa)(Ase)(Asi)(Aso)(Asu);
}
}
void Keccak::Update(const byte *input, size_t length)
{
assert((input && length) || !(input || length));
if (!length)
return;
size_t spaceLeft;
while (length >= (spaceLeft = r() - m_counter))
{
if (spaceLeft)
xorbuf(m_state.BytePtr() + m_counter, input, spaceLeft);
KeccakF1600(m_state);
input += spaceLeft;
length -= spaceLeft;
m_counter = 0;
}
if (length)
xorbuf(m_state.BytePtr() + m_counter, input, length);
m_counter += (unsigned int)length;
}
void Keccak::Restart()
{
memset(m_state, 0, m_state.SizeInBytes());
m_counter = 0;
}
void Keccak::TruncatedFinal(byte *hash, size_t size)
{
ThrowIfInvalidTruncatedSize(size);
m_state.BytePtr()[m_counter] ^= 1;
m_state.BytePtr()[r()-1] ^= 0x80;
KeccakF1600(m_state);
memcpy(hash, m_state, size);
Restart();
}
NAMESPACE_END

91
keccak.h Normal file
View File

@ -0,0 +1,91 @@
// keccak.h - written and placed in the public domain by Wei Dai
//! \file keccak.h
//! \brief Classes for Keccak message digests
//! \sa <a href="http://en.wikipedia.org/wiki/Keccak">Keccak</a>
#ifndef CRYPTOPP_KECCAK_H
#define CRYPTOPP_KECCAK_H
#include "cryptlib.h"
#include "secblock.h"
NAMESPACE_BEGIN(CryptoPP)
//! \class Keccak
//! \brief Keccak message digest base class
class Keccak : public HashTransformation
{
public:
//! \brief Construct a Keccak
//! \param digestSize the digest size, in bytes
//! \details Keccak is the base class for Keccak_224, Keccak_256, Keccak_384 and Keccak_512.
//! Library users should construct a derived class instead, and only use Keccak
//! as a base class reference or pointer.
Keccak(unsigned int digestSize) : m_digestSize(digestSize) {Restart();}
unsigned int DigestSize() const {return m_digestSize;}
std::string AlgorithmName() const {return "Keccak-" + IntToString(m_digestSize*8);}
unsigned int OptimalDataAlignment() const {return GetAlignmentOf<word64>();}
void Update(const byte *input, size_t length);
void Restart();
void TruncatedFinal(byte *hash, size_t size);
protected:
inline unsigned int r() const {return 200 - 2 * m_digestSize;}
FixedSizeSecBlock<word64, 25> m_state;
unsigned int m_digestSize, m_counter;
};
//! \class Keccak_224
//! \brief Keccak-224 message digest
class Keccak_224 : public Keccak
{
public:
CRYPTOPP_CONSTANT(DIGESTSIZE = 28)
//! \brief Construct a Keccak-224 message digest
Keccak_224() : Keccak(DIGESTSIZE) {}
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "Keccak-224";}
};
//! \class Keccak_256
//! \brief Keccak-256 message digest
class Keccak_256 : public Keccak
{
public:
CRYPTOPP_CONSTANT(DIGESTSIZE = 32)
//! \brief Construct a Keccak-256 message digest
Keccak_256() : Keccak(DIGESTSIZE) {}
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "Keccak-256";}
};
//! \class Keccak_384
//! \brief Keccak-384 message digest
class Keccak_384 : public Keccak
{
public:
CRYPTOPP_CONSTANT(DIGESTSIZE = 48)
//! \brief Construct a Keccak-384 message digest
Keccak_384() : Keccak(DIGESTSIZE) {}
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "Keccak-384";}
};
//! \class Keccak_512
//! \brief Keccak-512 message digest
class Keccak_512 : public Keccak
{
public:
CRYPTOPP_CONSTANT(DIGESTSIZE = 64)
//! \brief Construct a Keccak-512 message digest
Keccak_512() : Keccak(DIGESTSIZE) {}
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "Keccak-512";}
};
NAMESPACE_END
#endif

14
mqv.cpp
View File

@ -1,7 +1,11 @@
// mqv.cpp - written and placed in the public domain by Wei Dai
// HMQV provided by Jeffrey Walton, Ray Clayton and Uri Blumenthal.
// FHMQV provided by Uri Blumenthal.
#include "pch.h"
#include "mqv.h"
#include "hmqv.h"
#include "fhmqv.h"
NAMESPACE_BEGIN(CryptoPP)
@ -10,6 +14,16 @@ void TestInstantiations_MQV()
{
MQV mqv;
}
void TestInstantiations_HMQV()
{
HMQV hmqv;
}
void TestInstantiations_FHMQV()
{
FHMQV fhmqv;
}
#endif
NAMESPACE_END

View File

@ -50,6 +50,7 @@
#include "seal.h"
#include "crc.h"
#include "adler32.h"
#include "keccak.h"
#include "sha3.h"
#include "blake2.h"
#include "hkdf.h"
@ -94,6 +95,10 @@ void RegisterFactories()
RegisterDefaultFactoryFor<HashTransformation, RIPEMD256>();
RegisterDefaultFactoryFor<HashTransformation, Weak::PanamaHash<LittleEndian> >();
RegisterDefaultFactoryFor<HashTransformation, Weak::PanamaHash<BigEndian> >();
RegisterDefaultFactoryFor<HashTransformation, Keccak_224>();
RegisterDefaultFactoryFor<HashTransformation, Keccak_256>();
RegisterDefaultFactoryFor<HashTransformation, Keccak_384>();
RegisterDefaultFactoryFor<HashTransformation, Keccak_512>();
RegisterDefaultFactoryFor<HashTransformation, SHA3_224>();
RegisterDefaultFactoryFor<HashTransformation, SHA3_256>();
RegisterDefaultFactoryFor<HashTransformation, SHA3_384>();

View File

@ -19,14 +19,14 @@ http://creativecommons.org/publicdomain/zero/1.0/
NAMESPACE_BEGIN(CryptoPP)
static const word64 KeccakF_RoundConstants[24] =
static const word64 KeccakF_RoundConstants[24] =
{
W64LIT(0x0000000000000001), W64LIT(0x0000000000008082), W64LIT(0x800000000000808a),
W64LIT(0x8000000080008000), W64LIT(0x000000000000808b), W64LIT(0x0000000080000001),
W64LIT(0x8000000080008081), W64LIT(0x8000000000008009), W64LIT(0x000000000000008a),
W64LIT(0x0000000000000088), W64LIT(0x0000000080008009), W64LIT(0x000000008000000a),
W64LIT(0x000000008000808b), W64LIT(0x800000000000008b), W64LIT(0x8000000000008089),
W64LIT(0x8000000000008003), W64LIT(0x8000000000008002), W64LIT(0x8000000000000080),
W64LIT(0x8000000000008003), W64LIT(0x8000000000008002), W64LIT(0x8000000000000080),
W64LIT(0x000000000000800a), W64LIT(0x800000008000000a), W64LIT(0x8000000080008081),
W64LIT(0x8000000000008080), W64LIT(0x0000000080000001), W64LIT(0x8000000080008008)
};
@ -281,12 +281,7 @@ void SHA3::TruncatedFinal(byte *hash, size_t size)
{
ThrowIfInvalidTruncatedSize(size);
#if defined(CRYPTOPP_USE_FIPS_202_SHA3)
m_state.BytePtr()[m_counter] ^= 0x06;
#else
m_state.BytePtr()[m_counter] ^= 1;
#endif
m_state.BytePtr()[r()-1] ^= 0x80;
KeccakF1600(m_state);
memcpy(hash, m_state, size);

28
sha3.h
View File

@ -2,12 +2,10 @@
//! \file sha3.h
//! \brief Classes for SHA-3 message digests
//! \details The Crypto++ SHA-3 implementation dates back to January 2013 when NIST
//! selected Keccak as SHA-3. In August 2015 NIST finalized SHA-3, and it was a
//! modified version of the Keccak selection. Crypto++ 5.6.2 through 5.6.4 provides
//! the pre-FIPS 202 version of SHA-3; while Crypto++ 5.7 and above provides
//! the FIPS 202 version of SHA-3.
//! \sa <a href="http://en.wikipedia.org/wiki/SHA-3">SHA-3</a>
//! \details The Crypto++ SHA-3 conforms to FIPS 202 version of SHA-3.
//! Previous behavior is available in Keccak classes.
//! \sa <a href="http://en.wikipedia.org/wiki/SHA-3">SHA-3</a>,
//! <A HREF="http://csrc.nist.gov/groups/ST/hash/sha-3/fips202_standard_2015.html">SHA-3 STANDARD (FIPS 202)</A>.
#ifndef CRYPTOPP_SHA3_H
#define CRYPTOPP_SHA3_H
@ -29,7 +27,7 @@ public:
//! as a base class reference or pointer.
SHA3(unsigned int digestSize) : m_digestSize(digestSize) {Restart();}
unsigned int DigestSize() const {return m_digestSize;}
std::string AlgorithmName() const {return "SHA-3-" + IntToString(m_digestSize*8);}
std::string AlgorithmName() const {return "SHA3-" + IntToString(m_digestSize*8);}
unsigned int OptimalDataAlignment() const {return GetAlignmentOf<word64>();}
void Update(const byte *input, size_t length);
@ -52,8 +50,8 @@ public:
//! \brief Construct a SHA3-224 message digest
SHA3_224() : SHA3(DIGESTSIZE) {}
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "SHA-3-224";}
} CRYPTOPP_DEPRECATED("SHA-3 will be changing in the future due to FIPS 202 finalization");
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "SHA3-224";}
};
//! \class SHA3_256
//! \brief SHA3-256 message digest
@ -64,8 +62,8 @@ public:
//! \brief Construct a SHA3-256 message digest
SHA3_256() : SHA3(DIGESTSIZE) {}
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "SHA-3-256";}
} CRYPTOPP_DEPRECATED("SHA-3 will be changing in the future due to FIPS 202 finalization");
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "SHA3-256";}
};
//! \class SHA3_384
//! \brief SHA3-384 message digest
@ -76,8 +74,8 @@ public:
//! \brief Construct a SHA3-384 message digest
SHA3_384() : SHA3(DIGESTSIZE) {}
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "SHA-3-384";}
} CRYPTOPP_DEPRECATED("SHA-3 will be changing in the future due to FIPS 202 finalization");
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "SHA3-384";}
};
//! \class SHA3_512
//! \brief SHA3-512 message digest
@ -88,8 +86,8 @@ public:
//! \brief Construct a SHA3-512 message digest
SHA3_512() : SHA3(DIGESTSIZE) {}
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "SHA-3-512";}
} CRYPTOPP_DEPRECATED("SHA-3 will be changing in the future due to FIPS 202 finalization");
CRYPTOPP_CONSTEXPR static const char *StaticAlgorithmName() {return "SHA3-512";}
};
NAMESPACE_END

View File

@ -291,12 +291,6 @@ int CRYPTOPP_API main(int argc, char *argv[])
{
// TestDataFile() adds CRYPTOPP_DATA_DIR as required
std::string fname = (argv[2] ? argv[2] : "all");
#if defined(CRYPTOPP_USE_FIPS_202_SHA3)
if (fname == "sha3")
fname = "sha3_fips_202";
if (fname == "all")
fname = "all_fips_202";
#endif
if (fname.find(".txt") == std::string::npos)
fname = "TestVectors/" + fname + ".txt";

View File

@ -98,11 +98,8 @@ bool ValidateAll(bool thorough)
pass=ValidateMD5() && pass;
pass=ValidateSHA() && pass;
#if defined(CRYPTOPP_USE_FIPS_202_SHA3)
pass=RunTestDataFile(CRYPTOPP_DATA_DIR "TestVectors/keccak.txt") && pass;
pass=RunTestDataFile(CRYPTOPP_DATA_DIR "TestVectors/sha3_fips_202.txt") && pass;
#else
pass=RunTestDataFile(CRYPTOPP_DATA_DIR "TestVectors/sha3.txt") && pass;
#endif
pass=ValidateTiger() && pass;
pass=ValidateRIPEMD() && pass;

Binary file not shown.