diff options
author | Jeffrey Walton <noloader@gmail.com> | 2017-09-19 04:55:15 -0400 |
---|---|---|
committer | Jeffrey Walton <noloader@gmail.com> | 2017-09-19 04:55:15 -0400 |
commit | 6440921723695913cfcfffdf2c59f0cf01e59c89 (patch) | |
tree | 829bbe2fbf4886cfde36238add96a59f6530b973 /rijndael.cpp | |
parent | 3290711a823fd5c361ca4fb582f15f3e5754a40c (diff) | |
download | cryptopp-git-6440921723695913cfcfffdf2c59f0cf01e59c89.tar.gz |
Add Rijndael_UncheckedSetKey_POWER8
We are going to attempt to perform key setup using Power8 in-core vector instructions
Diffstat (limited to 'rijndael.cpp')
-rw-r--r-- | rijndael.cpp | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/rijndael.cpp b/rijndael.cpp index 704779e4..56ea9e77 100644 --- a/rijndael.cpp +++ b/rijndael.cpp @@ -253,6 +253,9 @@ extern size_t Rijndael_Dec_AdvancedProcessBlocks_ARMV8(const word32 *subkeys, si #if (CRYPTOPP_POWER8_AES_AVAILABLE)
extern void ReverseByteArrayLE(byte src[16]);
+extern void Rijndael_UncheckedSetKey_POWER8(word32* rk, size_t keyLen,
+ const word32* rc, const byte* Se, unsigned int rounds);
+
extern size_t Rijndael_Enc_AdvancedProcessBlocks_POWER8(const word32 *subkeys, size_t rounds,
const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags);
extern size_t Rijndael_Dec_AdvancedProcessBlocks_POWER8(const word32 *subkeys, size_t rounds,
@@ -265,7 +268,6 @@ void Rijndael::Base::UncheckedSetKey(const byte *userKey, unsigned int keyLen, c m_rounds = keyLen/4 + 6;
m_key.New(4*(m_rounds+1));
-
word32 *rk = m_key;
#if (CRYPTOPP_AESNI_AVAILABLE && CRYPTOPP_SSE41_AVAILABLE && (!defined(_MSC_VER) || _MSC_VER >= 1600 || CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32))
@@ -286,6 +288,14 @@ void Rijndael::Base::UncheckedSetKey(const byte *userKey, unsigned int keyLen, c const word32 *rc = rcon;
word32 temp;
+#if CRYPTOPP_POWER8_AES_AVAILABLE
+ if (HasAES())
+ {
+ Rijndael_UncheckedSetKey_POWER8(rk, keyLen, rc, Se, m_rounds);
+ return;
+ }
+#endif
+
while (true)
{
temp = rk[keyLen/4-1];
@@ -317,25 +327,6 @@ void Rijndael::Base::UncheckedSetKey(const byte *userKey, unsigned int keyLen, c rk = m_key;
-#if CRYPTOPP_POWER8_AES_AVAILABLE
- if (HasAES())
- {
- ConditionalByteReverse(BIG_ENDIAN_ORDER, rk, rk, 16);
- ConditionalByteReverse(BIG_ENDIAN_ORDER, rk + m_rounds*4, rk + m_rounds*4, 16);
- ConditionalByteReverse(BIG_ENDIAN_ORDER, rk+4, rk+4, (m_rounds-1)*16);
-
-#if defined(IS_LITTLE_ENDIAN)
- // VSX registers are big-endian. The entire subkey table must be byte
- // reversed on little-endian systems to ensure it loads properly.
- byte * ptr = reinterpret_cast<byte*>(rk);
- for (unsigned int i=0; i<=m_rounds; i++)
- ReverseByteArrayLE(ptr+i*16);
-#endif // IS_LITTLE_ENDIAN
-
- return;
- }
-#endif // CRYPTOPP_POWER8_AES_AVAILABLE
-
if (IsForwardTransformation())
{
if (!s_TeFilled)
|