Commit 19ff323a authored by Bernd Paysan's avatar Bernd Paysan

Add ARMv8 neon implementation

parent 0e31b34c
/*
The Keccak sponge function, designed by Guido Bertoni, Joan Daemen,
Michaël Peeters and Gilles Van Assche. For more information, feedback or
questions, please refer to our website: http://keccak.noekeon.org/
Implementation by the designers,
hereby denoted as "the implementer".
To the extent possible under law, the implementer has waived all copyright
and related or neighboring rights to the source code in this file.
http://creativecommons.org/publicdomain/zero/1.0/
*/
#define STATEI unsigned long long int
#include <string.h>
#include "brg_endian.h"
#include "KeccakF-1600-opt64-settings.h"
#include "KeccakF-1600.h"
extern void KeccakP1600_Permute(void * state, int round);
extern void KeccakP1600_Initialize(void * state);
void KeccakF(keccak_state state, int round)
{
KeccakP1600_Permute(state, round);
}
void KeccakInitializeState(keccak_state state)
{
KeccakP1600_Initialize(state);
}
void KeccakInitialize()
{
}
void KeccakExtract(keccak_state state, UINT64 *data, int byteCount)
{
memmove(data, state, byteCount);
}
void KeccakAbsorb(keccak_state state, UINT64 *data, int byteCount)
{
int i;
keccak_state datai;
memmove(datai, data, byteCount);
for(i=0; i<byteCount-7; i+=8) {
state[i>>3] ^= datai[i>>3];
}
if(byteCount & 7) {
UINT64 m = 0xffffffffffffffffull >> ((8-byteCount) & 7)*8;
state[i>>3] ^= datai[i>>3] & m;
}
}
void KeccakEncrypt(keccak_state state, UINT64 *data, int byteCount)
{
int i;
keccak_state datai;
memmove(datai, data, byteCount);
for(i=0; i<byteCount-7; i+=8) {
datai[i>>3] = state[i>>3] ^= datai[i>>3];
}
if(byteCount & 7) {
UINT64 m = 0xffffffffffffffffull >> ((8-byteCount) & 7)*8;
state[i>>3] ^= datai[i>>3] & m;
datai[i>>3] = state[i>>3];
}
memmove(data, datai, byteCount);
}
void KeccakDecrypt(keccak_state state, UINT64 *data, int byteCount)
{
int i;
UINT64 tmp;
keccak_state datai;
memmove(datai, data, byteCount);
for(i=0; i<byteCount-7; i+=8) {
tmp = datai[i>>3] ^ state[i>>3];
state[i>>3] = datai[i>>3];
datai[i>>3] = tmp;
}
if(byteCount & 7) {
UINT64 m = 0xffffffffffffffffull >> ((8-byteCount) & 7)*8;
tmp = datai[i>>3] ^ state[i>>3];
state[i>>3] = (datai[i>>3] & m) | (state[i>>3] & ~m);
datai[i>>3] = tmp;
}
memmove(data, datai, byteCount);
}
This diff is collapsed.
......@@ -29,6 +29,15 @@ nomflags="`echo $CFLAGS | sed -e 's/-m[[^ ]]* //g'`"
# special optimizations for some plattforms
case "$host" in
aarch64*)
asmflags="-O3 -mfpu=neon $nomflags"
flags="-O3 -mfpu=neon $nomflags"
as="armv8a-neon"
enable_asm=yes
plattform=armv8a-neon
CFLAGS=""
CCASFLAGS=""
;;
arm*-*linux*)
flags="$CFLAGS"
asmflags="$CFLAGS"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment