From c72d57175f368792d5abdd213073f6fa7534cd58 Mon Sep 17 00:00:00 2001 From: Silke Date: Sun, 16 Jul 2017 11:23:48 +0200 Subject: [PATCH] Fix pointer to AEAD context 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. --- build.sh | 3 ++- cryptoaead/crypto_aead_aes256gcm.go | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/build.sh b/build.sh index 991774c..77dbe0d 100755 --- a/build.sh +++ b/build.sh @@ -1,2 +1,3 @@ #!/bin/sh -exec go build ./... \ No newline at end of file +export CC=clang +exec go build ./... diff --git a/cryptoaead/crypto_aead_aes256gcm.go b/cryptoaead/crypto_aead_aes256gcm.go index db2f1fe..e8de873 100644 --- a/cryptoaead/crypto_aead_aes256gcm.go +++ b/cryptoaead/crypto_aead_aes256gcm.go @@ -149,7 +149,7 @@ func CryptoAEADAES256GCMEncryptAfterNM(m, ad, npub, ctx []byte) ([]byte, int) { (C.ulonglong)(len(ad)), (*C.uchar)(nil), (*C.uchar)(&npub[0]), - (*[512]C.uchar)(unsafe.Pointer(&ctx[0])))) + (*C.crypto_aead_aes256gcm_state)(unsafe.Pointer(&ctx[0])))) return c, exit } @@ -171,7 +171,7 @@ func CryptoAEADAES256GCMDecryptAfterNM(c, ad, npub, ctx []byte) ([]byte, int) { (*C.uchar)(support.BytePointer(ad)), (C.ulonglong)(len(ad)), (*C.uchar)(&npub[0]), - (*[512]C.uchar)(unsafe.Pointer(&ctx[0])))) + (*C.crypto_aead_aes256gcm_state)(unsafe.Pointer(&ctx[0])))) return m, exit } @@ -194,7 +194,7 @@ func CryptoAEADAES256GCMEncryptDetachedAfterNM(m, ad, npub, ctx []byte) ([]byte, (C.ulonglong)(len(ad)), (*C.uchar)(nil), (*C.uchar)(&npub[0]), - (*[512]C.uchar)(unsafe.Pointer(&ctx[0])))) + (*C.crypto_aead_aes256gcm_state)(unsafe.Pointer(&ctx[0])))) return c, mac, exit } @@ -215,7 +215,7 @@ func CryptoAEADAES256GCMDecryptDetachedAfterNM(c, mac, ad, npub, ctx []byte) ([] (*C.uchar)(support.BytePointer(ad)), (C.ulonglong)(len(ad)), (*C.uchar)(&npub[0]), - (*[512]C.uchar)(unsafe.Pointer(&ctx[0])))) + (*C.crypto_aead_aes256gcm_state)(unsafe.Pointer(&ctx[0])))) return m, exit }