* All tests are run regardless of if they fail or not.
* Return 0 if any test fails.
*/
-static int self_test_digests(OSSL_SELF_TEST *st, OSSL_LIB_CTX *libctx)
+static int self_test_digests(OSSL_SELF_TEST *st, OSSL_LIB_CTX *libctx,
+ int do_deferred)
{
int i, ret = 1;
for (i = 0; i < (int)OSSL_NELEM(st_kat_digest_tests); ++i) {
- if (st_kat_digest_tests[i].deferred)
+ if (st_kat_digest_tests[i].deferred && !do_deferred)
continue;
if (!self_test_digest(&st_kat_digest_tests[i], st, libctx))
ret = 0;
return ret;
}
-static int self_test_ciphers(OSSL_SELF_TEST *st, OSSL_LIB_CTX *libctx)
+static int self_test_ciphers(OSSL_SELF_TEST *st, OSSL_LIB_CTX *libctx,
+ int do_deferred)
{
int i, ret = 1;
for (i = 0; i < (int)OSSL_NELEM(st_kat_cipher_tests); ++i) {
- if (st_kat_cipher_tests[i].base.deferred)
+ if (st_kat_cipher_tests[i].base.deferred && !do_deferred)
continue;
if (!self_test_cipher(&st_kat_cipher_tests[i], st, libctx))
ret = 0;
return ret;
}
-static int self_test_kems(OSSL_SELF_TEST *st, OSSL_LIB_CTX *libctx)
+static int self_test_kems(OSSL_SELF_TEST *st, OSSL_LIB_CTX *libctx,
+ int do_deferred)
{
int ret = 1;
#ifndef OPENSSL_NO_ML_KEM
int i;
for (i = 0; i < (int)OSSL_NELEM(st_kat_kem_tests); ++i) {
- if (st_kat_kem_tests[i].deferred)
+ if (st_kat_kem_tests[i].deferred && !do_deferred)
continue;
if (!self_test_kem(&st_kat_kem_tests[i], st, libctx))
ret = 0;
return ret;
}
-static int self_test_asym_ciphers(OSSL_SELF_TEST *st, OSSL_LIB_CTX *libctx)
+static int self_test_asym_ciphers(OSSL_SELF_TEST *st, OSSL_LIB_CTX *libctx,
+ int do_deferred)
{
int i, ret = 1;
for (i = 0; i < (int)OSSL_NELEM(st_kat_asym_cipher_tests); ++i) {
- if (st_kat_asym_cipher_tests[i].deferred)
+ if (st_kat_asym_cipher_tests[i].deferred && !do_deferred)
continue;
if (!self_test_asym_cipher(&st_kat_asym_cipher_tests[i], st, libctx))
ret = 0;
return ret;
}
-static int self_test_kdfs(OSSL_SELF_TEST *st, OSSL_LIB_CTX *libctx)
+static int self_test_kdfs(OSSL_SELF_TEST *st, OSSL_LIB_CTX *libctx,
+ int do_deferred)
{
int i, ret = 1;
for (i = 0; i < (int)OSSL_NELEM(st_kat_kdf_tests); ++i) {
- if (st_kat_kdf_tests[i].deferred)
+ if (st_kat_kdf_tests[i].deferred && !do_deferred)
continue;
if (!self_test_kdf(&st_kat_kdf_tests[i], st, libctx))
ret = 0;
return ret;
}
-static int self_test_drbgs(OSSL_SELF_TEST *st, OSSL_LIB_CTX *libctx)
+static int self_test_drbgs(OSSL_SELF_TEST *st, OSSL_LIB_CTX *libctx,
+ int do_deferred)
{
int i, ret = 1;
for (i = 0; i < (int)OSSL_NELEM(st_kat_drbg_tests); ++i) {
- if (st_kat_drbg_tests[i].deferred)
+ if (st_kat_drbg_tests[i].deferred && !do_deferred)
continue;
if (!self_test_drbg(&st_kat_drbg_tests[i], st, libctx))
ret = 0;
return ret;
}
-static int self_test_kas(OSSL_SELF_TEST *st, OSSL_LIB_CTX *libctx)
+static int self_test_kas(OSSL_SELF_TEST *st, OSSL_LIB_CTX *libctx,
+ int do_deferred)
{
int ret = 1;
#if !defined(OPENSSL_NO_DH) || !defined(OPENSSL_NO_EC)
int i;
for (i = 0; i < (int)OSSL_NELEM(st_kat_kas_tests); ++i) {
- if (st_kat_kas_tests[i].deferred)
+ if (st_kat_kas_tests[i].deferred && !do_deferred)
continue;
if (!self_test_ka(&st_kat_kas_tests[i], st, libctx))
ret = 0;
return ret;
}
-static int self_test_signatures(OSSL_SELF_TEST *st, OSSL_LIB_CTX *libctx)
+static int self_test_signatures(OSSL_SELF_TEST *st, OSSL_LIB_CTX *libctx,
+ int do_deferred)
{
int i, ret = 1;
for (i = 0; i < (int)OSSL_NELEM(st_kat_sign_tests); ++i) {
- if (st_kat_sign_tests[i].deferred)
+ if (st_kat_sign_tests[i].deferred && !do_deferred)
continue;
if (!self_test_digest_sign(&st_kat_sign_tests[i], st, libctx))
ret = 0;
return 0;
}
-static int self_test_asym_keygens(OSSL_SELF_TEST *st, OSSL_LIB_CTX *libctx)
+static int self_test_asym_keygens(OSSL_SELF_TEST *st, OSSL_LIB_CTX *libctx,
+ int do_deferred)
{
#if !defined(OPENSSL_NO_ML_DSA) || !defined(OPENSSL_NO_SLH_DSA)
int i, ret = 1;
for (i = 0; i < (int)OSSL_NELEM(st_kat_asym_keygen_tests); ++i) {
- if (st_kat_asym_keygen_tests[i].deferred)
+ if (st_kat_asym_keygen_tests[i].deferred && !do_deferred)
continue;
if (!self_test_asym_keygen(&st_kat_asym_keygen_tests[i], st, libctx))
ret = 0;
* Run the algorithm KAT's.
* Return 1 is successful, otherwise return 0.
* This runs all the tests regardless of if any fail.
+ * when do_deferred is 1 also run deferred tests, they are normally skipped
*/
-int SELF_TEST_kats(OSSL_SELF_TEST *st, OSSL_LIB_CTX *libctx)
+int SELF_TEST_kats(OSSL_SELF_TEST *st, OSSL_LIB_CTX *libctx, int do_deferred)
{
EVP_RAND_CTX *saved_rand = ossl_rand_get0_private_noncreating(libctx);
int ret = 1;
return 0;
}
- if (!self_test_digests(st, libctx))
+ if (!self_test_digests(st, libctx, do_deferred))
ret = 0;
- if (!self_test_ciphers(st, libctx))
+ if (!self_test_ciphers(st, libctx, do_deferred))
ret = 0;
#ifndef OPENSSL_NO_LMS
/*
if (!self_test_LMS(st, libctx))
ret = 0;
#endif /* OPENSSL_NO_LMS */
- if (!self_test_signatures(st, libctx))
+ if (!self_test_signatures(st, libctx, do_deferred))
ret = 0;
- if (!self_test_kdfs(st, libctx))
+ if (!self_test_kdfs(st, libctx, do_deferred))
ret = 0;
- if (!self_test_drbgs(st, libctx))
+ if (!self_test_drbgs(st, libctx, do_deferred))
ret = 0;
- if (!self_test_kas(st, libctx))
+ if (!self_test_kas(st, libctx, do_deferred))
ret = 0;
- if (!self_test_asym_keygens(st, libctx))
+ if (!self_test_asym_keygens(st, libctx, do_deferred))
ret = 0;
- if (!self_test_kems(st, libctx))
+ if (!self_test_kems(st, libctx, do_deferred))
ret = 0;
- if (!self_test_asym_ciphers(st, libctx))
+ if (!self_test_asym_ciphers(st, libctx, do_deferred))
ret = 0;
RAND_set0_private(libctx, saved_rand);