aboutsummaryrefslogtreecommitdiffstats
path: root/src/rmd160.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2007-05-31 03:25:19 +0000
committerlloyd <[email protected]>2007-05-31 03:25:19 +0000
commit55608e7dd1aa593944f967f2549564e4f42b654e (patch)
treeec2ec03a762a6dac82eb608487d5394370135624 /src/rmd160.cpp
parent22ecdc45a0efa4c444d0b7010b7cd743aeb68c57 (diff)
Write functions to handle loading and saving words a block at a time, taking into
account endian differences. The current code does not take advantage of the knowledge of which endianness we are running on; an optimization suggested by Yves Jerschow is to use (unsafe) casts to speed up the load/store operations. This turns out to provide large performance increases (30% or more) in some cases. Even without the unsafe casts, this version seems to average a few percent faster, probably because the longer loading loops have been partially or fully unrolled. This also makes the code implementing low-level algorithms like ciphers and hashes a bit more succint.
Diffstat (limited to 'src/rmd160.cpp')
-rw-r--r--src/rmd160.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/rmd160.cpp b/src/rmd160.cpp
index 6cc80d999..e092b19a2 100644
--- a/src/rmd160.cpp
+++ b/src/rmd160.cpp
@@ -73,7 +73,7 @@ inline void F5(u32bit& A, u32bit B, u32bit& C, u32bit D, u32bit E,
void RIPEMD_160::hash(const byte input[])
{
for(u32bit j = 0; j != 16; ++j)
- M[j] = make_u32bit(input[4*j+3], input[4*j+2], input[4*j+1], input[4*j]);
+ M[j] = load_le<u32bit>(input, j);
u32bit A1 = digest[0], A2 = A1, B1 = digest[1], B2 = B1,
C1 = digest[2], C2 = C1, D1 = digest[3], D2 = D1,
@@ -179,8 +179,8 @@ void RIPEMD_160::hash(const byte input[])
*************************************************/
void RIPEMD_160::copy_out(byte output[])
{
- for(u32bit j = 0; j != OUTPUT_LENGTH; ++j)
- output[j] = get_byte(3 - (j % 4), digest[j/4]);
+ for(u32bit j = 0; j != OUTPUT_LENGTH; j += 4)
+ store_le(digest[j/4], output + j);
}
/*************************************************