PKCS11-TOOL(1) OpenSC Tools PKCS11-TOOL(1) (NAME) pkcs11-tool - PKCS #11 (SYNOPSIS) pkcs11-tool [] (DESCRIPTION) pkcs11-tool PKCS #11 . PIN . PIN . (OPTIONS) --attr-from filename filename ( DER) . : (subject) CKA_SUBJECT . --change-pin, -c PIN --unlock-pin PIN ( --login --login-type 'context-specific' ). --hash, -h ( ) . --hash-algorithm mechanism RSA-PKCS-PSS RSA-OAEP. "SHA-1" "SHA256" "SHA384" "SHA512" "SHA224" . "SHA-1" . RSA-PKCS-PSS . SHA256 ( SHA256-RSA-PKCS-PSS ). RSA-OAEP mLen keyLen - 2 - 2*hashLen . RSA SHA384 RSA-OAEP ( ) : 384 - 2 - 2*48 = 286 . --id id, -d id . --init-pin PIN . --change-pin PIN . PIN --change-pin . --init-token : PIN (SO-PIN) ( --label ). --input-file filename, -i filename . --keypairgen, -k ( ). --keygen . --key-type specification ( ) ( ). RSA:2048 EC:prime256v1 EC:ED25519 EC:X448 GOSTR3410-2012-256:B DES:8 DES3:24 AES:16 AES: CHACHA20 POLY1305 GENERIC:64. . --usage-sign 'sign' () ( SIGN privkey VERIFY pubkey). --usage-decrypt 'decrypt' (). RSA DECRYPT privkey ENCRYPT pubkey . DECRYPT ENCRYPT . --usage-derive 'derive' () ( EC). --usage-wrap 'wrap' (). --usage-encapsulate 'encapsulate' () ( DECAPSULATE privkey ENCAPSULATE pubkey). --label name, -a name ( --init-token). --list-mechanisms, -M (mechanisms) . --list-objects, -O . --keytype --label --id --application-id . --list-slots, -L . --list-token-slots, -T . --list-interfaces PKCS #11 3.0. --session-rw, PKCS#11 CKF_RW_SESSION. --login, -l . PIN . --login-type ('so' 'user' 'context-specific' : 'user'). --mechanism mechanism, -m mechanism (mechanism) . -M . 0x80001234. --mgf function (MGF) function RSA-PKCS-PSS RSA-OAEP. MGF1-SHA1 MGF1-SHA512 . . --module mod ( ) PKCS#11 . --moz-cert filename, -z filename . filename . --output-file filename, -o filename . --pin pin, -p pin pin . env:VARIABLE VARIABLE . : . --login . --public-key-info "CKA_PUBLIC_KEY_INFO" ( --read-object --type public ). "SubjectPublicKeyInfo" openssl . --puk puk PUK . --new-pin pin PIN . --sensitive CKA_SENSITIVE ( ). --extractable CKA_EXTRACTABLE ( ). --undestroyable CKA_DESTROYABLE false ( ). --set-id id, -e id CKA_ID . --show-info, -I . --sign, -s . --decrypt, . --encrypt, . --unwrap, (unwrap) . --wrap, (wrap) . --derive, . --derive-pass-der, DER ECDHpass PKCS#11. --salt-len bytes salt RSA-PSS. : "-1" salt digest "-2" "-3" . (verify) "-2" salt . "-2" opensc pkcs#11 . digest (-1) . --slot id ( HEX 0x ). --slot-description description . --slot-index index (index) . --object-index index (index) . --use-locking pkcs11 . --test-threads options pkcs11. ( ). --token-label label . . --so-pin pin pin PIN (SO-PIN) ( PIN ). env:VARIABLE VARIABLE . --pin . --test, -t . --login --pin . --test-hotplug (C_GetSlotList + C_WaitForSlotEvent). --private CKA_PRIVATE ( ). --always-auth CKA_ALWAYS_AUTHENTICATE . ( ) PIN . --allowed-mechanisms mechanisms CKA_ALLOWED_MECHANISMS . . --test-ec EC ( --login --pin ). --test-fork fork C_Initialize() . --type type, -y type . cert privkey pubkey secrkey data. --verbose, -v pkcs11-tool . : OpenSC ! OpenSC PKCS#11 OPENSC_DEBUG . --verify, . --read-object, -r CKA_VALUE ( --type ). --delete-object, -b . --application-label label ( --type data ). --application-id id ( --type data ). --issuer data ( --type cert ). --subject data (subject) ( --type cert/privkey/pubkey ). --signature-file filename --signature-format format ECDSA: 'rs' () 'sequence' 'openssl'. --write-object filename, -w filename . filename DER . --generate-random num num . --allow-sw CKF_HW . . --iv data (IV) . data "000013aa7bffa0". --mac-general-param num MAC MAC num . --aad data (AAD) AEAD. data . --tag-bits-len num (tag) AEAD num . --salt-file filename salt HKDF () --info-file filename (info) HKDF () --uri value PKCS#11 URI --uri-with-slot-id SlotId PKCS#11 URI (EXAMPLES) : pkcs11-tool --test --login : pkcs11-tool --list-objects --type cert CERT_ID DER PEM OpenSSL: pkcs11-tool --read-object --id $CERT_ID --type cert \ --output-file cert.der openssl x509 -inform DER -in cert.der -outform PEM > cert.pem : pkcs11-tool --login --write-object certificate.der --type cert RSA : pkcs11-tool --login --keypairgen --key-type RSA:2048 RSA : pkcs11-tool --login --keypairgen --key-type RSA:2048 --extractable OpenSSL $ID: openssl genpkey -out EC_private.der -outform DER \ -algorithm EC -pkeyopt ec_paramgen_curve:P-521 pkcs11-tool --write-object EC_private.der --id "$ID" \ --type privkey --label "EC private key" -p "$PIN" openssl pkey -in EC_private.der -out EC_public.der \ -pubout -inform DER -outform DER pkcs11-tool --write-object EC_public.der --id "$ID" \ --type pubkey --label "EC public key" -p $PIN : pkcs11-tool --login --list-objects --type privkey data ID RSA-PKCS: pkcs11-tool --sign --id $ID --mechanism RSA-PKCS \ --input-file data --output-file data.sig (pipe) stdin : dd if=data bs=128 count=1 \ | pkcs11-tool --sign --id $ID --mechanism RSA-PKCS \ > data.sig : pkcs11-tool --id ID --verify -m RSA-PKCS \ --input-file data --signature-file data.sig AES AES-CBC padding: pkcs11-tool --login --encrypt --id 85 -m AES-CBC-PAD \ --iv "00000000000000000000000000000000" \ -i file.txt -o encrypted_file.data : pkcs11-tool --login --decrypt --id 85 -m AES-CBC-PAD \ --iv "00000000000000000000000000000000" \ --i encrypted_file.data -o decrypted.txt AES-CBC-PAD "00000000000000000000000000000000" (wrap) exported_aes.key: pkcs11-tool --login --wrap --id 75 --mechanism AES-CBC-PAD \ --iv "00000000000000000000000000000000" \ --application-id 76 \ --output-file exported_aes.key RSA-PKCS (unwrap) aes_wrapped.key. unwrap AES . unwrapped-key . : MyEID AES AES:16. pkcs11-tool --login --unwrap --mechanism RSA-PKCS --id 22 \ -i aes_wrapped.key --key-type AES: \ --application-id 90 --application-label unwrapped-key SO-PIN PIN: pkcs11-tool --login --login-type so --init-pin (AUTHORS) pkcs11-tool Olaf Kirch . opensc 06/02/2026 PKCS11-TOOL(1)