]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
tests: added checks for gnutls_x509_crt_get_signature_algorithm and gnutls_x509_crt_g...
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Sat, 21 Feb 2015 06:35:01 +0000 (07:35 +0100)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Sat, 21 Feb 2015 06:35:01 +0000 (07:35 +0100)
tests/x509cert-tl.c

index ae247b931c776e1b3f4889f79f02de9f0f7645a5..8ee541c807f42037c9fdd4bd52bdfde6abd3138e 100644 (file)
@@ -195,6 +195,8 @@ void doit(void)
        gnutls_x509_trust_list_t tl;
        unsigned int status;
        gnutls_typed_vdata_st vdata;
+       gnutls_digest_algorithm_t hash;
+       unsigned int mand;
 
        /* this must be called once in the program
         */
@@ -220,6 +222,23 @@ void doit(void)
        if (ret < 0)
                fail("gnutls_x509_crt_import");
 
+       ret = gnutls_x509_crt_get_signature_algorithm(server_crt);
+       if (ret != GNUTLS_SIGN_RSA_SHA1) {
+               fail("detected wrong algorithm: %s\n", gnutls_sign_get_name(ret));
+               exit(1);
+       }
+
+       ret = gnutls_x509_crt_get_preferred_hash_algorithm(server_crt, &hash, &mand);
+       if (ret < 0) {
+               fail("error in gnutls_x509_crt_get_preferred_hash_algorithm: %s\n", gnutls_strerror(ret));
+               exit(1);
+       }
+
+       if (mand != 0 || hash != GNUTLS_DIG_SHA256) {
+               fail("gnutls_x509_crt_get_preferred_hash_algorithm returned: %s/%d\n", gnutls_digest_get_name(hash), mand);
+               exit(1);
+       }
+
        ret = gnutls_x509_crt_import(ca_crt2, &ca, GNUTLS_X509_FMT_PEM);
        if (ret < 0)
                fail("gnutls_x509_crt_import");