]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
tests: check whether PKCS #11 ID set on copy/generation is correct
authorNikos Mavrogiannopoulos <nmav@redhat.com>
Tue, 31 Mar 2015 06:48:37 +0000 (08:48 +0200)
committerNikos Mavrogiannopoulos <nmav@redhat.com>
Tue, 31 Mar 2015 06:49:53 +0000 (08:49 +0200)
tests/suite/testpkcs11

index eb8a53159a514d499f9ebb53defdabb12f1ca60f..2a4b88fee59927823d9dae07611e702104813784 100755 (executable)
@@ -120,7 +120,7 @@ generate_rsa_privkey () {
        bits=$3
 
        echo -n "* Generating RSA private key ($bits)... "
-       $P11TOOL $ADDITIONAL_PARAM --login --label gnutls-client --generate-rsa --bits $bits "$token" --outfile tmp-client.pub >>$TMPFILE 2>&1
+       $P11TOOL $ADDITIONAL_PARAM --login --id 000102030405 --label gnutls-client --generate-rsa --bits $bits "$token" --outfile tmp-client.pub >>$TMPFILE 2>&1
        if test $? = 0;then
                echo ok
        else
@@ -218,7 +218,7 @@ change_id_of_privkey () {
        token=$1
 
        echo -n "* Change the CKA_ID of generated private key... "
-       $P11TOOL $ADDITIONAL_PARAM --login --set-id "01a1b103" "$token;object=gnutls-client;object-type=private" >>$TMPFILE 2>&1
+       $P11TOOL $ADDITIONAL_PARAM --login --set-id "01a1b103" "$token;object=gnutls-client;id=%00%01%02%03%04%05;object-type=private" >>$TMPFILE 2>&1
        if test $? != 0;then
                echo failed
                exit_error
@@ -307,7 +307,7 @@ write_certificate_test () {
        fi
 
        echo -n "* Writing client certificate... "
-       $P11TOOL $ADDITIONAL_PARAM --login --write --label gnutls-client --load-certificate tmp-client.crt "$token" >>$TMPFILE 2>&1
+       $P11TOOL $ADDITIONAL_PARAM --login --write --id "01a1b103" --label gnutls-client --load-certificate tmp-client.crt "$token" >>$TMPFILE 2>&1
        if test $? = 0;then
                echo ok
        else
@@ -315,6 +315,14 @@ write_certificate_test () {
                exit_error
        fi
 
+       echo -n "* Checking whether ID was correctly set... "
+       $P11TOOL $ADDITIONAL_PARAM --login --list-certs "$token;object=gnutls-client;object-type=private;id=%01%a1%b1%03" 2>&1 | grep 'ID: 01:a1:b1:03' >>$TMPFILE 2>&1
+       if test $? != 0;then
+               echo "ID was not set on copy"
+               exit_error
+       fi
+       echo ok
+
        echo -n "* Writing certificate of client's CA... "
        $P11TOOL $ADDITIONAL_PARAM --login --mark-trusted --mark-ca --write --label gnutls-ca --load-certificate "$cacert" "$token" >>$TMPFILE 2>&1
        ret=$?