5.3 KiB
(private_key_chapter)=
OpenPGP private keys
Historically, terminology around OpenPGP certificates and keys has often been used inconsistently. The pair of terms "OpenPGP public key" and "OpenPGP private/secret keys" were commonly used (while the shorthand "OpenPGP key" can refer to both, depending on context).
Terms
In this document, we use the term OpenPGP certificate to refer "OpenPGP public keys": The combination of component public keys, identity components and bindings.
This chapter is about the counterpart to the public material in certificates: Here, we discuss the handling of private key material in OpenPGP.
In this text, we treat the private key material as logically separate from the OpenPGP certificate. Operations that use the private key material are typically handled by a separate subsystem. We think it is useful to think about OpenPGP certificates on one hand, and the associated private key material, on the other, as two related elements, which are usually handled separately1:
:class: warning
- OpenPGP certificate side-by-side with the associated, loose private key material
However, there is one exception. "OpenPGP private keys" are sometimes handled in a format that combines the certificate and the private key data: Transferable secret keys (TSK).
Transferable secret keys
Sometimes users handle "OpenPGP private keys" in the form of transferable secret keys (TSK). That is: a serialized format that combines the OpenPGP certificate data with the connected private key material, stored in a single file.
:class: warning
- OpenPGP certificate with integrated private key material, as TSK
The TSK format can be useful for backups of OpenPGP key material, or to move a key to a different computer2.
(encrypted_secrets)=
Protecting secret key material with a passphrase (using S2K)
In OpenPGP format, private key material can be optionally protected with a passphrase. This mechanism applies symmetric encryption to the private key data in component keys.
The symmetric encryption key is derived from a secret that the user knows (the passphrase).
Using a passphrase can be useful when a third party can obtain a copy of the OpenPGP key data, but doesn't know the passphrase. In this scenario, an attacker may have obtained a copy of an OpenPGP key, but is unable to use it, because the private key material is encrypted, and the attacker cannot decrypt it.
OpenPGP defines a mechanism called string-to-key (S2K) that is used to derive (high-entropy) symmetric encryption keys from (lower-entropy) passphrases, using a key derivation function (KDF).
:class: warning
- passphrase --(S2k mechanism)--> symmetric encryption key
Encryption of private key material can be configured independently for each component key. Component keys that are associated with the same certificate can use different mechanisms for passphrase protection, and/or different passphrases.
S2K mechanisms for symmetric key generation
Over time, OpenPGP has specified a series of S2K mechanisms, following the current state of the art. Of the specified S2K mechanisms, two remain relevant today:
- Iterated and Salted S2K, which OpenPGP version 4 implementations can handle
- Argon2, which was newly added in OpenPGP version 6, and additionally protects the passphrase against brute-force attacks because it is memory-hard (which reduces the efficiency of attacks with specialised hardware)
Mechanisms for secret key encryption with S2K
Different mechanisms are specified for the encryption of the secret key data.
Private key operations
The core of private key operations doesn't require access to the whole certificate. A private key subsystem only needs to handle the cryptographic key material.
OpenPGP card for private keys
OpenPGP card devices are a type of hardware security device. They are one popular way to handle OpenPGP private key material. These devices do not store the full OpenPGP certificate.
Advanced topics
TSKs: Best practices S2K + S2K migration?
The KOpenPGP attack
-
This kind of distinction between certificates (which combine public key material and identity information) on the one hand, and private key material on the other, is also applied in the data model of PKCS #11 cryptographic systems. ↩︎
-
For example, with GnuPG, an OpenPGP key can be exported in (armored) TSK format like this:
gpg --export-secret-key --armor <fingerprint>
↩︎