aboutsummaryrefslogtreecommitdiff
path: root/src/crypto/ripemd160.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2014-05-03 01:04:18 +0200
committerPieter Wuille <pieter.wuille@gmail.com>2014-06-21 19:47:42 +0200
commit7ecd9739d9439624399a4882a9f196ccf0c7ba4a (patch)
tree197b608c5f20f8eb2c6bf6e1364e422351df59b9 /src/crypto/ripemd160.cpp
parenta5bc9c09177420bd1c6a1f9ece9ecfbe80c453fe (diff)
Move {Read,Write}{LE,BE}{32,64} to common.h and use builtins if possible
Diffstat (limited to 'src/crypto/ripemd160.cpp')
-rw-r--r--src/crypto/ripemd160.cpp17
1 files changed, 2 insertions, 15 deletions
diff --git a/src/crypto/ripemd160.cpp b/src/crypto/ripemd160.cpp
index aa6874fa85..c5e6e2d696 100644
--- a/src/crypto/ripemd160.cpp
+++ b/src/crypto/ripemd160.cpp
@@ -4,24 +4,12 @@
#include "crypto/ripemd160.h"
+#include "crypto/common.h"
#include <string.h>
// Internal implementation code.
namespace {
-/** Read 4 bytes, and interpret them as a 32-bit unsigned little-endian integer. */
-uint32_t inline ReadLE32(const unsigned char *data) {
- return ((uint32_t)data[0] | (uint32_t)data[1] << 8 | (uint32_t)data[2] << 16 | (uint32_t)data[3] << 24);
-}
-
-/** Write a 32-bit unsigned little-endian integer. */
-void inline WriteLE32(unsigned char *data, uint32_t x) {
- data[0] = x;
- data[1] = x >> 8;
- data[2] = x >> 16;
- data[3] = x >> 24;
-}
-
/// Internal RIPEMD-160 implementation.
namespace ripemd160 {
@@ -199,8 +187,7 @@ CRIPEMD160& CRIPEMD160::Write(const unsigned char *data, size_t len) {
void CRIPEMD160::Finalize(unsigned char *hash) {
static const unsigned char pad[64] = {0x80};
unsigned char sizedesc[8];
- WriteLE32(sizedesc, bytes << 3);
- WriteLE32(sizedesc+4, bytes >> 29);
+ WriteLE64(sizedesc, bytes << 3);
Write(pad, 1 + ((119 - (bytes % 64)) % 64));
Write(sizedesc, 8);
WriteLE32(hash, s[0]);