summaryrefslogtreecommitdiff
path: root/extra/yassl/taocrypt/src
diff options
context:
space:
mode:
Diffstat (limited to 'extra/yassl/taocrypt/src')
-rw-r--r--extra/yassl/taocrypt/src/aes.cpp11
-rw-r--r--extra/yassl/taocrypt/src/algebra.cpp6
-rw-r--r--extra/yassl/taocrypt/src/asn.cpp8
-rw-r--r--extra/yassl/taocrypt/src/hash.cpp85
-rw-r--r--extra/yassl/taocrypt/src/integer.cpp2
-rw-r--r--extra/yassl/taocrypt/src/sha.cpp410
6 files changed, 505 insertions, 17 deletions
diff --git a/extra/yassl/taocrypt/src/aes.cpp b/extra/yassl/taocrypt/src/aes.cpp
index 4f87bf3778a..b2b42d3dcf0 100644
--- a/extra/yassl/taocrypt/src/aes.cpp
+++ b/extra/yassl/taocrypt/src/aes.cpp
@@ -90,14 +90,13 @@ void AES::SetKey(const byte* userKey, word32 keylen, CipherDir /*dummy*/)
rounds_ = keylen/4 + 6;
word32 temp, *rk = key_;
+ unsigned int i=0;
GetUserKey(BigEndianOrder, rk, keylen/4, userKey, keylen);
switch(keylen)
{
case 16:
- {
- unsigned int i=0;
while (true)
{
temp = rk[3];
@@ -115,10 +114,8 @@ void AES::SetKey(const byte* userKey, word32 keylen, CipherDir /*dummy*/)
rk += 4;
}
break;
- }
+
case 24:
- {
- unsigned int i=0;
while (true) // for (;;) here triggers a bug in VC60 SP4 w/ Pro Pack
{
temp = rk[ 5];
@@ -139,10 +136,7 @@ void AES::SetKey(const byte* userKey, word32 keylen, CipherDir /*dummy*/)
}
break;
- }
case 32:
- {
- unsigned int i=0;
while (true)
{
temp = rk[ 7];
@@ -171,7 +165,6 @@ void AES::SetKey(const byte* userKey, word32 keylen, CipherDir /*dummy*/)
}
break;
}
- }
if (dir_ == DECRYPTION)
{
diff --git a/extra/yassl/taocrypt/src/algebra.cpp b/extra/yassl/taocrypt/src/algebra.cpp
index d797d0d4108..cb597c41552 100644
--- a/extra/yassl/taocrypt/src/algebra.cpp
+++ b/extra/yassl/taocrypt/src/algebra.cpp
@@ -186,10 +186,10 @@ Integer AbstractGroup::CascadeScalarMultiply(const Element &x,
struct WindowSlider
{
- WindowSlider(const Integer &exp_arg, bool fastNegate_arg,
+ WindowSlider(const Integer &exp, bool fastNegate,
unsigned int windowSizeIn=0)
- : exp(exp_arg), windowModulus(Integer::One()), windowSize(windowSizeIn),
- windowBegin(0), fastNegate(fastNegate_arg), firstTime(true),
+ : exp(exp), windowModulus(Integer::One()), windowSize(windowSizeIn),
+ windowBegin(0), fastNegate(fastNegate), firstTime(true),
finished(false)
{
if (windowSize == 0)
diff --git a/extra/yassl/taocrypt/src/asn.cpp b/extra/yassl/taocrypt/src/asn.cpp
index 5bc865a4ba7..a06ab658c7b 100644
--- a/extra/yassl/taocrypt/src/asn.cpp
+++ b/extra/yassl/taocrypt/src/asn.cpp
@@ -737,17 +737,17 @@ void CertDecoder::GetName(NameType nt)
email = true;
source_.advance(oidSz + 1);
- word32 length2 = GetLength(source_);
+ word32 length = GetLength(source_);
if (email) {
memcpy(&ptr[idx], "/emailAddress=", 14);
idx += 14;
- memcpy(&ptr[idx], source_.get_current(), length2);
- idx += length2;
+ memcpy(&ptr[idx], source_.get_current(), length);
+ idx += length;
}
- source_.advance(length2);
+ source_.advance(length);
}
}
ptr[idx++] = 0;
diff --git a/extra/yassl/taocrypt/src/hash.cpp b/extra/yassl/taocrypt/src/hash.cpp
index 66598177631..c51dc42a909 100644
--- a/extra/yassl/taocrypt/src/hash.cpp
+++ b/extra/yassl/taocrypt/src/hash.cpp
@@ -108,4 +108,89 @@ void HASHwithTransform::Final(byte* hash)
Init(); // reset state
}
+
+#ifdef WORD64_AVAILABLE
+
+HASH64withTransform::HASH64withTransform(word32 digSz, word32 buffSz)
+{
+ assert(digSz <= MaxDigestSz);
+ assert(buffSz <= MaxBufferSz);
+}
+
+
+void HASH64withTransform::AddLength(word32 len)
+{
+ HashLengthType tmp = loLen_;
+ if ( (loLen_ += len) < tmp)
+ hiLen_++; // carry low to high
+ hiLen_ += SafeRightShift<8*sizeof(HashLengthType)>(len);
+}
+
+
+// Update digest with data of size len, do in blocks
+void HASH64withTransform::Update(const byte* data, word32 len)
+{
+ // do block size increments
+ word32 blockSz = getBlockSize();
+ byte* local = reinterpret_cast<byte*>(buffer_);
+
+ while (len) {
+ word32 add = min(len, blockSz - buffLen_);
+ memcpy(&local[buffLen_], data, add);
+
+ buffLen_ += add;
+ data += add;
+ len -= add;
+
+ if (buffLen_ == blockSz) {
+ ByteReverseIf(buffer_, buffer_, blockSz, getByteOrder());
+ Transform();
+ AddLength(blockSz);
+ buffLen_ = 0;
+ }
+ }
+}
+
+
+// Final process, place digest in hash
+void HASH64withTransform::Final(byte* hash)
+{
+ word32 blockSz = getBlockSize();
+ word32 digestSz = getDigestSize();
+ word32 padSz = getPadSize();
+ ByteOrder order = getByteOrder();
+
+ AddLength(buffLen_); // before adding pads
+ HashLengthType preLoLen = GetBitCountLo();
+ HashLengthType preHiLen = GetBitCountHi();
+ byte* local = reinterpret_cast<byte*>(buffer_);
+
+ local[buffLen_++] = 0x80; // add 1
+
+ // pad with zeros
+ if (buffLen_ > padSz) {
+ memset(&local[buffLen_], 0, blockSz - buffLen_);
+ buffLen_ += blockSz - buffLen_;
+
+ ByteReverseIf(buffer_, buffer_, blockSz, order);
+ Transform();
+ buffLen_ = 0;
+ }
+ memset(&local[buffLen_], 0, padSz - buffLen_);
+
+ ByteReverseIf(buffer_, buffer_, padSz, order);
+
+ buffer_[blockSz / sizeof(word64) - 2] = order ? preHiLen : preLoLen;
+ buffer_[blockSz / sizeof(word64) - 1] = order ? preLoLen : preHiLen;
+
+ Transform();
+ ByteReverseIf(digest_, digest_, digestSz, order);
+ memcpy(hash, digest_, digestSz);
+
+ Init(); // reset state
+}
+
+#endif // WORD64_AVAILABLE
+
+
} // namespace
diff --git a/extra/yassl/taocrypt/src/integer.cpp b/extra/yassl/taocrypt/src/integer.cpp
index 84255aa8544..85733b88aa9 100644
--- a/extra/yassl/taocrypt/src/integer.cpp
+++ b/extra/yassl/taocrypt/src/integer.cpp
@@ -3390,7 +3390,7 @@ void Integer::DivideByPowerOf2(Integer &r, Integer &q, const Integer &a,
CopyWords(r.reg_.get_buffer(), a.reg_.get_buffer(), wordCount);
SetWords(r.reg_+wordCount, 0, r.reg_.size()-wordCount);
if (n % WORD_BITS != 0)
- r.reg_[wordCount-1] %= ((word) 1 << (n % WORD_BITS));
+ r.reg_[wordCount-1] %= (word(1) << (n % WORD_BITS));
}
else
{
diff --git a/extra/yassl/taocrypt/src/sha.cpp b/extra/yassl/taocrypt/src/sha.cpp
index 9713940529a..ef165a342ad 100644
--- a/extra/yassl/taocrypt/src/sha.cpp
+++ b/extra/yassl/taocrypt/src/sha.cpp
@@ -69,6 +69,77 @@ void SHA::Init()
hiLen_ = 0;
}
+void SHA256::Init()
+{
+ digest_[0] = 0x6A09E667L;
+ digest_[1] = 0xBB67AE85L;
+ digest_[2] = 0x3C6EF372L;
+ digest_[3] = 0xA54FF53AL;
+ digest_[4] = 0x510E527FL;
+ digest_[5] = 0x9B05688CL;
+ digest_[6] = 0x1F83D9ABL;
+ digest_[7] = 0x5BE0CD19L;
+
+ buffLen_ = 0;
+ loLen_ = 0;
+ hiLen_ = 0;
+}
+
+
+void SHA224::Init()
+{
+ digest_[0] = 0xc1059ed8;
+ digest_[1] = 0x367cd507;
+ digest_[2] = 0x3070dd17;
+ digest_[3] = 0xf70e5939;
+ digest_[4] = 0xffc00b31;
+ digest_[5] = 0x68581511;
+ digest_[6] = 0x64f98fa7;
+ digest_[7] = 0xbefa4fa4;
+
+ buffLen_ = 0;
+ loLen_ = 0;
+ hiLen_ = 0;
+}
+
+
+#ifdef WORD64_AVAILABLE
+
+void SHA512::Init()
+{
+ digest_[0] = W64LIT(0x6a09e667f3bcc908);
+ digest_[1] = W64LIT(0xbb67ae8584caa73b);
+ digest_[2] = W64LIT(0x3c6ef372fe94f82b);
+ digest_[3] = W64LIT(0xa54ff53a5f1d36f1);
+ digest_[4] = W64LIT(0x510e527fade682d1);
+ digest_[5] = W64LIT(0x9b05688c2b3e6c1f);
+ digest_[6] = W64LIT(0x1f83d9abfb41bd6b);
+ digest_[7] = W64LIT(0x5be0cd19137e2179);
+
+ buffLen_ = 0;
+ loLen_ = 0;
+ hiLen_ = 0;
+}
+
+
+void SHA384::Init()
+{
+ digest_[0] = W64LIT(0xcbbb9d5dc1059ed8);
+ digest_[1] = W64LIT(0x629a292a367cd507);
+ digest_[2] = W64LIT(0x9159015a3070dd17);
+ digest_[3] = W64LIT(0x152fecd8f70e5939);
+ digest_[4] = W64LIT(0x67332667ffc00b31);
+ digest_[5] = W64LIT(0x8eb44a8768581511);
+ digest_[6] = W64LIT(0xdb0c2e0d64f98fa7);
+ digest_[7] = W64LIT(0x47b5481dbefa4fa4);
+
+ buffLen_ = 0;
+ loLen_ = 0;
+ hiLen_ = 0;
+}
+
+#endif // WORD64_AVAILABLE
+
SHA::SHA(const SHA& that) : HASHwithTransform(DIGEST_SIZE / sizeof(word32),
BLOCK_SIZE)
@@ -81,6 +152,59 @@ SHA::SHA(const SHA& that) : HASHwithTransform(DIGEST_SIZE / sizeof(word32),
memcpy(buffer_, that.buffer_, BLOCK_SIZE);
}
+
+SHA256::SHA256(const SHA256& that) : HASHwithTransform(DIGEST_SIZE /
+ sizeof(word32), BLOCK_SIZE)
+{
+ buffLen_ = that.buffLen_;
+ loLen_ = that.loLen_;
+ hiLen_ = that.hiLen_;
+
+ memcpy(digest_, that.digest_, DIGEST_SIZE);
+ memcpy(buffer_, that.buffer_, BLOCK_SIZE);
+}
+
+
+SHA224::SHA224(const SHA224& that) : HASHwithTransform(SHA256::DIGEST_SIZE /
+ sizeof(word32), BLOCK_SIZE)
+{
+ buffLen_ = that.buffLen_;
+ loLen_ = that.loLen_;
+ hiLen_ = that.hiLen_;
+
+ memcpy(digest_, that.digest_, DIGEST_SIZE);
+ memcpy(buffer_, that.buffer_, BLOCK_SIZE);
+}
+
+
+#ifdef WORD64_AVAILABLE
+
+SHA512::SHA512(const SHA512& that) : HASH64withTransform(DIGEST_SIZE /
+ sizeof(word64), BLOCK_SIZE)
+{
+ buffLen_ = that.buffLen_;
+ loLen_ = that.loLen_;
+ hiLen_ = that.hiLen_;
+
+ memcpy(digest_, that.digest_, DIGEST_SIZE);
+ memcpy(buffer_, that.buffer_, BLOCK_SIZE);
+}
+
+
+SHA384::SHA384(const SHA384& that) : HASH64withTransform(SHA512::DIGEST_SIZE /
+ sizeof(word64), BLOCK_SIZE)
+{
+ buffLen_ = that.buffLen_;
+ loLen_ = that.loLen_;
+ hiLen_ = that.hiLen_;
+
+ memcpy(digest_, that.digest_, DIGEST_SIZE);
+ memcpy(buffer_, that.buffer_, BLOCK_SIZE);
+}
+
+#endif // WORD64_AVAILABLE
+
+
SHA& SHA::operator= (const SHA& that)
{
SHA tmp(that);
@@ -90,6 +214,46 @@ SHA& SHA::operator= (const SHA& that)
}
+SHA256& SHA256::operator= (const SHA256& that)
+{
+ SHA256 tmp(that);
+ Swap(tmp);
+
+ return *this;
+}
+
+
+SHA224& SHA224::operator= (const SHA224& that)
+{
+ SHA224 tmp(that);
+ Swap(tmp);
+
+ return *this;
+}
+
+
+#ifdef WORD64_AVAILABLE
+
+SHA512& SHA512::operator= (const SHA512& that)
+{
+ SHA512 tmp(that);
+ Swap(tmp);
+
+ return *this;
+}
+
+
+SHA384& SHA384::operator= (const SHA384& that)
+{
+ SHA384 tmp(that);
+ Swap(tmp);
+
+ return *this;
+}
+
+#endif // WORD64_AVAILABLE
+
+
void SHA::Swap(SHA& other)
{
STL::swap(loLen_, other.loLen_);
@@ -101,6 +265,53 @@ void SHA::Swap(SHA& other)
}
+void SHA256::Swap(SHA256& other)
+{
+ STL::swap(loLen_, other.loLen_);
+ STL::swap(hiLen_, other.hiLen_);
+ STL::swap(buffLen_, other.buffLen_);
+
+ memcpy(digest_, other.digest_, DIGEST_SIZE);
+ memcpy(buffer_, other.buffer_, BLOCK_SIZE);
+}
+
+
+void SHA224::Swap(SHA224& other)
+{
+ STL::swap(loLen_, other.loLen_);
+ STL::swap(hiLen_, other.hiLen_);
+ STL::swap(buffLen_, other.buffLen_);
+
+ memcpy(digest_, other.digest_, DIGEST_SIZE);
+ memcpy(buffer_, other.buffer_, BLOCK_SIZE);
+}
+
+
+#ifdef WORD64_AVAILABLE
+
+void SHA512::Swap(SHA512& other)
+{
+ STL::swap(loLen_, other.loLen_);
+ STL::swap(hiLen_, other.hiLen_);
+ STL::swap(buffLen_, other.buffLen_);
+
+ memcpy(digest_, other.digest_, DIGEST_SIZE);
+ memcpy(buffer_, other.buffer_, BLOCK_SIZE);
+}
+
+
+void SHA384::Swap(SHA384& other)
+{
+ STL::swap(loLen_, other.loLen_);
+ STL::swap(hiLen_, other.hiLen_);
+ STL::swap(buffLen_, other.buffLen_);
+
+ memcpy(digest_, other.digest_, DIGEST_SIZE);
+ memcpy(buffer_, other.buffer_, BLOCK_SIZE);
+}
+
+#endif // WORD64_AVIALABLE
+
#ifdef DO_SHA_ASM
@@ -203,6 +414,205 @@ void SHA::Transform()
}
+#define blk2(i) (W[i&15]+=s1(W[(i-2)&15])+W[(i-7)&15]+s0(W[(i-15)&15]))
+
+#define Ch(x,y,z) (z^(x&(y^z)))
+#define Maj(x,y,z) ((x&y)|(z&(x|y)))
+
+#define a(i) T[(0-i)&7]
+#define b(i) T[(1-i)&7]
+#define c(i) T[(2-i)&7]
+#define d(i) T[(3-i)&7]
+#define e(i) T[(4-i)&7]
+#define f(i) T[(5-i)&7]
+#define g(i) T[(6-i)&7]
+#define h(i) T[(7-i)&7]
+
+#define R(i) h(i)+=S1(e(i))+Ch(e(i),f(i),g(i))+K[i+j]+(j?blk2(i):blk0(i));\
+ d(i)+=h(i);h(i)+=S0(a(i))+Maj(a(i),b(i),c(i))
+
+// for SHA256
+#define S0(x) (rotrFixed(x,2)^rotrFixed(x,13)^rotrFixed(x,22))
+#define S1(x) (rotrFixed(x,6)^rotrFixed(x,11)^rotrFixed(x,25))
+#define s0(x) (rotrFixed(x,7)^rotrFixed(x,18)^(x>>3))
+#define s1(x) (rotrFixed(x,17)^rotrFixed(x,19)^(x>>10))
+
+
+static const word32 K256[64] = {
+ 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
+ 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
+ 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
+ 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
+ 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
+ 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
+ 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
+ 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
+ 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
+ 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
+ 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
+ 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
+ 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
+ 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
+ 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
+ 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
+};
+
+
+static void Transform256(word32* digest_, word32* buffer_)
+{
+ const word32* K = K256;
+
+ word32 W[16];
+ word32 T[8];
+
+ // Copy digest to working vars
+ memcpy(T, digest_, sizeof(T));
+
+ // 64 operations, partially loop unrolled
+ for (unsigned int j = 0; j < 64; j += 16) {
+ R( 0); R( 1); R( 2); R( 3);
+ R( 4); R( 5); R( 6); R( 7);
+ R( 8); R( 9); R(10); R(11);
+ R(12); R(13); R(14); R(15);
+ }
+
+ // Add the working vars back into digest
+ digest_[0] += a(0);
+ digest_[1] += b(0);
+ digest_[2] += c(0);
+ digest_[3] += d(0);
+ digest_[4] += e(0);
+ digest_[5] += f(0);
+ digest_[6] += g(0);
+ digest_[7] += h(0);
+
+ // Wipe variables
+ memset(W, 0, sizeof(W));
+ memset(T, 0, sizeof(T));
+}
+
+
+// undef for 256
+#undef S0
+#undef S1
+#undef s0
+#undef s1
+
+
+void SHA256::Transform()
+{
+ Transform256(digest_, buffer_);
+}
+
+
+void SHA224::Transform()
+{
+ Transform256(digest_, buffer_);
+}
+
+
+#ifdef WORD64_AVAILABLE
+
+static const word64 K512[80] = {
+ W64LIT(0x428a2f98d728ae22), W64LIT(0x7137449123ef65cd),
+ W64LIT(0xb5c0fbcfec4d3b2f), W64LIT(0xe9b5dba58189dbbc),
+ W64LIT(0x3956c25bf348b538), W64LIT(0x59f111f1b605d019),
+ W64LIT(0x923f82a4af194f9b), W64LIT(0xab1c5ed5da6d8118),
+ W64LIT(0xd807aa98a3030242), W64LIT(0x12835b0145706fbe),
+ W64LIT(0x243185be4ee4b28c), W64LIT(0x550c7dc3d5ffb4e2),
+ W64LIT(0x72be5d74f27b896f), W64LIT(0x80deb1fe3b1696b1),
+ W64LIT(0x9bdc06a725c71235), W64LIT(0xc19bf174cf692694),
+ W64LIT(0xe49b69c19ef14ad2), W64LIT(0xefbe4786384f25e3),
+ W64LIT(0x0fc19dc68b8cd5b5), W64LIT(0x240ca1cc77ac9c65),
+ W64LIT(0x2de92c6f592b0275), W64LIT(0x4a7484aa6ea6e483),
+ W64LIT(0x5cb0a9dcbd41fbd4), W64LIT(0x76f988da831153b5),
+ W64LIT(0x983e5152ee66dfab), W64LIT(0xa831c66d2db43210),
+ W64LIT(0xb00327c898fb213f), W64LIT(0xbf597fc7beef0ee4),
+ W64LIT(0xc6e00bf33da88fc2), W64LIT(0xd5a79147930aa725),
+ W64LIT(0x06ca6351e003826f), W64LIT(0x142929670a0e6e70),
+ W64LIT(0x27b70a8546d22ffc), W64LIT(0x2e1b21385c26c926),
+ W64LIT(0x4d2c6dfc5ac42aed), W64LIT(0x53380d139d95b3df),
+ W64LIT(0x650a73548baf63de), W64LIT(0x766a0abb3c77b2a8),
+ W64LIT(0x81c2c92e47edaee6), W64LIT(0x92722c851482353b),
+ W64LIT(0xa2bfe8a14cf10364), W64LIT(0xa81a664bbc423001),
+ W64LIT(0xc24b8b70d0f89791), W64LIT(0xc76c51a30654be30),
+ W64LIT(0xd192e819d6ef5218), W64LIT(0xd69906245565a910),
+ W64LIT(0xf40e35855771202a), W64LIT(0x106aa07032bbd1b8),
+ W64LIT(0x19a4c116b8d2d0c8), W64LIT(0x1e376c085141ab53),
+ W64LIT(0x2748774cdf8eeb99), W64LIT(0x34b0bcb5e19b48a8),
+ W64LIT(0x391c0cb3c5c95a63), W64LIT(0x4ed8aa4ae3418acb),
+ W64LIT(0x5b9cca4f7763e373), W64LIT(0x682e6ff3d6b2b8a3),
+ W64LIT(0x748f82ee5defb2fc), W64LIT(0x78a5636f43172f60),
+ W64LIT(0x84c87814a1f0ab72), W64LIT(0x8cc702081a6439ec),
+ W64LIT(0x90befffa23631e28), W64LIT(0xa4506cebde82bde9),
+ W64LIT(0xbef9a3f7b2c67915), W64LIT(0xc67178f2e372532b),
+ W64LIT(0xca273eceea26619c), W64LIT(0xd186b8c721c0c207),
+ W64LIT(0xeada7dd6cde0eb1e), W64LIT(0xf57d4f7fee6ed178),
+ W64LIT(0x06f067aa72176fba), W64LIT(0x0a637dc5a2c898a6),
+ W64LIT(0x113f9804bef90dae), W64LIT(0x1b710b35131c471b),
+ W64LIT(0x28db77f523047d84), W64LIT(0x32caab7b40c72493),
+ W64LIT(0x3c9ebe0a15c9bebc), W64LIT(0x431d67c49c100d4c),
+ W64LIT(0x4cc5d4becb3e42b6), W64LIT(0x597f299cfc657e2a),
+ W64LIT(0x5fcb6fab3ad6faec), W64LIT(0x6c44198c4a475817)
+};
+
+
+// for SHA512
+#define S0(x) (rotrFixed(x,28)^rotrFixed(x,34)^rotrFixed(x,39))
+#define S1(x) (rotrFixed(x,14)^rotrFixed(x,18)^rotrFixed(x,41))
+#define s0(x) (rotrFixed(x,1)^rotrFixed(x,8)^(x>>7))
+#define s1(x) (rotrFixed(x,19)^rotrFixed(x,61)^(x>>6))
+
+
+static void Transform512(word64* digest_, word64* buffer_)
+{
+ const word64* K = K512;
+
+ word64 W[16];
+ word64 T[8];
+
+ // Copy digest to working vars
+ memcpy(T, digest_, sizeof(T));
+
+ // 64 operations, partially loop unrolled
+ for (unsigned int j = 0; j < 80; j += 16) {
+ R( 0); R( 1); R( 2); R( 3);
+ R( 4); R( 5); R( 6); R( 7);
+ R( 8); R( 9); R(10); R(11);
+ R(12); R(13); R(14); R(15);
+ }
+
+ // Add the working vars back into digest
+
+ digest_[0] += a(0);
+ digest_[1] += b(0);
+ digest_[2] += c(0);
+ digest_[3] += d(0);
+ digest_[4] += e(0);
+ digest_[5] += f(0);
+ digest_[6] += g(0);
+ digest_[7] += h(0);
+
+ // Wipe variables
+ memset(W, 0, sizeof(W));
+ memset(T, 0, sizeof(T));
+}
+
+
+void SHA512::Transform()
+{
+ Transform512(digest_, buffer_);
+}
+
+
+void SHA384::Transform()
+{
+ Transform512(digest_, buffer_);
+}
+
+#endif // WORD64_AVIALABLE
+
+
#ifdef DO_SHA_ASM
// f1(x,y,z) (z^(x &(y^z)))