aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/hash/rmd160
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2017-10-11 17:02:20 -0400
committerJack Lloyd <[email protected]>2017-10-12 11:13:11 -0400
commit175f09ffd806f2f19cd509017a67ae1384f29ae1 (patch)
tree6194884467e4720dd79797cd106a45d60211f35f /src/lib/hash/rmd160
parent40b3f979723b2b3dfb5c44047d7f786a73fd7f6f (diff)
Add compile-time rotation functions
The problem with asm rol/ror is the compiler can't schedule effectively. But we only need asm in the case when the rotation is variable, so distinguish the two cases. If a compile time constant, then static_assert that the rotation is in the correct range and do the straightforward expression knowing the compiler will probably do the right thing. Otherwise do a tricky expression that both GCC and Clang happen to have recognize. Avoid the reduction case; instead require that the rotation be in range (this reverts 2b37c13dcf). Remove the asm rotations (making this branch illnamed), because now both Clang and GCC will create a roll without any extra help. Remove the reduction/mask by the word size for the variable case. The compiler can't optimize that it out well, but it's easy to ensure it is valid in the callers, especially now that the variable input cases are easy to grep for.
Diffstat (limited to 'src/lib/hash/rmd160')
-rw-r--r--src/lib/hash/rmd160/rmd160.cpp229
1 files changed, 118 insertions, 111 deletions
diff --git a/src/lib/hash/rmd160/rmd160.cpp b/src/lib/hash/rmd160/rmd160.cpp
index 95f96c281..4c84ff422 100644
--- a/src/lib/hash/rmd160/rmd160.cpp
+++ b/src/lib/hash/rmd160/rmd160.cpp
@@ -19,56 +19,61 @@ namespace {
/*
* RIPEMD-160 F1 Function
*/
+template<size_t S>
inline void F1(uint32_t& A, uint32_t B, uint32_t& C, uint32_t D, uint32_t E,
- uint32_t msg, uint32_t shift)
+ uint32_t M)
{
- A += (B ^ C ^ D) + msg;
- A = rotate_left(A, shift) + E;
- C = rotate_left(C, 10);
+ A += (B ^ C ^ D) + M;
+ A = rotl<S>(A) + E;
+ C = rotl<10>(C);
}
/*
* RIPEMD-160 F2 Function
*/
+template<size_t S>
inline void F2(uint32_t& A, uint32_t B, uint32_t& C, uint32_t D, uint32_t E,
- uint32_t msg, uint32_t shift, uint32_t magic)
+ uint32_t M)
{
- A += (D ^ (B & (C ^ D))) + msg + magic;
- A = rotate_left(A, shift) + E;
- C = rotate_left(C, 10);
+ A += (D ^ (B & (C ^ D))) + M;
+ A = rotl<S>(A) + E;
+ C = rotl<10>(C);
}
/*
* RIPEMD-160 F3 Function
*/
+template<size_t S>
inline void F3(uint32_t& A, uint32_t B, uint32_t& C, uint32_t D, uint32_t E,
- uint32_t msg, uint32_t shift, uint32_t magic)
+ uint32_t M)
{
- A += (D ^ (B | ~C)) + msg + magic;
- A = rotate_left(A, shift) + E;
- C = rotate_left(C, 10);
+ A += (D ^ (B | ~C)) + M;
+ A = rotl<S>(A) + E;
+ C = rotl<10>(C);
}
/*
* RIPEMD-160 F4 Function
*/
+template<size_t S>
inline void F4(uint32_t& A, uint32_t B, uint32_t& C, uint32_t D, uint32_t E,
- uint32_t msg, uint32_t shift, uint32_t magic)
+ uint32_t M)
{
- A += (C ^ (D & (B ^ C))) + msg + magic;
- A = rotate_left(A, shift) + E;
- C = rotate_left(C, 10);
+ A += (C ^ (D & (B ^ C))) + M;
+ A = rotl<S>(A) + E;
+ C = rotl<10>(C);
}
/*
* RIPEMD-160 F5 Function
*/
+template<size_t S>
inline void F5(uint32_t& A, uint32_t B, uint32_t& C, uint32_t D, uint32_t E,
- uint32_t msg, uint32_t shift, uint32_t magic)
+ uint32_t M)
{
- A += (B ^ (C | ~D)) + msg + magic;
- A = rotate_left(A, shift) + E;
- C = rotate_left(C, 10);
+ A += (B ^ (C | ~D)) + M;
+ A = rotl<S>(A) + E;
+ C = rotl<10>(C);
}
}
@@ -79,102 +84,104 @@ inline void F5(uint32_t& A, uint32_t B, uint32_t& C, uint32_t D, uint32_t E,
void RIPEMD_160::compress_n(const uint8_t input[], size_t blocks)
{
const uint32_t MAGIC2 = 0x5A827999, MAGIC3 = 0x6ED9EBA1,
- MAGIC4 = 0x8F1BBCDC, MAGIC5 = 0xA953FD4E,
- MAGIC6 = 0x50A28BE6, MAGIC7 = 0x5C4DD124,
- MAGIC8 = 0x6D703EF3, MAGIC9 = 0x7A6D76E9;
+ MAGIC4 = 0x8F1BBCDC, MAGIC5 = 0xA953FD4E,
+ MAGIC6 = 0x50A28BE6, MAGIC7 = 0x5C4DD124,
+ MAGIC8 = 0x6D703EF3, MAGIC9 = 0x7A6D76E9;
for(size_t i = 0; i != blocks; ++i)
{
load_le(m_M.data(), input, m_M.size());
- uint32_t A1 = m_digest[0], A2 = A1, B1 = m_digest[1], B2 = B1,
- C1 = m_digest[2], C2 = C1, D1 = m_digest[3], D2 = D1,
- E1 = m_digest[4], E2 = E1;
-
- F1(A1,B1,C1,D1,E1,m_M[ 0],11 ); F5(A2,B2,C2,D2,E2,m_M[ 5], 8,MAGIC6);
- F1(E1,A1,B1,C1,D1,m_M[ 1],14 ); F5(E2,A2,B2,C2,D2,m_M[14], 9,MAGIC6);
- F1(D1,E1,A1,B1,C1,m_M[ 2],15 ); F5(D2,E2,A2,B2,C2,m_M[ 7], 9,MAGIC6);
- F1(C1,D1,E1,A1,B1,m_M[ 3],12 ); F5(C2,D2,E2,A2,B2,m_M[ 0],11,MAGIC6);
- F1(B1,C1,D1,E1,A1,m_M[ 4], 5 ); F5(B2,C2,D2,E2,A2,m_M[ 9],13,MAGIC6);
- F1(A1,B1,C1,D1,E1,m_M[ 5], 8 ); F5(A2,B2,C2,D2,E2,m_M[ 2],15,MAGIC6);
- F1(E1,A1,B1,C1,D1,m_M[ 6], 7 ); F5(E2,A2,B2,C2,D2,m_M[11],15,MAGIC6);
- F1(D1,E1,A1,B1,C1,m_M[ 7], 9 ); F5(D2,E2,A2,B2,C2,m_M[ 4], 5,MAGIC6);
- F1(C1,D1,E1,A1,B1,m_M[ 8],11 ); F5(C2,D2,E2,A2,B2,m_M[13], 7,MAGIC6);
- F1(B1,C1,D1,E1,A1,m_M[ 9],13 ); F5(B2,C2,D2,E2,A2,m_M[ 6], 7,MAGIC6);
- F1(A1,B1,C1,D1,E1,m_M[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], 6,MAGIC5); F1(C2,D2,E2,A2,B2,m_M[ 1],12 );
- F5(B1,C1,D1,E1,A1,m_M[12], 8,MAGIC5); F1(B2,C2,D2,E2,A2,m_M[ 5], 5 );
- F5(A1,B1,C1,D1,E1,m_M[ 2],13,MAGIC5); F1(A2,B2,C2,D2,E2,m_M[ 8],14 );
- F5(E1,A1,B1,C1,D1,m_M[10],12,MAGIC5); F1(E2,A2,B2,C2,D2,m_M[ 7], 6 );
- F5(D1,E1,A1,B1,C1,m_M[14], 5,MAGIC5); F1(D2,E2,A2,B2,C2,m_M[ 6], 8 );
- F5(C1,D1,E1,A1,B1,m_M[ 1],12,MAGIC5); F1(C2,D2,E2,A2,B2,m_M[ 2],13 );
- F5(B1,C1,D1,E1,A1,m_M[ 3],13,MAGIC5); F1(B2,C2,D2,E2,A2,m_M[13], 6 );
- F5(A1,B1,C1,D1,E1,m_M[ 8],14,MAGIC5); F1(A2,B2,C2,D2,E2,m_M[14], 5 );
- F5(E1,A1,B1,C1,D1,m_M[11],11,MAGIC5); F1(E2,A2,B2,C2,D2,m_M[ 0],15 );
- F5(D1,E1,A1,B1,C1,m_M[ 6], 8,MAGIC5); F1(D2,E2,A2,B2,C2,m_M[ 3],13 );
- F5(C1,D1,E1,A1,B1,m_M[15], 5,MAGIC5); F1(C2,D2,E2,A2,B2,m_M[ 9],11 );
- F5(B1,C1,D1,E1,A1,m_M[13], 6,MAGIC5); F1(B2,C2,D2,E2,A2,m_M[11],11 );
+ uint32_t A1 = m_digest[0], A2 = A1,
+ B1 = m_digest[1], B2 = B1,
+ C1 = m_digest[2], C2 = C1,
+ D1 = m_digest[3], D2 = D1,
+ E1 = m_digest[4], E2 = E1;
+
+ F1<11>(A1,B1,C1,D1,E1,m_M[ 0] ); F5< 8>(A2,B2,C2,D2,E2,m_M[ 5]+MAGIC6);
+ F1<14>(E1,A1,B1,C1,D1,m_M[ 1] ); F5< 9>(E2,A2,B2,C2,D2,m_M[14]+MAGIC6);
+ F1<15>(D1,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