Skip to content

Commit f228a85

Browse files
committed
AES-XTS: fix FIPS gating to use defined(HAVE_FIPS), not defined(HAVE_FIPS_VERSION).
1 parent 11e8a89 commit f228a85

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

linuxkm/lkcapi_glue.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,10 @@
5454
#define WOLFKM_DRIVER_ISA_EXT ""
5555
#endif
5656

57-
#ifdef HAVE_FIPS_VERSION
58-
#if HAVE_FIPS_VERSION >= 5
57+
#ifdef HAVE_FIPS
58+
#ifndef HAVE_FIPS_VERSION
59+
#define WOLFKM_DRIVER_FIPS "-fips-140"
60+
#elif HAVE_FIPS_VERSION >= 5
5961
#define WOLFKM_DRIVER_FIPS "-fips-140-3"
6062
#elif HAVE_FIPS_VERSION == 2
6163
#define WOLFKM_DRIVER_FIPS "-fips-140-2"
@@ -1648,7 +1650,7 @@ static int aes_xts_128_test(void)
16481650
0xff, 0x8d, 0xbc, 0x1d, 0x9f, 0x7f, 0xc8, 0x22
16491651
};
16501652

1651-
#ifndef HAVE_FIPS_VERSION /* FIPS requires different keys for main and tweak. */
1653+
#ifndef HAVE_FIPS /* FIPS requires different keys for main and tweak. */
16521654
WOLFSSL_SMALL_STACK_STATIC const unsigned char k3[] = {
16531655
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
16541656
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
@@ -1673,7 +1675,7 @@ static int aes_xts_128_test(void)
16731675
0xA0, 0x85, 0xD2, 0x69, 0x6E, 0x87, 0x0A, 0xBF,
16741676
0xB5, 0x5A, 0xDD, 0xCB, 0x80, 0xE0, 0xFC, 0xCD
16751677
};
1676-
#endif /* HAVE_FIPS_VERSION */
1678+
#endif /* HAVE_FIPS */
16771679

16781680
#if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC)
16791681
if ((aes = (XtsAes *)XMALLOC(sizeof(*aes), HEAP_HINT, DYNAMIC_TYPE_AES))
@@ -1866,7 +1868,7 @@ static int aes_xts_128_test(void)
18661868
if (XMEMCMP(p2, buf, sizeof(p2)))
18671869
ERROR_OUT(LINUXKM_LKCAPI_AES_KAT_MISMATCH_E, out);
18681870

1869-
#ifndef HAVE_FIPS_VERSION
1871+
#ifndef HAVE_FIPS
18701872

18711873
/* Test ciphertext stealing in-place. */
18721874
XMEMCPY(buf, p3, sizeof(p3));
@@ -1895,7 +1897,7 @@ static int aes_xts_128_test(void)
18951897
if (XMEMCMP(p3, buf, sizeof(p3)))
18961898
ERROR_OUT(LINUXKM_LKCAPI_AES_KAT_MISMATCH_E, out);
18971899

1898-
#endif /* HAVE_FIPS_VERSION */
1900+
#endif /* HAVE_FIPS */
18991901

19001902
#if !defined(BENCH_EMBEDDED) && !defined(HAVE_CAVIUM) && \
19011903
!defined(WOLFSSL_AFALG)

wolfcrypt/test/test.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9438,7 +9438,7 @@ static wc_test_ret_t aes_xts_128_test(void)
94389438
0x77, 0x8a, 0xe8, 0xb4, 0x3c, 0xb9, 0x8d, 0x5a
94399439
};
94409440

9441-
#ifndef HAVE_FIPS_VERSION /* FIPS requires different keys for main and tweak. */
9441+
#ifndef HAVE_FIPS /* FIPS requires different keys for main and tweak. */
94429442
WOLFSSL_SMALL_STACK_STATIC unsigned char k3[] = {
94439443
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
94449444
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
@@ -9463,7 +9463,7 @@ static wc_test_ret_t aes_xts_128_test(void)
94639463
0xA0, 0x85, 0xD2, 0x69, 0x6E, 0x87, 0x0A, 0xBF,
94649464
0xB5, 0x5A, 0xDD, 0xCB, 0x80, 0xE0, 0xFC, 0xCD
94659465
};
9466-
#endif /* HAVE_FIPS_VERSION */
9466+
#endif /* HAVE_FIPS */
94679467

94689468
#if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC)
94699469
if ((aes = (XtsAes *)XMALLOC(sizeof *aes, HEAP_HINT, DYNAMIC_TYPE_AES)) == NULL)
@@ -9666,7 +9666,7 @@ static wc_test_ret_t aes_xts_128_test(void)
96669666
if (XMEMCMP(p2, buf, sizeof(p2)))
96679667
ERROR_OUT(WC_TEST_RET_ENC_NC, out);
96689668

9669-
#ifndef HAVE_FIPS_VERSION
9669+
#ifndef HAVE_FIPS
96709670

96719671
/* Test ciphertext stealing in-place. */
96729672
XMEMCPY(buf, p3, sizeof(p3));
@@ -9699,7 +9699,7 @@ static wc_test_ret_t aes_xts_128_test(void)
96999699
if (XMEMCMP(p3, buf, sizeof(p3)))
97009700
ERROR_OUT(WC_TEST_RET_ENC_NC, out);
97019701

9702-
#endif /* !HAVE_FIPS_VERSION */
9702+
#endif /* !HAVE_FIPS */
97039703

97049704
#if !defined(BENCH_EMBEDDED) && !defined(HAVE_CAVIUM) && \
97059705
!defined(WOLFSSL_AFALG)

0 commit comments

Comments
 (0)