summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorClemens Lang <cllang@redhat.com>2022-06-21 19:00:44 +0200
committerNIIBE Yutaka <gniibe@fsij.org>2022-07-01 16:02:10 +0900
commite78cf3df23a2bf33dc7fdc99e55949732521668d (patch)
tree39aceed8cdf51a060bddc539822da9668d947146 /tests
parent4f4da6cbf065b3ae675e2b0d3ff56765025c2852 (diff)
downloadlibgcrypt-e78cf3df23a2bf33dc7fdc99e55949732521668d.tar.gz
tests/basic: Skip tests if PK algo is unavailable
* tests/basic.c (check_pubkey): Skip tests if the required public key algorithm is not available. -- When libgcrypt is configured with a non-default --enable-pubkey-ciphers option (e.g., without RSA), some of the tests cannot be run because the algorithms are not supported. Check for unsupported algorithms using gcry_pk_test_algo and print a message if they are not available. GnuPG-bug-id: 6048 Signed-off-by: Clemens Lang <cllang@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/basic.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/tests/basic.c b/tests/basic.c
index ab00667e..ecbe58c2 100644
--- a/tests/basic.c
+++ b/tests/basic.c
@@ -206,6 +206,22 @@ show_mac_not_available (int algo)
}
+static void
+show_pk_not_available (int algo)
+{
+ static int list[100];
+ static int listlen;
+ int i;
+
+ for (i = 0; i < listlen; i++)
+ if (algo == list[i])
+ return; /* Note already printed. */
+ if (listlen < DIM (list))
+ list[listlen++] = algo;
+ show_note ("PK algorithm %d not available - skipping tests", algo);
+}
+
+
static void
progress_handler (void *cb_data, const char *what, int printchar,
@@ -9428,6 +9444,8 @@ check_gost28147_cipher_basic (enum gcry_cipher_algos algo)
gcry_cipher_close (hdd);
}
+#else
+ (void) algo;
#endif
}
@@ -17079,7 +17097,7 @@ check_pubkey (void)
}
else
{
- fail ("gcry_pk_test_algo failed: %s\n", gpg_strerror (err));
+ show_pk_not_available (pubkeys[i].id);
continue;
}
}
@@ -17090,7 +17108,10 @@ check_pubkey (void)
if (verbose)
fprintf (stderr, "Starting additional public key check.\n");
- check_one_pubkey_new (i);
+ if (gcry_pk_test_algo (GCRY_PK_RSA) == 0)
+ check_one_pubkey_new (i);
+ else
+ show_pk_not_available (GCRY_PK_RSA);
if (verbose)
fprintf (stderr, "Completed additional public key check.\n");