summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2017-05-31 08:55:54 +0200
committerNikos Mavrogiannopoulos <nmav@redhat.com>2017-05-31 14:50:22 +0200
commitdbbbb05cbe9f09e1ac6a700761988095ee428c11 (patch)
tree69e279791460e645eaa085988c9f8239333fc64a /tests
parent008c1cf31bca12db9b33827b93d14b1b87da7c67 (diff)
downloadgnutls-dbbbb05cbe9f09e1ac6a700761988095ee428c11.tar.gz
tests: combined tables of sign-verify teststmp-rsa-pss-round-two
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am2
-rw-r--r--tests/cert-common.h1
-rw-r--r--tests/common-key-tests.h72
-rw-r--r--tests/sign-verify-data.c43
-rw-r--r--tests/sign-verify-ext.c53
-rw-r--r--tests/sign-verify.c49
-rw-r--r--tests/x509sign-verify.c44
7 files changed, 89 insertions, 175 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 3ad0c84bae..50830addd8 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -43,7 +43,7 @@ EXTRA_DIST = suppressions.valgrind eagain-common.h cert-common.h test-chains.h \
pkcs7-interesting/pkcs7-1.der.err pkcs7-interesting/pkcs7-2.der pkcs7-interesting/pkcs7-2.der.err \
client-interesting/client1.raw client-interesting/client2.raw client-interesting/client3.disabled \
server-interesting/server1.raw scripts/common.sh scripts/starttls-common.sh \
- client-interesting/client3.raw rng-op.c x509sign-verify-common.h \
+ client-interesting/client3.raw rng-op.c x509sign-verify-common.h common-key-tests.h \
ocsp-tests/certs/ca.key ocsp-tests/certs/ca.pem ocsp-tests/certs/ocsp-server.key ocsp-tests/certs/ocsp-server.pem ocsp-tests/response1.der \
ocsp-tests/response2.der ocsp-tests/certs/ocsp_index.txt ocsp-tests/certs/ocsp_index.txt.attr \
ocsp-tests/certs/server_good.key ocsp-tests/certs/server_bad.key ocsp-tests/certs/server_good.template \
diff --git a/tests/cert-common.h b/tests/cert-common.h
index 313a173e82..4d3b6b25d3 100644
--- a/tests/cert-common.h
+++ b/tests/cert-common.h
@@ -22,7 +22,6 @@
#include <gnutls/gnutls.h>
-
/* This file contains a lot of common parameters used by legacy and new
* tests. The recommended to use for new tests are:
*
diff --git a/tests/common-key-tests.h b/tests/common-key-tests.h
new file mode 100644
index 0000000000..464d73353c
--- /dev/null
+++ b/tests/common-key-tests.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2017 Red Hat Inc.
+ *
+ * Author: Nikos Mavrogiannopoulos
+ *
+ * This file is part of GnuTLS.
+ *
+ * GnuTLS is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GnuTLS is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GnuTLS; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include "cert-common.h"
+
+#include <gnutls/abstract.h>
+
+struct _key_tests_st {
+ const char *name;
+ gnutls_datum_t key;
+ gnutls_datum_t cert;
+ gnutls_pk_algorithm_t pk;
+ unsigned digest;
+ unsigned sigalgo;
+ unsigned sign_flags;
+};
+
+static const
+struct _key_tests_st common_key_tests[] = {
+ {
+ .name = "rsa key",
+ .cert = {(void *) cli_ca3_cert_pem, sizeof(cli_ca3_cert_pem)-1},
+ .key = {(void *) cli_ca3_key_pem, sizeof(cli_ca3_key_pem)-1},
+ .pk = GNUTLS_PK_RSA,
+ .digest = GNUTLS_DIG_SHA256,
+ .sigalgo = GNUTLS_SIGN_RSA_SHA256
+ },
+ {
+ .name = "dsa key",
+ .key = {(void *) clidsa_ca3_key_pem, sizeof(clidsa_ca3_key_pem)-1},
+ .cert = {(void *) clidsa_ca3_cert_pem, sizeof(clidsa_ca3_cert_pem)-1},
+ .pk = GNUTLS_PK_DSA,
+ .digest = GNUTLS_DIG_SHA1,
+ .sigalgo = GNUTLS_SIGN_DSA_SHA1
+ },
+ {
+ .name = "ecdsa key",
+ .key = {(void *) server_ca3_ecc_key_pem, sizeof(server_ca3_ecc_key_pem)-1},
+ .cert = {(void *) server_localhost_ca3_ecc_cert_pem, sizeof(server_localhost_ca3_ecc_cert_pem)-1},
+ .pk = GNUTLS_PK_ECDSA,
+ .digest = GNUTLS_DIG_SHA256,
+ .sigalgo = GNUTLS_SIGN_ECDSA_SHA256
+ },
+ {
+ .name = "rsa pss key",
+ .key = {(void *) server_ca3_rsa_pss_key_pem, sizeof(server_ca3_rsa_pss_key_pem)-1},
+ .cert = {(void *) server_ca3_rsa_pss_cert_pem, sizeof(server_ca3_rsa_pss_cert_pem)-1},
+ .pk = GNUTLS_PK_RSA_PSS,
+ .digest = GNUTLS_DIG_SHA256,
+ .sign_flags = GNUTLS_PRIVKEY_SIGN_FLAG_RSA_PSS,
+ .sigalgo = GNUTLS_SIGN_RSA_PSS_SHA256
+ }
+};
diff --git a/tests/sign-verify-data.c b/tests/sign-verify-data.c
index b638146cc3..cbcee12333 100644
--- a/tests/sign-verify-data.c
+++ b/tests/sign-verify-data.c
@@ -37,7 +37,7 @@
#include <gnutls/gnutls.h>
#include <gnutls/x509.h>
#include <gnutls/abstract.h>
-#include "cert-common.h"
+#include "common-key-tests.h"
#include "utils.h"
/* verifies whether the sign-data and verify-data APIs
@@ -63,44 +63,7 @@ const gnutls_datum_t invalid_raw_data = {
20
};
-struct tests_st {
- const char *name;
- gnutls_datum_t key;
- gnutls_datum_t cert;
- gnutls_pk_algorithm_t pk;
- unsigned digest;
- unsigned sigalgo;
- unsigned sign_flags;
-};
-
-struct tests_st tests[] = {
- {
- .name = "rsa key",
- .cert = {(void *) cli_ca3_cert_pem, sizeof(cli_ca3_cert_pem)-1},
- .key = {(void *) cli_ca3_key_pem, sizeof(cli_ca3_key_pem)-1},
- .pk = GNUTLS_PK_RSA,
- .digest = GNUTLS_DIG_SHA256,
- .sigalgo = GNUTLS_SIGN_RSA_SHA256
- },
- {
- .name = "ecdsa key",
- .key = {(void *) server_ca3_ecc_key_pem, sizeof(server_ca3_ecc_key_pem)-1},
- .cert = {(void *) server_localhost_ca3_ecc_cert_pem, sizeof(server_localhost_ca3_ecc_cert_pem)-1},
- .pk = GNUTLS_PK_ECDSA,
- .digest = GNUTLS_DIG_SHA256,
- .sigalgo = GNUTLS_SIGN_ECDSA_SHA256
- },
- {
- .name = "rsa pss key",
- .key = {(void *) server_ca3_rsa_pss_key_pem, sizeof(server_ca3_rsa_pss_key_pem)-1},
- .cert = {(void *) server_ca3_rsa_pss_cert_pem, sizeof(server_ca3_rsa_pss_cert_pem)-1},
- .pk = GNUTLS_PK_RSA_PSS,
- .digest = GNUTLS_DIG_SHA256,
- .sign_flags = GNUTLS_PRIVKEY_SIGN_FLAG_RSA_PSS,
- .sigalgo = GNUTLS_SIGN_RSA_PSS_SHA256
- }
-};
-
+#define tests common_key_tests
#define testfail(fmt, ...) \
fail("%s: "fmt, tests[i].name, ##__VA_ARGS__)
@@ -124,6 +87,8 @@ void doit(void)
if (debug)
success("loop %d\n", (int) i);
+ if (tests[i].pk == GNUTLS_PK_DSA)
+ continue;
ret = gnutls_pubkey_init(&pubkey);
if (ret < 0)
testfail("gnutls_privkey_init\n");
diff --git a/tests/sign-verify-ext.c b/tests/sign-verify-ext.c
index 08990be6d3..11812b77eb 100644
--- a/tests/sign-verify-ext.c
+++ b/tests/sign-verify-ext.c
@@ -39,7 +39,7 @@
#include <gnutls/gnutls.h>
#include <gnutls/x509.h>
#include <gnutls/abstract.h>
-#include "cert-common.h"
+#include "common-key-tests.h"
#include "utils.h"
static void tls_log_func(int level, const char *str)
@@ -67,53 +67,6 @@ const gnutls_datum_t raw_data = {
5
};
-struct tests_st {
- const char *name;
- gnutls_datum_t key;
- gnutls_datum_t cert;
- gnutls_pk_algorithm_t pk;
- unsigned digest;
- unsigned sigalgo;
- unsigned sign_flags;
-};
-
-struct tests_st tests[] = {
- {
- .name = "rsa key",
- .cert = {(void *) cli_ca3_cert_pem, sizeof(cli_ca3_cert_pem)-1},
- .key = {(void *) cli_ca3_key_pem, sizeof(cli_ca3_key_pem)-1},
- .pk = GNUTLS_PK_RSA,
- .digest = GNUTLS_DIG_SHA256,
- .sigalgo = GNUTLS_SIGN_RSA_SHA256
- },
- {
- .name = "dsa key",
- .key = {(void *) clidsa_ca3_key_pem, sizeof(clidsa_ca3_key_pem)-1},
- .cert = {(void *) clidsa_ca3_cert_pem, sizeof(clidsa_ca3_cert_pem)-1},
- .pk = GNUTLS_PK_DSA,
- .digest = GNUTLS_DIG_SHA1,
- .sigalgo = GNUTLS_SIGN_DSA_SHA1
- },
- {
- .name = "ecdsa key",
- .key = {(void *) server_ca3_ecc_key_pem, sizeof(server_ca3_ecc_key_pem)-1},
- .cert = {(void *) server_localhost_ca3_ecc_cert_pem, sizeof(server_localhost_ca3_ecc_cert_pem)-1},
- .pk = GNUTLS_PK_ECDSA,
- .digest = GNUTLS_DIG_SHA256,
- .sigalgo = GNUTLS_SIGN_ECDSA_SHA256
- },
-#if 0
- {
- .name = "rsa pss key",
- .key = {(void *) server_ca3_rsa_pss_key_pem, sizeof(server_ca3_rsa_pss_key_pem)-1},
- .cert = {(void *) server_ca3_rsa_pss_cert_pem, sizeof(server_ca3_rsa_pss_cert_pem)-1},
- .pk = GNUTLS_PK_RSA_PSS,
- .digest = GNUTLS_DIG_SHA256,
- .sign_flags = GNUTLS_PRIVKEY_SIGN_FLAG_RSA_PSS,
- .sigalgo = GNUTLS_SIGN_RSA_PSS_SHA256
- }
-#endif
-};
struct key_cb_data {
gnutls_privkey_t rkey; /* the real thing */
@@ -166,6 +119,7 @@ static gnutls_privkey_t load_virt_privkey(const gnutls_datum_t *txtkey, gnutls_p
return privkey;
}
+#define tests common_key_tests
#define testfail(fmt, ...) \
fail("%s: "fmt, tests[i].name, ##__VA_ARGS__)
@@ -190,6 +144,9 @@ void doit(void)
if (debug)
success("loop %d: %s\n", (int) i, tests[i].name);
+ if (tests[i].pk == GNUTLS_PK_RSA_PSS)
+ continue;
+
if (tests[i].digest == GNUTLS_DIG_SHA1) {
hash_data = &sha1_hash_data;
} else {
diff --git a/tests/sign-verify.c b/tests/sign-verify.c
index 69b004f427..81a1152962 100644
--- a/tests/sign-verify.c
+++ b/tests/sign-verify.c
@@ -39,7 +39,7 @@
#include <gnutls/gnutls.h>
#include <gnutls/x509.h>
#include <gnutls/abstract.h>
-#include "cert-common.h"
+#include "common-key-tests.h"
#include "utils.h"
static void tls_log_func(int level, const char *str)
@@ -81,52 +81,7 @@ const gnutls_datum_t raw_data = {
5
};
-struct tests_st {
- const char *name;
- gnutls_datum_t key;
- gnutls_datum_t cert;
- gnutls_pk_algorithm_t pk;
- unsigned digest;
- unsigned sigalgo;
- unsigned sign_flags;
-};
-
-struct tests_st tests[] = {
- {
- .name = "rsa key",
- .cert = {(void *) cli_ca3_cert_pem, sizeof(cli_ca3_cert_pem)-1},
- .key = {(void *) cli_ca3_key_pem, sizeof(cli_ca3_key_pem)-1},
- .pk = GNUTLS_PK_RSA,
- .digest = GNUTLS_DIG_SHA256,
- .sigalgo = GNUTLS_SIGN_RSA_SHA256
- },
- {
- .name = "dsa key",
- .key = {(void *) clidsa_ca3_key_pem, sizeof(clidsa_ca3_key_pem)-1},
- .cert = {(void *) clidsa_ca3_cert_pem, sizeof(clidsa_ca3_cert_pem)-1},
- .pk = GNUTLS_PK_DSA,
- .digest = GNUTLS_DIG_SHA1,
- .sigalgo = GNUTLS_SIGN_DSA_SHA1
- },
- {
- .name = "ecdsa key",
- .key = {(void *) server_ca3_ecc_key_pem, sizeof(server_ca3_ecc_key_pem)-1},
- .cert = {(void *) server_localhost_ca3_ecc_cert_pem, sizeof(server_localhost_ca3_ecc_cert_pem)-1},
- .pk = GNUTLS_PK_ECDSA,
- .digest = GNUTLS_DIG_SHA256,
- .sigalgo = GNUTLS_SIGN_ECDSA_SHA256
- },
- {
- .name = "rsa pss key",
- .key = {(void *) server_ca3_rsa_pss_key_pem, sizeof(server_ca3_rsa_pss_key_pem)-1},
- .cert = {(void *) server_ca3_rsa_pss_cert_pem, sizeof(server_ca3_rsa_pss_cert_pem)-1},
- .pk = GNUTLS_PK_RSA_PSS,
- .digest = GNUTLS_DIG_SHA256,
- .sign_flags = GNUTLS_PRIVKEY_SIGN_FLAG_RSA_PSS,
- .sigalgo = GNUTLS_SIGN_RSA_PSS_SHA256
- }
-};
-
+#define tests common_key_tests
#define testfail(fmt, ...) \
fail("%s: "fmt, tests[i].name, ##__VA_ARGS__)
diff --git a/tests/x509sign-verify.c b/tests/x509sign-verify.c
index 55633c8319..63a4b90775 100644
--- a/tests/x509sign-verify.c
+++ b/tests/x509sign-verify.c
@@ -37,7 +37,7 @@
#include <gnutls/gnutls.h>
#include <gnutls/x509.h>
#include <gnutls/abstract.h>
-#include "cert-common.h"
+#include "common-key-tests.h"
#include "utils.h"
/* verifies whether the sign-data and verify-data APIs
@@ -63,44 +63,7 @@ const gnutls_datum_t invalid_raw_data = {
20
};
-struct tests_st {
- const char *name;
- gnutls_datum_t key;
- gnutls_datum_t cert;
- gnutls_pk_algorithm_t pk;
- unsigned digest;
- unsigned sigalgo;
- unsigned sign_flags;
-};
-
-struct tests_st tests[] = {
- {
- .name = "rsa key",
- .cert = {(void *) cli_ca3_cert_pem, sizeof(cli_ca3_cert_pem)-1},
- .key = {(void *) cli_ca3_key_pem, sizeof(cli_ca3_key_pem)-1},
- .pk = GNUTLS_PK_RSA,
- .digest = GNUTLS_DIG_SHA256,
- .sigalgo = GNUTLS_SIGN_RSA_SHA256
- },
- {
- .name = "ecdsa key",
- .key = {(void *) server_ca3_ecc_key_pem, sizeof(server_ca3_ecc_key_pem)-1},
- .cert = {(void *) server_localhost_ca3_ecc_cert_pem, sizeof(server_localhost_ca3_ecc_cert_pem)-1},
- .pk = GNUTLS_PK_ECDSA,
- .digest = GNUTLS_DIG_SHA256,
- .sigalgo = GNUTLS_SIGN_ECDSA_SHA256
- },
- {
- .name = "rsa pss key",
- .key = {(void *) server_ca3_rsa_pss_key_pem, sizeof(server_ca3_rsa_pss_key_pem)-1},
- .cert = {(void *) server_ca3_rsa_pss_cert_pem, sizeof(server_ca3_rsa_pss_cert_pem)-1},
- .pk = GNUTLS_PK_RSA_PSS,
- .digest = GNUTLS_DIG_SHA256,
- .sign_flags = GNUTLS_PRIVKEY_SIGN_FLAG_RSA_PSS,
- .sigalgo = GNUTLS_SIGN_RSA_PSS_SHA256
- }
-};
-
+#define tests common_key_tests
#define testfail(fmt, ...) \
fail("%s: "fmt, tests[i].name, ##__VA_ARGS__)
@@ -122,6 +85,9 @@ void doit(void)
gnutls_global_set_log_level(6);
for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) {
+ if (tests[i].pk == GNUTLS_PK_DSA)
+ continue;
+
if (debug)
success("loop %d\n", (int) i);