aboutsummaryrefslogtreecommitdiff
path: root/src/crypto/slow-hash.c
diff options
context:
space:
mode:
authorLee Clagett <code@leeclagett.com>2018-09-19 00:30:58 -0400
committerLee Clagett <code@leeclagett.com>2018-09-22 03:47:50 +0000
commitf3cd51a12b202875bd8191668aceb8a4f810ecd4 (patch)
tree3c0e73146233fe57fdbd59ab8d85eafd0cbbd362 /src/crypto/slow-hash.c
parentMerge pull request #4381 (diff)
downloadmonero-f3cd51a12b202875bd8191668aceb8a4f810ecd4.tar.xz
cryptonote tweak v2.2
Diffstat (limited to 'src/crypto/slow-hash.c')
-rw-r--r--src/crypto/slow-hash.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/crypto/slow-hash.c b/src/crypto/slow-hash.c
index 914ba6dc0..80bf4e06f 100644
--- a/src/crypto/slow-hash.c
+++ b/src/crypto/slow-hash.c
@@ -198,6 +198,22 @@ extern int aesb_pseudo_round(const uint8_t *in, uint8_t *out, const uint8_t *exp
} while (0)
#endif
+#define VARIANT2_2_PORTABLE() \
+ if (variant >= 2) { \
+ xor_blocks(long_state + (j ^ 0x10), d); \
+ xor_blocks(d, long_state + (j ^ 0x20)); \
+ }
+
+#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); \
+ } while (0)
+
+
#if !defined NO_AES && (defined(__x86_64__) || (defined(_MSC_VER) && defined(_WIN64)))
// Optimised code below, uses x86-specific intrinsics, SSE2, AES-NI
// Fall back to more portable code is down at the bottom
@@ -282,6 +298,7 @@ extern int aesb_pseudo_round(const uint8_t *in, uint8_t *out, const uint8_t *exp
b[0] = p[0]; b[1] = p[1]; \
VARIANT2_INTEGER_MATH_SSE2(b, c); \
__mul(); \
+ VARIANT2_2(); \
VARIANT2_SHUFFLE_ADD_SSE2(hp_state, j); \
a[0] += hi; a[1] += lo; \
p = U64(&hp_state[j]); \
@@ -884,6 +901,7 @@ union cn_slow_hash_state
b[0] = p[0]; b[1] = p[1]; \
VARIANT2_PORTABLE_INTEGER_MATH(b, c); \
__mul(); \
+ VARIANT2_2(); \
VARIANT2_SHUFFLE_ADD_NEON(hp_state, j); \
a[0] += hi; a[1] += lo; \
p = U64(&hp_state[j]); \
@@ -1305,6 +1323,7 @@ void cn_slow_hash(const void *data, size_t length, char *hash, int variant, int
VARIANT2_PORTABLE_INTEGER_MATH(c, c1);
mul(c1, c, d);
+ VARIANT2_2_PORTABLE();
VARIANT2_PORTABLE_SHUFFLE_ADD(long_state, j);
sum_half_blocks(a, d);
swap_blocks(a, c);
@@ -1486,6 +1505,7 @@ void cn_slow_hash(const void *data, size_t length, char *hash, int variant, int
copy_block(c2, &long_state[j]);
VARIANT2_PORTABLE_INTEGER_MATH(c2, c1);
mul(c1, c2, d);
+ VARIANT2_2_PORTABLE();
VARIANT2_PORTABLE_SHUFFLE_ADD(long_state, j);
swap_blocks(a, c1);
sum_half_blocks(c1, d);