OpenSC pkcs11 testing suite
OpenSC offers automatic testing tools, useful for debugging purpose.
It will test each RSA key and X.509 certificate.
Of course, this is a non-destructive test.
To run the test, simply type:
Logging in to "Jean-Michel Pouré (User PIN)".
Please enter User PIN:
C_SeedRandom() and C_GenerateRandom():
seeding (C_SeedRandom) not supported
seems to be OK
Digests:
all 4 digest functions seem to work
MD5: OK
SHA-1: OK
RIPEMD160: OK
Signatures (currently only RSA signatures)
testing key 0 (Private Key)
all 4 signature functions seem to work
testing signature mechanisms:
RSA-X-509: OK
RSA-PKCS: OK
SHA1-RSA-PKCS: OK
MD5-RSA-PKCS: OK
RIPEMD160-RSA-PKCS: OK
testing key 1 (2048 bits, label=Private Key) with 1 signature mechanism
MD5-RSA-PKCS: OK
testing key 2 (2048 bits, label=Private Key) with 1 signature mechanism
MD5-RSA-PKCS: OK
Verify (currently only for RSA):
testing key 0 (Private Key)
RSA-X-509: OK
RSA-PKCS: OK
SHA1-RSA-PKCS: OK
MD5-RSA-PKCS: OK
RIPEMD160-RSA-PKCS: OK
testing key 1 (Private Key) with 1 mechanism
RSA-X-509: OK
testing key 2 (Private Key) with 1 mechanism
RSA-X-509: OK
Unwrap: not implemented
Decryption (RSA)
testing key 0 (Private Key) -- can't be used to decrypt, skipping
testing key 1 (Private Key)
RSA-X-509: OK
RSA-PKCS: OK
testing key 2 (Private Key)
RSA-X-509: OK
RSA-PKCS: OK
No errors
Your key/smartcard is usable.
More detailed testing suite for the ePass2003
This sample script can also be used for testing.
WARNING: it will blank and erase ALL DATA on your smartcard/token.
p15temp=/tmp
m=$p15temp/message
h=$p15temp/hashed
s=$p15temp/signed
e=$p15temp/encrypted
d=$p15temp/decrypted
k=$p15temp/puk.rsa.1024.pem
log="v"
openssl genrsa -aes256 2048 > key.priv.pem
openssl rsa -pubout -in key.priv.pem > key.pem
openssl req -new -key key.priv.pem -x509 > key.cert
openssl rand 24 -out 3des.key
echo "This is a test" > plain.txt
rm -rf cipher.bin decipher.txt
# This works for the ePass2003 as well
echo "Creating the PKCS15 (onepin) structure.."
pkcs15-init -$log -E -T
pkcs15-init -$log -C -p pkcs15+onepin --pin 1234 --puk 123456
# DO NOT USE PKCS15 profile until further notice, as it will render the ePass2003 unusable
#echo "Creating the PKCS15 structure.."
#pkcs15-init -$log -E -T
#pkcs15-init -$log -C --pin 1234 --puk 123456 --so-pin 123456 --so-puk 12345678
echo "Generate keypair"
pkcs15-init -$log -G rsa/1024 -i 45 -a 01 -u sign,decrypt --pin 1234
pkcs15-tool --read-public-key 45 -o $k
echo lalla > $m
echo "Signing and verifying using MD5"
openssl dgst -md5 -binary -out $h < $m
pkcs15-crypt -$log -s --md5 --pkcs1 -i $h -o $s
openssl dgst -verify $k -md5 -signature $s < $m
echo "Encrypting message (pkcs1 padding)"
openssl rsautl -pubin -inkey $k -encrypt -in $m -out $e
pkcs15-crypt -$log -c --pkcs1 -i $e -o $d
cmp $d $m
pkcs15-tool -D
#echo "Adding new pin..."
#pkcs15-init -$log -P -a 01 -l "UserName"
echo "Storing private key..."
pkcs15-init -$log -S key.priv.pem -i 46 -a 01 -u sign,decrypt --pin 1234
echo "Storing certificate..."
pkcs15-init -$log -X key.cert -i 46 -a 01 --pin 1234
echo "Generate keypair"
pkcs15-init -$log -G rsa/2048 -i 47 -a 01 -u sign,decrypt --pin 1234
pkcs15-init -$log -G rsa/2048 -i 48 -a 01 -u sign,decrypt --pin 1234
pkcs15-init -$log -G rsa/2048 -i 49 -a 01 -u sign,decrypt --pin 1234
pkcs15-init -$log -G rsa/2048 -i 50 -a 01 -u sign,decrypt --pin 1234
pkcs15-init -$log -G rsa/2048 -i 51 -a 01 -u sign,decrypt --pin 1234
pkcs15-init -$log -G rsa/2048 -i 52 -a 01 -u sign,decrypt --pin 1234
echo "Changing pin..."
pkcs15-tool -$log --change-pin --pin 1234
#echo "Blocking pin..."
#pkcs11-tool -vvvvvvv -t -l
#pkcs11-tool -vvvvvvv -t -l
#pkcs11-tool -vvvvvvv -t -l
#pkcs11-tool -vvvvvvv -t -l
#pkcs11-tool -vvvvvvv -t -l
#pkcs11-tool -vvvvvvv -t -l
#pkcs11-tool -vvvvvvv -t -l
#pkcs11-tool -vvvvvvv -t -l
#pkcs11-tool -vvvvvvv -t -l
#pkcs11-tool -vvvvvvv -t -l
#pkcs11-tool -vvvvvvv -t -l
echo "Unblocking pin..."
pkcs15-tool -$log --unblock-pin --pin 1234 --puk 123456
pkcs15-tool -$log -D
Printer-friendly version- 814 reads
PDF version




