Merge pull request #4846 from haydenroche5/fips_mode_compat

Implement FIPS_mode and FIPS_mode_set in the compat layer.
This commit is contained in:
David Garske 2022-02-11 12:50:30 -08:00 committed by GitHub
commit 2fa542eb28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 12 deletions

View File

@ -48636,26 +48636,31 @@ void wolfSSL_ERR_load_crypto_strings(void)
return;
}
#ifndef NO_WOLFSSL_STUB
int wolfSSL_FIPS_mode(void)
{
WOLFSSL_ENTER("wolfSSL_FIPS_mode");
WOLFSSL_STUB("FIPS_mode");
return WOLFSSL_FAILURE;
}
#ifdef HAVE_FIPS
return 1;
#else
return 0;
#endif
}
#ifndef NO_WOLFSSL_STUB
int wolfSSL_FIPS_mode_set(int r)
{
(void)r;
WOLFSSL_ENTER("wolfSSL_FIPS_mode_set");
WOLFSSL_STUB("FIPS_mode_set");
#ifdef HAVE_FIPS
if (r == 0) {
WOLFSSL_MSG("Cannot disable FIPS at runtime.");
return WOLFSSL_FAILURE;
}
return WOLFSSL_SUCCESS;
#else
if (r == 0) {
return WOLFSSL_SUCCESS;
}
WOLFSSL_MSG("Cannot enable FIPS. This isn't the wolfSSL FIPS code.");
return WOLFSSL_FAILURE;
}
#endif
}
int wolfSSL_CIPHER_get_bits(const WOLFSSL_CIPHER *c, int *alg_bits)
{

View File

@ -52071,7 +52071,24 @@ static void test_openssl_FIPS_drbg(void)
#endif
}
static void test_wolfSSL_FIPS_mode(void)
{
#if defined(OPENSSL_ALL)
printf(testingFmt, "test_wolfSSL_FIPS_mode()");
#ifdef HAVE_FIPS
AssertIntEQ(wolfSSL_FIPS_mode(), 1);
AssertIntEQ(wolfSSL_FIPS_mode_set(0), WOLFSSL_FAILURE);
AssertIntEQ(wolfSSL_FIPS_mode_set(1), WOLFSSL_SUCCESS);
#else
AssertIntEQ(wolfSSL_FIPS_mode(), 0);
AssertIntEQ(wolfSSL_FIPS_mode_set(0), WOLFSSL_SUCCESS);
AssertIntEQ(wolfSSL_FIPS_mode_set(1), WOLFSSL_FAILURE);
#endif
printf(resultFmt, passed);
#endif
}
/*----------------------------------------------------------------------------*
| Main
@ -52933,6 +52950,7 @@ void ApiTest(void)
test_openssl_FIPS_drbg();
test_wc_CryptoCb();
test_wolfSSL_CTX_StaticMemory();
test_wolfSSL_FIPS_mode();
AssertIntEQ(test_ForceZero(), 0);