summaryrefslogtreecommitdiff
path: root/tests/keygen.c
diff options
context:
space:
mode:
authorClemens Lang <cllang@redhat.com>2022-06-21 19:00:46 +0200
committerNIIBE Yutaka <gniibe@fsij.org>2022-07-01 16:02:51 +0900
commit572b0bf9668d6a01cd7ce1c2227d5a4899ad3502 (patch)
tree9239a8e9bc10046ec44d1201fa267ffb95736acd /tests/keygen.c
parent78c0d76f809262184ef0198be087fc2b133c880b (diff)
downloadlibgcrypt-572b0bf9668d6a01cd7ce1c2227d5a4899ad3502.tar.gz
tests/keygen.c: Skip unavailable PK algorithms
* tests/keygen.c (show_mpi, check_rsa_keys, check_elg_keys, check_dsa_keys, check_generated_ecc_key, check_ecc_keys): Skip tests if the required public key algorithm is not available. -- When libgcrypt is configured with a non-default --enable-pubkey-ciphers option, some of the keygen tests cannot be run because the algorithms are not supported. Disable those using preprocessor macros. GnuPG-bug-id: 6048 Signed-off-by: Clemens Lang <cllang@redhat.com>
Diffstat (limited to 'tests/keygen.c')
-rw-r--r--tests/keygen.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/keygen.c b/tests/keygen.c
index 5b154c94..45cd0dcc 100644
--- a/tests/keygen.c
+++ b/tests/keygen.c
@@ -69,6 +69,7 @@ show_sexp (const char *prefix, gcry_sexp_t a)
}
+#if USE_RSA
static void
show_mpi (const char *prefix, gcry_mpi_t a)
{
@@ -131,11 +132,13 @@ check_generated_rsa_key (gcry_sexp_t key, unsigned long expected_e)
gcry_sexp_release (skey);
}
}
+#endif /* USE_RSA */
static void
check_rsa_keys (void)
{
+#if USE_RSA
gcry_sexp_t keyparm, key;
int rc;
@@ -249,12 +252,14 @@ check_rsa_keys (void)
if (!rc)
check_generated_rsa_key (key, 0); /* We don't expect a constant exponent. */
gcry_sexp_release (key);
+#endif /* USE_RSA */
}
static void
check_elg_keys (void)
{
+#if USE_ELGAMAL
gcry_sexp_t keyparm, key;
int rc;
@@ -276,12 +281,14 @@ check_elg_keys (void)
if (verbose > 1)
show_sexp ("1024 bit Elgamal key:\n", key);
gcry_sexp_release (key);
+#endif /* USE_ELGAMAL */
}
static void
check_dsa_keys (void)
{
+#if USE_DSA
gcry_sexp_t keyparm, key;
int rc;
int i;
@@ -389,9 +396,11 @@ check_dsa_keys (void)
if (verbose > 1)
show_sexp ("2048 bit DSA key:\n", key);
gcry_sexp_release (key);
+#endif /* USE_DSA */
}
+#if USE_ECC
static void
check_generated_ecc_key (gcry_sexp_t key)
{
@@ -425,11 +434,13 @@ check_generated_ecc_key (gcry_sexp_t key)
fail ("gcry_pk_testkey failed on key pair: %s\n", gpg_strerror (rc));
}
}
+#endif /* USE_ECC */
static void
check_ecc_keys (void)
{
+#if USE_ECC
const char *curves[] = { "NIST P-521", "NIST P-384", "NIST P-256",
"Ed25519", NULL };
int testno;
@@ -611,6 +622,7 @@ check_ecc_keys (void)
check_generated_ecc_key (key);
}
gcry_sexp_release (key);
+#endif /* USE_ECC */
}