aboutsummaryrefslogtreecommitdiff
path: root/src/crypto/sha2.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/sha2.cpp
parenta5bc9c09177420bd1c6a1f9ece9ecfbe80c453fe (diff)
Move {Read,Write}{LE,BE}{32,64} to common.h and use builtins if possible
Diffstat (limited to 'src/crypto/sha2.cpp')
-rw-r--r--src/crypto/sha2.cpp32
1 files changed, 1 insertions, 31 deletions
diff --git a/src/crypto/sha2.cpp b/src/crypto/sha2.cpp
index 0d0c32883f..77f35f38d8 100644
--- a/src/crypto/sha2.cpp
+++ b/src/crypto/sha2.cpp
@@ -4,42 +4,12 @@
#include "crypto/sha2.h"
+#include "crypto/common.h"
#include <string.h>
// Internal implementation code.
namespace {
-/** Read 4 bytes, and interpret them as a 32-bit unsigned big-endian integer. */
-uint32_t inline ReadBE32(const unsigned char *data) {
- return ((uint32_t)data[0] << 24 | (uint32_t)data[1] << 16 | (uint32_t)data[2] << 8 | (uint32_t)data[3]);
-}
-
-/** Write a 32-bit unsigned big-endian integer. */
-void inline WriteBE32(unsigned char *data, uint32_t x) {
- data[0] = x >> 24;
- data[1] = x >> 16;
- data[2] = x >> 8;
- data[3] = x;
-}
-
-/** Read 8 bytes, and interpret them as a 64-bit unsigned big-endian integer. */
-uint64_t inline ReadBE64(const unsigned char *data) {
- return ((uint64_t)data[0] << 56 | (uint64_t)data[1] << 48 | (uint64_t)data[2] << 40 | (uint64_t)data[3] << 32 |
- (uint64_t)data[4] << 24 | (uint64_t)data[5] << 16 | (uint64_t)data[6] << 8 | (uint64_t)data[7]);
-}
-
-/** Write a 64-bit unsigned big-endian integer. */
-void inline WriteBE64(unsigned char *data, uint64_t x) {
- data[0] = x >> 56;
- data[1] = x >> 48;
- data[2] = x >> 40;
- data[3] = x >> 32;
- data[4] = x >> 24;
- data[5] = x >> 16;
- data[6] = x >> 8;
- data[7] = x;
-}
-
/// Internal SHA-256 implementation.
namespace sha256 {