Split simon-simd.cpp and speck-simd.cpp into separate source files
SIMON-64 and SIMON-128 have different ISA requirements. The same applies to SPECK-64 and SPECK-128. GCC generated code that resulted in a SIGILL due to the ISA differences on a down level machine. The instructions was a mtfprwz from POWER8. It was prsent in a function prologue on a POWER7 machine.pull/703/head
parent
eb57dc5481
commit
7a43a04048
|
|
@ -300,7 +300,8 @@ simeck.cpp
|
|||
simeck-simd.cpp
|
||||
simeck.h
|
||||
simon.cpp
|
||||
simon-simd.cpp
|
||||
simon64-simd.cpp
|
||||
simon128-simd.cpp
|
||||
simon.h
|
||||
skipjack.cpp
|
||||
skipjack.h
|
||||
|
|
@ -315,7 +316,8 @@ socketft.h
|
|||
sosemanuk.cpp
|
||||
sosemanuk.h
|
||||
speck.cpp
|
||||
speck-simd.cpp
|
||||
speck64-simd.cpp
|
||||
speck128-simd.cpp
|
||||
speck.h
|
||||
square.cpp
|
||||
square.h
|
||||
|
|
|
|||
74
GNUmakefile
74
GNUmakefile
|
|
@ -246,15 +246,17 @@ ifeq ($(findstring -DCRYPTOPP_DISABLE_SSSE3,$(CXXFLAGS)),)
|
|||
LEA_FLAG = -mssse3
|
||||
SSSE3_FLAG = -mssse3
|
||||
SIMECK_FLAG = -mssse3
|
||||
SIMON_FLAG = -mssse3
|
||||
SPECK_FLAG = -mssse3
|
||||
SIMON64_FLAG = -mssse3
|
||||
SIMON128_FLAG = -mssse3
|
||||
SPECK64_FLAG = -mssse3
|
||||
SPECK128_FLAG = -mssse3
|
||||
endif
|
||||
ifeq ($(findstring -DCRYPTOPP_DISABLE_SSE4,$(CXXFLAGS)),)
|
||||
HAVE_SSE4 = $(shell $(CXX) $(CXXFLAGS) -DADHOC_MAIN -msse4.1 -dM -E adhoc.cpp 2>&1 | $(GREP) -i -c __SSE4_1__)
|
||||
ifeq ($(HAVE_SSE4),1)
|
||||
BLAKE2_FLAG = -msse4.1
|
||||
SIMON_FLAG = -msse4.1
|
||||
SPECK_FLAG = -msse4.1
|
||||
SIMON64_FLAG = -msse4.1
|
||||
SPECK64_FLAG = -msse4.1
|
||||
endif
|
||||
HAVE_SSE4 = $(shell $(CXX) $(CXXFLAGS) -DADHOC_MAIN -msse4.2 -dM -E adhoc.cpp 2>&1 | $(GREP) -i -c __SSE4_2__)
|
||||
ifeq ($(HAVE_SSE4),1)
|
||||
|
|
@ -296,15 +298,17 @@ ifeq ($(SUN_COMPILER),1)
|
|||
CHAM_FLAG = -xarch=ssse3 -D__SSSE3__=1
|
||||
LEA_FLAG = -xarch=ssse3 -D__SSSE3__=1
|
||||
SIMECK_FLAG = -xarch=ssse3 -D__SSSE3__=1
|
||||
SIMON_FLAG = -xarch=ssse3 -D__SSSE3__=1
|
||||
SPECK_FLAG = -xarch=ssse3 -D__SSSE3__=1
|
||||
SIMON64_FLAG = -xarch=ssse3 -D__SSSE3__=1
|
||||
SIMON128_FLAG = -xarch=ssse3 -D__SSSE3__=1
|
||||
SPECK64_FLAG = -xarch=ssse3 -D__SSSE3__=1
|
||||
SPECK128_FLAG = -xarch=ssse3 -D__SSSE3__=1
|
||||
LDFLAGS += -xarch=ssse3
|
||||
endif
|
||||
COUNT := $(shell $(CXX) $(CXXFLAGS) -E -xarch=sse4_1 -xdumpmacros /dev/null 2>&1 | $(GREP) -i -c "illegal")
|
||||
ifeq ($(COUNT),0)
|
||||
BLAKE2_FLAG = -xarch=sse4_1 -D__SSE4_1__=1
|
||||
SIMON_FLAG = -xarch=sse4_1 -D__SSE4_1__=1
|
||||
SPECK_FLAG = -xarch=sse4_1 -D__SSE4_1__=1
|
||||
SIMON64_FLAG = -xarch=sse4_1 -D__SSE4_1__=1
|
||||
SPECK64_FLAG = -xarch=sse4_1 -D__SSE4_1__=1
|
||||
LDFLAGS += -xarch=sse4_1
|
||||
endif
|
||||
COUNT := $(shell $(CXX) $(CXXFLAGS) -E -xarch=sse4_2 -xdumpmacros /dev/null 2>&1 | $(GREP) -i -c "illegal")
|
||||
|
|
@ -375,8 +379,10 @@ ifeq ($(IS_NEON),1)
|
|||
LEA_FLAG = -march=armv7-a -mfloat-abi=$(FP_ABI) -mfpu=neon
|
||||
SHA_FLAG = -march=armv7-a -mfloat-abi=$(FP_ABI) -mfpu=neon
|
||||
SIMECK_FLAG = -march=armv7-a -mfloat-abi=$(FP_ABI) -mfpu=neon
|
||||
SIMON_FLAG = -march=armv7-a -mfloat-abi=$(FP_ABI) -mfpu=neon
|
||||
SPECK_FLAG = -march=armv7-a -mfloat-abi=$(FP_ABI) -mfpu=neon
|
||||
SIMON64_FLAG = -march=armv7-a -mfloat-abi=$(FP_ABI) -mfpu=neon
|
||||
SIMON128_FLAG = -march=armv7-a -mfloat-abi=$(FP_ABI) -mfpu=neon
|
||||
SPECK64_FLAG = -march=armv7-a -mfloat-abi=$(FP_ABI) -mfpu=neon
|
||||
SPECK128_FLAG = -march=armv7-a -mfloat-abi=$(FP_ABI) -mfpu=neon
|
||||
SM4_FLAG = -march=armv7-a -mfloat-abi=$(FP_ABI) -mfpu=neon
|
||||
endif
|
||||
endif
|
||||
|
|
@ -390,8 +396,10 @@ ifeq ($(IS_ARMV8),1)
|
|||
LEA_FLAG = -march=armv8-a
|
||||
NEON_FLAG = -march=armv8-a
|
||||
SIMECK_FLAG = -march=armv8-a
|
||||
SIMON_FLAG = -march=armv8-a
|
||||
SPECK_FLAG = -march=armv8-a
|
||||
SIMON64_FLAG = -march=armv8-a
|
||||
SIMON128_FLAG = -march=armv8-a
|
||||
SPECK64_FLAG = -march=armv8-a
|
||||
SPECK128_FLAG = -march=armv8-a
|
||||
SM4_FLAG = -march=armv8-a
|
||||
endif
|
||||
HAVE_CRC = $(shell $(CXX) $(CXXFLAGS) -DADHOC_MAIN -march=armv8-a+crc -dM -E adhoc.cpp 2>&1 | $(GREP) -i -c __ARM_FEATURE_CRC32)
|
||||
|
|
@ -422,8 +430,10 @@ ifneq ($(IS_PPC32)$(IS_PPC64),00)
|
|||
GCM_FLAG = $(POWER8_FLAG)
|
||||
SHA_FLAG = $(POWER8_FLAG)
|
||||
SM4_FLAG = $(POWER8_FLAG)
|
||||
SIMON_FLAG = $(POWER8_FLAG)
|
||||
SPECK_FLAG = $(POWER8_FLAG)
|
||||
SIMON64_FLAG = $(POWER8_FLAG)
|
||||
SIMON128_FLAG = $(POWER8_FLAG)
|
||||
SPECK64_FLAG = $(POWER8_FLAG)
|
||||
SPECK128_FLAG = $(POWER8_FLAG)
|
||||
endif
|
||||
|
||||
# GCC and some compatibles
|
||||
|
|
@ -435,6 +445,8 @@ ifneq ($(IS_PPC32)$(IS_PPC64),00)
|
|||
CHAM_FLAG = $(POWER7_FLAG)
|
||||
LEA_FLAG = $(POWER7_FLAG)
|
||||
SIMECK_FLAG = $(POWER7_FLAG)
|
||||
SIMON64_FLAG = $(POWER7_FLAG)
|
||||
SPECK64_FLAG = $(POWER7_FLAG)
|
||||
endif
|
||||
|
||||
# GCC and some compatibles
|
||||
|
|
@ -451,8 +463,10 @@ ifneq ($(IS_PPC32)$(IS_PPC64),00)
|
|||
GCM_FLAG = $(POWER8_FLAG)
|
||||
SHA_FLAG = $(POWER8_FLAG)
|
||||
SM4_FLAG = $(POWER8_FLAG)
|
||||
SIMON_FLAG = $(POWER8_FLAG)
|
||||
SPECK_FLAG = $(POWER8_FLAG)
|
||||
SIMON64_FLAG = $(POWER8_FLAG)
|
||||
SIMON128_FLAG = $(POWER8_FLAG)
|
||||
SPECK64_FLAG = $(POWER8_FLAG)
|
||||
SPECK128_FLAG = $(POWER8_FLAG)
|
||||
endif
|
||||
|
||||
# IBM XL C/C++
|
||||
|
|
@ -464,6 +478,8 @@ ifneq ($(IS_PPC32)$(IS_PPC64),00)
|
|||
CHAM_FLAG = $(POWER7_FLAG)
|
||||
LEA_FLAG = $(POWER7_FLAG)
|
||||
SIMECK_FLAG = $(POWER7_FLAG)
|
||||
SIMON64_FLAG = $(POWER7_FLAG)
|
||||
SPECK64_FLAG = $(POWER7_FLAG)
|
||||
endif
|
||||
|
||||
# IBM XL C/C++
|
||||
|
|
@ -483,8 +499,10 @@ ifneq ($(IS_PPC32)$(IS_PPC64),00)
|
|||
CHAM_FLAG = $(POWER8_FLAG)
|
||||
LEA_FLAG = $(POWER8_FLAG)
|
||||
SIMECK_FLAG = $(POWER8_FLAG)
|
||||
SIMON_FLAG = $(POWER8_FLAG)
|
||||
SPECK_FLAG = $(POWER8_FLAG)
|
||||
SIMON64_FLAG = $(POWER8_FLAG)
|
||||
SIMON128_FLAG = $(POWER8_FLAG)
|
||||
SPECK64_FLAG = $(POWER8_FLAG)
|
||||
SPECK128_FLAG = $(POWER8_FLAG)
|
||||
ALTIVEC_FLAG = $(POWER8_FLAG)
|
||||
endif
|
||||
|
||||
|
|
@ -1166,13 +1184,21 @@ shacal2-simd.o : shacal2-simd.cpp
|
|||
simeck-simd.o : simeck-simd.cpp
|
||||
$(CXX) $(strip $(CXXFLAGS) $(SIMECK_FLAG) -c) $<
|
||||
|
||||
# SSSE3 or NEON available
|
||||
simon-simd.o : simon-simd.cpp
|
||||
$(CXX) $(strip $(CXXFLAGS) $(SIMON_FLAG) -c) $<
|
||||
# SSE4.1, NEON or POWER7 available
|
||||
simon64-simd.o : simon64-simd.cpp
|
||||
$(CXX) $(strip $(CXXFLAGS) $(SIMON64_FLAG) -c) $<
|
||||
|
||||
# SSSE3 or NEON available
|
||||
speck-simd.o : speck-simd.cpp
|
||||
$(CXX) $(strip $(CXXFLAGS) $(SPECK_FLAG) -c) $<
|
||||
# SSSE3, NEON or POWER8 available
|
||||
simon128-simd.o : simon128-simd.cpp
|
||||
$(CXX) $(strip $(CXXFLAGS) $(SIMON128_FLAG) -c) $<
|
||||
|
||||
# SSE4.1, NEON or POWER7 available
|
||||
speck64-simd.o : speck64-simd.cpp
|
||||
$(CXX) $(strip $(CXXFLAGS) $(SPECK64_FLAG) -c) $<
|
||||
|
||||
# SSSE3, NEON or POWER8 available
|
||||
speck128-simd.o : speck128-simd.cpp
|
||||
$(CXX) $(strip $(CXXFLAGS) $(SPECK128_FLAG) -c) $<
|
||||
|
||||
# AESNI available
|
||||
sm4-simd.o : sm4-simd.cpp
|
||||
|
|
|
|||
|
|
@ -47,9 +47,9 @@
|
|||
|
||||
# If you use 'make sources' from Linux makefile, then add 'winpipes.cpp' to the list below.
|
||||
|
||||
LIB_SRCS = cryptlib.cpp cpu.cpp integer.cpp 3way.cpp adler32.cpp algebra.cpp algparam.cpp arc4.cpp aria-simd.cpp aria.cpp ariatab.cpp asn.cpp authenc.cpp base32.cpp base64.cpp basecode.cpp bfinit.cpp blake2-simd.cpp blake2.cpp blowfish.cpp blumshub.cpp camellia.cpp cast.cpp casts.cpp cbcmac.cpp ccm.cpp chacha.cpp cham.cpp cham-simd.cpp channels.cpp cmac.cpp crc-simd.cpp crc.cpp default.cpp des.cpp dessp.cpp dh.cpp dh2.cpp dll.cpp dsa.cpp eax.cpp ec2n.cpp eccrypto.cpp ecp.cpp elgamal.cpp emsa2.cpp eprecomp.cpp esign.cpp files.cpp filters.cpp fips140.cpp fipstest.cpp gcm-simd.cpp gcm.cpp gf256.cpp gf2_32.cpp gf2n.cpp gfpcrypt.cpp gost.cpp gzip.cpp hc128.cpp hc256.cpp hex.cpp hight.cpp hmac.cpp hrtimer.cpp ida.cpp idea.cpp iterhash.cpp kalyna.cpp kalynatab.cpp keccak.cpp lea.cpp lea-simd.cpp luc.cpp mars.cpp marss.cpp md2.cpp md4.cpp md5.cpp misc.cpp modes.cpp mqueue.cpp mqv.cpp nbtheory.cpp neon-simd.cpp network.cpp oaep.cpp osrng.cpp padlkrng.cpp panama.cpp pkcspad.cpp poly1305.cpp polynomi.cpp pssr.cpp pubkey.cpp queue.cpp rabin.cpp randpool.cpp rabbit.cpp rc2.cpp rc5.cpp rc6.cpp rdrand.cpp rdtables.cpp rijndael-simd.cpp rijndael.cpp ripemd.cpp rng.cpp rsa.cpp rw.cpp safer.cpp salsa.cpp scrypt.cpp seal.cpp seed.cpp serpent.cpp sha-simd.cpp sha.cpp sha3.cpp shacal2-simd.cpp shacal2.cpp shark.cpp sharkbox.cpp simeck-simd.cpp simeck.cpp simon.cpp simon-simd.cpp skipjack.cpp sm3.cpp sm4.cpp sm4-simd.cpp socketft.cpp sosemanuk.cpp speck.cpp speck-simd.cpp square.cpp squaretb.cpp sse-simd.cpp strciphr.cpp tea.cpp tftables.cpp threefish.cpp tiger.cpp tigertab.cpp trdlocal.cpp ttmac.cpp tweetnacl.cpp twofish.cpp vmac.cpp wait.cpp wake.cpp whrlpool.cpp winpipes.cpp xtr.cpp xtrcrypt.cpp zdeflate.cpp zinflate.cpp zlib.cpp
|
||||
LIB_SRCS = cryptlib.cpp cpu.cpp integer.cpp 3way.cpp adler32.cpp algebra.cpp algparam.cpp arc4.cpp aria-simd.cpp aria.cpp ariatab.cpp asn.cpp authenc.cpp base32.cpp base64.cpp basecode.cpp bfinit.cpp blake2-simd.cpp blake2.cpp blowfish.cpp blumshub.cpp camellia.cpp cast.cpp casts.cpp cbcmac.cpp ccm.cpp chacha.cpp cham.cpp cham-simd.cpp channels.cpp cmac.cpp crc-simd.cpp crc.cpp default.cpp des.cpp dessp.cpp dh.cpp dh2.cpp dll.cpp dsa.cpp eax.cpp ec2n.cpp eccrypto.cpp ecp.cpp elgamal.cpp emsa2.cpp eprecomp.cpp esign.cpp files.cpp filters.cpp fips140.cpp fipstest.cpp gcm-simd.cpp gcm.cpp gf256.cpp gf2_32.cpp gf2n.cpp gfpcrypt.cpp gost.cpp gzip.cpp hc128.cpp hc256.cpp hex.cpp hight.cpp hmac.cpp hrtimer.cpp ida.cpp idea.cpp iterhash.cpp kalyna.cpp kalynatab.cpp keccak.cpp lea.cpp lea-simd.cpp luc.cpp mars.cpp marss.cpp md2.cpp md4.cpp md5.cpp misc.cpp modes.cpp mqueue.cpp mqv.cpp nbtheory.cpp neon-simd.cpp network.cpp oaep.cpp osrng.cpp padlkrng.cpp panama.cpp pkcspad.cpp poly1305.cpp polynomi.cpp pssr.cpp pubkey.cpp queue.cpp rabin.cpp randpool.cpp rabbit.cpp rc2.cpp rc5.cpp rc6.cpp rdrand.cpp rdtables.cpp rijndael-simd.cpp rijndael.cpp ripemd.cpp rng.cpp rsa.cpp rw.cpp safer.cpp salsa.cpp scrypt.cpp seal.cpp seed.cpp serpent.cpp sha-simd.cpp sha.cpp sha3.cpp shacal2-simd.cpp shacal2.cpp shark.cpp sharkbox.cpp simeck-simd.cpp simeck.cpp simon.cpp simon64-simd.cpp simon128-simd.cpp skipjack.cpp sm3.cpp sm4.cpp sm4-simd.cpp socketft.cpp sosemanuk.cpp speck.cpp speck64-simd.cpp speck128-simd.cpp square.cpp squaretb.cpp sse-simd.cpp strciphr.cpp tea.cpp tftables.cpp threefish.cpp tiger.cpp tigertab.cpp trdlocal.cpp ttmac.cpp tweetnacl.cpp twofish.cpp vmac.cpp wait.cpp wake.cpp whrlpool.cpp winpipes.cpp xtr.cpp xtrcrypt.cpp zdeflate.cpp zinflate.cpp zlib.cpp
|
||||
|
||||
LIB_OBJS = cryptlib.obj cpu.obj integer.obj 3way.obj adler32.obj algebra.obj algparam.obj arc4.obj aria-simd.obj aria.obj ariatab.obj asn.obj authenc.obj base32.obj base64.obj basecode.obj bfinit.obj blake2-simd.obj blake2.obj blowfish.obj blumshub.obj camellia.obj cast.obj casts.obj cbcmac.obj ccm.obj chacha.obj cham.obj cham-simd.obj channels.obj cmac.obj crc-simd.obj crc.obj default.obj des.obj dessp.obj dh.obj dh2.obj dll.obj dsa.obj eax.obj ec2n.obj eccrypto.obj ecp.obj elgamal.obj emsa2.obj eprecomp.obj esign.obj files.obj filters.obj fips140.obj fipstest.obj gcm-simd.obj gcm.obj gf256.obj gf2_32.obj gf2n.obj gfpcrypt.obj gost.obj gzip.obj hc128.obj hc256.obj hex.obj hight.obj hmac.obj hrtimer.obj ida.obj idea.obj iterhash.obj kalyna.obj kalynatab.obj keccak.obj lea.obj lea-simd.obj luc.obj mars.obj marss.obj md2.obj md4.obj md5.obj misc.obj modes.obj mqueue.obj mqv.obj nbtheory.obj neon-simd.obj network.obj oaep.obj osrng.obj padlkrng.obj panama.obj pkcspad.obj poly1305.obj polynomi.obj pssr.obj pubkey.obj queue.obj rabin.obj randpool.obj rabbit.obj rc2.obj rc5.obj rc6.obj rdrand.obj rdtables.obj rijndael-simd.obj rijndael.obj ripemd.obj rng.obj rsa.obj rw.obj safer.obj salsa.obj scrypt.obj seal.obj seed.obj serpent.obj sha-simd.obj sha.obj sha3.obj shacal2-simd.obj shacal2.obj shark.obj sharkbox.obj simeck-simd.obj simeck.obj simon.obj simon-simd.obj skipjack.obj sm3.obj sm4.obj sm4-simd.obj socketft.obj sosemanuk.obj speck.obj speck-simd.obj square.obj squaretb.obj sse-simd.obj strciphr.obj tea.obj tftables.obj threefish.obj tiger.obj tigertab.obj trdlocal.obj ttmac.obj tweetnacl.obj twofish.obj vmac.obj wait.obj wake.obj whrlpool.obj winpipes.obj xtr.obj xtrcrypt.obj zdeflate.obj zinflate.obj zlib.obj
|
||||
LIB_OBJS = cryptlib.obj cpu.obj integer.obj 3way.obj adler32.obj algebra.obj algparam.obj arc4.obj aria-simd.obj aria.obj ariatab.obj asn.obj authenc.obj base32.obj base64.obj basecode.obj bfinit.obj blake2-simd.obj blake2.obj blowfish.obj blumshub.obj camellia.obj cast.obj casts.obj cbcmac.obj ccm.obj chacha.obj cham.obj cham-simd.obj channels.obj cmac.obj crc-simd.obj crc.obj default.obj des.obj dessp.obj dh.obj dh2.obj dll.obj dsa.obj eax.obj ec2n.obj eccrypto.obj ecp.obj elgamal.obj emsa2.obj eprecomp.obj esign.obj files.obj filters.obj fips140.obj fipstest.obj gcm-simd.obj gcm.obj gf256.obj gf2_32.obj gf2n.obj gfpcrypt.obj gost.obj gzip.obj hc128.obj hc256.obj hex.obj hight.obj hmac.obj hrtimer.obj ida.obj idea.obj iterhash.obj kalyna.obj kalynatab.obj keccak.obj lea.obj lea-simd.obj luc.obj mars.obj marss.obj md2.obj md4.obj md5.obj misc.obj modes.obj mqueue.obj mqv.obj nbtheory.obj neon-simd.obj network.obj oaep.obj osrng.obj padlkrng.obj panama.obj pkcspad.obj poly1305.obj polynomi.obj pssr.obj pubkey.obj queue.obj rabin.obj randpool.obj rabbit.obj rc2.obj rc5.obj rc6.obj rdrand.obj rdtables.obj rijndael-simd.obj rijndael.obj ripemd.obj rng.obj rsa.obj rw.obj safer.obj salsa.obj scrypt.obj seal.obj seed.obj serpent.obj sha-simd.obj sha.obj sha3.obj shacal2-simd.obj shacal2.obj shark.obj sharkbox.obj simeck-simd.obj simeck.obj simon.obj simon64-simd.obj simon128-simd.obj skipjack.obj sm3.obj sm4.obj sm4-simd.obj socketft.obj sosemanuk.obj speck.obj speck64-simd.obj speck128-simd.obj square.obj squaretb.obj sse-simd.obj strciphr.obj tea.obj tftables.obj threefish.obj tiger.obj tigertab.obj trdlocal.obj ttmac.obj tweetnacl.obj twofish.obj vmac.obj wait.obj wake.obj whrlpool.obj winpipes.obj xtr.obj xtrcrypt.obj zdeflate.obj zinflate.obj zlib.obj
|
||||
|
||||
TEST_SRCS = bench1.cpp bench2.cpp bench3.cpp test.cpp validat0.cpp validat1.cpp validat2.cpp validat3.cpp validat4.cpp validat5.cpp validat6.cpp validat7.cpp validat8.cpp validat9.cpp validat10.cpp datatest.cpp regtest1.cpp regtest2.cpp regtest3.cpp regtest4.cpp fipsalgt.cpp dlltest.cpp fipstest.cpp
|
||||
|
||||
|
|
|
|||
|
|
@ -301,7 +301,8 @@
|
|||
<ClCompile Include="simeck.cpp" />
|
||||
<ClCompile Include="simeck-simd.cpp" />
|
||||
<ClCompile Include="simon.cpp" />
|
||||
<ClCompile Include="simon-simd.cpp" />
|
||||
<ClCompile Include="simon64-simd.cpp" />
|
||||
<ClCompile Include="simon128-simd.cpp" />
|
||||
<ClCompile Include="simple.cpp" />
|
||||
<ClCompile Include="skipjack.cpp" />
|
||||
<ClCompile Include="sm3.cpp" />
|
||||
|
|
@ -310,7 +311,8 @@
|
|||
<ClCompile Include="socketft.cpp" />
|
||||
<ClCompile Include="sosemanuk.cpp" />
|
||||
<ClCompile Include="speck.cpp" />
|
||||
<ClCompile Include="speck-simd.cpp" />
|
||||
<ClCompile Include="speck64-simd.cpp" />
|
||||
<ClCompile Include="speck128-simd.cpp" />
|
||||
<ClCompile Include="square.cpp" />
|
||||
<ClCompile Include="squaretb.cpp" />
|
||||
<ClCompile Include="sse-simd.cpp" />
|
||||
|
|
|
|||
|
|
@ -395,7 +395,10 @@
|
|||
<ClCompile Include="simon.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="simon-simd.cpp">
|
||||
<ClCompile Include="simon64-simd.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="simon128-simd.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="simple.cpp">
|
||||
|
|
@ -416,7 +419,10 @@
|
|||
<ClCompile Include="speck.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="speck-simd.cpp">
|
||||
<ClCompile Include="speck64-simd.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="speck128-simd.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="socketft.cpp">
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@
|
|||
#endif
|
||||
|
||||
// Squash MS LNK4221 and libtool warnings
|
||||
extern const char SIMON_SIMD_FNAME[] = __FILE__;
|
||||
extern const char SIMON64_SIMD_FNAME[] = __FILE__;
|
||||
|
||||
ANONYMOUS_NAMESPACE_BEGIN
|
||||
|
||||
|
|
@ -287,233 +287,9 @@ inline void SIMON64_Dec_6_Blocks(uint32x4_t &block0, uint32x4_t &block1,
|
|||
|
||||
#endif // CRYPTOPP_ARM_NEON_AVAILABLE
|
||||
|
||||
#if (CRYPTOPP_ARM_NEON_AVAILABLE)
|
||||
|
||||
template <class T>
|
||||
inline T UnpackHigh64(const T& a, const T& b)
|
||||
{
|
||||
const uint64x1_t x(vget_high_u64((uint64x2_t)a));
|
||||
const uint64x1_t y(vget_high_u64((uint64x2_t)b));
|
||||
return (T)vcombine_u64(x, y);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T UnpackLow64(const T& a, const T& b)
|
||||
{
|
||||
const uint64x1_t x(vget_low_u64((uint64x2_t)a));
|
||||
const uint64x1_t y(vget_low_u64((uint64x2_t)b));
|
||||
return (T)vcombine_u64(x, y);
|
||||
}
|
||||
|
||||
template <unsigned int R>
|
||||
inline uint64x2_t RotateLeft64(const uint64x2_t& val)
|
||||
{
|
||||
const uint64x2_t a(vshlq_n_u64(val, R));
|
||||
const uint64x2_t b(vshrq_n_u64(val, 64 - R));
|
||||
return vorrq_u64(a, b);
|
||||
}
|
||||
|
||||
template <unsigned int R>
|
||||
inline uint64x2_t RotateRight64(const uint64x2_t& val)
|
||||
{
|
||||
const uint64x2_t a(vshlq_n_u64(val, 64 - R));
|
||||
const uint64x2_t b(vshrq_n_u64(val, R));
|
||||
return vorrq_u64(a, b);
|
||||
}
|
||||
|
||||
#if defined(__aarch32__) || defined(__aarch64__)
|
||||
// Faster than two Shifts and an Or. Thanks to Louis Wingers and Bryan Weeks.
|
||||
template <>
|
||||
inline uint64x2_t RotateLeft64<8>(const uint64x2_t& val)
|
||||
{
|
||||
#if defined(CRYPTOPP_BIG_ENDIAN)
|
||||
const uint8_t maskb[16] = { 14,13,12,11, 10,9,8,15, 6,5,4,3, 2,1,0,7 };
|
||||
const uint8x16_t mask = vld1q_u8(maskb);
|
||||
#else
|
||||
const uint8_t maskb[16] = { 7,0,1,2, 3,4,5,6, 15,8,9,10, 11,12,13,14 };
|
||||
const uint8x16_t mask = vld1q_u8(maskb);
|
||||
#endif
|
||||
|
||||
return vreinterpretq_u64_u8(
|
||||
vqtbl1q_u8(vreinterpretq_u8_u64(val), mask));
|
||||
}
|
||||
|
||||
// Faster than two Shifts and an Or. Thanks to Louis Wingers and Bryan Weeks.
|
||||
template <>
|
||||
inline uint64x2_t RotateRight64<8>(const uint64x2_t& val)
|
||||
{
|
||||
#if defined(CRYPTOPP_BIG_ENDIAN)
|
||||
const uint8_t maskb[16] = { 8,15,14,13, 12,11,10,9, 0,7,6,5, 4,3,2,1 };
|
||||
const uint8x16_t mask = vld1q_u8(maskb);
|
||||
#else
|
||||
const uint8_t maskb[16] = { 1,2,3,4, 5,6,7,0, 9,10,11,12, 13,14,15,8 };
|
||||
const uint8x16_t mask = vld1q_u8(maskb);
|
||||
#endif
|
||||
|
||||
return vreinterpretq_u64_u8(
|
||||
vqtbl1q_u8(vreinterpretq_u8_u64(val), mask));
|
||||
}
|
||||
#endif
|
||||
|
||||
inline uint64x2_t SIMON128_f(const uint64x2_t& val)
|
||||
{
|
||||
return veorq_u64(RotateLeft64<2>(val),
|
||||
vandq_u64(RotateLeft64<1>(val), RotateLeft64<8>(val)));
|
||||
}
|
||||
|
||||
inline void SIMON128_Enc_Block(uint64x2_t &block0, uint64x2_t &block1,
|
||||
const word64 *subkeys, unsigned int rounds)
|
||||
{
|
||||
// [A1 A2][B1 B2] ... => [A1 B1][A2 B2] ...
|
||||
uint64x2_t x1 = UnpackHigh64(block0, block1);
|
||||
uint64x2_t y1 = UnpackLow64(block0, block1);
|
||||
|
||||
for (int i = 0; i < static_cast<int>(rounds & ~1)-1; i += 2)
|
||||
{
|
||||
const uint64x2_t rk1 = vld1q_dup_u64(subkeys+i);
|
||||
y1 = veorq_u64(veorq_u64(y1, SIMON128_f(x1)), rk1);
|
||||
|
||||
const uint64x2_t rk2 = vld1q_dup_u64(subkeys+i+1);
|
||||
x1 = veorq_u64(veorq_u64(x1, SIMON128_f(y1)), rk2);
|
||||
}
|
||||
|
||||
if (rounds & 1)
|
||||
{
|
||||
const uint64x2_t rk = vld1q_dup_u64(subkeys+rounds-1);
|
||||
|
||||
y1 = veorq_u64(veorq_u64(y1, SIMON128_f(x1)), rk);
|
||||
std::swap(x1, y1);
|
||||
}
|
||||
|
||||
// [A1 B1][A2 B2] ... => [A1 A2][B1 B2] ...
|
||||
block0 = UnpackLow64(y1, x1);
|
||||
block1 = UnpackHigh64(y1, x1);
|
||||
}
|
||||
|
||||
inline void SIMON128_Enc_6_Blocks(uint64x2_t &block0, uint64x2_t &block1,
|
||||
uint64x2_t &block2, uint64x2_t &block3, uint64x2_t &block4, uint64x2_t &block5,
|
||||
const word64 *subkeys, unsigned int rounds)
|
||||
{
|
||||
// [A1 A2][B1 B2] ... => [A1 B1][A2 B2] ...
|
||||
uint64x2_t x1 = UnpackHigh64(block0, block1);
|
||||
uint64x2_t y1 = UnpackLow64(block0, block1);
|
||||
uint64x2_t x2 = UnpackHigh64(block2, block3);
|
||||
uint64x2_t y2 = UnpackLow64(block2, block3);
|
||||
uint64x2_t x3 = UnpackHigh64(block4, block5);
|
||||
uint64x2_t y3 = UnpackLow64(block4, block5);
|
||||
|
||||
for (int i = 0; i < static_cast<int>(rounds & ~1) - 1; i += 2)
|
||||
{
|
||||
const uint64x2_t rk1 = vld1q_dup_u64(subkeys+i);
|
||||
y1 = veorq_u64(veorq_u64(y1, SIMON128_f(x1)), rk1);
|
||||
y2 = veorq_u64(veorq_u64(y2, SIMON128_f(x2)), rk1);
|
||||
y3 = veorq_u64(veorq_u64(y3, SIMON128_f(x3)), rk1);
|
||||
|
||||
const uint64x2_t rk2 = vld1q_dup_u64(subkeys+i+1);
|
||||
x1 = veorq_u64(veorq_u64(x1, SIMON128_f(y1)), rk2);
|
||||
x2 = veorq_u64(veorq_u64(x2, SIMON128_f(y2)), rk2);
|
||||
x3 = veorq_u64(veorq_u64(x3, SIMON128_f(y3)), rk2);
|
||||
}
|
||||
|
||||
if (rounds & 1)
|
||||
{
|
||||
const uint64x2_t rk = vld1q_dup_u64(subkeys + rounds - 1);
|
||||
|
||||
y1 = veorq_u64(veorq_u64(y1, SIMON128_f(x1)), rk);
|
||||
y2 = veorq_u64(veorq_u64(y2, SIMON128_f(x2)), rk);
|
||||
y3 = veorq_u64(veorq_u64(y3, SIMON128_f(x3)), rk);
|
||||
std::swap(x1, y1); std::swap(x2, y2); std::swap(x3, y3);
|
||||
}
|
||||
|
||||
// [A1 B1][A2 B2] ... => [A1 A2][B1 B2] ...
|
||||
block0 = UnpackLow64(y1, x1);
|
||||
block1 = UnpackHigh64(y1, x1);
|
||||
block2 = UnpackLow64(y2, x2);
|
||||
block3 = UnpackHigh64(y2, x2);
|
||||
block4 = UnpackLow64(y3, x3);
|
||||
block5 = UnpackHigh64(y3, x3);
|
||||
}
|
||||
|
||||
inline void SIMON128_Dec_Block(uint64x2_t &block0, uint64x2_t &block1,
|
||||
const word64 *subkeys, unsigned int rounds)
|
||||
{
|
||||
// [A1 A2][B1 B2] ... => [A1 B1][A2 B2] ...
|
||||
uint64x2_t x1 = UnpackHigh64(block0, block1);
|
||||
uint64x2_t y1 = UnpackLow64(block0, block1);
|
||||
|
||||
if (rounds & 1)
|
||||
{
|
||||
std::swap(x1, y1);
|
||||
const uint64x2_t rk = vld1q_dup_u64(subkeys + rounds - 1);
|
||||
|
||||
y1 = veorq_u64(veorq_u64(y1, rk), SIMON128_f(x1));
|
||||
rounds--;
|
||||
}
|
||||
|
||||
for (int i = static_cast<int>(rounds-2); i >= 0; i -= 2)
|
||||
{
|
||||
const uint64x2_t rk1 = vld1q_dup_u64(subkeys+i+1);
|
||||
x1 = veorq_u64(veorq_u64(x1, SIMON128_f(y1)), rk1);
|
||||
|
||||
const uint64x2_t rk2 = vld1q_dup_u64(subkeys+i);
|
||||
y1 = veorq_u64(veorq_u64(y1, SIMON128_f(x1)), rk2);
|
||||
}
|
||||
|
||||
// [A1 B1][A2 B2] ... => [A1 A2][B1 B2] ...
|
||||
block0 = UnpackLow64(y1, x1);
|
||||
block1 = UnpackHigh64(y1, x1);
|
||||
}
|
||||
|
||||
inline void SIMON128_Dec_6_Blocks(uint64x2_t &block0, uint64x2_t &block1,
|
||||
uint64x2_t &block2, uint64x2_t &block3, uint64x2_t &block4, uint64x2_t &block5,
|
||||
const word64 *subkeys, unsigned int rounds)
|
||||
{
|
||||
// [A1 A2][B1 B2] ... => [A1 B1][A2 B2] ...
|
||||
uint64x2_t x1 = UnpackHigh64(block0, block1);
|
||||
uint64x2_t y1 = UnpackLow64(block0, block1);
|
||||
uint64x2_t x2 = UnpackHigh64(block2, block3);
|
||||
uint64x2_t y2 = UnpackLow64(block2, block3);
|
||||
uint64x2_t x3 = UnpackHigh64(block4, block5);
|
||||
uint64x2_t y3 = UnpackLow64(block4, block5);
|
||||
|
||||
if (rounds & 1)
|
||||
{
|
||||
std::swap(x1, y1); std::swap(x2, y2); std::swap(x3, y3);
|
||||
const uint64x2_t rk = vld1q_dup_u64(subkeys + rounds - 1);
|
||||
|
||||
y1 = veorq_u64(veorq_u64(y1, rk), SIMON128_f(x1));
|
||||
y2 = veorq_u64(veorq_u64(y2, rk), SIMON128_f(x2));
|
||||
y3 = veorq_u64(veorq_u64(y3, rk), SIMON128_f(x3));
|
||||
rounds--;
|
||||
}
|
||||
|
||||
for (int i = static_cast<int>(rounds-2); i >= 0; i -= 2)
|
||||
{
|
||||
const uint64x2_t rk1 = vld1q_dup_u64(subkeys + i + 1);
|
||||
x1 = veorq_u64(veorq_u64(x1, SIMON128_f(y1)), rk1);
|
||||
x2 = veorq_u64(veorq_u64(x2, SIMON128_f(y2)), rk1);
|
||||
x3 = veorq_u64(veorq_u64(x3, SIMON128_f(y3)), rk1);
|
||||
|
||||
const uint64x2_t rk2 = vld1q_dup_u64(subkeys + i);
|
||||
y1 = veorq_u64(veorq_u64(y1, SIMON128_f(x1)), rk2);
|
||||
y2 = veorq_u64(veorq_u64(y2, SIMON128_f(x2)), rk2);
|
||||
y3 = veorq_u64(veorq_u64(y3, SIMON128_f(x3)), rk2);
|
||||
}
|
||||
|
||||
// [A1 B1][A2 B2] ... => [A1 A2][B1 B2] ...
|
||||
block0 = UnpackLow64(y1, x1);
|
||||
block1 = UnpackHigh64(y1, x1);
|
||||
block2 = UnpackLow64(y2, x2);
|
||||
block3 = UnpackHigh64(y2, x2);
|
||||
block4 = UnpackLow64(y3, x3);
|
||||
block5 = UnpackHigh64(y3, x3);
|
||||
}
|
||||
|
||||
#endif // CRYPTOPP_ARM_NEON_AVAILABLE
|
||||
|
||||
// ***************************** IA-32 ***************************** //
|
||||
|
||||
#if defined(CRYPTOPP_SSSE3_AVAILABLE)
|
||||
#if (CRYPTOPP_SSSE3_AVAILABLE)
|
||||
|
||||
// Clang __m128i casts, http://bugs.llvm.org/show_bug.cgi?id=20670
|
||||
#ifndef M128_CAST
|
||||
|
|
@ -960,6 +736,7 @@ using CryptoPP::uint32x4_p;
|
|||
|
||||
using CryptoPP::VectorAnd;
|
||||
using CryptoPP::VectorXor;
|
||||
using CryptoPP::VectorLoadBE;
|
||||
|
||||
// Rotate left by bit count
|
||||
template<unsigned int C>
|
||||
|
|
@ -1193,245 +970,6 @@ inline void SIMON64_Dec_6_Blocks(uint32x4_p &block0, uint32x4_p &block1,
|
|||
|
||||
#endif // CRYPTOPP_POWER7_AVAILABLE
|
||||
|
||||
// ***************************** Power8 ***************************** //
|
||||
|
||||
#if defined(CRYPTOPP_POWER8_AVAILABLE)
|
||||
|
||||
using CryptoPP::uint8x16_p;
|
||||
using CryptoPP::uint32x4_p;
|
||||
using CryptoPP::uint64x2_p;
|
||||
|
||||
using CryptoPP::VectorAnd;
|
||||
using CryptoPP::VectorXor;
|
||||
|
||||
// Rotate left by bit count
|
||||
template<unsigned int C>
|
||||
inline uint64x2_p RotateLeft64(const uint64x2_p val)
|
||||
{
|
||||
const uint64x2_p m = {C, C};
|
||||
return vec_rl(val, m);
|
||||
}
|
||||
|
||||
// Rotate right by bit count
|
||||
template<unsigned int C>
|
||||
inline uint64x2_p RotateRight64(const uint64x2_p val)
|
||||
{
|
||||
const uint64x2_p m = {64-C, 64-C};
|
||||
return vec_rl(val, m);
|
||||
}
|
||||
|
||||
inline uint64x2_p SIMON128_f(const uint64x2_p val)
|
||||
{
|
||||
return VectorXor(RotateLeft64<2>(val),
|
||||
VectorAnd(RotateLeft64<1>(val), RotateLeft64<8>(val)));
|
||||
}
|
||||
|
||||
inline void SIMON128_Enc_Block(uint32x4_p &block, const word64 *subkeys, unsigned int rounds)
|
||||
{
|
||||
#if defined(CRYPTOPP_BIG_ENDIAN)
|
||||
const uint8x16_p m1 = {31,30,29,28,27,26,25,24, 15,14,13,12,11,10,9,8};
|
||||
const uint8x16_p m2 = {23,22,21,20,19,18,17,16, 7,6,5,4,3,2,1,0};
|
||||
#else
|
||||
const uint8x16_p m1 = {7,6,5,4,3,2,1,0, 23,22,21,20,19,18,17,16};
|
||||
const uint8x16_p m2 = {15,14,13,12,11,10,9,8, 31,30,29,28,27,26,25,24};
|
||||
#endif
|
||||
|
||||
// [A1 A2][B1 B2] ... => [A1 B1][A2 B2] ...
|
||||
uint64x2_p x1 = (uint64x2_p)vec_perm(block, block, m1);
|
||||
uint64x2_p y1 = (uint64x2_p)vec_perm(block, block, m2);
|
||||
|
||||
for (int i = 0; i < static_cast<int>(rounds & ~1)-1; i += 2)
|
||||
{
|
||||
const uint64x2_p rk1 = vec_splats((unsigned long long)subkeys[i]);
|
||||
y1 = VectorXor(VectorXor(y1, SIMON128_f(x1)), rk1);
|
||||
|
||||
const uint64x2_p rk2 = vec_splats((unsigned long long)subkeys[i+1]);
|
||||
x1 = VectorXor(VectorXor(x1, SIMON128_f(y1)), rk2);
|
||||
}
|
||||
|
||||
if (rounds & 1)
|
||||
{
|
||||
const uint64x2_p rk = vec_splats((unsigned long long)subkeys[rounds-1]);
|
||||
y1 = VectorXor(VectorXor(y1, SIMON128_f(x1)), rk);
|
||||
std::swap(x1, y1);
|
||||
}
|
||||
|
||||
#if defined(CRYPTOPP_BIG_ENDIAN)
|
||||
const uint8x16_p m3 = {31,30,29,28,27,26,25,24, 15,14,13,12,11,10,9,8};
|
||||
//const uint8x16_p m4 = {23,22,21,20,19,18,17,16, 7,6,5,4,3,2,1,0};
|
||||
#else
|
||||
const uint8x16_p m3 = {7,6,5,4,3,2,1,0, 23,22,21,20,19,18,17,16};
|
||||
//const uint8x16_p m4 = {15,14,13,12,11,10,9,8, 31,30,29,28,27,26,25,24};
|
||||
#endif
|
||||
|
||||
// [A1 B1][A2 B2] ... => [A1 A2][B1 B2] ...
|
||||
block = (uint32x4_p)vec_perm(x1, y1, m1);
|
||||
}
|
||||
|
||||
inline void SIMON128_Dec_Block(uint32x4_p &block, const word64 *subkeys, unsigned int rounds)
|
||||
{
|
||||
#if defined(CRYPTOPP_BIG_ENDIAN)
|
||||
const uint8x16_p m1 = {31,30,29,28,27,26,25,24, 15,14,13,12,11,10,9,8};
|
||||
const uint8x16_p m2 = {23,22,21,20,19,18,17,16, 7,6,5,4,3,2,1,0};
|
||||
#else
|
||||
const uint8x16_p m1 = {7,6,5,4,3,2,1,0, 23,22,21,20,19,18,17,16};
|
||||
const uint8x16_p m2 = {15,14,13,12,11,10,9,8, 31,30,29,28,27,26,25,24};
|
||||
#endif
|
||||
|
||||
// [A1 A2][B1 B2] ... => [A1 B1][A2 B2] ...
|
||||
uint64x2_p x1 = (uint64x2_p)vec_perm(block, block, m1);
|
||||
uint64x2_p y1 = (uint64x2_p)vec_perm(block, block, m2);
|
||||
|
||||
if (rounds & 1)
|
||||
{
|
||||
std::swap(x1, y1);
|
||||
const uint64x2_p rk = vec_splats((unsigned long long)subkeys[rounds-1]);
|
||||
y1 = VectorXor(VectorXor(y1, rk), SIMON128_f(x1));
|
||||
rounds--;
|
||||
}
|
||||
|
||||
for (int i = static_cast<int>(rounds-2); i >= 0; i -= 2)
|
||||
{
|
||||
const uint64x2_p rk1 = vec_splats((unsigned long long)subkeys[i+1]);
|
||||
x1 = VectorXor(VectorXor(x1, SIMON128_f(y1)), rk1);
|
||||
|
||||
const uint64x2_p rk2 = vec_splats((unsigned long long)subkeys[i]);
|
||||
y1 = VectorXor(VectorXor(y1, SIMON128_f(x1)), rk2);
|
||||
}
|
||||
|
||||
#if defined(CRYPTOPP_BIG_ENDIAN)
|
||||
const uint8x16_p m3 = {31,30,29,28,27,26,25,24, 15,14,13,12,11,10,9,8};
|
||||
//const uint8x16_p m4 = {23,22,21,20,19,18,17,16, 7,6,5,4,3,2,1,0};
|
||||
#else
|
||||
const uint8x16_p m3 = {7,6,5,4,3,2,1,0, 23,22,21,20,19,18,17,16};
|
||||
//const uint8x16_p m4 = {15,14,13,12,11,10,9,8, 31,30,29,28,27,26,25,24};
|
||||
#endif
|
||||
|
||||
// [A1 B1][A2 B2] ... => [A1 A2][B1 B2] ...
|
||||
block = (uint32x4_p)vec_perm(x1, y1, m1);
|
||||
}
|
||||
|
||||
inline void SIMON128_Enc_6_Blocks(uint32x4_p &block0, uint32x4_p &block1,
|
||||
uint32x4_p &block2, uint32x4_p &block3, uint32x4_p &block4,
|
||||
uint32x4_p &block5, const word64 *subkeys, unsigned int rounds)
|
||||
{
|
||||
#if defined(CRYPTOPP_BIG_ENDIAN)
|
||||
const uint8x16_p m1 = {31,30,29,28,27,26,25,24, 15,14,13,12,11,10,9,8};
|
||||
const uint8x16_p m2 = {23,22,21,20,19,18,17,16, 7,6,5,4,3,2,1,0};
|
||||
#else
|
||||
const uint8x16_p m1 = {7,6,5,4,3,2,1,0, 23,22,21,20,19,18,17,16};
|
||||
const uint8x16_p m2 = {15,14,13,12,11,10,9,8, 31,30,29,28,27,26,25,24};
|
||||
#endif
|
||||
|
||||
// [A1 A2][B1 B2] ... => [A1 B1][A2 B2] ...
|
||||
uint64x2_p x1 = (uint64x2_p)vec_perm(block0, block1, m1);
|
||||
uint64x2_p y1 = (uint64x2_p)vec_perm(block0, block1, m2);
|
||||
uint64x2_p x2 = (uint64x2_p)vec_perm(block2, block3, m1);
|
||||
uint64x2_p y2 = (uint64x2_p)vec_perm(block2, block3, m2);
|
||||
uint64x2_p x3 = (uint64x2_p)vec_perm(block4, block5, m1);
|
||||
uint64x2_p y3 = (uint64x2_p)vec_perm(block4, block5, m2);
|
||||
|
||||
for (int i = 0; i < static_cast<int>(rounds & ~1)-1; i += 2)
|
||||
{
|
||||
const uint64x2_p rk1 = vec_splats((unsigned long long)subkeys[i]);
|
||||
y1 = VectorXor(VectorXor(y1, SIMON128_f(x1)), rk1);
|
||||
y2 = VectorXor(VectorXor(y2, SIMON128_f(x2)), rk1);
|
||||
y3 = VectorXor(VectorXor(y3, SIMON128_f(x3)), rk1);
|
||||
|
||||
const uint64x2_p rk2 = vec_splats((unsigned long long)subkeys[i+1]);
|
||||
x1 = VectorXor(VectorXor(x1, SIMON128_f(y1)), rk2);
|
||||
x2 = VectorXor(VectorXor(x2, SIMON128_f(y2)), rk2);
|
||||
x3 = VectorXor(VectorXor(x3, SIMON128_f(y3)), rk2);
|
||||
}
|
||||
|
||||
if (rounds & 1)
|
||||
{
|
||||
const uint64x2_p rk = vec_splats((unsigned long long)subkeys[rounds-1]);
|
||||
y1 = VectorXor(VectorXor(y1, SIMON128_f(x1)), rk);
|
||||
y2 = VectorXor(VectorXor(y2, SIMON128_f(x2)), rk);
|
||||
y3 = VectorXor(VectorXor(y3, SIMON128_f(x3)), rk);
|
||||
std::swap(x1, y1); std::swap(x2, y2); std::swap(x3, y3);
|
||||
}
|
||||
|
||||
#if defined(CRYPTOPP_BIG_ENDIAN)
|
||||
const uint8x16_p m3 = {31,30,29,28,27,26,25,24, 15,14,13,12,11,10,9,8};
|
||||
const uint8x16_p m4 = {23,22,21,20,19,18,17,16, 7,6,5,4,3,2,1,0};
|
||||
#else
|
||||
const uint8x16_p m3 = {7,6,5,4,3,2,1,0, 23,22,21,20,19,18,17,16};
|
||||
const uint8x16_p m4 = {15,14,13,12,11,10,9,8, 31,30,29,28,27,26,25,24};
|
||||
#endif
|
||||
|
||||
// [A1 B1][A2 B2] ... => [A1 A2][B1 B2] ...
|
||||
block0 = (uint32x4_p)vec_perm(x1, y1, m3);
|
||||
block1 = (uint32x4_p)vec_perm(x1, y1, m4);
|
||||
block2 = (uint32x4_p)vec_perm(x2, y2, m3);
|
||||
block3 = (uint32x4_p)vec_perm(x2, y2, m4);
|
||||
block4 = (uint32x4_p)vec_perm(x3, y3, m3);
|
||||
block5 = (uint32x4_p)vec_perm(x3, y3, m4);
|
||||
}
|
||||
|
||||
inline void SIMON128_Dec_6_Blocks(uint32x4_p &block0, uint32x4_p &block1,
|
||||
uint32x4_p &block2, uint32x4_p &block3, uint32x4_p &block4,
|
||||
uint32x4_p &block5, const word64 *subkeys, unsigned int rounds)
|
||||
{
|
||||
#if defined(CRYPTOPP_BIG_ENDIAN)
|
||||
const uint8x16_p m1 = {31,30,29,28,27,26,25,24, 15,14,13,12,11,10,9,8};
|
||||
const uint8x16_p m2 = {23,22,21,20,19,18,17,16, 7,6,5,4,3,2,1,0};
|
||||
#else
|
||||
const uint8x16_p m1 = {7,6,5,4,3,2,1,0, 23,22,21,20,19,18,17,16};
|
||||
const uint8x16_p m2 = {15,14,13,12,11,10,9,8, 31,30,29,28,27,26,25,24};
|
||||
#endif
|
||||
|
||||
// [A1 A2][B1 B2] ... => [A1 B1][A2 B2] ...
|
||||
uint64x2_p x1 = (uint64x2_p)vec_perm(block0, block1, m1);
|
||||
uint64x2_p y1 = (uint64x2_p)vec_perm(block0, block1, m2);
|
||||
uint64x2_p x2 = (uint64x2_p)vec_perm(block2, block3, m1);
|
||||
uint64x2_p y2 = (uint64x2_p)vec_perm(block2, block3, m2);
|
||||
uint64x2_p x3 = (uint64x2_p)vec_perm(block4, block5, m1);
|
||||
uint64x2_p y3 = (uint64x2_p)vec_perm(block4, block5, m2);
|
||||
|
||||
if (rounds & 1)
|
||||
{
|
||||
std::swap(x1, y1); std::swap(x2, y2); std::swap(x3, y3);
|
||||
const uint64x2_p rk = vec_splats((unsigned long long)subkeys[rounds-1]);
|
||||
y1 = VectorXor(VectorXor(y1, rk), SIMON128_f(x1));
|
||||
y2 = VectorXor(VectorXor(y2, rk), SIMON128_f(x2));
|
||||
y3 = VectorXor(VectorXor(y3, rk), SIMON128_f(x3));
|
||||
rounds--;
|
||||
}
|
||||
|
||||
for (int i = static_cast<int>(rounds-2); i >= 0; i -= 2)
|
||||
{
|
||||
const uint64x2_p rk1 = vec_splats((unsigned long long)subkeys[i+1]);
|
||||
x1 = VectorXor(VectorXor(x1, SIMON128_f(y1)), rk1);
|
||||
x2 = VectorXor(VectorXor(x2, SIMON128_f(y2)), rk1);
|
||||
x3 = VectorXor(VectorXor(x3, SIMON128_f(y3)), rk1);
|
||||
|
||||
const uint64x2_p rk2 = vec_splats((unsigned long long)subkeys[i]);
|
||||
y1 = VectorXor(VectorXor(y1, SIMON128_f(x1)), rk2);
|
||||
y2 = VectorXor(VectorXor(y2, SIMON128_f(x2)), rk2);
|
||||
y3 = VectorXor(VectorXor(y3, SIMON128_f(x3)), rk2);
|
||||
}
|
||||
|
||||
#if defined(CRYPTOPP_BIG_ENDIAN)
|
||||
const uint8x16_p m3 = {31,30,29,28,27,26,25,24, 15,14,13,12,11,10,9,8};
|
||||
const uint8x16_p m4 = {23,22,21,20,19,18,17,16, 7,6,5,4,3,2,1,0};
|
||||
#else
|
||||
const uint8x16_p m3 = {7,6,5,4,3,2,1,0, 23,22,21,20,19,18,17,16};
|
||||
const uint8x16_p m4 = {15,14,13,12,11,10,9,8, 31,30,29,28,27,26,25,24};
|
||||
#endif
|
||||
|
||||
// [A1 B1][A2 B2] ... => [A1 A2][B1 B2] ...
|
||||
block0 = (uint32x4_p)vec_perm(x1, y1, m3);
|
||||
block1 = (uint32x4_p)vec_perm(x1, y1, m4);
|
||||
block2 = (uint32x4_p)vec_perm(x2, y2, m3);
|
||||
block3 = (uint32x4_p)vec_perm(x2, y2, m4);
|
||||
block4 = (uint32x4_p)vec_perm(x3, y3, m3);
|
||||
block5 = (uint32x4_p)vec_perm(x3, y3, m4);
|
||||
}
|
||||
|
||||
#endif // CRYPTOPP_POWER8_AVAILABLE
|
||||
|
||||
ANONYMOUS_NAMESPACE_END
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -1456,22 +994,6 @@ size_t SIMON64_Dec_AdvancedProcessBlocks_NEON(const word32* subKeys, size_t roun
|
|||
}
|
||||
#endif // CRYPTOPP_ARM_NEON_AVAILABLE
|
||||
|
||||
#if (CRYPTOPP_ARM_NEON_AVAILABLE)
|
||||
size_t SIMON128_Enc_AdvancedProcessBlocks_NEON(const word64* subKeys, size_t rounds,
|
||||
const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags)
|
||||
{
|
||||
return AdvancedProcessBlocks128_6x2_NEON(SIMON128_Enc_Block, SIMON128_Enc_6_Blocks,
|
||||
subKeys, rounds, inBlocks, xorBlocks, outBlocks, length, flags);
|
||||
}
|
||||
|
||||
size_t SIMON128_Dec_AdvancedProcessBlocks_NEON(const word64* subKeys, size_t rounds,
|
||||
const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags)
|
||||
{
|
||||
return AdvancedProcessBlocks128_6x2_NEON(SIMON128_Dec_Block, SIMON128_Dec_6_Blocks,
|
||||
subKeys, rounds, inBlocks, xorBlocks, outBlocks, length, flags);
|
||||
}
|
||||
#endif // CRYPTOPP_ARM_NEON_AVAILABLE
|
||||
|
||||
// ***************************** IA-32 ***************************** //
|
||||
|
||||
#if defined(CRYPTOPP_SSE41_AVAILABLE)
|
||||
|
|
@ -1490,22 +1012,6 @@ size_t SIMON64_Dec_AdvancedProcessBlocks_SSE41(const word32* subKeys, size_t rou
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(CRYPTOPP_SSSE3_AVAILABLE)
|
||||
size_t SIMON128_Enc_AdvancedProcessBlocks_SSSE3(const word64* subKeys, size_t rounds,
|
||||
const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags)
|
||||
{
|
||||
return AdvancedProcessBlocks128_6x2_SSE(SIMON128_Enc_Block, SIMON128_Enc_6_Blocks,
|
||||
subKeys, rounds, inBlocks, xorBlocks, outBlocks, length, flags);
|
||||
}
|
||||
|
||||
size_t SIMON128_Dec_AdvancedProcessBlocks_SSSE3(const word64* subKeys, size_t rounds,
|
||||
const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags)
|
||||
{
|
||||
return AdvancedProcessBlocks128_6x2_SSE(SIMON128_Dec_Block, SIMON128_Dec_6_Blocks,
|
||||
subKeys, rounds, inBlocks, xorBlocks, outBlocks, length, flags);
|
||||
}
|
||||
#endif // CRYPTOPP_SSSE3_AVAILABLE
|
||||
|
||||
// ***************************** Power7 ***************************** //
|
||||
|
||||
#if defined(CRYPTOPP_POWER7_AVAILABLE)
|
||||
|
|
@ -1524,22 +1030,4 @@ size_t SIMON64_Dec_AdvancedProcessBlocks_POWER7(const word32* subKeys, size_t ro
|
|||
}
|
||||
#endif
|
||||
|
||||
// ***************************** Power8 ***************************** //
|
||||
|
||||
#if defined(CRYPTOPP_POWER8_AVAILABLE)
|
||||
size_t SIMON128_Enc_AdvancedProcessBlocks_POWER8(const word64* subKeys, size_t rounds,
|
||||
const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags)
|
||||
{
|
||||
return AdvancedProcessBlocks128_6x1_ALTIVEC(SIMON128_Enc_Block, SIMON128_Enc_6_Blocks,
|
||||
subKeys, rounds, inBlocks, xorBlocks, outBlocks, length, flags);
|
||||
}
|
||||
|
||||
size_t SIMON128_Dec_AdvancedProcessBlocks_POWER8(const word64* subKeys, size_t rounds,
|
||||
const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags)
|
||||
{
|
||||
return AdvancedProcessBlocks128_6x1_ALTIVEC(SIMON128_Dec_Block, SIMON128_Dec_6_Blocks,
|
||||
subKeys, rounds, inBlocks, xorBlocks, outBlocks, length, flags);
|
||||
}
|
||||
#endif // CRYPTOPP_POWER8_AVAILABLE
|
||||
|
||||
NAMESPACE_END
|
||||
|
|
@ -48,7 +48,7 @@
|
|||
#endif
|
||||
|
||||
// Squash MS LNK4221 and libtool warnings
|
||||
extern const char SPECK_SIMD_FNAME[] = __FILE__;
|
||||
extern const char SPECK64_SIMD_FNAME[] = __FILE__;
|
||||
|
||||
ANONYMOUS_NAMESPACE_BEGIN
|
||||
|
||||
|
|
@ -260,400 +260,8 @@ inline void SPECK64_Dec_6_Blocks(uint32x4_t &block0, uint32x4_t &block1,
|
|||
|
||||
#endif // CRYPTOPP_ARM_NEON_AVAILABLE
|
||||
|
||||
#if (CRYPTOPP_ARM_NEON_AVAILABLE)
|
||||
|
||||
template <class T>
|
||||
inline T UnpackHigh64(const T& a, const T& b)
|
||||
{
|
||||
const uint64x1_t x(vget_high_u64((uint64x2_t)a));
|
||||
const uint64x1_t y(vget_high_u64((uint64x2_t)b));
|
||||
return (T)vcombine_u64(x, y);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T UnpackLow64(const T& a, const T& b)
|
||||
{
|
||||
const uint64x1_t x(vget_low_u64((uint64x2_t)a));
|
||||
const uint64x1_t y(vget_low_u64((uint64x2_t)b));
|
||||
return (T)vcombine_u64(x, y);
|
||||
}
|
||||
|
||||
template <unsigned int R>
|
||||
inline uint64x2_t RotateLeft64(const uint64x2_t& val)
|
||||
{
|
||||
const uint64x2_t a(vshlq_n_u64(val, R));
|
||||
const uint64x2_t b(vshrq_n_u64(val, 64 - R));
|
||||
return vorrq_u64(a, b);
|
||||
}
|
||||
|
||||
template <unsigned int R>
|
||||
inline uint64x2_t RotateRight64(const uint64x2_t& val)
|
||||
{
|
||||
const uint64x2_t a(vshlq_n_u64(val, 64 - R));
|
||||
const uint64x2_t b(vshrq_n_u64(val, R));
|
||||
return vorrq_u64(a, b);
|
||||
}
|
||||
|
||||
#if defined(__aarch32__) || defined(__aarch64__)
|
||||
// Faster than two Shifts and an Or. Thanks to Louis Wingers and Bryan Weeks.
|
||||
template <>
|
||||
inline uint64x2_t RotateLeft64<8>(const uint64x2_t& val)
|
||||
{
|
||||
#if defined(CRYPTOPP_BIG_ENDIAN)
|
||||
const uint8_t maskb[16] = { 14,13,12,11, 10,9,8,15, 6,5,4,3, 2,1,0,7 };
|
||||
const uint8x16_t mask = vld1q_u8(maskb);
|
||||
#else
|
||||
const uint8_t maskb[16] = { 7,0,1,2, 3,4,5,6, 15,8,9,10, 11,12,13,14 };
|
||||
const uint8x16_t mask = vld1q_u8(maskb);
|
||||
#endif
|
||||
|
||||
return vreinterpretq_u64_u8(
|
||||
vqtbl1q_u8(vreinterpretq_u8_u64(val), mask));
|
||||
}
|
||||
|
||||
// Faster than two Shifts and an Or. Thanks to Louis Wingers and Bryan Weeks.
|
||||
template <>
|
||||
inline uint64x2_t RotateRight64<8>(const uint64x2_t& val)
|
||||
{
|
||||
#if defined(CRYPTOPP_BIG_ENDIAN)
|
||||
const uint8_t maskb[16] = { 8,15,14,13, 12,11,10,9, 0,7,6,5, 4,3,2,1 };
|
||||
const uint8x16_t mask = vld1q_u8(maskb);
|
||||
#else
|
||||
const uint8_t maskb[16] = { 1,2,3,4, 5,6,7,0, 9,10,11,12, 13,14,15,8 };
|
||||
const uint8x16_t mask = vld1q_u8(maskb);
|
||||
#endif
|
||||
|
||||
return vreinterpretq_u64_u8(
|
||||
vqtbl1q_u8(vreinterpretq_u8_u64(val), mask));
|
||||
}
|
||||
#endif
|
||||
|
||||
inline void SPECK128_Enc_Block(uint64x2_t &block0, uint64x2_t &block1,
|
||||
const word64 *subkeys, unsigned int rounds)
|
||||
{
|
||||
// [A1 A2][B1 B2] ... => [A1 B1][A2 B2] ...
|
||||
uint64x2_t x1 = UnpackHigh64(block0, block1);
|
||||
uint64x2_t y1 = UnpackLow64(block0, block1);
|
||||
|
||||
for (int i=0; i < static_cast<int>(rounds); ++i)
|
||||
{
|
||||
const uint64x2_t rk = vld1q_dup_u64(subkeys+i);
|
||||
|
||||
x1 = RotateRight64<8>(x1);
|
||||
x1 = vaddq_u64(x1, y1);
|
||||
x1 = veorq_u64(x1, rk);
|
||||
y1 = RotateLeft64<3>(y1);
|
||||
y1 = veorq_u64(y1, x1);
|
||||
}
|
||||
|
||||
// [A1 B1][A2 B2] ... => [A1 A2][B1 B2] ...
|
||||
block0 = UnpackLow64(y1, x1);
|
||||
block1 = UnpackHigh64(y1, x1);
|
||||
}
|
||||
|
||||
inline void SPECK128_Enc_6_Blocks(uint64x2_t &block0, uint64x2_t &block1,
|
||||
uint64x2_t &block2, uint64x2_t &block3, uint64x2_t &block4, uint64x2_t &block5,
|
||||
const word64 *subkeys, unsigned int rounds)
|
||||
{
|
||||
// [A1 A2][B1 B2] ... => [A1 B1][A2 B2] ...
|
||||
uint64x2_t x1 = UnpackHigh64(block0, block1);
|
||||
uint64x2_t y1 = UnpackLow64(block0, block1);
|
||||
uint64x2_t x2 = UnpackHigh64(block2, block3);
|
||||
uint64x2_t y2 = UnpackLow64(block2, block3);
|
||||
uint64x2_t x3 = UnpackHigh64(block4, block5);
|
||||
uint64x2_t y3 = UnpackLow64(block4, block5);
|
||||
|
||||
for (int i=0; i < static_cast<int>(rounds); ++i)
|
||||
{
|
||||
const uint64x2_t rk = vld1q_dup_u64(subkeys+i);
|
||||
|
||||
x1 = RotateRight64<8>(x1);
|
||||
x2 = RotateRight64<8>(x2);
|
||||
x3 = RotateRight64<8>(x3);
|
||||
x1 = vaddq_u64(x1, y1);
|
||||
x2 = vaddq_u64(x2, y2);
|
||||
x3 = vaddq_u64(x3, y3);
|
||||
x1 = veorq_u64(x1, rk);
|
||||
x2 = veorq_u64(x2, rk);
|
||||
x3 = veorq_u64(x3, rk);
|
||||
y1 = RotateLeft64<3>(y1);
|
||||
y2 = RotateLeft64<3>(y2);
|
||||
y3 = RotateLeft64<3>(y3);
|
||||
y1 = veorq_u64(y1, x1);
|
||||
y2 = veorq_u64(y2, x2);
|
||||
y3 = veorq_u64(y3, x3);
|
||||
}
|
||||
|
||||
// [A1 B1][A2 B2] ... => [A1 A2][B1 B2] ...
|
||||
block0 = UnpackLow64(y1, x1);
|
||||
block1 = UnpackHigh64(y1, x1);
|
||||
block2 = UnpackLow64(y2, x2);
|
||||
block3 = UnpackHigh64(y2, x2);
|
||||
block4 = UnpackLow64(y3, x3);
|
||||
block5 = UnpackHigh64(y3, x3);
|
||||
}
|
||||
|
||||
inline void SPECK128_Dec_Block(uint64x2_t &block0, uint64x2_t &block1,
|
||||
const word64 *subkeys, unsigned int rounds)
|
||||
{
|
||||
// [A1 A2][B1 B2] ... => [A1 B1][A2 B2] ...
|
||||
uint64x2_t x1 = UnpackHigh64(block0, block1);
|
||||
uint64x2_t y1 = UnpackLow64(block0, block1);
|
||||
|
||||
for (int i = static_cast<int>(rounds-1); i >= 0; --i)
|
||||
{
|
||||
const uint64x2_t rk = vld1q_dup_u64(subkeys+i);
|
||||
|
||||
y1 = veorq_u64(y1, x1);
|
||||
y1 = RotateRight64<3>(y1);
|
||||
x1 = veorq_u64(x1, rk);
|
||||
x1 = vsubq_u64(x1, y1);
|
||||
x1 = RotateLeft64<8>(x1);
|
||||
}
|
||||
|
||||
// [A1 B1][A2 B2] ... => [A1 A2][B1 B2] ...
|
||||
block0 = UnpackLow64(y1, x1);
|
||||
block1 = UnpackHigh64(y1, x1);
|
||||
}
|
||||
|
||||
inline void SPECK128_Dec_6_Blocks(uint64x2_t &block0, uint64x2_t &block1,
|
||||
uint64x2_t &block2, uint64x2_t &block3, uint64x2_t &block4, uint64x2_t &block5,
|
||||
const word64 *subkeys, unsigned int rounds)
|
||||
{
|
||||
// [A1 A2][B1 B2] ... => [A1 B1][A2 B2] ...
|
||||
uint64x2_t x1 = UnpackHigh64(block0, block1);
|
||||
uint64x2_t y1 = UnpackLow64(block0, block1);
|
||||
uint64x2_t x2 = UnpackHigh64(block2, block3);
|
||||
uint64x2_t y2 = UnpackLow64(block2, block3);
|
||||
uint64x2_t x3 = UnpackHigh64(block4, block5);
|
||||
uint64x2_t y3 = UnpackLow64(block4, block5);
|
||||
|
||||
for (int i = static_cast<int>(rounds-1); i >= 0; --i)
|
||||
{
|
||||
const uint64x2_t rk = vld1q_dup_u64(subkeys+i);
|
||||
|
||||
y1 = veorq_u64(y1, x1);
|
||||
y2 = veorq_u64(y2, x2);
|
||||
y3 = veorq_u64(y3, x3);
|
||||
y1 = RotateRight64<3>(y1);
|
||||
y2 = RotateRight64<3>(y2);
|
||||
y3 = RotateRight64<3>(y3);
|
||||
x1 = veorq_u64(x1, rk);
|
||||
x2 = veorq_u64(x2, rk);
|
||||
x3 = veorq_u64(x3, rk);
|
||||
x1 = vsubq_u64(x1, y1);
|
||||
x2 = vsubq_u64(x2, y2);
|
||||
x3 = vsubq_u64(x3, y3);
|
||||
x1 = RotateLeft64<8>(x1);
|
||||
x2 = RotateLeft64<8>(x2);
|
||||
x3 = RotateLeft64<8>(x3);
|
||||
}
|
||||
|
||||
// [A1 B1][A2 B2] ... => [A1 A2][B1 B2] ...
|
||||
block0 = UnpackLow64(y1, x1);
|
||||
block1 = UnpackHigh64(y1, x1);
|
||||
block2 = UnpackLow64(y2, x2);
|
||||
block3 = UnpackHigh64(y2, x2);
|
||||
block4 = UnpackLow64(y3, x3);
|
||||
block5 = UnpackHigh64(y3, x3);
|
||||
}
|
||||
|
||||
#endif // CRYPTOPP_ARM_NEON_AVAILABLE
|
||||
|
||||
// ***************************** IA-32 ***************************** //
|
||||
|
||||
#if defined(CRYPTOPP_SSSE3_AVAILABLE)
|
||||
|
||||
// Clang __m128i casts, http://bugs.llvm.org/show_bug.cgi?id=20670
|
||||
#ifndef M128_CAST
|
||||
# define M128_CAST(x) ((__m128i *)(void *)(x))
|
||||
#endif
|
||||
#ifndef CONST_M128_CAST
|
||||
# define CONST_M128_CAST(x) ((const __m128i *)(const void *)(x))
|
||||
#endif
|
||||
|
||||
// GCC double casts, https://www.spinics.net/lists/gcchelp/msg47735.html
|
||||
#ifndef DOUBLE_CAST
|
||||
# define DOUBLE_CAST(x) ((double *)(void *)(x))
|
||||
#endif
|
||||
#ifndef CONST_DOUBLE_CAST
|
||||
# define CONST_DOUBLE_CAST(x) ((const double *)(const void *)(x))
|
||||
#endif
|
||||
|
||||
template <unsigned int R>
|
||||
inline __m128i RotateLeft64(const __m128i& val)
|
||||
{
|
||||
#if defined(CRYPTOPP_AVX512_ROTATE)
|
||||
return _mm_rol_epi64(val, R);
|
||||
#else
|
||||
return _mm_or_si128(
|
||||
_mm_slli_epi64(val, R), _mm_srli_epi64(val, 64-R));
|
||||
#endif
|
||||
}
|
||||
|
||||
template <unsigned int R>
|
||||
inline __m128i RotateRight64(const __m128i& val)
|
||||
{
|
||||
#if defined(CRYPTOPP_AVX512_ROTATE)
|
||||
return _mm_ror_epi64(val, R);
|
||||
#else
|
||||
return _mm_or_si128(
|
||||
_mm_slli_epi64(val, 64-R), _mm_srli_epi64(val, R));
|
||||
#endif
|
||||
}
|
||||
|
||||
// Faster than two Shifts and an Or. Thanks to Louis Wingers and Bryan Weeks.
|
||||
template <>
|
||||
inline __m128i RotateLeft64<8>(const __m128i& val)
|
||||
{
|
||||
const __m128i mask = _mm_set_epi8(14,13,12,11, 10,9,8,15, 6,5,4,3, 2,1,0,7);
|
||||
return _mm_shuffle_epi8(val, mask);
|
||||
}
|
||||
|
||||
// Faster than two Shifts and an Or. Thanks to Louis Wingers and Bryan Weeks.
|
||||
template <>
|
||||
inline __m128i RotateRight64<8>(const __m128i& val)
|
||||
{
|
||||
const __m128i mask = _mm_set_epi8(8,15,14,13, 12,11,10,9, 0,7,6,5, 4,3,2,1);
|
||||
return _mm_shuffle_epi8(val, mask);
|
||||
}
|
||||
|
||||
inline void SPECK128_Enc_Block(__m128i &block0, __m128i &block1,
|
||||
const word64 *subkeys, unsigned int rounds)
|
||||
{
|
||||
// [A1 A2][B1 B2] ... => [A1 B1][A2 B2] ...
|
||||
__m128i x1 = _mm_unpackhi_epi64(block0, block1);
|
||||
__m128i y1 = _mm_unpacklo_epi64(block0, block1);
|
||||
|
||||
for (int i=0; i < static_cast<int>(rounds); ++i)
|
||||
{
|
||||
const __m128i rk = _mm_castpd_si128(
|
||||
_mm_loaddup_pd(CONST_DOUBLE_CAST(subkeys+i)));
|
||||
|
||||
x1 = RotateRight64<8>(x1);
|
||||
x1 = _mm_add_epi64(x1, y1);
|
||||
x1 = _mm_xor_si128(x1, rk);
|
||||
y1 = RotateLeft64<3>(y1);
|
||||
y1 = _mm_xor_si128(y1, x1);
|
||||
}
|
||||
|
||||
// [A1 B1][A2 B2] ... => [A1 A2][B1 B2] ...
|
||||
block0 = _mm_unpacklo_epi64(y1, x1);
|
||||
block1 = _mm_unpackhi_epi64(y1, x1);
|
||||
}
|
||||
|
||||
inline void SPECK128_Enc_6_Blocks(__m128i &block0, __m128i &block1,
|
||||
__m128i &block2, __m128i &block3, __m128i &block4, __m128i &block5,
|
||||
const word64 *subkeys, unsigned int rounds)
|
||||
{
|
||||
// [A1 A2][B1 B2] ... => [A1 B1][A2 B2] ...
|
||||
__m128i x1 = _mm_unpackhi_epi64(block0, block1);
|
||||
__m128i y1 = _mm_unpacklo_epi64(block0, block1);
|
||||
__m128i x2 = _mm_unpackhi_epi64(block2, block3);
|
||||
__m128i y2 = _mm_unpacklo_epi64(block2, block3);
|
||||
__m128i x3 = _mm_unpackhi_epi64(block4, block5);
|
||||
__m128i y3 = _mm_unpacklo_epi64(block4, block5);
|
||||
|
||||
for (int i=0; i < static_cast<int>(rounds); ++i)
|
||||
{
|
||||
const __m128i rk = _mm_castpd_si128(
|
||||
_mm_loaddup_pd(CONST_DOUBLE_CAST(subkeys+i)));
|
||||
|
||||
x1 = RotateRight64<8>(x1);
|
||||
x2 = RotateRight64<8>(x2);
|
||||
x3 = RotateRight64<8>(x3);
|
||||
x1 = _mm_add_epi64(x1, y1);
|
||||
x2 = _mm_add_epi64(x2, y2);
|
||||
x3 = _mm_add_epi64(x3, y3);
|
||||
x1 = _mm_xor_si128(x1, rk);
|
||||
x2 = _mm_xor_si128(x2, rk);
|
||||
x3 = _mm_xor_si128(x3, rk);
|
||||
y1 = RotateLeft64<3>(y1);
|
||||
y2 = RotateLeft64<3>(y2);
|
||||
y3 = RotateLeft64<3>(y3);
|
||||
y1 = _mm_xor_si128(y1, x1);
|
||||
y2 = _mm_xor_si128(y2, x2);
|
||||
y3 = _mm_xor_si128(y3, x3);
|
||||
}
|
||||
|
||||
// [A1 B1][A2 B2] ... => [A1 A2][B1 B2] ...
|
||||
block0 = _mm_unpacklo_epi64(y1, x1);
|
||||
block1 = _mm_unpackhi_epi64(y1, x1);
|
||||
block2 = _mm_unpacklo_epi64(y2, x2);
|
||||
block3 = _mm_unpackhi_epi64(y2, x2);
|
||||
block4 = _mm_unpacklo_epi64(y3, x3);
|
||||
block5 = _mm_unpackhi_epi64(y3, x3);
|
||||
}
|
||||
|
||||
inline void SPECK128_Dec_Block(__m128i &block0, __m128i &block1,
|
||||
const word64 *subkeys, unsigned int rounds)
|
||||
{
|
||||
// [A1 A2][B1 B2] ... => [A1 B1][A2 B2] ...
|
||||
__m128i x1 = _mm_unpackhi_epi64(block0, block1);
|
||||
__m128i y1 = _mm_unpacklo_epi64(block0, block1);
|
||||
|
||||
for (int i = static_cast<int>(rounds-1); i >= 0; --i)
|
||||
{
|
||||
const __m128i rk = _mm_castpd_si128(
|
||||
_mm_loaddup_pd(CONST_DOUBLE_CAST(subkeys+i)));
|
||||
|
||||
y1 = _mm_xor_si128(y1, x1);
|
||||
y1 = RotateRight64<3>(y1);
|
||||
x1 = _mm_xor_si128(x1, rk);
|
||||
x1 = _mm_sub_epi64(x1, y1);
|
||||
x1 = RotateLeft64<8>(x1);
|
||||
}
|
||||
|
||||
// [A1 B1][A2 B2] ... => [A1 A2][B1 B2] ...
|
||||
block0 = _mm_unpacklo_epi64(y1, x1);
|
||||
block1 = _mm_unpackhi_epi64(y1, x1);
|
||||
}
|
||||
|
||||
inline void SPECK128_Dec_6_Blocks(__m128i &block0, __m128i &block1,
|
||||
__m128i &block2, __m128i &block3, __m128i &block4, __m128i &block5,
|
||||
const word64 *subkeys, unsigned int rounds)
|
||||
{
|
||||
// [A1 A2][B1 B2] ... => [A1 B1][A2 B2] ...
|
||||
__m128i x1 = _mm_unpackhi_epi64(block0, block1);
|
||||
__m128i y1 = _mm_unpacklo_epi64(block0, block1);
|
||||
__m128i x2 = _mm_unpackhi_epi64(block2, block3);
|
||||
__m128i y2 = _mm_unpacklo_epi64(block2, block3);
|
||||
__m128i x3 = _mm_unpackhi_epi64(block4, block5);
|
||||
__m128i y3 = _mm_unpacklo_epi64(block4, block5);
|
||||
|
||||
for (int i = static_cast<int>(rounds-1); i >= 0; --i)
|
||||
{
|
||||
const __m128i rk = _mm_castpd_si128(
|
||||
_mm_loaddup_pd(CONST_DOUBLE_CAST(subkeys+i)));
|
||||
|
||||
y1 = _mm_xor_si128(y1, x1);
|
||||
y2 = _mm_xor_si128(y2, x2);
|
||||
y3 = _mm_xor_si128(y3, x3);
|
||||
y1 = RotateRight64<3>(y1);
|
||||
y2 = RotateRight64<3>(y2);
|
||||
y3 = RotateRight64<3>(y3);
|
||||
x1 = _mm_xor_si128(x1, rk);
|
||||
x2 = _mm_xor_si128(x2, rk);
|
||||
x3 = _mm_xor_si128(x3, rk);
|
||||
x1 = _mm_sub_epi64(x1, y1);
|
||||
x2 = _mm_sub_epi64(x2, y2);
|
||||
x3 = _mm_sub_epi64(x3, y3);
|
||||
x1 = RotateLeft64<8>(x1);
|
||||
x2 = RotateLeft64<8>(x2);
|
||||
x3 = RotateLeft64<8>(x3);
|
||||
}
|
||||
|
||||
// [A1 B1][A2 B2] ... => [A1 A2][B1 B2] ...
|
||||
block0 = _mm_unpacklo_epi64(y1, x1);
|
||||
block1 = _mm_unpackhi_epi64(y1, x1);
|
||||
block2 = _mm_unpacklo_epi64(y2, x2);
|
||||
block3 = _mm_unpackhi_epi64(y2, x2);
|
||||
block4 = _mm_unpacklo_epi64(y3, x3);
|
||||
block5 = _mm_unpackhi_epi64(y3, x3);
|
||||
}
|
||||
|
||||
#endif // CRYPTOPP_SSSE3_AVAILABLE
|
||||
|
||||
#if defined(CRYPTOPP_SSE41_AVAILABLE)
|
||||
|
||||
template <unsigned int R>
|
||||
|
|
@ -1074,229 +682,6 @@ void SPECK64_Dec_6_Blocks(uint32x4_p &block0, uint32x4_p &block1,
|
|||
|
||||
#endif // CRYPTOPP_POWER7_AVAILABLE
|
||||
|
||||
// ***************************** Power8 ***************************** //
|
||||
|
||||
#if defined(CRYPTOPP_POWER8_AVAILABLE)
|
||||
|
||||
using CryptoPP::uint8x16_p;
|
||||
using CryptoPP::uint32x4_p;
|
||||
using CryptoPP::uint64x2_p;
|
||||
|
||||
using CryptoPP::VectorAdd;
|
||||
using CryptoPP::VectorSub;
|
||||
using CryptoPP::VectorXor;
|
||||
|
||||
// Rotate left by bit count
|
||||
template<unsigned int C>
|
||||
inline uint64x2_p RotateLeft64(const uint64x2_p val)
|
||||
{
|
||||
const uint64x2_p m = {C, C};
|
||||
return vec_rl(val, m);
|
||||
}
|
||||
|
||||
// Rotate right by bit count
|
||||
template<unsigned int C>
|
||||
inline uint64x2_p RotateRight64(const uint64x2_p val)
|
||||
{
|
||||
const uint64x2_p m = {64-C, 64-C};
|
||||
return vec_rl(val, m);
|
||||
}
|
||||
|
||||
void SPECK128_Enc_Block(uint32x4_p &block, const word64 *subkeys, unsigned int rounds)
|
||||
{
|
||||
#if defined(CRYPTOPP_BIG_ENDIAN)
|
||||
const uint8x16_p m1 = {31,30,29,28,27,26,25,24, 15,14,13,12,11,10,9,8};
|
||||
const uint8x16_p m2 = {23,22,21,20,19,18,17,16, 7,6,5,4,3,2,1,0};
|
||||
#else
|
||||
const uint8x16_p m1 = {7,6,5,4,3,2,1,0, 23,22,21,20,19,18,17,16};
|
||||
const uint8x16_p m2 = {15,14,13,12,11,10,9,8, 31,30,29,28,27,26,25,24};
|
||||
#endif
|
||||
|
||||
// [A1 A2][B1 B2] ... => [A1 B1][A2 B2] ...
|
||||
uint64x2_p x1 = (uint64x2_p)vec_perm(block, block, m1);
|
||||
uint64x2_p y1 = (uint64x2_p)vec_perm(block, block, m2);
|
||||
|
||||
for (int i=0; i < static_cast<int>(rounds); ++i)
|
||||
{
|
||||
const uint64x2_p rk = vec_splats((unsigned long long)subkeys[i]);
|
||||
|
||||
x1 = RotateRight64<8>(x1);
|
||||
x1 = VectorAdd(x1, y1);
|
||||
x1 = VectorXor(x1, rk);
|
||||
|
||||
y1 = RotateLeft64<3>(y1);
|
||||
y1 = VectorXor(y1, x1);
|
||||
}
|
||||
|
||||
#if defined(CRYPTOPP_BIG_ENDIAN)
|
||||
const uint8x16_p m3 = {31,30,29,28,27,26,25,24, 15,14,13,12,11,10,9,8};
|
||||
//const uint8x16_p m4 = {23,22,21,20,19,18,17,16, 7,6,5,4,3,2,1,0};
|
||||
#else
|
||||
const uint8x16_p m3 = {7,6,5,4,3,2,1,0, 23,22,21,20,19,18,17,16};
|
||||
//const uint8x16_p m4 = {15,14,13,12,11,10,9,8, 31,30,29,28,27,26,25,24};
|
||||
#endif
|
||||
|
||||
// [A1 B1][A2 B2] ... => [A1 A2][B1 B2] ...
|
||||
block = (uint32x4_p)vec_perm(x1, y1, m3);
|
||||
}
|
||||
|
||||
void SPECK128_Dec_Block(uint32x4_p &block, const word64 *subkeys, unsigned int rounds)
|
||||
{
|
||||
#if defined(CRYPTOPP_BIG_ENDIAN)
|
||||
const uint8x16_p m1 = {31,30,29,28,27,26,25,24, 15,14,13,12,11,10,9,8};
|
||||
const uint8x16_p m2 = {23,22,21,20,19,18,17,16, 7,6,5,4,3,2,1,0};
|
||||
#else
|
||||
const uint8x16_p m1 = {7,6,5,4,3,2,1,0, 23,22,21,20,19,18,17,16};
|
||||
const uint8x16_p m2 = {15,14,13,12,11,10,9,8, 31,30,29,28,27,26,25,24};
|
||||
#endif
|
||||
|
||||
// [A1 A2][B1 B2] ... => [A1 B1][A2 B2] ...
|
||||
uint64x2_p x1 = (uint64x2_p)vec_perm(block, block, m1);
|
||||
uint64x2_p y1 = (uint64x2_p)vec_perm(block, block, m2);
|
||||
|
||||
for (int i = static_cast<int>(rounds-1); i >= 0; --i)
|
||||
{
|
||||
const uint64x2_p rk = vec_splats((unsigned long long)subkeys[i]);
|
||||
|
||||
y1 = VectorXor(y1, x1);
|
||||
y1 = RotateRight64<3>(y1);
|
||||
x1 = VectorXor(x1, rk);
|
||||
x1 = VectorSub(x1, y1);
|
||||
x1 = RotateLeft64<8>(x1);
|
||||
}
|
||||
|
||||
#if defined(CRYPTOPP_BIG_ENDIAN)
|
||||
const uint8x16_p m3 = {31,30,29,28,27,26,25,24, 15,14,13,12,11,10,9,8};
|
||||
//const uint8x16_p m4 = {23,22,21,20,19,18,17,16, 7,6,5,4,3,2,1,0};
|
||||
#else
|
||||
const uint8x16_p m3 = {7,6,5,4,3,2,1,0, 23,22,21,20,19,18,17,16};
|
||||
//const uint8x16_p m4 = {15,14,13,12,11,10,9,8, 31,30,29,28,27,26,25,24};
|
||||
#endif
|
||||
|
||||
// [A1 B1][A2 B2] ... => [A1 A2][B1 B2] ...
|
||||
block = (uint32x4_p)vec_perm(x1, y1, m3);
|
||||
}
|
||||
|
||||
void SPECK128_Enc_6_Blocks(uint32x4_p &block0, uint32x4_p &block1,
|
||||
uint32x4_p &block2, uint32x4_p &block3, uint32x4_p &block4,
|
||||
uint32x4_p &block5, const word64 *subkeys, unsigned int rounds)
|
||||
{
|
||||
#if defined(CRYPTOPP_BIG_ENDIAN)
|
||||
const uint8x16_p m1 = {31,30,29,28,27,26,25,24, 15,14,13,12,11,10,9,8};
|
||||
const uint8x16_p m2 = {23,22,21,20,19,18,17,16, 7,6,5,4,3,2,1,0};
|
||||
#else
|
||||
const uint8x16_p m1 = {7,6,5,4,3,2,1,0, 23,22,21,20,19,18,17,16};
|
||||
const uint8x16_p m2 = {15,14,13,12,11,10,9,8, 31,30,29,28,27,26,25,24};
|
||||
#endif
|
||||
|
||||
// [A1 A2][B1 B2] ... => [A1 B1][A2 B2] ...
|
||||
uint64x2_p x1 = (uint64x2_p)vec_perm(block0, block1, m1);
|
||||
uint64x2_p y1 = (uint64x2_p)vec_perm(block0, block1, m2);
|
||||
uint64x2_p x2 = (uint64x2_p)vec_perm(block2, block3, m1);
|
||||
uint64x2_p y2 = (uint64x2_p)vec_perm(block2, block3, m2);
|
||||
uint64x2_p x3 = (uint64x2_p)vec_perm(block4, block5, m1);
|
||||
uint64x2_p y3 = (uint64x2_p)vec_perm(block4, block5, m2);
|
||||
|
||||
for (int i=0; i < static_cast<int>(rounds); ++i)
|
||||
{
|
||||
const uint64x2_p rk = vec_splats((unsigned long long)subkeys[i]);
|
||||
|
||||
x1 = RotateRight64<8>(x1);
|
||||
x2 = RotateRight64<8>(x2);
|
||||
x3 = RotateRight64<8>(x3);
|
||||
x1 = VectorAdd(x1, y1);
|
||||
x2 = VectorAdd(x2, y2);
|
||||
x3 = VectorAdd(x3, y3);
|
||||
x1 = VectorXor(x1, rk);
|
||||
x2 = VectorXor(x2, rk);
|
||||
x3 = VectorXor(x3, rk);
|
||||
|
||||
y1 = RotateLeft64<3>(y1);
|
||||
y2 = RotateLeft64<3>(y2);
|
||||
y3 = RotateLeft64<3>(y3);
|
||||
y1 = VectorXor(y1, x1);
|
||||
y2 = VectorXor(y2, x2);
|
||||
y3 = VectorXor(y3, x3);
|
||||
}
|
||||
|
||||
#if defined(CRYPTOPP_BIG_ENDIAN)
|
||||
const uint8x16_p m3 = {31,30,29,28,27,26,25,24, 15,14,13,12,11,10,9,8};
|
||||
const uint8x16_p m4 = {23,22,21,20,19,18,17,16, 7,6,5,4,3,2,1,0};
|
||||
#else
|
||||
const uint8x16_p m3 = {7,6,5,4,3,2,1,0, 23,22,21,20,19,18,17,16};
|
||||
const uint8x16_p m4 = {15,14,13,12,11,10,9,8, 31,30,29,28,27,26,25,24};
|
||||
#endif
|
||||
|
||||
// [A1 B1][A2 B2] ... => [A1 A2][B1 B2] ...
|
||||
block0 = (uint32x4_p)vec_perm(x1, y1, m3);
|
||||
block1 = (uint32x4_p)vec_perm(x1, y1, m4);
|
||||
block2 = (uint32x4_p)vec_perm(x2, y2, m3);
|
||||
block3 = (uint32x4_p)vec_perm(x2, y2, m4);
|
||||
block4 = (uint32x4_p)vec_perm(x3, y3, m3);
|
||||
block5 = (uint32x4_p)vec_perm(x3, y3, m4);
|
||||
}
|
||||
|
||||
void SPECK128_Dec_6_Blocks(uint32x4_p &block0, uint32x4_p &block1,
|
||||
uint32x4_p &block2, uint32x4_p &block3, uint32x4_p &block4,
|
||||
uint32x4_p &block5, const word64 *subkeys, unsigned int rounds)
|
||||
{
|
||||
#if defined(CRYPTOPP_BIG_ENDIAN)
|
||||
const uint8x16_p m1 = {31,30,29,28,27,26,25,24, 15,14,13,12,11,10,9,8};
|
||||
const uint8x16_p m2 = {23,22,21,20,19,18,17,16, 7,6,5,4,3,2,1,0};
|
||||
#else
|
||||
const uint8x16_p m1 = {7,6,5,4,3,2,1,0, 23,22,21,20,19,18,17,16};
|
||||
const uint8x16_p m2 = {15,14,13,12,11,10,9,8, 31,30,29,28,27,26,25,24};
|
||||
#endif
|
||||
|
||||
// [A1 A2][B1 B2] ... => [A1 B1][A2 B2] ...
|
||||
uint64x2_p x1 = (uint64x2_p)vec_perm(block0, block1, m1);
|
||||
uint64x2_p y1 = (uint64x2_p)vec_perm(block0, block1, m2);
|
||||
uint64x2_p x2 = (uint64x2_p)vec_perm(block2, block3, m1);
|
||||
uint64x2_p y2 = (uint64x2_p)vec_perm(block2, block3, m2);
|
||||
uint64x2_p x3 = (uint64x2_p)vec_perm(block4, block5, m1);
|
||||
uint64x2_p y3 = (uint64x2_p)vec_perm(block4, block5, m2);
|
||||
|
||||
for (int i = static_cast<int>(rounds-1); i >= 0; --i)
|
||||
{
|
||||
const uint64x2_p rk = vec_splats((unsigned long long)subkeys[i]);
|
||||
|
||||
y1 = VectorXor(y1, x1);
|
||||
y2 = VectorXor(y2, x2);
|
||||
y3 = VectorXor(y3, x3);
|
||||
y1 = RotateRight64<3>(y1);
|
||||
y2 = RotateRight64<3>(y2);
|
||||
y3 = RotateRight64<3>(y3);
|
||||
|
||||
x1 = VectorXor(x1, rk);
|
||||
x2 = VectorXor(x2, rk);
|
||||
x3 = VectorXor(x3, rk);
|
||||
x1 = VectorSub(x1, y1);
|
||||
x2 = VectorSub(x2, y2);
|
||||
x3 = VectorSub(x3, y3);
|
||||
x1 = RotateLeft64<8>(x1);
|
||||
x2 = RotateLeft64<8>(x2);
|
||||
x3 = RotateLeft64<8>(x3);
|
||||
}
|
||||
|
||||
#if defined(CRYPTOPP_BIG_ENDIAN)
|
||||
const uint8x16_p m3 = {31,30,29,28,27,26,25,24, 15,14,13,12,11,10,9,8};
|
||||
const uint8x16_p m4 = {23,22,21,20,19,18,17,16, 7,6,5,4,3,2,1,0};
|
||||
#else
|
||||
const uint8x16_p m3 = {7,6,5,4,3,2,1,0, 23,22,21,20,19,18,17,16};
|
||||
const uint8x16_p m4 = {15,14,13,12,11,10,9,8, 31,30,29,28,27,26,25,24};
|
||||
#endif
|
||||
|
||||
// [A1 B1][A2 B2] ... => [A1 A2][B1 B2] ...
|
||||
block0 = (uint32x4_p)vec_perm(x1, y1, m3);
|
||||
block1 = (uint32x4_p)vec_perm(x1, y1, m4);
|
||||
block2 = (uint32x4_p)vec_perm(x2, y2, m3);
|
||||
block3 = (uint32x4_p)vec_perm(x2, y2, m4);
|
||||
block4 = (uint32x4_p)vec_perm(x3, y3, m3);
|
||||
block5 = (uint32x4_p)vec_perm(x3, y3, m4);
|
||||
}
|
||||
|
||||
#endif // CRYPTOPP_POWER8_AVAILABLE
|
||||
|
||||
ANONYMOUS_NAMESPACE_END
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -1321,22 +706,6 @@ size_t SPECK64_Dec_AdvancedProcessBlocks_NEON(const word32* subKeys, size_t roun
|
|||
}
|
||||
#endif
|
||||
|
||||
#if (CRYPTOPP_ARM_NEON_AVAILABLE)
|
||||
size_t SPECK128_Enc_AdvancedProcessBlocks_NEON(const word64* subKeys, size_t rounds,
|
||||
const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags)
|
||||
{
|
||||
return AdvancedProcessBlocks128_6x2_NEON(SPECK128_Enc_Block, SPECK128_Enc_6_Blocks,
|
||||
subKeys, rounds, inBlocks, xorBlocks, outBlocks, length, flags);
|
||||
}
|
||||
|
||||
size_t SPECK128_Dec_AdvancedProcessBlocks_NEON(const word64* subKeys, size_t rounds,
|
||||
const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags)
|
||||
{
|
||||
return AdvancedProcessBlocks128_6x2_NEON(SPECK128_Dec_Block, SPECK128_Dec_6_Blocks,
|
||||
subKeys, rounds, inBlocks, xorBlocks, outBlocks, length, flags);
|
||||
}
|
||||
#endif // CRYPTOPP_ARM_NEON_AVAILABLE
|
||||
|
||||
// ***************************** IA-32 ***************************** //
|
||||
|
||||
#if defined(CRYPTOPP_SSE41_AVAILABLE)
|
||||
|
|
@ -1355,22 +724,6 @@ size_t SPECK64_Dec_AdvancedProcessBlocks_SSE41(const word32* subKeys, size_t rou
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(CRYPTOPP_SSSE3_AVAILABLE)
|
||||
size_t SPECK128_Enc_AdvancedProcessBlocks_SSSE3(const word64* subKeys, size_t rounds,
|
||||
const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags)
|
||||
{
|
||||
return AdvancedProcessBlocks128_6x2_SSE(SPECK128_Enc_Block, SPECK128_Enc_6_Blocks,
|
||||
subKeys, rounds, inBlocks, xorBlocks, outBlocks, length, flags);
|
||||
}
|
||||
|
||||
size_t SPECK128_Dec_AdvancedProcessBlocks_SSSE3(const word64* subKeys, size_t rounds,
|
||||
const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags)
|
||||
{
|
||||
return AdvancedProcessBlocks128_6x2_SSE(SPECK128_Dec_Block, SPECK128_Dec_6_Blocks,
|
||||
subKeys, rounds, inBlocks, xorBlocks, outBlocks, length, flags);
|
||||
}
|
||||
#endif // CRYPTOPP_SSSE3_AVAILABLE
|
||||
|
||||
// ***************************** Power7 ***************************** //
|
||||
|
||||
#if defined(CRYPTOPP_POWER7_AVAILABLE)
|
||||
|
|
@ -1389,22 +742,4 @@ size_t SPECK64_Dec_AdvancedProcessBlocks_POWER7(const word32* subKeys, size_t ro
|
|||
}
|
||||
#endif
|
||||
|
||||
// ***************************** Power8 ***************************** //
|
||||
|
||||
#if defined(CRYPTOPP_POWER8_AVAILABLE)
|
||||
size_t SPECK128_Enc_AdvancedProcessBlocks_POWER8(const word64* subKeys, size_t rounds,
|
||||
const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags)
|
||||
{
|
||||
return AdvancedProcessBlocks128_6x1_ALTIVEC(SPECK128_Enc_Block, SPECK128_Enc_6_Blocks,
|
||||
subKeys, rounds, inBlocks, xorBlocks, outBlocks, length, flags);
|
||||
}
|
||||
|
||||
size_t SPECK128_Dec_AdvancedProcessBlocks_POWER8(const word64* subKeys, size_t rounds,
|
||||
const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags)
|
||||
{
|
||||
return AdvancedProcessBlocks128_6x1_ALTIVEC(SPECK128_Dec_Block, SPECK128_Dec_6_Blocks,
|
||||
subKeys, rounds, inBlocks, xorBlocks, outBlocks, length, flags);
|
||||
}
|
||||
#endif // CRYPTOPP_POWER8_AVAILABLE
|
||||
|
||||
NAMESPACE_END
|
||||
Loading…
Reference in New Issue