summaryrefslogtreecommitdiff
path: root/src/p11tool-args.def
blob: b017ae93459a7f0ed39a63b7cd18da8df77fb445 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
AutoGen Definitions options;
prog-name     = p11tool;
prog-title    = "GnuTLS PKCS #11 tool";
prog-desc     = "Program to handle PKCS #11 smart cards and security modules.\n";
detail    = "Program that allows operations on PKCS #11 smart cards
and security modules. 

To use PKCS #11 tokens with GnuTLS the p11-kit configuration files need to be setup.
That is create a .module file in /etc/pkcs11/modules with the contents 'module: /path/to/pkcs11.so'.
Alternatively the configuration file /etc/gnutls/pkcs11.conf has to exist and contain a number
of lines of the form 'load=/usr/lib/opensc-pkcs11.so'.

You can provide the PIN to be used for the PKCS #11 operations with the environment variables
GNUTLS_PIN and GNUTLS_SO_PIN.
";

short-usage   = "p11tool [options] [url]\np11tool --help for usage instructions.\n";
explain       = "";
reorder-args;
argument = "[url]";

flag = {
    name = token_related_options;
    documentation;
    descrip = "Tokens";
};

flag = {
    name      = list-tokens;
    descrip   = "List all available tokens";
    doc = "";
};

flag = {
    name      = list-token-urls;
    descrip   = "List the URLs available tokens";
    doc = "This is a more compact version of --list-tokens.";
};

flag = {
    name      = list-mechanisms;
    descrip   = "List all available mechanisms in a token";
    doc = "";
};

flag = {
    name      = initialize;
    descrip   = "Initializes a PKCS #11 token";
    doc = "";
};

flag = {
    name      = set-pin;
    arg-type  = string;
    descrip   = "Specify the PIN to use on token initialization";
    doc      = "Alternatively the GNUTLS_PIN environment variable may be used.";
};

flag = {
    name      = set-so-pin;
    arg-type  = string;
    descrip   = "Specify the Security Officer's PIN to use on token initialization";
    doc      = "Alternatively the GNUTLS_SO_PIN environment variable may be used.";
};

flag = {
    name = object_list_related_options;
    documentation;
    descrip = "Object listing";
};

flag = {
    name      = list-all;
    descrip   = "List all available objects in a token";
    doc = "";
};

flag = {
    name      = list-all-certs;
    descrip   = "List all available certificates in a token";
    doc = "";
};

flag = {
    name      = list-certs;
    descrip   = "List all certificates that have an associated private key";
    doc = "";
};

flag = {
    name      = list-all-privkeys;
    descrip   = "List all available private keys in a token";
    doc = "Lists all the private keys in a token that match the specified URL.";
};

flag = {
    name      = list-privkeys;
    aliases   = list-all-privkeys;
};

flag = {
    name      = list-keys;
    aliases   = list-all-privkeys;
};

flag = {
    name      = list-all-trusted;
    descrip   = "List all available certificates marked as trusted";
    doc = "";
};

flag = {
    name      = export;
    descrip   = "Export the object specified by the URL";
    doc = "";
    flags-cant = export-stapled;
    flags-cant = export-chain;
    flags-cant = export-pubkey;
};

flag = {
    name      = export-stapled;
    descrip   = "Export the certificate object specified by the URL";
    doc = "Exports the certificate specified by the URL while including any attached extensions to it.";
    flags-cant = export;
    flags-cant = export-chain;
    flags-cant = export-pubkey;
};

flag = {
    name      = export-chain;
    descrip   = "Export the certificate specified by the URL and its chain of trust";
    doc = "Exports the certificate specified by the URL and generates its chain of trust based on the stored certificates in the module.";
    flags-cant = export-stapled;
    flags-cant = export;
    flags-cant = export-pubkey;
};

flag = {
    name      = export-pubkey;
    descrip   = "Export the public key for a private key";
    doc = "Exports the public key for the specified private key";
    flags-cant = export-stapled;
    flags-cant = export;
    flags-cant = export-chain;
};

flag = {
    name      = info;
    descrip   = "List information on an available object in a token";
    doc = "";
};

flag = {
    name = keygen_related_options;
    documentation;
    descrip = "Key generation";
};

