Skip to content

Commit

Permalink
alignas(16) unsupported w/ GCC 7.2 for ARM32
Browse files Browse the repository at this point in the history
  • Loading branch information
justsmth committed Jan 3, 2025
1 parent 6aa30a9 commit 5407140
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions crypto/cipher_extra/aead_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -831,11 +831,17 @@ TEST_P(PerAEADTest, AliasedBuffers) {
EXPECT_EQ(Bytes(kPlaintext), Bytes(in, out_len));
}

#if defined(__BIGGEST_ALIGNMENT__)
#define UNALIGNED_TEST_ALIGNMENT __BIGGEST_ALIGNMENT__
#else
#define UNALIGNED_TEST_ALIGNMENT 8
#endif // defined(__BIGGEST_ALIGNMENT__)

TEST_P(PerAEADTest, UnalignedInput) {
alignas(16) uint8_t key[EVP_AEAD_MAX_KEY_LENGTH + 1];
alignas(16) uint8_t nonce[EVP_AEAD_MAX_NONCE_LENGTH + 1];
alignas(16) uint8_t plaintext[32 + 1];
alignas(16) uint8_t ad[32 + 1];
alignas(UNALIGNED_TEST_ALIGNMENT) uint8_t key[EVP_AEAD_MAX_KEY_LENGTH + 1];
alignas(UNALIGNED_TEST_ALIGNMENT) uint8_t nonce[EVP_AEAD_MAX_NONCE_LENGTH + 1];
alignas(UNALIGNED_TEST_ALIGNMENT) uint8_t plaintext[32 + 1];
alignas(UNALIGNED_TEST_ALIGNMENT) uint8_t ad[32 + 1];
OPENSSL_memset(key, 'K', sizeof(key));
OPENSSL_memset(nonce, 'N', sizeof(nonce));
OPENSSL_memset(plaintext, 'P', sizeof(plaintext));
Expand All @@ -854,15 +860,15 @@ TEST_P(PerAEADTest, UnalignedInput) {
ASSERT_TRUE(EVP_AEAD_CTX_init_with_direction(
ctx.get(), aead(), key + 1, key_len, EVP_AEAD_DEFAULT_TAG_LENGTH,
evp_aead_seal));
alignas(16) uint8_t ciphertext[sizeof(plaintext) + EVP_AEAD_MAX_OVERHEAD];
alignas(UNALIGNED_TEST_ALIGNMENT) uint8_t ciphertext[sizeof(plaintext) + EVP_AEAD_MAX_OVERHEAD];
size_t ciphertext_len;
ASSERT_TRUE(EVP_AEAD_CTX_seal(ctx.get(), ciphertext + 1, &ciphertext_len,
sizeof(ciphertext) - 1, nonce + 1, nonce_len,
plaintext + 1, sizeof(plaintext) - 1, ad + 1,
ad_len));

// It must successfully decrypt.
alignas(16) uint8_t out[sizeof(ciphertext)];
alignas(UNALIGNED_TEST_ALIGNMENT) uint8_t out[sizeof(ciphertext)];
ctx.Reset();
ASSERT_TRUE(EVP_AEAD_CTX_init_with_direction(
ctx.get(), aead(), key + 1, key_len, EVP_AEAD_DEFAULT_TAG_LENGTH,
Expand Down

0 comments on commit 5407140

Please sign in to comment.