@@ -17,6 +17,14 @@ and related or neighboring rights to the source code in this file.
1717#include "brg_endian.h"
1818#include "KeccakP-1600-SnP.h"
1919#include "SnP-Relaned.h"
20+ #ifdef __has_feature
21+ # if __has_feature (undefined_behavior_sanitizer )
22+ # define ALLOW_MISALIGNED_ACCESS __attribute__((no_sanitize("alignment")))
23+ # endif
24+ #endif
25+ #ifndef ALLOW_MISALIGNED_ACCESS
26+ # define ALLOW_MISALIGNED_ACCESS
27+ #endif
2028
2129typedef unsigned char UINT8 ;
2230typedef unsigned int UINT32 ;
@@ -162,6 +170,7 @@ void KeccakP1600_AddBytesInLane(void *state, unsigned int lanePosition, const un
162170
163171/* ---------------------------------------------------------------- */
164172
173+ ALLOW_MISALIGNED_ACCESS
165174void KeccakP1600_AddLanes (void * state , const unsigned char * data , unsigned int laneCount )
166175{
167176#if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN )
@@ -217,6 +226,7 @@ void KeccakP1600_OverwriteBytesInLane(void *state, unsigned int lanePosition, co
217226
218227/* ---------------------------------------------------------------- */
219228
229+ ALLOW_MISALIGNED_ACCESS
220230void KeccakP1600_OverwriteLanes (void * state , const unsigned char * data , unsigned int laneCount )
221231{
222232#if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN )
@@ -304,6 +314,7 @@ void KeccakP1600_ExtractBytesInLane(const void *state, unsigned int lanePosition
304314
305315/* ---------------------------------------------------------------- */
306316
317+ ALLOW_MISALIGNED_ACCESS
307318void KeccakP1600_ExtractLanes (const void * state , unsigned char * data , unsigned int laneCount )
308319{
309320#if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN )
@@ -378,6 +389,7 @@ void KeccakP1600_ExtractAndAddBytesInLane(const void *state, unsigned int lanePo
378389
379390/* ---------------------------------------------------------------- */
380391
392+ ALLOW_MISALIGNED_ACCESS
381393void KeccakP1600_ExtractAndAddLanes (const void * state , const unsigned char * input , unsigned char * output , unsigned int laneCount )
382394{
383395#if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN )
0 commit comments