Fixup under-aligned buffers when using AES on AltiVec and Power8
This commit supports the upcoming AltiVec and Power8 processor. This commit affects a number of classes due to the ubiquitous use of AES. The commit provides the data alignment requirements.pull/489/head
parent
32cc92e048
commit
75aef9bded
|
|
@ -10,6 +10,9 @@
|
||||||
// Skip Hovsmith and Barry O'Rourke for the mbedTLS project. Stepping
|
// Skip Hovsmith and Barry O'Rourke for the mbedTLS project. Stepping
|
||||||
// mbedTLS under a debugger was helped for us to determine problems
|
// mbedTLS under a debugger was helped for us to determine problems
|
||||||
// with our subkey generation and scheduling.
|
// with our subkey generation and scheduling.
|
||||||
|
//
|
||||||
|
// AltiVec and Power8 code based on "POWER8 in-core cryptography."
|
||||||
|
// http://www.ibm.com/developerworks/library/se-power8-in-core-cryptography/index.html
|
||||||
|
|
||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
@ -24,7 +27,7 @@
|
||||||
// Hack... We are supposed to use <nmmintrin.h>. GCC 4.8, LLVM Clang 3.5
|
// Hack... We are supposed to use <nmmintrin.h>. GCC 4.8, LLVM Clang 3.5
|
||||||
// and Apple Clang 6.0 conflates SSE4.1 and SSE4.2. If we use <nmmintrin.h>
|
// and Apple Clang 6.0 conflates SSE4.1 and SSE4.2. If we use <nmmintrin.h>
|
||||||
// then compile fails with "SSE4.2 instruction set not enabled". Also see
|
// then compile fails with "SSE4.2 instruction set not enabled". Also see
|
||||||
// https://gcc.gnu.org/ml/gcc-help/2017-08/msg00015.html.
|
// http://gcc.gnu.org/ml/gcc-help/2017-08/msg00015.html.
|
||||||
# include "smmintrin.h"
|
# include "smmintrin.h"
|
||||||
# include "wmmintrin.h"
|
# include "wmmintrin.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -220,6 +220,15 @@ void Rijndael::Base::FillDecTable()
|
||||||
s_TdFilled = true;
|
s_TdFilled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int Rijndael::Base::OptimalDataAlignment() const
|
||||||
|
{
|
||||||
|
#if CRYPTOPP_BOOL_ALIGN16
|
||||||
|
return 16;
|
||||||
|
#else
|
||||||
|
return GetAlignmentOf<word32>();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#if (CRYPTOPP_AESNI_AVAILABLE)
|
#if (CRYPTOPP_AESNI_AVAILABLE)
|
||||||
extern void Rijndael_UncheckedSetKey_SSE4_AESNI(const byte *userKey, size_t keyLen, word32* rk);
|
extern void Rijndael_UncheckedSetKey_SSE4_AESNI(const byte *userKey, size_t keyLen, word32* rk);
|
||||||
extern void Rijndael_UncheckedSetKeyRev_AESNI(word32 *key, unsigned int rounds);
|
extern void Rijndael_UncheckedSetKeyRev_AESNI(word32 *key, unsigned int rounds);
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,9 @@ class CRYPTOPP_DLL Rijndael : public Rijndael_Info, public BlockCipherDocumentat
|
||||||
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<Rijndael_Info>
|
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<Rijndael_Info>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
// Intel and ARM SIMD units can handle unaligned loads, but AltiVec and Power8 cannot.
|
||||||
|
unsigned int OptimalDataAlignment() const;
|
||||||
|
|
||||||
void UncheckedSetKey(const byte *userKey, unsigned int keyLength, const NameValuePairs ¶ms);
|
void UncheckedSetKey(const byte *userKey, unsigned int keyLength, const NameValuePairs ¶ms);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue