PKCS#11
What is PKCS#11?
PKCS#11A standard C API, also called Cryptoki, that lets applications use cryptographic tokens such as hardware security modules and smart cards without depending on a vendor-specific driver.
PKCS#11, also called Cryptoki, defines a platform-independent C API for cryptographic tokens such as HSMs, smart cards and TPM-backed stores. Originally published by RSA Laboratories, it is now maintained by the OASIS PKCS 11 Technical Committee; the current edition, PKCS#11 v3.1, was ratified as an OASIS Standard in 2023 and adds modern primitives (EdDSA/Ed25519, SHA-3, AES-GCM and hooks for post-quantum algorithms). A token exposes slots, sessions and objects (keys, certificates, data); operations such as C_Sign, C_Encrypt, C_WrapKey and C_DeriveKey run inside the device, so a key marked CKA_SENSITIVE and CKA_EXTRACTABLE=false never leaves it in plaintext.
A classic weakness sits at the API level rather than in the crypto. Jolyon Clulow's On the Security of PKCS#11 (CHES 2003) described the wrap-then-decrypt attack: if one key carries both the CKA_WRAP and CKA_DECRYPT attributes, an attacker wraps a sensitive key under it and then decrypts the ciphertext to recover that key in cleartext — defeating the "sensitive stays sensitive" promise. The root cause is missing key separation between roles. Mitigations make attributes sticky and roles mutually exclusive, or derive distinct keys per role; later work (the Tookan tool, CCS 2010, and the University of Venice APDU-level studies) found several commercial tokens still exploitable.
flowchart LR APP["Application: OpenSSL, PKI, code signing"] -->|"Cryptoki C API"| LIB["PKCS#11 library / driver"] LIB -->|"C_Sign / C_Encrypt / C_WrapKey"| TOK["Token: HSM / smart card / TPM"] TOK --> OBJ["Objects: keys & certs (CKA_SENSITIVE)"] OBJ --> NX["Private key stays inside the device"] TOK -->|"result only"| APP
● Examples
- 01
OpenSSL using a YubiHSM 2 through pkcs11-provider to sign a TLS certificate request.
- 02
A code-signing CI job calling C_Sign on an AWS CloudHSM-backed key without ever exporting it.
● Frequently asked questions
What is PKCS#11?
A standard C API, also called Cryptoki, that lets applications use cryptographic tokens such as hardware security modules and smart cards without depending on a vendor-specific driver. It belongs to the Cryptography category of cybersecurity.
What does PKCS#11 mean?
A standard C API, also called Cryptoki, that lets applications use cryptographic tokens such as hardware security modules and smart cards without depending on a vendor-specific driver.
How do you defend against PKCS#11?
Defences for PKCS#11 typically combine technical controls and operational practices, as detailed in the full definition above.
What are other names for PKCS#11?
Common alternative names include: Cryptoki, PKCS11.