Previous: Using a PKCS11 token with TLS, Up: Smart cards and HSMs [Contents][Index]
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.
This section was generated by AutoGen,
using the agtexi-cmd
template and the option descriptions for the p11tool
program.
This software is released under the GNU General Public License, version 3 or later.
This is the automatically generated usage text for p11tool.
The text printed is the same whether selected with the help
option
(--help) or the more-help
option (--more-help). more-help
will print
the usage text by passing it through a pager program.
more-help
is disabled on platforms without a working
fork(2)
function. The PAGER
environment variable is
used to select the program, defaulting to more. Both will exit
with a status code of 0.
p11tool - GnuTLS PKCS #11 tool Usage: p11tool [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [url] -d, --debug=num Enable debugging - it must be in the range: 0 to 9999 --outfile=str Output file --list-tokens List all available tokens --export Export the object specified by the URL --export-chain Export the certificate specified by the URL and its chain of trust --list-mechanisms List all available mechanisms in a token --info List information on an available object in a token --list-all List all available objects in a token --list-all-certs List all available certificates in a token --list-certs List all certificates that have an associated private key --list-all-privkeys List all available private keys in a token --list-privkeys an alias for the 'list-all-privkeys' option --list-keys an alias for the 'list-all-privkeys' option --list-all-trusted List all available certificates marked as trusted --write Writes the loaded objects to a PKCS #11 token --delete Deletes the objects matching the PKCS #11 URL --generate-random=num Generate random data --generate-rsa Generate an RSA private-public key pair --generate-dsa Generate an RSA private-public key pair --generate-ecc Generate an RSA private-public key pair --export-pubkey Export the public key for a private key --label=str Sets a label for the write operation --mark-wrap Marks the generated key to be a wrapping key - disabled as '--no-mark-wrap' --mark-trusted Marks the object to be written as trusted - disabled as '--no-mark-trusted' --mark-ca Marks the object to be written as a CA - disabled as '--no-mark-ca' --mark-private Marks the object to be written as private - disabled as '--no-mark-private' - enabled by default --trusted an alias for the 'mark-trusted' option --ca an alias for the 'mark-ca' option --private an alias for the 'mark-private' option - enabled by default --login Force (user) login to token - disabled as '--no-login' --so-login Force security officer login to token - disabled as '--no-so-login' --admin-login an alias for the 'so-login' option --detailed-url Print detailed URLs - disabled as '--no-detailed-url' -!, --secret-key=str Provide a hex encoded secret key -", --load-privkey=file Private key file to use - file must pre-exist -#, --load-pubkey=file Public key file to use - file must pre-exist -$, --load-certificate=file Certificate file to use - file must pre-exist -8, --pkcs8 Use PKCS #8 format for private keys -%, --bits=num Specify the number of bits for key generate -&, --curve=str Specify the curve used for EC key generation -', --sec-param=str Specify the security level -(, --inder Use DER/RAW format for input - disabled as '--no-inder' -), --inraw an alias for the 'inder' option -*, --outder Use DER format for output certificates, private keys, and DH parameters - disabled as '--no-outder' -+, --outraw an alias for the 'outder' option -,, --initialize Initializes a PKCS #11 token --, --set-pin=str Specify the PIN to use on token initialization -., --set-so-pin=str Specify the Security Officer's PIN to use on token initialization -/, --provider=file Specify the PKCS #11 provider library - file must pre-exist -0, --batch Disable all interaction with the tool. All parameters need to be specified on command line. -v, --version[=arg] output version information and exit -h, --help display extended usage information and exit -!, --more-help extended usage information passed thru pager Options are specified by doubled hyphens and their name or by a single hyphen and the flag character. Operands and options may be intermixed. They will be reordered. 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.
Tokens.
This is the “list the urls available tokens” option. This is a more compact version of –list-tokens.
This is the “specify the pin to use on token initialization” option. This option takes a string argument. Alternatively the GNUTLS_PIN environment variable may be used.
This is the “specify the security officer’s pin to use on token initialization” option. This option takes a string argument. Alternatively the GNUTLS_SO_PIN environment variable may be used.
Object listing.
This is the “list all available private keys in a token” option. Lists all the private keys in a token that match the specified URL.
This is an alias for the list-all-privkeys
option,
see the list-all-privkeys option documentation.
This is an alias for the list-all-privkeys
option,
see the list-all-privkeys option documentation.
This is the “export the certificate specified by the url and its chain of trust” option. Exports the certificate specified by the URL and generates its chain of trust based on the stored certificates in the module.
This is the “export the public key for a private key” option. Exports the public key for the specified private key
Key generation.
This is the “generate an rsa private-public key pair” option. Generates an RSA private-public key pair on the specified token.
This is the “generate an rsa private-public key pair” option. Generates an RSA private-public key pair on the specified token.
This is the “generate an rsa private-public key pair” option. Generates an RSA private-public key pair on the specified token.
This is the “specify the curve used for ec key generation” option. This option takes a string argument. Supported values are secp192r1, secp224r1, secp256r1, secp384r1 and secp521r1.
This is the “specify the security level” option. This option takes a string argument Security parameter. This is alternative to the bits option. Available options are [low, legacy, medium, high, ultra].
Writing objects.
This is the “set the cka_id (in hex) for the specified by the url object” option. This option takes a string argument.
This option has some usage constraints. It:
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.
This is the “set the cka_label for the specified by the url object” option. This option takes a string argument.
This option has some usage constraints. It:
Modifies or sets the CKA_LABEL in the specified by the URL object
This is the “writes the loaded objects to a pkcs #11 token” option. It can be used to write private keys, certificates or secret keys to a token. Must be combined with a –load option.
This is the “sets an id for the write operation” option. This option takes a string argument. Sets the CKA_ID to be set by the write operation. The ID should be specified in hexadecimal format without a ’0x’ prefix.
This is the “marks the generated key to be a wrapping key” option.
This option has some usage constraints. It:
Marks the generated key with the CKA_WRAP flag.
This is the “marks the object to be written as trusted” option.
This option has some usage constraints. It:
Marks the object to be generated/written with the CKA_TRUST flag.
This is the “marks the object to be written for decryption” option.
This option has some usage constraints. It:
Marks the object to be generated/written with the CKA_DECRYPT flag set to true.
This is the “marks the object to be written for signature generation” option.
This option has some usage constraints. It:
Marks the object to be generated/written with the CKA_SIGN flag set to true.
This is the “marks the object to be written as a ca” option.
This option has some usage constraints. It:
Marks the object to be generated/written with the CKA_CERTIFICATE_CATEGORY as CA.
This is the “marks the object to be written as private” option.
This option has some usage constraints. It:
Marks the object to be generated/written with the CKA_PRIVATE flag. The written object will require a PIN to be used.
This is an alias for the mark-trusted
option,
see the mark-trusted option documentation.
This is an alias for the mark-ca
option,
see the mark-ca option documentation.
This is an alias for the mark-private
option,
see the mark-private option documentation.
This is the “provide a hex encoded secret key” option. This option takes a string argument. This secret key will be written to the module if –write is specified.
Other options.
This is the “enable debugging” option. This option takes a number argument. Specifies the debug level.
This is the “force security officer login to token” option.
This option has some usage constraints. It:
Forces login to the token as security officer (admin).
This is an alias for the so-login
option,
see the so-login option documentation.
This is the “tests the signature operation of the provided object” option. 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.
This is the “generate random data” option. This option takes a number argument. Asks the token to generate a number of bytes of random bytes.
This is the “use der/raw format for input” option.
This option has some usage constraints. It:
Use DER/RAW format for input certificates and private keys.
This is an alias for the inder
option,
see the inder option documentation.
This is the “use der format for output certificates, private keys, and dh parameters” option.
This option has some usage constraints. It:
The output will be in DER or RAW format.
This is an alias for the outder
option,
see the outder option documentation.
This is the “specify the pkcs #11 provider library” option. This option takes a file argument. This will override the default options in /etc/gnutls/pkcs11.conf
This is the “disable all interaction with the tool” option. In batch mode there will be no prompts, all parameters need to be specified on command line.
One of the following exit values will be returned:
Successful program execution.
The operation failed or the command syntax was not valid.
To view all tokens in your system use:
$ p11tool --list-tokens
To view all objects in a token use:
$ p11tool --login --list-all "pkcs11:TOKEN-URL"
To store a private key and a certificate in a token run:
$ p11tool --login --write "pkcs11:URL" --load-privkey key.pem \ --label "Mykey" $ p11tool --login --write "pkcs11:URL" --load-certificate cert.pem \ --label "Mykey"
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:
$ p11tool --login --generate-rsa --bits 1024 --label "MyNewKey" \ --outfile MyNewKey.pub "pkcs11:TOKEN-URL"
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.
certtool --generate-request --load-privkey "pkcs11:KEY-URL" \ --load-pubkey MyNewKey.pub --outfile request.pem
Previous: Using a PKCS11 token with TLS, Up: Smart cards and HSMs [Contents][Index]