mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-08-15 01:03:23 +00:00
Fixed Keccak implementation on big-endian platforms
This commit is contained in:
parent
bb30a72367
commit
9bf0105e25
1 changed files with 8 additions and 3 deletions
|
@ -5,6 +5,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include "common/int-util.h"
|
||||||
#include "hash-ops.h"
|
#include "hash-ops.h"
|
||||||
#include "keccak.h"
|
#include "keccak.h"
|
||||||
|
|
||||||
|
@ -105,7 +106,7 @@ void keccak(const uint8_t *in, size_t inlen, uint8_t *md, int mdlen)
|
||||||
|
|
||||||
for ( ; inlen >= rsiz; inlen -= rsiz, in += rsiz) {
|
for ( ; inlen >= rsiz; inlen -= rsiz, in += rsiz) {
|
||||||
for (i = 0; i < rsizw; i++)
|
for (i = 0; i < rsizw; i++)
|
||||||
st[i] ^= ((uint64_t *) in)[i];
|
st[i] ^= swap64le(((uint64_t *) in)[i]);
|
||||||
keccakf(st, KECCAK_ROUNDS);
|
keccakf(st, KECCAK_ROUNDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,11 +122,15 @@ void keccak(const uint8_t *in, size_t inlen, uint8_t *md, int mdlen)
|
||||||
temp[rsiz - 1] |= 0x80;
|
temp[rsiz - 1] |= 0x80;
|
||||||
|
|
||||||
for (i = 0; i < rsizw; i++)
|
for (i = 0; i < rsizw; i++)
|
||||||
st[i] ^= ((uint64_t *) temp)[i];
|
st[i] ^= swap64le(((uint64_t *) temp)[i]);
|
||||||
|
|
||||||
keccakf(st, KECCAK_ROUNDS);
|
keccakf(st, KECCAK_ROUNDS);
|
||||||
|
|
||||||
memcpy(md, st, mdlen);
|
if (((size_t)mdlen % sizeof(uint64_t)) != 0)
|
||||||
|
{
|
||||||
|
local_abort("Bad keccak use");
|
||||||
|
}
|
||||||
|
memcpy_swap64le(md, st, mdlen/sizeof(uint64_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
void keccak1600(const uint8_t *in, size_t inlen, uint8_t *md)
|
void keccak1600(const uint8_t *in, size_t inlen, uint8_t *md)
|
||||||
|
|
Loading…
Reference in a new issue