Skip to content

Commit

Permalink
Update x25519_test.cc array initialization to avoid a bug with a GCC …
Browse files Browse the repository at this point in the history
…13 warning (#1555)

### Issues:
Resolves V1360237371

### Description of changes: 
Avoid a [GCC 13
bug](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114826) by
initializing the test vector separately. This test still needs the `=
{}` to zero initialize the entire array.

### Call-outs:
This isn't tested in the CI because we don't want to test all
march/compiler combinations at this time, this support is best effort
for now.

### Testing:
```
docker run -v `pwd`:`pwd` -w `pwd` -it gcc:13
apt update && apt install cmake ninja less -y
export CFLAGS='-march=haswell -mcrc32'
export CXXFLAGS='-march=haswell -mcrc32'
cmake -GNinja ../
ninja run_tests
```
By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license and the ISC license.
  • Loading branch information
andrewhop committed Apr 29, 2024
1 parent 388cbe7 commit 9a4b43e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions crypto/curve25519/x25519_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ TEST(X25519Test, SmallOrder) {

TEST(X25519Test, Iterated) {
// Taken from https://tools.ietf.org/html/rfc7748#section-5.2.
uint8_t scalar[32] = {9}, point[32] = {9}, out[32];
uint8_t scalar[32] = {}, point[32] = {}, out[32];
scalar[0] = 9;
point[0] = 9;

for (unsigned i = 0; i < 1000; i++) {
EXPECT_TRUE(ctwrapX25519(out, scalar, point));
Expand All @@ -176,7 +178,9 @@ TEST(X25519Test, Iterated) {

TEST(X25519Test, DISABLED_IteratedLarge) {
// Taken from https://tools.ietf.org/html/rfc7748#section-5.2.
uint8_t scalar[32] = {9}, point[32] = {9}, out[32];
uint8_t scalar[32] = {}, point[32] = {}, out[32];
scalar[0] = 9;
point[0] = 9;

for (unsigned i = 0; i < 1000000; i++) {
EXPECT_TRUE(ctwrapX25519(out, scalar, point));
Expand Down

0 comments on commit 9a4b43e

Please sign in to comment.