8.2 KiB
(cyrptography_chapter)=
Cryptographic concepts and terms
:class: warning
- Introduce visualizations for cryptographic primitives
- Show example visualizations for operations? (encrypt/decrypt and signing/verification - only if we're going to reuse the visual primitives later)
Cryptographic hash functions
Cryptographic hash functions take data strings of any length (like a text message or file) and output a fixed-size code, often called a "hash" or "digest." This hash acts like a unique identifier for the original data.
Here are two important properties of cryptographic hash functions:
- "Pre-image resistance": Given a hash value, it should be very difficult to determine the original data it represents.
- "Collision resistance": It should be very difficult to find two distinct pieces of data that map to the same hash value.
Symmetric-key cryptography
Symmetric-key cryptography uses the same cryptographic key for both encryption and decryption, unlike asymmetric cryptography where a pair of keys is used: a public key for encryption and a corresponding private key for decryption. Symmetric-key cryptographic systems support encryption/decryption operations.
Participants in symmetric-key operations need to exchange the shared secret over a secure channel.
:class: warning
- visualization? (maybe a black key icon, following wikipedia's example?)
Benefits and downsides
Symmetric-key cryptography has major benefits: It is much faster than public-key cryptography (see below). Also, most current symmetric cryptographic algorithms are considered quantum-resistant[^postquantum].
:class: warning
I am not convinced that this information is helpful but, if it remains, perhaps we need this additional statement: "That is, symmetric-key cryptographic mechanisms are currently considered to be resilient against known computer threats, providing a measure of assurance in the evolving landscape of cryptography and quantum computing."
[^postquantum]: Daniel J. Bernstein (2009). ["Introduction to post-quantum cryptography" (PDF)](http://www.pqcrypto.org/www.springer.com/cda/content/document/cda_downloaddocument/9783540887010-c1.pdf) states that: "many important classes of cryptographic systems", including secret-key cryptographic mechanisms like AES "[..] are believed to resist classical computers and quantum computers." (pages 1, 2).
However, exchanging the required shared secret is a problem that needs to be solved separately.
Hybrid cryptosystems combine the advantages of symmetric-key cryptography with a separate mechanism for managing the shared secret, using public-key cryptography.
Symmetric-key cryptography in OpenPGP
Symmetric-key cryptography is used in OpenPGP in three contexts:
- most prominently, as part of a hybrid cryptosystem to encrypt and decrypt data,
- to encrypt password-protected private key material, and
- for password-protected data encryption, a less commonly used feature of the standard.
Where symmetric keys are used in OpenPGP for data encryption, they are called either "message keys" or "session keys1."
Authenticated encryption with associated data (AEAD)
Authenticated encryption offers more than just confidentiality; it ensures data integrity too.
In OpenPGP version 6, AEAD replaced the MDC2 mechanism to address malleability. In earlier OpenPGP versions, malicious alterations to ciphertext might go unnoticed. AEAD guards against such undetected changes.
By addressing the malleability problem, AEAD also counters a variation of the EFAIL3 attack.
Public-key (asymmetric) cryptography
Public-key cryptography uses asymmetric pairs of related keys. Each pair consists of a public key and a private key. These systems support encryption, decryption, and digital signature operations.
Unlike symmetric cryptography, participants are not required to pre-arrange a shared secret. In public-key cryptography, the public key material is shared openly for certain cryptographic operations, such as encryption and signature creation, while the private key, kept confidential, is used for operations like decryption and signature verification.
(asymmetric_key_pair)=
Asymmetric cryptographic key pairs
Throughout this document, we will frequently reference asymmetric cryptographic key pairs:
---
---
An asymmetric cryptographic key pair
Each key pair comprises two components: the public key and the private key. For ease of identification, we will depict the public key in green and the private key in red throughout this document.
It's important to note that in many scenarios, only the public key is exposed or used (we will expand on these situations in subsequent sections):
---
---
The public component of an asymmetric key pair
Public-key cryptography in OpenPGP
OpenPGP makes heavy use of public-key cryptography, both for encryption and signing operations.
:class: note
For historical reasons, the OpenPGP RFC and other documentation often use the non-standard term "secret key" instead of the more common "private key."
So in OpenPGP, the pair of terms "public/secret key" is sometimes used instead of the more common "public/private key."
Cryptographic digital signatures
Digital signatures are a mechanism that is based on asymmetric cryptography. With this mechanism, one actor can make a signature over a digital message, and another actor can check the validity of that signature.
The signer uses digital signatures to make statements about the message. Third parties can then inspect these statements.
:class: warning
- add visualization showing: message + private key + sign = signature -> message + signature + public key + verify = ok?
In OpenPGP, digital signatures are used in two different contexts:
(hybrid_cryptosystems)=
Hybrid cryptosystems
Hybrid cryptosystems combine two cryptosystems and make use of their respective advantages:
- A public-key cryptosystem is used to safely handle shared secrets over insecure channels (in OpenPGP: so-called "session keys")
- A symmetric-key cryptosystem is used to efficiently encrypt and decrypt long messages (using an OpenPGP "session key" as the shared secret)
-
In OpenPGP version 6, the "Version 2 Symmetrically Encrypted Integrity Protected Data Packet Format" requires that a "message key" is derived from a "session key." In contrast, up to OpenPGP version 4, and in version 6 when using "Version 1 Symmetrically Encrypted Integrity Protected Data Packet Format", the "session key" was used directly as a symmetric encryption key. ↩︎
-
In OpenPGP version 4, a mechanism called MDC (Modification Detection Code) was introduced to serve a comparable purpose as AEAD. While MDC is a non-standard mechanism, as of this writing, there are no known attacks against the scheme. ↩︎
-
A variation of the EFAIL attack can be prevented by both the MDC and AEAD mechanisms. Also see "No, PGP is not broken, not even with the Efail vulnerabilities," especially the section "Malleability Gadget Exfiltration Channel Attack." ↩︎