mirror of
https://github.com/shadps4-emu/ext-cryptopp.git
synced 2024-11-26 19:30:21 +00:00
Add CRYPTOPP_LEA_ARM_SPLAT_ROUNDKEYS for LEA
This commit is contained in:
parent
2d0d87b57a
commit
d9797c414a
@ -140,7 +140,11 @@ uint32x4_t UnpackHigh64(uint32x4_t a, uint32x4_t b)
|
||||
template <unsigned int IDX>
|
||||
inline uint32x4_t LoadKey(const word32 rkey[])
|
||||
{
|
||||
#if (CRYPTOPP_LEA_ARM_SPLAT_ROUNDKEYS)
|
||||
return vld1q_u32(&rkey[IDX*4]);
|
||||
#else
|
||||
return vdupq_n_u32(rkey[IDX]);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <unsigned int IDX>
|
||||
@ -1012,15 +1016,17 @@ size_t LEA_Dec_AdvancedProcessBlocks_SSSE3(const word32* subKeys, size_t rounds,
|
||||
#endif // CRYPTOPP_SSSE3_AVAILABLE
|
||||
|
||||
#if defined(CRYPTOPP_ARM_NEON_AVAILABLE)
|
||||
# if (CRYPTOPP_LEA_ARM_SPLAT_ROUNDKEYS)
|
||||
void LEA_SplatKeys_NEON(SecBlock<word32>& rkeys)
|
||||
{
|
||||
SecBlock<word32> temp(rkeys.size() * 4);
|
||||
for (size_t i=0, j=0; i<rkeys.size(); i++, j+=4)
|
||||
{
|
||||
vst1q_u32(&temp[j], vdupq_n_u32(rkeys[i]));
|
||||
vst1q_u32(&temp[j], vdupq_n_u32(rkeys[i]));
|
||||
}
|
||||
std::swap(rkeys, temp);
|
||||
}
|
||||
# endif // CRYPTOPP_LEA_ARM_SPLAT_ROUNDKEYS
|
||||
|
||||
size_t LEA_Enc_AdvancedProcessBlocks_NEON(const word32* subKeys, size_t rounds,
|
||||
const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags)
|
||||
|
4
lea.cpp
4
lea.cpp
@ -567,7 +567,9 @@ extern size_t LEA_Dec_AdvancedProcessBlocks_SSSE3(const word32* subKeys, size_t
|
||||
# endif
|
||||
|
||||
# if (CRYPTOPP_ARM_NEON_AVAILABLE)
|
||||
# if (CRYPTOPP_LEA_ARM_SPLAT_ROUNDKEYS)
|
||||
extern void LEA_SplatKeys_NEON(SecBlock<word32>& rkeys);
|
||||
# endif // CRYPTOPP_LEA_ARM_SPLAT_ROUNDKEYS
|
||||
|
||||
extern size_t LEA_Enc_AdvancedProcessBlocks_NEON(const word32* subKeys, size_t rounds,
|
||||
const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags);
|
||||
@ -616,8 +618,10 @@ void LEA::Base::UncheckedSetKey(const byte *userKey, unsigned int keyLength, con
|
||||
LEA_SplatKeys_SSSE3(m_rkey);
|
||||
#endif
|
||||
#if (CRYPTOPP_LEA_ADVANCED_PROCESS_BLOCKS) && (CRYPTOPP_ARM_NEON_AVAILABLE)
|
||||
# if (CRYPTOPP_LEA_ARM_SPLAT_ROUNDKEYS)
|
||||
if (HasNEON())
|
||||
LEA_SplatKeys_NEON(m_rkey);
|
||||
# endif // CRYPTOPP_LEA_ARM_SPLAT_ROUNDKEYS
|
||||
#endif
|
||||
}
|
||||
|
||||
|
8
lea.h
8
lea.h
@ -19,6 +19,14 @@
|
||||
# define CRYPTOPP_LEA_ADVANCED_PROCESS_BLOCKS 1
|
||||
#endif
|
||||
|
||||
// Define this if you want to pre-splat the round key table
|
||||
// for NEON and Aarch64. Pre-splatting the round key increases
|
||||
// performance by about 0.7 cpb on ARM server boards like an
|
||||
// AMD Opteron A1100. However, it crushes performance on ARM
|
||||
// dev-boards like LeMaker HiKey and Pine64. HiKey and Pine64
|
||||
// run about 8 cpb slower when pre-splatting the round keys.
|
||||
// # define CRYPTOPP_LEA_ARM_SPLAT_ROUNDKEYS 1
|
||||
|
||||
NAMESPACE_BEGIN(CryptoPP)
|
||||
|
||||
/// \brief LEA block cipher information
|
||||
|
Loading…
Reference in New Issue
Block a user