Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid compiler warning #1981

Merged
merged 2 commits into from
Nov 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions crypto/fipsmodule/modes/gcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,15 @@ int CRYPTO_gcm128_aad(GCM128_CONTEXT *ctx, const uint8_t *aad, size_t len) {

// Process the remainder.
if (len != 0) {
// This is needed to avoid a compiler warning on powerpc64le using GCC 12.2:
// .../aws-lc/crypto/fipsmodule/modes/gcm.c:428:18: error: writing 1 byte into
// a region of size 0 [-Werror=stringop-overflow=]
// 428 | ctx->Xi[i] ^= aad[i];
// | ~~~~~~~~~~~^~~~~~~~~
if (len > 16) {
abort();
return 0;
}
n = (unsigned int)len;
for (size_t i = 0; i < len; ++i) {
ctx->Xi[i] ^= aad[i];
Expand Down Expand Up @@ -684,6 +693,14 @@ int CRYPTO_gcm128_encrypt_ctr32(GCM128_CONTEXT *ctx, const AES_KEY *key,
(*ctx->gcm_key.block)(ctx->Yi, ctx->EKi, key);
++ctr;
CRYPTO_store_u32_be(ctx->Yi + 12, ctr);
// This is needed to avoid a compiler warning on powerpc64le using GCC 12.2:
// .../aws-lc/crypto/fipsmodule/modes/gcm.c:688:18: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
// 688 | ctx->Xi[n] ^= out[n] = in[n] ^ ctx->EKi[n];
// | ^~
if ((n + len) > 16) {
abort();
return 0;
}
while (len--) {
ctx->Xi[n] ^= out[n] = in[n] ^ ctx->EKi[n];
++n;
Expand Down Expand Up @@ -780,6 +797,15 @@ int CRYPTO_gcm128_decrypt_ctr32(GCM128_CONTEXT *ctx, const AES_KEY *key,
(*ctx->gcm_key.block)(ctx->Yi, ctx->EKi, key);
++ctr;
CRYPTO_store_u32_be(ctx->Yi + 12, ctr);
// This is needed to avoid a compiler warning on powerpc64le using GCC 12.2:
// aws-lc/crypto/fipsmodule/modes/gcm.c:785:18: error: writing 1 byte into a
// region of size 0 [-Werror=stringop-overflow=]
// 785 | ctx->Xi[n] ^= c;
// | ~~~~~~~~~~~^~~~
if ((n + len) > 16) {
abort();
return 0;
}
while (len--) {
uint8_t c = in[n];
ctx->Xi[n] ^= c;
Expand Down
Loading