fix(crypto): unify AES context layout on GCC and clang (bindgen)
What changed, and why it matters
This commit fixes a compiler-specific alignment definition for AES cryptographic data structures. Previously, the code only forced memory alignment when compiled with GCC on 64-bit x86, but not when compiled with Clang on the same architecture. The change makes Clang behave the same way as GCC, ensuring the AES context has the same memory layout regardless of which compiler is used. This is a hardening/fix for consistency in cryptographic code, but the commit message does not describe an active exploit or security vulnerability.
Treat as a low-risk hardening fix. Include in routine firmware builds and verify that Clang-based builds now produce the same `aes_context` size and alignment as GCC-based builds. No urgent security response is warranted absent additional evidence of an exploitable condition.
Security signals we found
Cryptographic code affected (AES context layout)
Compiler-specific alignment macro previously inconsistent for Clang
Potential bindgen/Rust FFI layout mismatch addressed
No changelog entry provided
No CVE, advisory, or researcher attribution in commit
Evidence from the diff
The patch adds an #elif defined(__clang__) && defined(__x86_64__) branch to the ALIGNED_ macro in crypto/aes/aes.h. Previously, only __GNUC__ on __x86_64__ triggered __attribute__((aligned(x))); Clang defines __GNUC__ for compatibility in many modes, but not all, and the explicit Clang branch unifies the ABI/memory layout of the aes_context union across GCC and Clang builds. This matters because the AES context is exposed to Rust via bindgen; differing layouts could cause miscompilation, incorrect field offsets, or unsafe memory access in the Rust bindings. The commit is defensive hardening rather than a demonstrated vulnerability fix.
Changed components
crypto/aes/aes.hAES context/union memory layoutGCC and Clang x86_64 buildsRust bindgen FFI bindings for AESInspect captured patch +2 / −0
diff --git a/crypto/aes/aes.h b/crypto/aes/aes.h
index f56a64ad..d57fa922 100644
--- a/crypto/aes/aes.h
+++ b/crypto/aes/aes.h
@@ -90,6 +90,8 @@ typedef union
#define ALIGNED_(x) __declspec(align(x))
#elif defined(__GNUC__) && defined(__x86_64__)
#define ALIGNED_(x) __attribute__ ((aligned(x)))
+#elif defined(__clang__) && defined(__x86_64__)
+#define ALIGNED_(x) __attribute__ ((aligned(x)))
#else
#define ALIGNED_(x)
#endif
Why this scored 30/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.