Skip to content

Commit 748bae4

Browse files
committed
doc: beautify pkcs11-tool man page examples
1 parent 00ab96d commit 748bae4

File tree

1 file changed

+43
-32
lines changed

1 file changed

+43
-32
lines changed

doc/tools/pkcs11-tool.1.xml

+43-32
Original file line numberDiff line numberDiff line change
@@ -710,19 +710,19 @@
710710
Perform a basic functionality test of the card:
711711
<programlisting>pkcs11-tool --test --login</programlisting>
712712

713-
To list all certificates on the smart card:
713+
List all certificates on the smart card:
714714
<programlisting>pkcs11-tool --list-objects --type cert</programlisting>
715715

716-
To read the certificate with ID <replaceable>KEY_ID</replaceable>
717-
in DER format from smart card:
718-
<programlisting>pkcs11-tool --read-object --id KEY_ID --type cert --output-file cert.der</programlisting>
716+
Read the certificate with ID <varname>CERT_ID</varname>
717+
in DER format from smart card and convert it to PEM via OpenSSL:
718+
<programlisting>
719+
pkcs11-tool --read-object --id $CERT_ID --type cert \
720+
--output-file cert.der
721+
openssl x509 -inform DER -in cert.der -outform PEM > cert.pem
722+
</programlisting>
719723

720-
Write certificate to token:
721-
<programlisting> pkcs11-tool --login --write-object certificate.der --type cert</programlisting>
722-
723-
To convert the certificate in DER format to PEM format, use OpenSSL
724-
tools:
725-
<programlisting>openssl x509 -inform DER -in cert.der -outform PEM > cert.pem</programlisting>
724+
Write a certificate to token:
725+
<programlisting>pkcs11-tool --login --write-object certificate.der --type cert</programlisting>
726726

727727
Generate new RSA Key pair:
728728
<programlisting>pkcs11-tool --login --keypairgen --key-type RSA:2048</programlisting>
@@ -732,58 +732,69 @@
732732

733733
Generate an elliptic curve key pair with OpenSSL and import it to the card as <varname>$ID</varname>:
734734
<programlisting>openssl genpkey -out EC_private.der -outform DER \
735-
-algorithm EC -pkeyopt ec_paramgen_curve:P-521
735+
-algorithm EC -pkeyopt ec_paramgen_curve:P-521
736736
pkcs11-tool --write-object EC_private.der --id "$ID" \
737-
--type privkey --label "EC private key" -p "$PIN"
737+
--type privkey --label "EC private key" -p "$PIN"
738738
openssl pkey -in EC_private.der -out EC_public.der \
739-
-pubout -inform DER -outform DER
739+
-pubout -inform DER -outform DER
740740
pkcs11-tool --write-object EC_public.der --id "$ID" \
741-
--type pubkey --label "EC public key" -p $PIN</programlisting>
741+
--type pubkey --label "EC public key" -p $PIN</programlisting>
742742

743743
List private keys:
744744
<programlisting>pkcs11-tool --login --list-objects --type privkey</programlisting>
745745

746-
To sign some data stored in file <replaceable>data</replaceable>
747-
using the private key with ID <replaceable>ID</replaceable> and
746+
Sign some data stored in file <filename>data</filename>
747+
using the private key with ID <varname>ID</varname> and
748748
using the RSA-PKCS mechanism:
749-
<programlisting>pkcs11-tool --sign --id ID --mechanism RSA-PKCS --input-file data --output-file data.sig</programlisting>
749+
<programlisting>
750+
pkcs11-tool --sign --id $ID --mechanism RSA-PKCS \
751+
--input-file data --output-file data.sig
752+
</programlisting>
750753
The same is also possible by piping the data from stdin rather than specifying a input file:
751-
<programlisting>dd if=data bs=128 count=1 | pkcs11-tool --sign --id ID --mechanism RSA-PKCS --pin=$PIN > data.sig</programlisting>
754+
<programlisting>
755+
dd if=data bs=128 count=1 \
756+
| pkcs11-tool --sign --id $ID --mechanism RSA-PKCS \
757+
> data.sig
758+
</programlisting>
752759

753760
Verify the signed data:
754-
<programlisting>pkcs11-tool --id ID --verify -m RSA-PKCS --input-file data --signature-file data.sig</programlisting>
761+
<programlisting>
762+
pkcs11-tool --id ID --verify -m RSA-PKCS \
763+
--input-file data --signature-file data.sig
764+
</programlisting>
755765

756766
To encrypt file using the AES key with ID 85 and using mechanism AES-CBC with padding:
757767
<programlisting>
758768
pkcs11-tool --login --encrypt --id 85 -m AES-CBC-PAD \
759-
--iv "00000000000000000000000000000000" \
760-
-i file.txt -o encrypted_file.data
761-
Decipher the encrypted file:
769+
--iv "00000000000000000000000000000000" \
770+
-i file.txt -o encrypted_file.data
762771
</programlisting>
772+
Decipher the encrypted file:
773+
<programlisting>
763774
pkcs11-tool --login --decrypt --id 85 -m AES-CBC-PAD \
764-
--iv "00000000000000000000000000000000" \
765-
--i encrypted_file.data -o decrypted.txt
775+
--iv "00000000000000000000000000000000" \
776+
--i encrypted_file.data -o decrypted.txt
766777
</programlisting>
767778

768779
Use the key with ID 75 using mechanism AES-CBC-PAD, with initialization vector
769780
"00000000000000000000000000000000" to wrap the key with ID 76 into output file
770-
<replaceable>exported_aes.key</replaceable>
781+
<filename>exported_aes.key</filename>
771782
<programlisting>
772783
pkcs11-tool --login --wrap --id 75 --mechanism AES-CBC-PAD \
773-
--iv "00000000000000000000000000000000" \
774-
--application-id 76 \
775-
--output-file exported_aes.key
784+
--iv "00000000000000000000000000000000" \
785+
--application-id 76 \
786+
--output-file exported_aes.key
776787
</programlisting>
777788
Use the key with ID 22 and mechanism RSA-PKCS to unwrap key from file
778-
<replaceable>aes_wrapped.key</replaceable>. After a successful unwrap operation,
789+
<filename>aes_wrapped.key</filename>. After a successful unwrap operation,
779790
a new AES key is created on token. ID of this key is set to 90 and label of this
780-
key is set to <replaceable>unwrapped-key</replaceable>
791+
key is set to <literal>unwrapped-key</literal>
781792
Note: for the MyEID card, the AES key size must be present in key
782793
specification i.e. AES:16
783794
<programlisting>
784795
pkcs11-tool --login --unwrap --mechanism RSA-PKCS --id 22 \
785-
-i aes_wrapped.key --key-type AES: \
786-
--application-id 90 --applicatin-label unwrapped-key
796+
-i aes_wrapped.key --key-type AES: \
797+
--application-id 90 --applicatin-label unwrapped-key
787798
</programlisting>
788799

789800
Use the SO-PIN to initialize or re-set the PIN:

0 commit comments

Comments
 (0)