flag = {
    name      = generate-rsa;
    descrip   = "Generate an RSA private-public key pair";
    doc = "Generates an RSA private-public key pair on the specified token.";
};

flag = {
    name      = generate-dsa;
    descrip   = "Generate a DSA private-public key pair";
    doc = "Generates a DSA private-public key pair on the specified token.";
};
flag = {
    name      = generate-ecc;
    descrip   = "Generate an ECDSA private-public key pair";
    doc = "Generates an ECDSA private-public key pair on the specified token.";
};

flag = {
    name      = bits;
    arg-type  = number;
    descrip   = "Specify the number of bits for key generate";
    doc      = "";
};

flag = {
    name      = curve;
    arg-type  = string;
    descrip   = "Specify the curve used for EC key generation";
    doc      = "Supported values are secp192r1, secp224r1, secp256r1, secp384r1 and secp521r1.";
};

flag = {
    name      = sec-param;
    arg-type  = string;
    arg-name  = "Security parameter";
    descrip   = "Specify the security level";
    doc      = "This is alternative to the bits option. Available options are [low, legacy, medium, high, ultra].";
};

flag = {
    name = write_object_related_options;
    documentation;
    descrip = "Writing objects";
};

flag = {
    name      = set-id;
    descrip   = "Set the CKA_ID (in hex) for the specified by the URL object";
    doc = "Modifies or sets the CKA_ID in the specified by the URL object. The ID should be specified in hexadecimal format without a '0x' prefix.";
    arg-type  = string;
    flags_cant = write;
};

flag = {
    name      = set-label;
    descrip   = "Set the CKA_LABEL for the specified by the URL object";
    doc = "Modifies or sets the CKA_LABEL in the specified by the URL object";
    arg-type  = string;
    flags_cant = write;
    flags_cant = set-id;
};

flag = {
    name      = write;
    descrip   = "Writes the loaded objects to a PKCS #11 token";
    doc = "It can be used to write private keys, certificates or secret keys to a token. Must be combined with a --load option.";
};

flag = {
    name      = delete;
    descrip   = "Deletes the objects matching the given PKCS #11 URL";
    doc = "";
};

flag = {
    name      = label;
    arg-type  = string;
    descrip   = "Sets a label for the write operation";
    doc       = "";
};

flag = {
    name      = id;
    arg-type  = string;
    descrip   = "Sets an ID for the write operation";
    doc       = "Sets the CKA_ID to be set by the write operation. The ID should be specified in hexadecimal format without a '0x' prefix.";
};

flag = {
    name      = mark-wrap;
    disable   = "no";
    disabled;
    descrip   = "Marks the generated key to be a wrapping key";
    doc = "Marks the generated key with the CKA_WRAP flag.";
};

flag = {
    name      = mark-trusted;
    disable   = "no";
    disabled;
    descrip   = "Marks the object to be written as trusted";
    doc = "Marks the object to be generated/written with the CKA_TRUST flag.";
};

flag = {
    name      = mark-decrypt;
    disable   = "no";
    disabled;
    descrip   = "Marks the object to be written for decryption";
    doc = "Marks the object to be generated/written with the CKA_DECRYPT flag set to true.";
};

flag = {
    name      = mark-sign;
    disable   = "no";
    disabled;
    descrip   = "Marks the object to be written for signature generation";
    doc = "Marks the object to be generated/written with the CKA_SIGN flag set to true.";
};

flag = {
    name      = mark-ca;
    disable   = "no";
    disabled;
    descrip   = "Marks the object to be written as a CA";
    doc = "Marks the object to be generated/written with the CKA_CERTIFICATE_CATEGORY as CA.";
};

flag = {
    name      = mark-private;
    disable   = "no";
    descrip   = "Marks the object to be written as private";
    doc = "Marks the object to be generated/written with the CKA_PRIVATE flag. The written object will require a PIN to be used.";
};

flag = {
    name      = trusted;
    aliases   = mark-trusted;
};

flag = {
    name      = ca;
    aliases   = mark-ca;
};

flag = {
    name      = private;
    aliases   = mark-private;
};

flag = {
    name      = secret-key;
    arg-type  = string;
    descrip   = "Provide a hex encoded secret key";
    doc   = "This secret key will be written to the module if --write is specified.";
};

