]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
Move alignas declaration, to be compatible with C++.
authorNiels Möller <nisse@lysator.liu.se>
Mon, 16 Jun 2025 19:13:33 +0000 (21:13 +0200)
committerNiels Möller <nisse@lysator.liu.se>
Mon, 16 Jun 2025 19:13:33 +0000 (21:13 +0200)
aes.h
nettle-types.h
umac.h

diff --git a/aes.h b/aes.h
index 3b6f9fb74332c5033c97813cd4a0f9a125de8fe8..913c8463e728a43faf7ca5ea54dc4c170bceb5ba 100644 (file)
--- a/aes.h
+++ b/aes.h
@@ -68,7 +68,7 @@ extern "C" {
 
 struct aes128_ctx
 {
-  uint32_t _NETTLE_ALIGN16 keys[4 * (_AES128_ROUNDS + 1)];
+  _NETTLE_ALIGN16 uint32_t keys[4 * (_AES128_ROUNDS + 1)];
 };
 
 void
index da4195abe87898b3e4f388de0d4bfb5695fc01f2..3069c377182920ad2ec8b746a8df0614e7f3833b 100644 (file)
@@ -59,14 +59,15 @@ extern "C" {
 #endif
 
 /* On 64-bit platforms where uint64_t requires 8 byte alignment, use
-   twice the alignment. */
+   twice the alignment. To work for both C and C++, needs to be placed
+   before the type, see example for nettle_block16 below. */
 #define _NETTLE_ALIGN16 alignas(alignof(uint64_t) == 8 ? 16 : 0)
 
 /* An aligned 16-byte block. */
 union nettle_block16
 {
   uint8_t b[16];
-  uint64_t _NETTLE_ALIGN16 u64[2];
+  _NETTLE_ALIGN16 uint64_t u64[2];
 };
 
 union nettle_block8
diff --git a/umac.h b/umac.h
index 01579f365906c107fa86c4d34e3fc9083e60af0c..88544e61e6eaa20f86e08e38c1eb94524605df1d 100644 (file)
--- a/umac.h
+++ b/umac.h
@@ -70,7 +70,7 @@ extern "C" {
 
 /* Subkeys and state for UMAC with tag size 32*n bits. */
 #define _UMAC_STATE(n)                                 \
-  uint32_t _NETTLE_ALIGN16 l1_key[UMAC_BLOCK_SIZE/4 + 4*((n)-1)];      \
+  _NETTLE_ALIGN16 uint32_t l1_key[UMAC_BLOCK_SIZE/4 + 4*((n)-1)];      \
   /* Keys in 32-bit pieces, high first */              \
   uint32_t l2_key[6*(n)];                              \
   uint64_t l3_key1[8*(n)];                             \