aboutsummaryrefslogtreecommitdiff
path: root/src/crypto
diff options
context:
space:
mode:
Diffstat (limited to 'src/crypto')
-rw-r--r--src/crypto/aesb.c2
-rw-r--r--src/crypto/chacha.c2
-rw-r--r--src/crypto/crypto.cpp1
-rw-r--r--src/crypto/crypto.h3
-rw-r--r--src/crypto/groestl_tables.h2
-rw-r--r--src/crypto/hash-ops.h2
-rw-r--r--src/crypto/keccak.c2
-rw-r--r--src/crypto/skein_port.h2
-rw-r--r--src/crypto/slow-hash.c43
9 files changed, 28 insertions, 31 deletions
diff --git a/src/crypto/aesb.c b/src/crypto/aesb.c
index 8a22a4b93..efdeef8d1 100644
--- a/src/crypto/aesb.c
+++ b/src/crypto/aesb.c
@@ -19,7 +19,7 @@ Issue Date: 20/12/2007
*/
#include <stdint.h>
-#include "common/int-util.h"
+#include "int-util.h"
#if defined(__cplusplus)
extern "C"
diff --git a/src/crypto/chacha.c b/src/crypto/chacha.c
index 5d3edb98d..d734e8b1b 100644
--- a/src/crypto/chacha.c
+++ b/src/crypto/chacha.c
@@ -11,7 +11,7 @@ Public domain.
#endif
#include "chacha.h"
-#include "common/int-util.h"
+#include "int-util.h"
#include "warnings.h"
/*
diff --git a/src/crypto/crypto.cpp b/src/crypto/crypto.cpp
index ad7721cf0..ddf072f68 100644
--- a/src/crypto/crypto.cpp
+++ b/src/crypto/crypto.cpp
@@ -34,7 +34,6 @@
#include <cstdint>
#include <cstdlib>
#include <cstring>
-#include <memory>
#include <boost/thread/mutex.hpp>
#include <boost/thread/lock_guard.hpp>
#include <boost/shared_ptr.hpp>
diff --git a/src/crypto/crypto.h b/src/crypto/crypto.h
index 33cc0a25a..f22df1230 100644
--- a/src/crypto/crypto.h
+++ b/src/crypto/crypto.h
@@ -32,14 +32,11 @@
#include <cstddef>
#include <iostream>
-#include <boost/thread/mutex.hpp>
-#include <boost/thread/lock_guard.hpp>
#include <boost/optional.hpp>
#include <type_traits>
#include <vector>
#include "common/pod-class.h"
-#include "common/util.h"
#include "memwipe.h"
#include "mlocker.h"
#include "generic-ops.h"
diff --git a/src/crypto/groestl_tables.h b/src/crypto/groestl_tables.h
index 53594c569..12472dced 100644
--- a/src/crypto/groestl_tables.h
+++ b/src/crypto/groestl_tables.h
@@ -29,7 +29,7 @@
#ifndef __tables_h
#define __tables_h
-#include "common/int-util.h"
+#include "int-util.h"
#if BYTE_ORDER == LITTLE_ENDIAN
diff --git a/src/crypto/hash-ops.h b/src/crypto/hash-ops.h
index d77d55cf3..77b52e2d4 100644
--- a/src/crypto/hash-ops.h
+++ b/src/crypto/hash-ops.h
@@ -37,7 +37,7 @@
#include <stddef.h>
#include <stdint.h>
-#include "common/int-util.h"
+#include "int-util.h"
#include "warnings.h"
static inline void *padd(void *p, size_t i) {
diff --git a/src/crypto/keccak.c b/src/crypto/keccak.c
index b095b5ce2..170911262 100644
--- a/src/crypto/keccak.c
+++ b/src/crypto/keccak.c
@@ -5,7 +5,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
-#include "common/int-util.h"
+#include "int-util.h"
#include "hash-ops.h"
#include "keccak.h"
diff --git a/src/crypto/skein_port.h b/src/crypto/skein_port.h
index a50a28e6b..8a1640e57 100644
--- a/src/crypto/skein_port.h
+++ b/src/crypto/skein_port.h
@@ -114,7 +114,7 @@ typedef uint64_t u64b_t; /* 64-bit unsigned integer */
#ifndef SKEIN_NEED_SWAP /* compile-time "override" for endianness? */
-#include "common/int-util.h"
+#include "int-util.h"
#define IS_BIG_ENDIAN 4321 /* byte 0 is most significant (mc68k) */
#define IS_LITTLE_ENDIAN 1234 /* byte 0 is least significant (i386) */
diff --git a/src/crypto/slow-hash.c b/src/crypto/slow-hash.c
index ed61e1017..ae0bd4e98 100644
--- a/src/crypto/slow-hash.c
+++ b/src/crypto/slow-hash.c
@@ -35,7 +35,7 @@
#include <stdio.h>
#include <unistd.h>
-#include "common/int-util.h"
+#include "int-util.h"
#include "hash-ops.h"
#include "oaes_lib.h"
#include "variant2_int_sqrt.h"
@@ -109,8 +109,8 @@ extern void aesb_pseudo_round(const uint8_t *in, uint8_t *out, const uint8_t *ex
memcpy(b + AES_BLOCK_SIZE, state.hs.b + 64, AES_BLOCK_SIZE); \
xor64(b + AES_BLOCK_SIZE, state.hs.b + 80); \
xor64(b + AES_BLOCK_SIZE + 8, state.hs.b + 88); \
- division_result = state.hs.w[12]; \
- sqrt_result = state.hs.w[13]; \
+ division_result = SWAP64LE(state.hs.w[12]); \
+ sqrt_result = SWAP64LE(state.hs.w[13]); \
} while (0)
#define VARIANT2_SHUFFLE_ADD_SSE2(base_ptr, offset) \
@@ -145,30 +145,31 @@ extern void aesb_pseudo_round(const uint8_t *in, uint8_t *out, const uint8_t *ex
const uint64_t chunk1_old[2] = { chunk1[0], chunk1[1] }; \
\
uint64_t b1[2]; \
- memcpy(b1, b + 16, 16); \
- chunk1[0] = chunk3[0] + b1[0]; \
- chunk1[1] = chunk3[1] + b1[1]; \
+ memcpy_swap64le(b1, b + 16, 2); \
+ chunk1[0] = SWAP64LE(SWAP64LE(chunk3[0]) + b1[0]); \
+ chunk1[1] = SWAP64LE(SWAP64LE(chunk3[1]) + b1[1]); \
\
uint64_t a0[2]; \
- memcpy(a0, a, 16); \
- chunk3[0] = chunk2[0] + a0[0]; \
- chunk3[1] = chunk2[1] + a0[1]; \
+ memcpy_swap64le(a0, a, 2); \
+ chunk3[0] = SWAP64LE(SWAP64LE(chunk2[0]) + a0[0]); \
+ chunk3[1] = SWAP64LE(SWAP64LE(chunk2[1]) + a0[1]); \
\
uint64_t b0[2]; \
- memcpy(b0, b, 16); \
- chunk2[0] = chunk1_old[0] + b0[0]; \
- chunk2[1] = chunk1_old[1] + b0[1]; \
+ memcpy_swap64le(b0, b, 2); \
+ chunk2[0] = SWAP64LE(SWAP64LE(chunk1_old[0]) + b0[0]); \
+ chunk2[1] = SWAP64LE(SWAP64LE(chunk1_old[1]) + b0[1]); \
} while (0)
#define VARIANT2_INTEGER_MATH_DIVISION_STEP(b, ptr) \
- ((uint64_t*)(b))[0] ^= division_result ^ (sqrt_result << 32); \
+ uint64_t tmpx = division_result ^ (sqrt_result << 32); \
+ ((uint64_t*)(b))[0] ^= SWAP64LE(tmpx); \
{ \
- const uint64_t dividend = ((uint64_t*)(ptr))[1]; \
- const uint32_t divisor = (((uint64_t*)(ptr))[0] + (uint32_t)(sqrt_result << 1)) | 0x80000001UL; \
+ const uint64_t dividend = SWAP64LE(((uint64_t*)(ptr))[1]); \
+ const uint32_t divisor = (SWAP64LE(((uint64_t*)(ptr))[0]) + (uint32_t)(sqrt_result << 1)) | 0x80000001UL; \
division_result = ((uint32_t)(dividend / divisor)) + \
(((uint64_t)(dividend % divisor)) << 32); \
} \
- const uint64_t sqrt_input = ((uint64_t*)(ptr))[0] + division_result
+ const uint64_t sqrt_input = SWAP64LE(((uint64_t*)(ptr))[0]) + division_result
#define VARIANT2_INTEGER_MATH_SSE2(b, ptr) \
do if (variant >= 2) \
@@ -207,10 +208,10 @@ extern void aesb_pseudo_round(const uint8_t *in, uint8_t *out, const uint8_t *ex
#define VARIANT2_2() \
do if (variant >= 2) \
{ \
- *U64(hp_state + (j ^ 0x10)) ^= hi; \
- *(U64(hp_state + (j ^ 0x10)) + 1) ^= lo; \
- hi ^= *U64(hp_state + (j ^ 0x20)); \
- lo ^= *(U64(hp_state + (j ^ 0x20)) + 1); \
+ *U64(hp_state + (j ^ 0x10)) ^= SWAP64LE(hi); \
+ *(U64(hp_state + (j ^ 0x10)) + 1) ^= SWAP64LE(lo); \
+ hi ^= SWAP64LE(*U64(hp_state + (j ^ 0x20))); \
+ lo ^= SWAP64LE(*(U64(hp_state + (j ^ 0x20)) + 1)); \
} while (0)
@@ -1408,7 +1409,7 @@ static void (*const extra_hashes[4])(const void *, size_t, char *) = {
hash_extra_blake, hash_extra_groestl, hash_extra_jh, hash_extra_skein
};
-static size_t e2i(const uint8_t* a, size_t count) { return (*((uint64_t*)a) / AES_BLOCK_SIZE) & (count - 1); }
+static size_t e2i(const uint8_t* a, size_t count) { return (SWAP64LE(*((uint64_t*)a)) / AES_BLOCK_SIZE) & (count - 1); }
static void mul(const uint8_t* a, const uint8_t* b, uint8_t* res) {
uint64_t a0, b0;