SC-HSM-TOOL(1)
π SC-HSM-TOOL β the smart card glow-up utility for SmartCard-HSM π
okay bestie, welcome to sc-hsm-tool, the little OpenSC tool that does all the β¨extraβ¨ maintenance stuff that PKCS#11 and the other OpenSC tools just can't be bothered with. Think of it as the backstage pass π β it can check up on your SmartCard-HSM's whole status, initialize a fresh device, generate and import Device Key Encryption Key (DKEK) shares, and wrap + unwrap keys like it's wrapping a birthday present. π
β¨ SYNOPSIS β¨
sc-hsm-tool [OPTIONS]
The sc-hsm-tool utility is a command-line queen π β you run it to do extended maintenance tasks that you literally cannot do through PKCS#11 or any of the other tools hanging out in the OpenSC package. She can query the status of a SmartCard-HSM, initialize a device, generate and import Device Key Encryption Key (DKEK) shares, and wrap and unwrap keys. periodt. π
πΈ OPTIONS πΈ
--initialize,-Xβ Initialize token, removing all existing keys, certificates and files. yes this is the full factory reset, bestie, everything goes π- Use
--so-pinto define SO-PIN for first initialization or to verify in subsequent initializations. - Use
--pinto define the initial user pin value. - Use
--pin-retryto define the maximum number of wrong user PIN presentations. - Use with
--dkek-sharesto enable key wrap / unwrap. - Use with
--labelto define a token label - Use with
--public-key-authand--required-pub-keysto require public key authentication for login
- Use
--create-dkek-share filename,-C filenameβ Create a DKEK share encrypted under a password and save it to the file given as parameter. it's giving "make me a secret and lock it up" π- Use
--passwordto provide a password for encryption rather than prompting for one. - Use
--pwd-shares-thresholdand--pwd-shares-totalto randomly generate a password and split is using a (t, n) threshold scheme.
- Use
--import-dkek-share filename,-I filenameβ Prompt for user password, read and decrypt DKEK share and import into SmartCard-HSM. reverse uno card, we're bringing the secret home π- Use
--passwordto provide a password for decryption rather than prompting for one. - Use
--pwd-shares-totalto specify the number of shares that should be entered to reconstruct the password.
- Use
--wrap-key filename,-W filenameβ Wrap the key referenced in--key-referenceand save with it together with the key description and certificate to the given file. cozy lil bundle π- Use
--pinto provide the user PIN on the command line.
- Use
--unwrap-key filename,-U filenameβ Read wrapped key, description and certificate from file and import into SmartCard-HSM under the key reference given in--key-reference. unwrapping szn π- Determine the key reference using the output of
pkcs15-tool -D. - Use
--pinto provide a user PIN on the command line. - Use
--forceto remove any key, key description or certificate in the way.
- Determine the key reference using the output of
--dkek-shares number-of-shares,-s number-of-sharesβ Define the number of DKEK shares to use for recreating the DKEK.- This is an optional parameter. Using
--initializewithout--dkek-shareswill disable the DKEK completely. - Using
--dkek-shareswith0shares requests the SmartCard-HSM to generate a random DKEK. Keys wrapped with this DKEK can only be unwrapped in the same SmartCard-HSM. - After using
--initializewith one or more DKEK shares, the SmartCard-HSM will remain in the initialized state until all DKEK shares have been imported. During this phase no new keys can be generated or imported.
- This is an optional parameter. Using
--pin pin,--so-pin sopinβ These options can be used to specify the PIN values on the command line. If the value is set toenv:VARIABLE, the value of the specified environment variable is used. By default, the code is prompted on the command line if needed.
β οΈ Note that on most operation systems, any user can display the command line of any process on the system using utilities such as ps(1). Therefore, you should prefer passing the codes via an environment variable on an unsecured system. stay safe bestie, seriously π
--pin-retry valueβ Define number of PIN retries for user PIN during initialization. Default is3.--bio-server1 valueβ The hexadecimal AID of of the biometric server for template 1. Switches on the use of the user PIN as session PIN.--bio-server2 valueβ The hexadecimal AID of of the biometric server for template 2. Switches on the use of the user PIN as session PIN.--password valueβ Define password for DKEK share encryption. If set toenv:VARIABLE, the value of the environment variableVARIABLEis used.--pwd-shares-threshold valueβ Define threshold for number of password shares required for reconstruction.--pwd-shares-total valueβ Define number of password shares.--forceβ Force removal of existing key, description and certificate. no hesitation, no mercy π₯--label label,-l labelβ Define the token label to be used in--initialize.--reader arg,-r argβ Number of the reader to use. By default, the first reader with a present card is used. If arg is an ATR, the reader with a matching card will be chosen.--public-key-auth total-number-of-public-keys,-K total-number-of-public-keysβ Define the total number of public keys to use for public key authentication when using--initialize.--public-key-authis optional, but if it's present, it must be used with--required-pub-keys.
When the SmartCard-HSM is initialized with these options, it will require M-of-N public key authentication to be used, where --required-pub-keys sets the M and --public-key-auth sets the N. After the initialization, the user should use --register-public-key to register the N public keys before the SmartCard-HSM can be used.
--required-pub-keys required-number-of-public-keys,-n required-number-of-public-keysβ Define the required number of public keys to use for public key authentication when using--initialize. This is the M in M-of-N public key authentication. See--public-key-authfor more information.--register-public-key input-public-key-file,-g input-public-key-fileβ Register a public key to be used for M-of-N public key authentication. The file can be exported from a different SmartCard-HSM with--export-for-pub-key-auth. This can only be used when the SmartCard-HSM has been initialized with--public-key-authand--required-pub-keysand fewer than N public keys have been registered. Use--public-key-auth-statusto check the how many public keys have been registered.--export-for-pub-key-auth output-public-key-file,-e output-public-key-fileβ Export a public key to be used for M-of-N public key authentication. This should be used with--key-referenceto choose the key to export. The file should be registered on another SmartCard-HSM using--register-public-key.--public-key-auth-status,-Sβ Print the public key authentication status. This is only valid if the SmartCard-HSM was initialized to use M-of-N public key authentication.--wait,-wβ Wait for a card to be inserted. she'll just sit there patiently like a good friend π«Ά--verbose,-vβ Causessc-hsm-toolto be more verbose. Specify this flag several times to enable debug output in the opensc library.
π EXAMPLES π
Create a DKEK share:
sc-hsm-tool --create-dkek-share dkek-share-1.pbe
Create a DKEK share with random password split up using a (3, 5) threshold scheme:
sc-hsm-tool --create-dkek-share dkek-share-1.pbe --pwd-shares-threshold 3 --pwd-shares-total 5
Initialize SmartCard-HSM to use a single DKEK share:
sc-hsm-tool --initialize --so-pin 3537363231383830 --pin 648219 --dkek-shares 1 --label mytoken
Import DKEK share:
sc-hsm-tool --import-dkek-share dkek-share-1.pbe
Import DKEK share using a password split up using a (3, 5) threshold scheme for encryption:
sc-hsm-tool --import-dkek-share dkek-share-1.pbe --pwd-shares-total 3
Wrap referenced key, description and certificate:
sc-hsm-tool --wrap-key wrap-key.bin --key-reference 1 --pin 648219
Unwrap key into same or in different SmartCard-HSM with the same DKEK:
sc-hsm-tool --unwrap-key wrap-key.bin --key-reference 10 --pin 648219 --force
Initialize SmartCard-HSM to use M-of-N public key authentication with M=2 and N=5
sc-hsm-tool --initialize --required-pub-keys 2 --public-key-auth 5
Export a public key for M-of-N public key authentication to a file
sc-hsm-tool --key-reference 1 --export-for-pub-key-auth ./public_key1.asn1
Register a public key for M-of-N public key authentication from a file
sc-hsm-tool --register-public-key ./public_key1.asn1
π¦ SEE ALSO π¦
π AUTHORS π
sc-hsm-tool was written by Andreas Schwier <andreas.schwier@cardcontact.de>. absolute legend, no cap π
okay that's the whole thing bestie, you're basically a SmartCard-HSM expert now, go off π β¨
this page came from the opensc manual set β dated 04/19/2026 β and yeah, that's the whole vibe check, love u, bye ππ
π¦ where this page comes from
- fedora 43: opensc 0.27.1-2.fc43 Β· LGPL-2.1-or-later AND BSD-3-Clause
- fedora 44: opensc 0.27.1-2.fc44 Β· LGPL-2.1-or-later AND BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms