diff options
author | Daniel Neus <[email protected]> | 2016-01-09 12:37:13 +0100 |
---|---|---|
committer | Daniel Neus <[email protected]> | 2016-01-09 12:37:13 +0100 |
commit | f391635f202cf6f83539bd69688975a30f5f874f (patch) | |
tree | 206459e94ab379ba18a8e8035b1855327aa02126 /src/lib/hash/sha1 | |
parent | 52afcc69d97621e5a3880798d7814a474e71c03b (diff) | |
parent | 791b3dc9947a94d35e6d54b274b0512fb0ebd09c (diff) |
Merge remote-tracking branch 'remotes/github/master' into noreturn
# Conflicts:
# src/build-data/cc/gcc.txt
Diffstat (limited to 'src/lib/hash/sha1')
-rw-r--r-- | src/lib/hash/sha1/sha160.cpp | 134 | ||||
-rw-r--r-- | src/lib/hash/sha1/sha160.h | 8 |
2 files changed, 71 insertions, 71 deletions
diff --git a/src/lib/hash/sha1/sha160.cpp b/src/lib/hash/sha1/sha160.cpp index 39d14f486..21e87465a 100644 --- a/src/lib/hash/sha1/sha160.cpp +++ b/src/lib/hash/sha1/sha160.cpp @@ -60,74 +60,74 @@ void SHA_160::compress_n(const byte input[], size_t blocks) { using namespace SHA1_F; - u32bit A = digest[0], B = digest[1], C = digest[2], - D = digest[3], E = digest[4]; + u32bit A = m_digest[0], B = m_digest[1], C = m_digest[2], + D = m_digest[3], E = m_digest[4]; for(size_t i = 0; i != blocks; ++i) { - load_be(W.data(), input, 16); + load_be(m_W.data(), input, 16); for(size_t j = 16; j != 80; j += 8) { - W[j ] = rotate_left((W[j-3] ^ W[j-8] ^ W[j-14] ^ W[j-16]), 1); - W[j+1] = rotate_left((W[j-2] ^ W[j-7] ^ W[j-13] ^ W[j-15]), 1); - W[j+2] = rotate_left((W[j-1] ^ W[j-6] ^ W[j-12] ^ W[j-14]), 1); - W[j+3] = rotate_left((W[j ] ^ W[j-5] ^ W[j-11] ^ W[j-13]), 1); - W[j+4] = rotate_left((W[j+1] ^ W[j-4] ^ W[j-10] ^ W[j-12]), 1); - W[j+5] = rotate_left((W[j+2] ^ W[j-3] ^ W[j- 9] ^ W[j-11]), 1); - W[j+6] = rotate_left((W[j+3] ^ W[j-2] ^ W[j- 8] ^ W[j-10]), 1); - W[j+7] = rotate_left((W[j+4] ^ W[j-1] ^ W[j- 7] ^ W[j- 9]), 1); + m_W[j ] = rotate_left((m_W[j-3] ^ m_W[j-8] ^ m_W[j-14] ^ m_W[j-16]), 1); + m_W[j+1] = rotate_left((m_W[j-2] ^ m_W[j-7] ^ m_W[j-13] ^ m_W[j-15]), 1); + m_W[j+2] = rotate_left((m_W[j-1] ^ m_W[j-6] ^ m_W[j-12] ^ m_W[j-14]), 1); + m_W[j+3] = rotate_left((m_W[j ] ^ m_W[j-5] ^ m_W[j-11] ^ m_W[j-13]), 1); + m_W[j+4] = rotate_left((m_W[j+1] ^ m_W[j-4] ^ m_W[j-10] ^ m_W[j-12]), 1); + m_W[j+5] = rotate_left((m_W[j+2] ^ m_W[j-3] ^ m_W[j- 9] ^ m_W[j-11]), 1); + m_W[j+6] = rotate_left((m_W[j+3] ^ m_W[j-2] ^ m_W[j- 8] ^ m_W[j-10]), 1); + m_W[j+7] = rotate_left((m_W[j+4] ^ m_W[j-1] ^ m_W[j- 7] ^ m_W[j- 9]), 1); } - F1(A, B, C, D, E, W[ 0]); F1(E, A, B, C, D, W[ 1]); - F1(D, E, A, B, C, W[ 2]); F1(C, D, E, A, B, W[ 3]); - F1(B, C, D, E, A, W[ 4]); F1(A, B, C, D, E, W[ 5]); - F1(E, A, B, C, D, W[ 6]); F1(D, E, A, B, C, W[ 7]); - F1(C, D, E, A, B, W[ 8]); F1(B, C, D, E, A, W[ 9]); - F1(A, B, C, D, E, W[10]); F1(E, A, B, C, D, W[11]); - F1(D, E, A, B, C, W[12]); F1(C, D, E, A, B, W[13]); - F1(B, C, D, E, A, W[14]); F1(A, B, C, D, E, W[15]); - F1(E, A, B, C, D, W[16]); F1(D, E, A, B, C, W[17]); - F1(C, D, E, A, B, W[18]); F1(B, C, D, E, A, W[19]); - - F2(A, B, C, D, E, W[20]); F2(E, A, B, C, D, W[21]); - F2(D, E, A, B, C, W[22]); F2(C, D, E, A, B, W[23]); - F2(B, C, D, E, A, W[24]); F2(A, B, C, D, E, W[25]); - F2(E, A, B, C, D, W[26]); F2(D, E, A, B, C, W[27]); - F2(C, D, E, A, B, W[28]); F2(B, C, D, E, A, W[29]); - F2(A, B, C, D, E, W[30]); F2(E, A, B, C, D, W[31]); - F2(D, E, A, B, C, W[32]); F2(C, D, E, A, B, W[33]); - F2(B, C, D, E, A, W[34]); F2(A, B, C, D, E, W[35]); - F2(E, A, B, C, D, W[36]); F2(D, E, A, B, C, W[37]); - F2(C, D, E, A, B, W[38]); F2(B, C, D, E, A, W[39]); - - F3(A, B, C, D, E, W[40]); F3(E, A, B, C, D, W[41]); - F3(D, E, A, B, C, W[42]); F3(C, D, E, A, B, W[43]); - F3(B, C, D, E, A, W[44]); F3(A, B, C, D, E, W[45]); - F3(E, A, B, C, D, W[46]); F3(D, E, A, B, C, W[47]); - F3(C, D, E, A, B, W[48]); F3(B, C, D, E, A, W[49]); - F3(A, B, C, D, E, W[50]); F3(E, A, B, C, D, W[51]); - F3(D, E, A, B, C, W[52]); F3(C, D, E, A, B, W[53]); - F3(B, C, D, E, A, W[54]); F3(A, B, C, D, E, W[55]); - F3(E, A, B, C, D, W[56]); F3(D, E, A, B, C, W[57]); - F3(C, D, E, A, B, W[58]); F3(B, C, D, E, A, W[59]); - - F4(A, B, C, D, E, W[60]); F4(E, A, B, C, D, W[61]); - F4(D, E, A, B, C, W[62]); F4(C, D, E, A, B, W[63]); - F4(B, C, D, E, A, W[64]); F4(A, B, C, D, E, W[65]); - F4(E, A, B, C, D, W[66]); F4(D, E, A, B, C, W[67]); - F4(C, D, E, A, B, W[68]); F4(B, C, D, E, A, W[69]); - F4(A, B, C, D, E, W[70]); F4(E, A, B, C, D, W[71]); - F4(D, E, A, B, C, W[72]); F4(C, D, E, A, B, W[73]); - F4(B, C, D, E, A, W[74]); F4(A, B, C, D, E, W[75]); - F4(E, A, B, C, D, W[76]); F4(D, E, A, B, C, W[77]); - F4(C, D, E, A, B, W[78]); F4(B, C, D, E, A, W[79]); - - A = (digest[0] += A); - B = (digest[1] += B); - C = (digest[2] += C); - D = (digest[3] += D); - E = (digest[4] += E); + F1(A, B, C, D, E, m_W[ 0]); F1(E, A, B, C, D, m_W[ 1]); + F1(D, E, A, B, C, m_W[ 2]); F1(C, D, E, A, B, m_W[ 3]); + F1(B, C, D, E, A, m_W[ 4]); F1(A, B, C, D, E, m_W[ 5]); + F1(E, A, B, C, D, m_W[ 6]); F1(D, E, A, B, C, m_W[ 7]); + F1(C, D, E, A, B, m_W[ 8]); F1(B, C, D, E, A, m_W[ 9]); + F1(A, B, C, D, E, m_W[10]); F1(E, A, B, C, D, m_W[11]); + F1(D, E, A, B, C, m_W[12]); F1(C, D, E, A, B, m_W[13]); + F1(B, C, D, E, A, m_W[14]); F1(A, B, C, D, E, m_W[15]); + F1(E, A, B, C, D, m_W[16]); F1(D, E, A, B, C, m_W[17]); + F1(C, D, E, A, B, m_W[18]); F1(B, C, D, E, A, m_W[19]); + + F2(A, B, C, D, E, m_W[20]); F2(E, A, B, C, D, m_W[21]); + F2(D, E, A, B, C, m_W[22]); F2(C, D, E, A, B, m_W[23]); + F2(B, C, D, E, A, m_W[24]); F2(A, B, C, D, E, m_W[25]); + F2(E, A, B, C, D, m_W[26]); F2(D, E, A, B, C, m_W[27]); + F2(C, D, E, A, B, m_W[28]); F2(B, C, D, E, A, m_W[29]); + F2(A, B, C, D, E, m_W[30]); F2(E, A, B, C, D, m_W[31]); + F2(D, E, A, B, C, m_W[32]); F2(C, D, E, A, B, m_W[33]); + F2(B, C, D, E, A, m_W[34]); F2(A, B, C, D, E, m_W[35]); + F2(E, A, B, C, D, m_W[36]); F2(D, E, A, B, C, m_W[37]); + F2(C, D, E, A, B, m_W[38]); F2(B, C, D, E, A, m_W[39]); + + F3(A, B, C, D, E, m_W[40]); F3(E, A, B, C, D, m_W[41]); + F3(D, E, A, B, C, m_W[42]); F3(C, D, E, A, B, m_W[43]); + F3(B, C, D, E, A, m_W[44]); F3(A, B, C, D, E, m_W[45]); + F3(E, A, B, C, D, m_W[46]); F3(D, E, A, B, C, m_W[47]); + F3(C, D, E, A, B, m_W[48]); F3(B, C, D, E, A, m_W[49]); + F3(A, B, C, D, E, m_W[50]); F3(E, A, B, C, D, m_W[51]); + F3(D, E, A, B, C, m_W[52]); F3(C, D, E, A, B, m_W[53]); + F3(B, C, D, E, A, m_W[54]); F3(A, B, C, D, E, m_W[55]); + F3(E, A, B, C, D, m_W[56]); F3(D, E, A, B, C, m_W[57]); + F3(C, D, E, A, B, m_W[58]); F3(B, C, D, E, A, m_W[59]); + + F4(A, B, C, D, E, m_W[60]); F4(E, A, B, C, D, m_W[61]); + F4(D, E, A, B, C, m_W[62]); F4(C, D, E, A, B, m_W[63]); + F4(B, C, D, E, A, m_W[64]); F4(A, B, C, D, E, m_W[65]); + F4(E, A, B, C, D, m_W[66]); F4(D, E, A, B, C, m_W[67]); + F4(C, D, E, A, B, m_W[68]); F4(B, C, D, E, A, m_W[69]); + F4(A, B, C, D, E, m_W[70]); F4(E, A, B, C, D, m_W[71]); + F4(D, E, A, B, C, m_W[72]); F4(C, D, E, A, B, m_W[73]); + F4(B, C, D, E, A, m_W[74]); F4(A, B, C, D, E, m_W[75]); + F4(E, A, B, C, D, m_W[76]); F4(D, E, A, B, C, m_W[77]); + F4(C, D, E, A, B, m_W[78]); F4(B, C, D, E, A, m_W[79]); + + A = (m_digest[0] += A); + B = (m_digest[1] += B); + C = (m_digest[2] += C); + D = (m_digest[3] += D); + E = (m_digest[4] += E); input += hash_block_size(); } @@ -138,7 +138,7 @@ void SHA_160::compress_n(const byte input[], size_t blocks) */ void SHA_160::copy_out(byte output[]) { - copy_out_vec_be(output, output_length(), digest); + copy_out_vec_be(output, output_length(), m_digest); } /* @@ -147,12 +147,12 @@ void SHA_160::copy_out(byte output[]) void SHA_160::clear() { MDx_HashFunction::clear(); - zeroise(W); - digest[0] = 0x67452301; - digest[1] = 0xEFCDAB89; - digest[2] = 0x98BADCFE; - digest[3] = 0x10325476; - digest[4] = 0xC3D2E1F0; + zeroise(m_W); + m_digest[0] = 0x67452301; + m_digest[1] = 0xEFCDAB89; + m_digest[2] = 0x98BADCFE; + m_digest[3] = 0x10325476; + m_digest[4] = 0xC3D2E1F0; } } diff --git a/src/lib/hash/sha1/sha160.h b/src/lib/hash/sha1/sha160.h index 6328d74c4..2f5d9b16e 100644 --- a/src/lib/hash/sha1/sha160.h +++ b/src/lib/hash/sha1/sha160.h @@ -24,7 +24,7 @@ class BOTAN_DLL SHA_160 : public MDx_HashFunction void clear() override; - SHA_160() : MDx_HashFunction(64, true, true), digest(5), W(80) + SHA_160() : MDx_HashFunction(64, true, true), m_digest(5), m_W(80) { clear(); } @@ -36,7 +36,7 @@ class BOTAN_DLL SHA_160 : public MDx_HashFunction * @param W_size how big to make W */ SHA_160(size_t W_size) : - MDx_HashFunction(64, true, true), digest(5), W(W_size) + MDx_HashFunction(64, true, true), m_digest(5), m_W(W_size) { clear(); } @@ -47,12 +47,12 @@ class BOTAN_DLL SHA_160 : public MDx_HashFunction /** * The digest value, exposed for use by subclasses (asm, SSE2) */ - secure_vector<u32bit> digest; + secure_vector<u32bit> m_digest; /** * The message buffer, exposed for use by subclasses (asm, SSE2) */ - secure_vector<u32bit> W; + secure_vector<u32bit> m_W; }; } |