$ openssl list -digest-algorithms
Cryptography
What is it?
The cryptography used at each step of the Hardware page: authentication, signature, hash and cipher, and what each guarantees.
// three questions
Hash, authentication, signature
Hash
Has it changed?
SHA-256, SHA-384, SHA-512
Authentication
Does the sender hold our secret key?
HMAC, AES-GCM and AES-CCM tags. Key from ECDH or ECDHE, or a hardware key (HUK).
Signature
Did the key owner produce it?
RSA (PSS or PKCS#1 v1.5), ECDSA
What each step can guarantee
- Authenticity
- who produced it
- Integrity
- it was not modified
- Confidentiality
- unreadable without the key
- Freshness
- not a replay or a rollback
- Binding
- tied to one device or one boot state
// shared-secret tags
HMAC, AES-GCM and AES-CCM
All three produce a tag: a short value that only a holder of the secret key can compute. The receiver recomputes it and compares. A match proves the data was not modified and that the sender holds the key, but not which key holder sent it.
HMAC: a tag from a hash
HMAC(K, m) = H((K ⊕ opad) || H((K ⊕ ipad) || m)), where opad and ipad are two fixed padding constants and H is a hash such as SHA-256.
The double hash is what makes it safe. With the naive H(K || m), an attacker who sees one tag can append data to a SHA-256 message and compute a valid tag without the key (a length-extension attack). HMAC only authenticates: the data stays readable. On this page it authenticates TPM session commands and RPMB frames, and serves as a key derivation function (OP-TEE's SSK and TSK, the HKDF of TLS 1.3).
AES-GCM and AES-CCM: encrypt and tag in one mode
Both are authenticated encryption (AEAD). AES in counter mode (CTR) encrypts, and the tag covers the ciphertext plus optional header data that stays in clear. They differ in how the tag is computed:
| AES-GCMGalois/Counter Mode | AES-CCMCounter with CBC-MAC | |
|---|---|---|
| Tag | GHASH: a polynomial over the ciphertext, evaluated in GF(2^128) at a key H = AES(K, 0). Encrypt, then authenticate. | CBC-MAC: AES chained over the plaintext, then the tag itself is encrypted. Authenticate, then encrypt. |
| Cost | One AES call per block, parallel. Fast with carry-less multiply instructions (x86 PCLMULQDQ, Arm PMULL). | Two AES calls per block, and the CBC-MAC part is sequential. |
| Streaming | Yes: the message length is only needed at the end. | No: the message length goes into the first CBC-MAC block, so it must be known before starting. |
| Hardware | An AES core plus a GF(2^128) multiplier. | Only an AES encryption core, which is why small microcontrollers like it. |
| Nonce and tag | 96-bit nonce recommended; 128-bit tag typical. | 7 to 13-byte nonce (a longer nonce caps the message length); 4 to 16-byte tag. |
| Nonce reused | Leaks the XOR of the two plaintexts and lets an attacker recover H, then forge tags. | Leaks the XOR of the two plaintexts. |
| Seen in | TLS 1.3, TF-A encrypted firmware (aes_gcm), OP-TEE REE FS and encrypted TAs. | Wi-Fi WPA2 (CCMP), Bluetooth LE, Zigbee and IEEE 802.15.4, TF-A (aes_ccm). |
Sources: RFC 2104 (HMAC), NIST SP 800-38D (GCM), NIST SP 800-38C and RFC 3610 (CCM).
// how they work together
One step: loading an encrypted image
The cipher gives confidentiality only. The image sits in flash as ciphertext; hash and signature decide whether it may run. BL2 loading an encrypted BL31 in TF-A:
What each one gives
- Signature
- Authenticity: only the vendor's private key can make the certificate that carries H.
- Hash
- Integrity: D equal to H ties the decrypted bytes to the signed value.
- Cipher
- Confidentiality: flash content is unreadable without the key. The GCM tag detects modified ciphertext but does not prove who built it.
// per boot step
Cryptography at each boot step
Badges match the steps on the Hardware page. An empty cell means none.
| Step | Authenticationshared secret | Signaturekey pair | Hashwhat, compared with what | Cipherwhat, with which key | Guarantees |
|---|---|---|---|---|---|
| Secure bootverify: may this code run? | |||||
2 | none |
|
| none | AuthenticityIntegrityFreshness |
3 | none |
|
| none | AuthenticityIntegrityFreshness |
3 BL2 decrypts BL31, BL32, BL33Optional encrypted firmware, off by defaultbuild options, io_encrypted.c |
| none | none |
| ConfidentialityIntegrity |
4 | none | none | none | none | none |
5 | none |
|
|
| AuthenticityIntegrityConfidentiality |
6 | none |
|
| none | AuthenticityIntegrity |
PC firmware verifies itselfIntel Boot Guard, AMD Platform Secure BootIntel key usage, Boot Guard chain, AMD PSB | none |
|
| none | AuthenticityIntegrity |
Updating the Secure Boot keysUEFI authenticated variables: PK, KEK, db, dbxSecure Boot keys, UEFI on U-Boot | none |
|
| none | AuthenticityIntegrity |
| none |
|
| none | AuthenticityIntegrity | |
| none |
|
| none | AuthenticityIntegrity | |
8 | none |
|
| none | AuthenticityIntegrity |
9 | none |
|
| none | IntegrityAuthenticity |
| Measured bootrecord: what code did run? | |||||
2, 3 BL1 and BL2 measure what they loadExtend a PCR in a TPM or RSE, or write the event logTF-A measured boot, bl_common.c, TPM 2.0 Part 1 | none | none |
| none | Integrity |
| none | none |
| none | Integrity | |
| none | none |
| AuthenticityIntegrityConfidentialityFreshness | |
Sealing a key to the boot stateThe TPM releases it only if the PCRs matchTPM 2.0 Part 1, BitLocker FAQ |
|
|
|
| ConfidentialityIntegrityBinding |
|
|
| none | AuthenticityIntegrityFreshness | |
|
|
|
| AuthenticityIntegrityConfidentiality | |
| Runtime and OSkeep data safe after boot | |||||
5 |
| none |
|
| ConfidentialityIntegrityBindingFreshness |
| none | none | none |
| ConfidentialityBinding | |
Common mix-up. AES-GCM is not part of measured boot, which only hashes into a PCR. It appears next to it: encrypted firmware, OP-TEE secure storage, TLS to the verifier.
// build options
TF-A options that choose the algorithms
| Option | Values | Used for |
|---|---|---|
| KEY_ALG | rsa (default), rsa_1_5, ecdsa, ecdsa-brainpool-regular, ecdsa-brainpool-twisted | Certificate signatures. rsa_1_5 is legacy and not TBBR compliant. |
| KEY_SIZE | rsa: 1024, 2048 (default), 3072, 4096. ecdsa: 256 (default), 384 | Key size for the chosen algorithm. |
| HASH_ALG | sha256 (default), sha384, sha512 | Image and key hashes in the certificates. |
| MBOOT_TPM_HASH_ALG | sha256, sha384 | Digests extended into the TPM by measured boot. |
| DECRYPTION_SUPPORT | none (default), aes_gcm, aes_ccm | Authenticated decryption of encrypted firmware. |
| ENC_KEY, ENC_NONCE | 256-bit key, 96-bit nonce | Encrypt firmware at build time. The nonce is stored in clear in the image header: it must be unique, not secret. |
Source: TF-A build options.