1PKCS11-TOOL(1)                   OpenSC Tools                   PKCS11-TOOL(1)
2
3
4

NAME

6       pkcs11-tool - utility for managing and using PKCS #11 security tokens
7

SYNOPSIS

9       pkcs11-tool [OPTIONS]
10

DESCRIPTION

12       The pkcs11-tool utility is used to manage the data objects on smart
13       cards and similar PKCS #11 security tokens. Users can list and read
14       PINs, keys and certificates stored on the token. User PIN
15       authentication is performed for those operations that require it.
16

OPTIONS

18       --attr-from filename
19           Extract information from filename (DER-encoded certificate file)
20           and create the corresponding attributes when writing an object to
21           the token. Example: the certificate subject name is used to create
22           the CKA_SUBJECT attribute.
23
24       --change-pin, -c
25           Change the user PIN on the token
26
27       --unlock-pin
28           Unlock User PIN (without --login unlock in logged in session;
29           otherwise --login-type has to be 'context-specific').
30
31       --hash, -h
32           Hash some data.
33
34       --hash-algorithm mechanism
35           Specify hash algorithm used with RSA-PKCS-PSS signature or RSA-OAEP
36           decryption. Allowed values are "SHA-1", "SHA256", "SHA384",
37           "SHA512", and some tokens may also allow "SHA224". Default is
38           "SHA-1".
39
40           Note that the input to RSA-PKCS-PSS has to be of the size equal to
41           the specified hash algorithm. E.g., for SHA256 the signature input
42           must be exactly 32 bytes long (for mechanisms SHA256-RSA-PKCS-PSS
43           there is no such restriction). For RSA-OAEP, the plaintext input
44           size mLen must be at most keyLen - 2 - 2*hashLen. For example, for
45           RSA 3072-bit key and SHA384, the longest plaintext to encrypt with
46           RSA-OAEP is (with all sizes in bytes): 384 - 2 - 2*48 = 286, aka
47           286 bytes.
48
49       --id id, -d id
50           Specify the id of the object to operate on.
51
52       --init-pin
53           Initializes the user PIN. This option differs from --change-pin in
54           that it sets the user PIN for the first time. Once set, the user
55           PIN can be changed using --change-pin.
56
57       --init-token
58           Initialize a token: set the token label as well as a Security
59           Officer PIN (the label must be specified using --label).
60
61       --input-file filename, -i filename
62           Specify the path to a file for input.
63
64       --keypairgen, -k
65           Generate a new key pair (public and private pair.)
66
67       --keygen
68           Generate a new key.
69
70       --key-type specification
71           Specify the type and length of the key to create, for example
72           rsa:1024 or EC:prime256v1.
73
74       --usage-sign
75           Specify 'sign' key usage flag (sets SIGN in privkey, sets VERIFY in
76           pubkey).
77
78       --usage-decrypt
79           Specify 'decrypt' key usage flag (RSA only, set DECRYPT privkey,
80           ENCRYPT in pubkey).
81
82       --usage-derive
83           Specify 'derive' key usage flag (EC only).
84
85       --usage-wrap
86           Specify 'wrap' key usage flag.
87
88       --label name, -a name
89           Specify the name of the object to operate on (or the token label
90           when --init-token is used).
91
92       --list-mechanisms, -M
93           Display a list of mechanisms supported by the token.
94
95       --list-objects, -O
96           Display a list of objects.
97
98       --list-slots, -L
99           Display a list of available slots on the token.
100
101       --list-token-slots, -T
102           List slots with tokens.
103
104       --login, -l
105           Authenticate to the token before performing other operations. This
106           option is not needed if a PIN is provided on the command line.
107
108       --login-type
109           Specify login type ('so', 'user', 'context-specific';
110           default:'user').
111
112       --mechanism mechanism, -m mechanism
113           Use the specified mechanism for token operations. See -M for a list
114           of mechanisms supported by your token. The mechanism can also be
115           specified in hexadecimal, e.g., 0x80001234.
116
117       --mgf function
118           Use the specified Message Generation Function (MGF) function for
119           RSA-PKCS-PSS signatures or RSA-OAEP decryptions. Supported
120           arguments are MGF1-SHA1 to MGF1-SHA512 if supported by the driver.
121           The default is based on the hash selection.
122
123       --module mod
124           Specify a PKCS#11 module (or library) to load.
125
126       --moz-cert filename, -z filename
127           Test a Mozilla-like key pair generation and certificate request.
128           Specify the filename to the certificate file.
129
130       --output-file filename, -o filename
131           Specify the path to a file for output.
132
133       --pin pin, -p pin
134           Use the given pin for token operations. If set to env:VARIABLE, the
135           value of the environment variable VARIABLE is used. WARNING: Be
136           careful using this option as other users may be able to read the
137           command line from the system or if it is embedded in a script. If
138           set to env:VARIABLE, the value of the environment variable VARIABLE
139           is used.
140
141           This option will also set the --login option.
142
143       --puk puk
144           Supply User PUK on the command line.
145
146       --new-pin pin
147           Supply new User PIN on the command line.
148
149       --sensitive
150           Set the CKA_SENSITIVE attribute (object cannot be revealed in
151           plaintext).
152
153       --extractable
154           Set the CKA_EXTRACTABLE attribute (object can be extracted)
155
156       --set-id id, -e id
157           Set the CKA_ID of the object.
158
159       --show-info, -I
160           Display general token information.
161
162       --sign, -s
163           Sign some data.
164
165       --decrypt,
166           Decrypt some data.
167
168       --derive,
169           Derive a secret key using another key and some data.
170
171       --derive-pass-der,
172           Derive ECDHpass DER encoded pubkey for compatibility with some
173           PKCS#11 implementations
174
175       --salt-len bytes
176           Specify how many bytes of salt should be used in RSA-PSS
177           signatures. Accepts two special values: "-1" means salt length
178           equals to digest length, "-2" means use maximum permissible length.
179           Default is digest length (-1).
180
181       --slot id
182           Specify the id of the slot to use.
183
184       --slot-description description
185           Specify the description of the slot to use.
186
187       --slot-index index
188           Specify the index of the slot to use.
189
190       --object-index index
191           Specify the index of the object to use.
192
193       --token-label label
194           Specify the label of token. Will be used the first slot, that has
195           the inserted token with this label.
196
197       --so-pin pin
198           Use the given pin as the Security Officer PIN for some token
199           operations (token initialization, user PIN initialization, etc). If
200           set to env:VARIABLE, the value of the environment variable VARIABLE
201           is used. The same warning as --pin also applies here.
202
203       --test, -t
204           Perform some tests on the token. This option is most useful when
205           used with either --login or --pin.
206
207       --test-hotplug
208           Test hotplug capabilities (C_GetSlotList + C_WaitForSlotEvent).
209
210       --private
211           Set the CKA_PRIVATE attribute (object is only viewable after a
212           login).
213
214       --always-auth
215           Set the CKA_ALWAYS_AUTHENTICATE attribute to a private key object.
216           If set, the user has to supply the PIN for each use (sign or
217           decrypt) with the key.
218
219       --allowed-mechanisms mechanisms
220           Sets the CKA_ALLOWED_MECHANISMS attribute to a key objects when
221           importing an object or generating a keys. The argument accepts
222           comma-separated list of algorithmsm, that can be used with the
223           given key.
224
225       --test-ec
226           Test EC (best used with the --login or --pin option).
227
228       --test-fork
229           Test forking and calling C_Initialize() in the child.
230
231       --type type, -y type
232           Specify the type of object to operate on. Valid value are cert,
233           privkey, pubkey, secrkey and data.
234
235       --verbose, -v
236           Cause pkcs11-tool to be more verbose.
237
238           NB! This does not affect OpenSC debugging level! To set OpenSC
239           PKCS#11 module into debug mode, set the OPENSC_DEBUG environment
240           variable to a non-zero number.
241
242       --verify,
243           Verify signature of some data.
244
245       --read-object, -r
246           Get object's CKA_VALUE attribute (use with --type).
247
248       --delete-object, -b
249           Delete an object.
250
251       --application-label label
252           Specify the application label of the data object (use with --type
253           data).
254
255       --application-id id
256           Specify the application ID of the data object (use with --type
257           data).
258
259       --issuer data
260           Specify the issuer in hexadecimal format (use with --type cert).
261
262       --subject data
263           Specify the subject in hexadecimal format (use with --type
264           cert/privkey/pubkey).
265
266       --signature-file filename
267           The path to the signature file for signature verification
268
269       --signature-format format
270           Format for ECDSA signature: 'rs' (default), 'sequence', 'openssl'.
271
272       --write-object filename, -w filename
273           Write a key or certificate object to the token.  filename points to
274           the DER-encoded certificate or key file.
275
276       --generate-random num
277           Get num bytes of random data.
278
279       --allow-sw
280           Allow using software mechanisms that do not have the CKF_HW flag
281           set. May be required when using software tokens and emulators.
282

EXAMPLES

284       To list all certificates on the smart card:
285
286           pkcs11-tool --list-objects --type cert
287
288       To read the certificate with ID KEY_ID in DER format from smart card:
289
290           pkcs11-tool --read-object --id KEY_ID --type cert --output-file cert.der
291
292       To convert the certificate in DER format to PEM format, use OpenSSL
293       tools:
294
295           openssl x509 -inform DER -in cert.der -outform PEM > cert.pem
296
297       To sign some data stored in file data using the private key with ID ID
298       and using the RSA-PKCS mechanism:
299
300           pkcs11-tool --sign --id ID --mechanism RSA-PKCS --input-file data --output-file data.sig
301
302

AUTHORS

304       pkcs11-tool was written by Olaf Kirch <okir@suse.de>.
305
306
307
308opensc                            11/24/2020                    PKCS11-TOOL(1)
Impressum