majek / csiphash

SipHash in C
https://github.com/majek/csiphash
48 stars 17 forks source link

invalid code, casting a void pointer to an uint64_t pointer #6

Open doko42 opened 7 years ago

doko42 commented 7 years ago

siphash24 casts a void pointer to an uint64_t pointer, which has more strict alignment requirements on some targets, leading to a bus error. that's not valid code.

seen in the siphash24 copy in Python: http://bugs.python.org/issue28055

The proposed solution is to use a memcpy for all little endian targets.

majek commented 7 years ago

"on some targets" can you be more precise?

cgrzemba commented 6 years ago

I see this problem on Solaris Sparc and fixed it in this kind:

@@ -75,7 +90,9 @@ uint64_t uint64_t siphash24(const void *src, unsigned long src_sz, const char key[16]) { {

doko42 commented 6 years ago

the original target was ARM32, using a 64bit AArch64 kernel

mcqtom commented 1 year ago

+1

siphash24(...) fails to run on ARM Cortex M0+ (STM32L0) due to this cast.

Passed in key has to be manually aligned in order to work. unsigned char __attribute__ ((aligned (16))) secret_key[16] = {...};

majek commented 1 year ago

@mcqtom PR?