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

Disable XTS-384 as an allowed use in FIPS mode #8509

Merged
merged 3 commits into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions fips-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,9 @@ linuxv5|linuxv5.2.1)
)
;;
v6.0.0)
WOLF_REPO_TAG='WCv6.0.0-RC3'
WOLF_REPO_TAG='WCv6.0.0-RC4'
FIPS_REPO_TAG='WCv6.0.0-RC4'
ASM_PICKUPS_TAG='WCv6.0.0-RC3'
ASM_PICKUPS_TAG='WCv6.0.0-RC4'
FIPS_OPTION='v6'
FIPS_FILES=(
"wolfcrypt/src/fips.c:${FIPS_REPO_TAG}"
Expand Down
5 changes: 5 additions & 0 deletions wolfcrypt/src/aes.c
Original file line number Diff line number Diff line change
Expand Up @@ -12818,7 +12818,12 @@ int wc_AesXtsSetKeyNoInit(XtsAes* aes, const byte* key, word32 len, int dir)
}

if ((len != (AES_128_KEY_SIZE*2)) &&
#ifndef HAVE_FIPS
/* XTS-384 not allowed by FIPS and can not be treated like
* RSA-4096 bit keys back in the day, can not vendor affirm
* the use of 2 concatenated 192-bit keys (XTS-384) */
(len != (AES_192_KEY_SIZE*2)) &&
#endif
(len != (AES_256_KEY_SIZE*2)))
{
WOLFSSL_MSG("Unsupported key size");
Expand Down
13 changes: 6 additions & 7 deletions wolfcrypt/test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -11585,6 +11585,8 @@ static wc_test_ret_t aes_xts_128_test(void)
}
#endif /* WOLFSSL_AES_128 */

#ifndef HAVE_FIPS
/* FIPS won't allow for XTS-384 (two 192-bit keys) */
#ifdef WOLFSSL_AES_192
static wc_test_ret_t aes_xts_192_test(void)
{
Expand Down Expand Up @@ -11675,7 +11677,6 @@ static wc_test_ret_t aes_xts_192_test(void)
0x65, 0x37, 0x15, 0x53, 0xf1, 0x98, 0xab, 0xb4
};

#ifndef HAVE_FIPS /* FIPS requires different keys for main and tweak. */
WOLFSSL_SMALL_STACK_STATIC unsigned char k3[] = {
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
Expand All @@ -11702,7 +11703,6 @@ static wc_test_ret_t aes_xts_192_test(void)
0xe8, 0xc5, 0x99, 0x3d, 0x58, 0x3c, 0xeb, 0xba,
0x86, 0xea, 0x2c, 0x7e, 0x1f, 0xba, 0x81, 0xde
};
#endif /* HAVE_FIPS */

#if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC)
if ((aes = (XtsAes *)XMALLOC(sizeof *aes, HEAP_HINT, DYNAMIC_TYPE_AES)) == NULL)
Expand Down Expand Up @@ -12017,8 +12017,6 @@ static wc_test_ret_t aes_xts_192_test(void)
if (XMEMCMP(p2, buf, sizeof(p2)))
ERROR_OUT(WC_TEST_RET_ENC_NC, out);

#ifndef HAVE_FIPS

/* Test ciphertext stealing in-place. */
XMEMCPY(buf, p3, sizeof(p3));
ret = wc_AesXtsSetKeyNoInit(aes, k3, sizeof(k3), AES_ENCRYPTION);
Expand Down Expand Up @@ -12102,8 +12100,6 @@ static wc_test_ret_t aes_xts_192_test(void)
ERROR_OUT(WC_TEST_RET_ENC_NC, out);
#endif /* WOLFSSL_AESXTS_STREAM */

#endif /* !HAVE_FIPS */

#if !defined(BENCH_EMBEDDED) && !defined(HAVE_CAVIUM) && \
!defined(WOLFSSL_AFALG)
{
Expand Down Expand Up @@ -12288,7 +12284,7 @@ static wc_test_ret_t aes_xts_192_test(void)
return ret;
}
#endif /* WOLFSSL_AES_192 */

#endif /* HAVE_FIPS */

#ifdef WOLFSSL_AES_256
static wc_test_ret_t aes_xts_256_test(void)
Expand Down Expand Up @@ -14637,11 +14633,14 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t aes_xts_test(void)
return ret;
#endif

/* FIPS won't allow for XTS-384 (two 192-bit keys) */
#ifndef HAVE_FIPS
#ifdef WOLFSSL_AES_192
ret = aes_xts_192_test();
if (ret != 0)
return ret;
#endif
#endif

#ifdef WOLFSSL_AES_256
ret = aes_xts_256_test();
Expand Down
Loading