]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
tests: simple: check if the digest algorithm is compiled in
authorDaiki Ueno <ueno@gnu.org>
Wed, 12 Jan 2022 07:15:24 +0000 (08:15 +0100)
committerDaiki Ueno <ueno@gnu.org>
Wed, 12 Jan 2022 07:16:03 +0000 (08:16 +0100)
When the library is built with --disable-gost, gnutls_digest_get_id
returns GNUTLS_DIG_UNKNOWN for GOST algorithms.

Signed-off-by: Daiki Ueno <ueno@gnu.org>
tests/simple.c

index 5e20c61182d727db9fcbbb267c7df286e5f27baf..b2d53d8032a1b4a9c12eee71bcc73b4aa633eafd 100644 (file)
@@ -128,7 +128,12 @@ void doit(void)
                        hash = gnutls_sign_get_hash_algorithm(algs[i]);
                        if (hash != GNUTLS_DIG_UNKNOWN) {
                                const char *name = gnutls_digest_get_name(hash);
-                               if (gnutls_digest_get_id(name) != hash)
+                               gnutls_digest_algorithm_t hash2 = gnutls_digest_get_id(name);
+                               /* gnutls_digest_get_id returns
+                                * GNUTLS_DIG_UNKNOWN if the algorithm is not
+                                * compiled in.
+                                */
+                               if (hash2 != GNUTLS_DIG_UNKNOWN && hash2 != hash)
                                        fail("gnutls_digest id for %s doesn't match %s\n",
                                             gnutls_sign_algorithm_get_name(algs[i]),
                                             name);