[pkg-opensc-commit] [engine-pkcs11] 128/152: tests: enhanced test suite to include legacy IDs

Eric Dorland eric at moszumanska.debian.org
Mon Oct 19 03:11:25 UTC 2015


This is an automated email from the git hooks/post-receive script.

eric pushed a commit to branch master
in repository engine-pkcs11.

commit 8d7c6e8a5594270bd38b2899581b83874f0843e6
Author: Nikos Mavrogiannopoulos <nmav at redhat.com>
Date:   Tue Sep 15 15:37:45 2015 +0200

    tests: enhanced test suite to include legacy IDs
---
 tests/evp-sign.c | 22 +++++++++++-----------
 tests/softhsm    | 22 ++++++++++++++++++++--
 2 files changed, 31 insertions(+), 13 deletions(-)

diff --git a/tests/evp-sign.c b/tests/evp-sign.c
index f371fdb..96947e8 100755
--- a/tests/evp-sign.c
+++ b/tests/evp-sign.c
@@ -63,7 +63,7 @@ int main(int argc, char **argv)
 	unsigned char buf[4096];
 	const EVP_MD *digest_algo;
 	EVP_PKEY *private_key, *pubkey;
-	char *key_pass;
+	char *key_pass = NULL;
 	X509 *x509;
 	unsigned n;
 	int ret;
@@ -71,20 +71,22 @@ int main(int argc, char **argv)
 	ENGINE *e;
 	CONF *conf;
 	EVP_MD_CTX ctx;
-	const char *module_path;
+	const char *module_path, *efile;
 	BIO *in, *b;
 
-	if (argc < 4) {
-		fprintf(stderr, "usage: %s [CONF] [private key URL] [module]\n", argv[0]);
+	if (argc < 5) {
+		fprintf(stderr, "usage: %s [PIN] [CONF] [private key URL] [module]\n", argv[0]);
 		exit(1);
 	}
 
-	private_key_name = argv[2];
-	module_path = argv[3];
+	key_pass = argv[1];
+	private_key_name = argv[3];
+	module_path = argv[4];
+	efile = argv[2];
 
-	ret = CONF_modules_load_file(argv[1], "engines", 0);
+	ret = CONF_modules_load_file(efile, "engines", 0);
 	if (ret <= 0) {
-		fprintf(stderr, "cannot load %s\n", argv[1]);
+		fprintf(stderr, "cannot load %s\n", efile);
 		display_openssl_errors(__LINE__);
 		exit(1);
 	}
@@ -111,12 +113,10 @@ int main(int argc, char **argv)
 		exit(1);
 	}
 
-#if 0
-	if (!ENGINE_ctrl_cmd_string(e, "PIN", key_pass, 0)) {
+	if (key_pass && !ENGINE_ctrl_cmd_string(e, "PIN", key_pass, 0)) {
 		display_openssl_errors(__LINE__);
 		exit(1);
 	}
-#endif
 
 	private_key = ENGINE_load_private_key(e, private_key_name, NULL, NULL);
 	if (!private_key) {
diff --git a/tests/softhsm b/tests/softhsm
index 97ae308..3aa37b0 100755
--- a/tests/softhsm
+++ b/tests/softhsm
@@ -27,9 +27,27 @@ sed -e "s|@MODULE_PATH@|${ADDITIONAL_PARAM}|g" -e "s|@ENGINE_PATH@|../src/.libs/
 
 export OPENSSL_ENGINES="../src/.libs/"
 
-./evp-sign engines.cnf "pkcs11:model=SoftHSM%20v2;manufacturer=SoftHSM%20project;token=libp11-test;id=%00%01%02%03;object=server-key;type=private;pin-value=1234" ${ADDITIONAL_PARAM}
+./evp-sign false engines.cnf "pkcs11:model=SoftHSM%20v2;manufacturer=SoftHSM%20project;token=libp11-test;id=%00%01%02%03;object=server-key;type=private;pin-value=1234" ${ADDITIONAL_PARAM}
 if test $? != 0;then
-	echo "Basic PKCS #11 test test failed"
+	echo "Basic PKCS #11 test failed"
+	exit 1;
+fi
+
+./evp-sign 1234 engines.cnf "pkcs11:model=SoftHSM%20v2;manufacturer=SoftHSM%20project;token=libp11-test;id=%00%01%02%03;object=server-key;type=private" ${ADDITIONAL_PARAM}
+if test $? != 0;then
+	echo "Basic PKCS #11 test without pin-value failed"
+	exit 1;
+fi
+
+./evp-sign 1234 engines.cnf "label_server-key" ${ADDITIONAL_PARAM}
+if test $? != 0;then
+	echo "Basic PKCS #11 test with legacy name #1 failed"
+	exit 1;
+fi
+
+./evp-sign 1234 engines.cnf "id_00010203" ${ADDITIONAL_PARAM}
+if test $? != 0;then
+	echo "Basic PKCS #11 test with legacy name #2 failed"
 	exit 1;
 fi
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-opensc/engine-pkcs11.git



More information about the pkg-opensc-commit mailing list