in src/sha3/keccak4x/KeccakP-1600-times4-SIMD256.c [88:121]
void KeccakP1600times4_AddBytes(void *states, unsigned int instanceIndex, const unsigned char *data, unsigned int offset, unsigned int length)
{
unsigned int sizeLeft = length;
unsigned int lanePosition = offset/SnP_laneLengthInBytes;
unsigned int offsetInLane = offset%SnP_laneLengthInBytes;
const unsigned char *curData = data;
UINT64 *statesAsLanes = (UINT64 *)states;
if ((sizeLeft > 0) && (offsetInLane != 0)) {
unsigned int bytesInLane = SnP_laneLengthInBytes - offsetInLane;
UINT64 lane = 0;
if (bytesInLane > sizeLeft)
bytesInLane = sizeLeft;
memcpy((unsigned char*)&lane + offsetInLane, curData, bytesInLane);
statesAsLanes[laneIndex(instanceIndex, lanePosition)] ^= lane;
sizeLeft -= bytesInLane;
lanePosition++;
curData += bytesInLane;
}
while(sizeLeft >= SnP_laneLengthInBytes) {
UINT64 lane = *((const UINT64*)curData);
statesAsLanes[laneIndex(instanceIndex, lanePosition)] ^= lane;
sizeLeft -= SnP_laneLengthInBytes;
lanePosition++;
curData += SnP_laneLengthInBytes;
}
if (sizeLeft > 0) {
UINT64 lane = 0;
memcpy(&lane, curData, sizeLeft);
statesAsLanes[laneIndex(instanceIndex, lanePosition)] ^= lane;
}
}