mirror of
https://github.com/shadps4-emu/ext-cryptopp.git
synced 2024-11-27 11:50:29 +00:00
Avoid extra ByteReverse
This gains about 0.6 cpb. SHA-1 is down to 1.9 cpb. SHA-256 is not affected
This commit is contained in:
parent
b65ec291ea
commit
3b56ba118f
11
iterhash.cpp
11
iterhash.cpp
@ -82,11 +82,14 @@ template <class T, class BASE> byte * IteratedHashBase<T, BASE>::CreateUpdateSpa
|
||||
|
||||
template <class T, class BASE> size_t IteratedHashBase<T, BASE>::HashMultipleBlocks(const T *input, size_t length)
|
||||
{
|
||||
// Hardware based SHA1 and SHA256 correct blocks themselves due to hardware requirements.
|
||||
// For Intel, SHA1 will effectively call ByteReverse(). SHA256 formats data to Intel
|
||||
// requirements, which means eight words ABCD EFGH are transformed to ABEF CDGH.
|
||||
#if CRYPTOPP_BOOL_SSE_SHA_INTRINSICS_AVAILABLE
|
||||
// SHA-1 and SHA-256 only
|
||||
static const bool noReverse = HasSHA() && this->BlockSize() <= 64;
|
||||
#else
|
||||
const bool noReverse = NativeByteOrderIs(this->GetByteOrder());
|
||||
#endif
|
||||
|
||||
unsigned int blockSize = this->BlockSize();
|
||||
bool noReverse = NativeByteOrderIs(this->GetByteOrder());
|
||||
T* dataBuf = this->DataBuf();
|
||||
do
|
||||
{
|
||||
|
2
sha.cpp
2
sha.cpp
@ -112,7 +112,7 @@ static void SHA1_SSE_SHA_Transform(word32 *state, const word32 *data)
|
||||
ABCD = _mm_loadu_si128((__m128i*) state);
|
||||
E0 = _mm_set_epi32(state[4], 0, 0, 0);
|
||||
ABCD = _mm_shuffle_epi32(ABCD, 0x1B);
|
||||
MASK = _mm_set_epi8(3,2,1,0, 7,6,5,4, 11,10,9,8, 15,14,13,12);
|
||||
MASK = _mm_set_epi8(0,1,2,3, 4,5,6,7, 8,9,10,11, 12,13,14,15);
|
||||
|
||||
// Save current hash
|
||||
ABCD_SAVE = ABCD;
|
||||
|
Loading…
Reference in New Issue
Block a user