summaryrefslogtreecommitdiff
path: root/iterhash.cpp
diff options
context:
space:
mode:
authorweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2009-03-10 02:56:19 +0000
committerweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2009-03-10 02:56:19 +0000
commitcc319dc33cc73b0ec368864a4220604170acb674 (patch)
tree1c52d52d455d3b48e60bfc8b075f4d611068be14 /iterhash.cpp
parent77d342339b3149f02aaa3521a27b6216468d43dc (diff)
downloadcryptopp-cc319dc33cc73b0ec368864a4220604170acb674.tar.gz
add x86/x64 assembly for SHA-256,
add DEFAULT_CHANNEL and AAD_CHANNEL, fix macChannel for AuthenticatedEncryptionFilter git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@440 57ff6487-cd31-0410-9ec3-f628ee90f5f0
Diffstat (limited to 'iterhash.cpp')
-rw-r--r--iterhash.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/iterhash.cpp b/iterhash.cpp
index 642a7ca..478950c 100644
--- a/iterhash.cpp
+++ b/iterhash.cpp
@@ -132,14 +132,18 @@ template <class T, class BASE> void IteratedHashBase<T, BASE>::TruncatedFinal(by
ByteOrder order = this->GetByteOrder();
PadLastBlock(blockSize - 2*sizeof(HashWordType));
- ConditionalByteReverse<HashWordType>(order, dataBuf, dataBuf, blockSize - 2*sizeof(HashWordType));
+ dataBuf[blockSize/sizeof(T)-2+order] = ConditionalByteReverse(order, this->GetBitCountLo());
+ dataBuf[blockSize/sizeof(T)-1-order] = ConditionalByteReverse(order, this->GetBitCountHi());
- dataBuf[blockSize/sizeof(T)-2] = order ? this->GetBitCountHi() : this->GetBitCountLo();
- dataBuf[blockSize/sizeof(T)-1] = order ? this->GetBitCountLo() : this->GetBitCountHi();
+ HashBlock(dataBuf);
- HashEndianCorrectedBlock(dataBuf);
- ConditionalByteReverse<HashWordType>(order, stateBuf, stateBuf, this->DigestSize());
- memcpy(digest, stateBuf, size);
+ if (IsAligned<HashWordType>(digest) && size%sizeof(HashWordType)==0)
+ ConditionalByteReverse<HashWordType>(order, (HashWordType *)digest, stateBuf, size);
+ else
+ {
+ ConditionalByteReverse<HashWordType>(order, stateBuf, stateBuf, this->DigestSize());
+ memcpy(digest, stateBuf, size);
+ }
this->Restart(); // reinit for next use
}