flag = {
    name      = load-privkey;
    arg-type  = file;
    file-exists = yes;
    descrip   = "Private key file to use";
    doc      = "";
};

flag = {
    name      = load-pubkey;
    arg-type  = file;
    file-exists = yes;
    descrip   = "Public key file to use";
    doc      = "";
};

flag = {
    name      = load-certificate;
    arg-type  = file;
    file-exists = yes;
    descrip   = "Certificate file to use";
    doc      = "";
};

flag = {
    name = other_options;
    documentation;
    descrip = "Other options";
};

#define  OUTFILE_OPT   1
#include args-std.def

flag = {
    name      = login;
    descrip   = "Force (user) login to token";
    disabled;
    disable   = "no";
    doc       = "";
};

flag = {
    name      = so-login;
    descrip   = "Force security officer login to token";
    disabled;
    disable   = "no";
    doc       = "Forces login to the token as security officer (admin).";
};

flag = {
    name      = admin-login;
    aliases   = so-login;
};

flag = {
    name      = test-sign;
    descrip   = "Tests the signature operation of the provided object";
    doc = "It can be used to test the correct operation of the signature operation.
If both a private and a public key are available this operation will sign and verify
the signed data.";
};

flag = {
    name      = generate-random;
    descrip   = "Generate random data";
    arg-type  = number;
    doc = "Asks the token to generate a number of bytes of random bytes.";
};

flag = {
    name      = pkcs8;
    value     = 8;
    descrip   = "Use PKCS #8 format for private keys";
    doc      = "";
};

flag = {
    name      = inder;
    descrip   = "Use DER/RAW format for input";
    disabled;
    disable   = "no";
    doc      = "Use DER/RAW format for input certificates and private keys.";
};

flag = {
    name      = inraw;
    aliases   = inder;
};

flag = {
    name      = outder;
    descrip   = "Use DER format for output certificates, private keys, and DH parameters";
    disabled;
    disable   = "no";
    doc       = "The output will be in DER or RAW format.";
};

flag = {
    name      = outraw;
    aliases   = outder;
};

flag = {
    name      = provider;
    arg-type  = file;
    descrip   = "Specify the PKCS #11 provider library";
    doc      = "This will override the default options in /etc/gnutls/pkcs11.conf";
};

flag = {
    name      = detailed-url;
    descrip   = "Print detailed URLs";
    disabled;
    disable   = "no";
    doc   = "";
};

flag = {
    name      = only-urls;
    descrip   = "Print a compact listing using only the URLs";
    doc   = "";
};

flag = {
    name      = batch;
    descrip   = "Disable all interaction with the tool";
    doc = "In batch mode there will be no prompts, all parameters need to be specified on command line.";
};


doc-section = {
  ds-type = 'SEE ALSO';
  ds-format = 'texi';
  ds-text   = <<-_EOT_
    certtool (1)
_EOT_;
};

doc-section = {
  ds-type = 'EXAMPLES';
  ds-format = 'texi';
  ds-text   = <<-_EOT_
To view all tokens in your system use:
@example
$ p11tool --list-tokens
@end example

To view all objects in a token use:
@example
$ p11tool --login --list-all "pkcs11:TOKEN-URL"
@end example

To store a private key and a certificate in a token run:
@example
$ p11tool --login --write "pkcs11:URL" --load-privkey key.pem \
          --label "Mykey"
$ p11tool --login --write "pkcs11:URL" --load-certificate cert.pem \
          --label "Mykey"
@end example
Note that some tokens require the same label to be used for the certificate
and its corresponding private key.

To generate an RSA private key inside the token use:
@example
$ p11tool --login --generate-rsa --bits 1024 --label "MyNewKey" \
          --outfile MyNewKey.pub "pkcs11:TOKEN-URL"
@end example
The bits parameter in the above example is explicitly set because some
tokens only support limited choices in the bit length. The output file is the
corresponding public key. This key can be used to general a certificate
request with certtool.
@example
certtool --generate-request --load-privkey "pkcs11:KEY-URL" \
   --load-pubkey MyNewKey.pub --outfile request.pem
@end example

_EOT_;
};