@@ -17,6 +17,14 @@ and related or neighboring rights to the source code in this file.
17
17
#include "brg_endian.h"
18
18
#include "KeccakP-1600-SnP.h"
19
19
#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
20
28
21
29
typedef unsigned char UINT8 ;
22
30
typedef unsigned int UINT32 ;
@@ -162,6 +170,7 @@ void KeccakP1600_AddBytesInLane(void *state, unsigned int lanePosition, const un
162
170
163
171
/* ---------------------------------------------------------------- */
164
172
173
+ ALLOW_MISALIGNED_ACCESS
165
174
void KeccakP1600_AddLanes (void * state , const unsigned char * data , unsigned int laneCount )
166
175
{
167
176
#if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN )
@@ -217,6 +226,7 @@ void KeccakP1600_OverwriteBytesInLane(void *state, unsigned int lanePosition, co
217
226
218
227
/* ---------------------------------------------------------------- */
219
228
229
+ ALLOW_MISALIGNED_ACCESS
220
230
void KeccakP1600_OverwriteLanes (void * state , const unsigned char * data , unsigned int laneCount )
221
231
{
222
232
#if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN )
@@ -304,6 +314,7 @@ void KeccakP1600_ExtractBytesInLane(const void *state, unsigned int lanePosition
304
314
305
315
/* ---------------------------------------------------------------- */
306
316
317
+ ALLOW_MISALIGNED_ACCESS
307
318
void KeccakP1600_ExtractLanes (const void * state , unsigned char * data , unsigned int laneCount )
308
319
{
309
320
#if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN )
@@ -378,6 +389,7 @@ void KeccakP1600_ExtractAndAddBytesInLane(const void *state, unsigned int lanePo
378
389
379
390
/* ---------------------------------------------------------------- */
380
391
392
+ ALLOW_MISALIGNED_ACCESS
381
393
void KeccakP1600_ExtractAndAddLanes (const void * state , const unsigned char * input , unsigned char * output , unsigned int laneCount )
382
394
{
383
395
#if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN )
0 commit comments