[PATCH 1/7] kdf: Skip tests if hash algo is not available

Clemens Lang cllang at redhat.com
Tue Jun 21 19:00:42 CEST 2022


* tests/t-kdf.c (check_openpgp, check_pbkdf2): Test digest availability.

--

Skip tests that would fail if libgcrypt is compiled with an
--enable-digests option that does not include the required digest
algorithms for the test vectors.

Signed-off-by: Clemens Lang <cllang at redhat.com>
---
 tests/t-kdf.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tests/t-kdf.c b/tests/t-kdf.c
index 4596c5c7..18c0602d 100644
--- a/tests/t-kdf.c
+++ b/tests/t-kdf.c
@@ -862,6 +862,8 @@ check_openpgp (void)
       /* MD5 isn't supported in fips mode */
       if (in_fips_mode && tv[tvidx].hashalgo == GCRY_MD_MD5)
         continue;
+      if (gcry_md_test_algo (tv[tvidx].hashalgo) != 0)
+        continue;
       if (verbose)
         fprintf (stderr, "checking S2K test vector %d\n", tvidx);
       assert (tv[tvidx].dklen <= sizeof outbuf);
@@ -1097,6 +1099,8 @@ check_pbkdf2 (void)
     {
       if (tv[tvidx].disabled)
         continue;
+      if (gcry_md_test_algo (tv[tvidx].hashalgo) != 0)
+        continue;
       if (verbose)
         fprintf (stderr, "checking PBKDF2 test vector %d algo %d\n", tvidx,
                  tv[tvidx].hashalgo);
-- 
2.35.3




More information about the Gcrypt-devel mailing list