@@ -10,6 +10,8 @@ export SIGN_KEY=11
1010export ENC_KEY=55
1111```
1212
13+ ## Functionality of card
14+
1315You can find the IDs of the objects on card with the ` -O ` option:
1416
1517``` sh
@@ -22,6 +24,62 @@ and the mechanisms that the card supports with the `-M` option:
2224pkcs11-tool -M
2325```
2426
27+ Perform a basic functionality test of the card:
28+
29+ ``` sh
30+ pkcs11-tool --test --login
31+ ```
32+
33+ ## Reading objects from card
34+
35+ List all certificates on the smart card:
36+
37+ ``` sh
38+ pkcs11-tool --list-objects --type cert
39+ ```
40+
41+ Read the certificate with ID ` CERT_ID ` in DER format from smart card and convert it to PEM via OpenSSL:
42+
43+ ``` sh
44+ pkcs11-tool --read-object --id $CERT_ID --type cert --output-file cert.der
45+ openssl x509 -inform DER -in cert.der -outform PEM > cert.pem
46+ ```
47+
48+ List private keys:
49+
50+ ``` sh
51+ pkcs11-tool --login --list-objects --type privkey
52+ ```
53+
54+ Write a certificate to token:
55+
56+ ``` sh
57+ pkcs11-tool --login --write-object certificate.der --type cert
58+ ```
59+
60+ ## Generate keys
61+
62+ Generate new RSA Key pair:
63+
64+ ``` sh
65+ pkcs11-tool --login --keypairgen --key-type RSA:2048
66+ ```
67+
68+ Generate new extractable RSA Key pair:
69+
70+ ``` sh
71+ pkcs11-tool --login --keypairgen --key-type RSA:2048 --extractable
72+ ```
73+
74+ Generate an elliptic curve key pair with OpenSSL and import it to the card as ` $ID ` :
75+
76+ ``` sh
77+ openssl genpkey -out EC_private.der -outform DER -algorithm EC -pkeyopt ec_paramgen_curve:P-521
78+ pkcs11-tool --write-object EC_private.der --id " $ID " --type privkey --label " EC private key" -p " $PIN "
79+ openssl pkey -in EC_private.der -out EC_public.der -pubout -inform DER -outform DER
80+ pkcs11-tool --write-object EC_public.der --id " $ID " --type pubkey --label " EC public key" -p $PIN
81+ ```
82+
2583## Sign/Verify using private key/certificate
2684
2785* Create a data to sign:
0 commit comments