aboutsummaryrefslogtreecommitdiff
path: root/src/ext/keccak-tiny
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2017-03-14 14:20:15 -0400
committerNick Mathewson <nickm@torproject.org>2017-03-14 14:20:15 -0400
commit9014dc111a46ae7e9443eb4f41969cfc20e79acc (patch)
tree74d1475880b345255e58b66bf2fc1a6050bb0c7a /src/ext/keccak-tiny
parentf38f9b33d0bf52583491cdea6f41eb51819c627b (diff)
downloadtor-9014dc111a46ae7e9443eb4f41969cfc20e79acc.tar.gz
tor-9014dc111a46ae7e9443eb4f41969cfc20e79acc.zip
Improve keccak-tiny performance by 15% on LE intel
The 64-bit load and store code was generating pretty bad output with my compiler, so I extracted the code from csiphash and used that instead. Close ticket 21737
Diffstat (limited to 'src/ext/keccak-tiny')
-rw-r--r--src/ext/keccak-tiny/keccak-tiny-unrolled.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/src/ext/keccak-tiny/keccak-tiny-unrolled.c b/src/ext/keccak-tiny/keccak-tiny-unrolled.c
index d1342c3601..d8d7fe335a 100644
--- a/src/ext/keccak-tiny/keccak-tiny-unrolled.c
+++ b/src/ext/keccak-tiny/keccak-tiny-unrolled.c
@@ -10,28 +10,21 @@
#include <string.h>
#include "crypto.h"
+#include "byteorder.h"
/******** Endianness conversion helpers ********/
static inline uint64_t
loadu64le(const unsigned char *x) {
- uint64_t r = 0;
- size_t i;
-
- for (i = 0; i < 8; ++i) {
- r |= (uint64_t)x[i] << 8 * i;
- }
- return r;
+ uint64_t r;
+ memcpy(&r, x, sizeof(r));
+ return _le64toh(r);
}
static inline void
storeu64le(uint8_t *x, uint64_t u) {
- size_t i;
-
- for(i=0; i<8; ++i) {
- x[i] = u;
- u >>= 8;
- }
+ uint64_t val = _le64toh(u);
+ memcpy(x, &val, sizeof(u));
}
/******** The Keccak-f[1600] permutation ********/