libsodium-go icon indicating copy to clipboard operation
libsodium-go copied to clipboard

Fix pointer to AEAD context

Open silkeh opened this issue 8 years ago • 14 comments

The crypto_aead functions with precomputation take a pointer to a crypto_aead_aes256gcm_state object as argument, not a char array.

The compiler is changed to clang because the code with the correct pointer does not compile with GCC, see golang/go#7270.

silkeh avatar Jul 16 '17 09:07 silkeh

Does it compile on Windows too?

redragonx avatar Aug 13 '17 01:08 redragonx

I don't see why not, but I don't have any way to verify.

silkeh avatar Aug 13 '17 12:08 silkeh

Hmm, ok.

Me neither, the batch file needs updating before I can accept this PR. Maybe it's a small change.

redragonx avatar Aug 14 '17 00:08 redragonx

I have changed the batch file as well.

silkeh avatar Aug 24 '17 14:08 silkeh

Is there any news on this? It doesn't compile on macos with apple-clang 9.0 either, this patch fixes it

theodelrieu avatar Oct 03 '17 15:10 theodelrieu

It's weird that it breaks GCC, crypto_aead_aes256gcm_state is just a C typedef. This PR fixed clang but broke GCC.

Do you think there is a way to make both happy?

theodelrieu avatar Oct 04 '17 09:10 theodelrieu

That structure must be stored at a 16 bytes aligned location.

The same thing applies to crypto_onetimeauth_poly1305_state.

jedisct1 avatar Oct 04 '17 10:10 jedisct1

@theodelrieu GCC has an open issue for this: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81001

silkeh avatar Oct 04 '17 10:10 silkeh

This seems to explain how to deal with alignment constraints: http://www.tapirgames.com/blog/golang-memory-alignment

jedisct1 avatar Oct 04 '17 10:10 jedisct1

@jedisct1 I will look into alignment constraints for this (and for #31), thanks!

silkeh avatar Oct 04 '17 10:10 silkeh

Thank you to everyone that's helping with this issue.

redragonx avatar Oct 05 '17 07:10 redragonx

I have updated #31 and created #32 for the alignment issue.

silkeh avatar Oct 07 '17 21:10 silkeh

Does this work for CLANG and GCC now then?

redragonx avatar Oct 22 '17 21:10 redragonx

@redragonx no, that is not possible until this GCC bug is solved.

silkeh avatar Oct 23 '17 09:10 silkeh