In the output above, there are 2 implementations of cbc(aes) transformation. The CAAM-backed implementation has a priority
of 3000 while the software implementation has a value of 300. This means that if you instruct DM-Crypt to use cbc(aes) cipher,
the CAAM-backed implementation is used.
To list all transformations registered by CAAM driver:
# grep -B1 -A2 caam /proc/crypto|grep -v kernel
name : rsa
driver : rsa-caam
priority : 3000
--
name : xcbc(aes)
driver : xcbc-aes-caam
priority : 3000
AES in XTS mode is not supported on i.MX devices.
NOTE
2.3 DM-Crypt using CAAM's Secure Key
In Linux Unified Key Setup (LUKS) mode, to generate the disk encryption key (master key), the user supplies a passphrase
which is combined with a salt, then a hash function is applied for a supplied number of rounds. When the user wants to mount
an encrypted volume, the passphrase should be supplied. An alternative could be providing a key file stored in an external drive
containing necessary decryption information. Those approaches are not convenient with embedded devices usage. The aim of
using DM-Crypt with CAAM’s secure key is to suppress the mechanism of encrypting the master volume key with a key derived
from a user-supplied passphrase. DM-Crypt can take advantages of secure key also to protect storage volumes from offline
decryption. The volume encryption key is only seen encrypted on device DDR. In addition, the volume could only be opened by
the devices that have the same OTPMK burned in the fuses.
The secure key feature is based on CAAM’s black key mechanism. Black key protects user keys against bus snooping while the
keys are being written to or read from memory external to the SOC. called a 'Black Key'.
CAAM supports two different black key encapsulation schemes, which are AES-ECB and AES-CBC. Regarding AES-ECB
encryption, the data is a multiple of 16 bytes long. If the key is a multiple of 128-bit, which will be if AES-256 or AES-128 encryption
is used, then the AES-ECB encrypted data encryption key would fit in the same buffer as the original unencrypted data encryption
key. If the data encryption key is not a multiple of 16 bytes long, it is padded before being encrypted. A CCM-encrypted black
key is always at least 12 bytes longer than the encapsulated key (nonce value + MAC tag), where the "MAC tag" (integrity check
value) ensures the integrity of the encapsulated key. While AES-ECB encryption is intended for quick decryption, AES-CCM
encryption is used for high assurance. CCM-encrypted keys are preferred, unless there is a need to fit the encrypted key in the
same space as the unencrypted key.
Black keys are session keys, therefore, they are not power-cycles safe. CAAM's blob mechanism provides a method for protecting
user-defined data across system power cycles. It provides both confidentiality and integrity protection. The data to be protected
is encrypted so that it can be safely placed into non-volatile storage before the SoC is powered down.
The following diagram illustrates the changes that have been added to support full disk encryption using secure key. The CAAM
driver registers new Cryptographic transformations in the kernel to use ECB and CBC blacken keys,
tk(ecb(aes))
and
tk(cbc(aes))
respectively. The
tk
prefix refers to Tagged Key. A Tagged Key is a key that contains metadata indicating which key it is, black
key or red key, and how to handle it, that is encapsulate in secure memory or in general memory. Linux provides an in-kernel
key management and retention facility called Keyrings. Keyring also enables interfaces to allow accessing keys and performing
operations such as add, update, and delete from user-space.
The kernel provides several basic types of keys including keyring, user, and logon. The CAAM driver introduces a new key type
named caam_tk relative to CAAM Tagged Key. Basically, CAAM Tagged Key provisioning can be done through Linux Key
Retention service and managed by user-space application such as keyctl. Secure key can be placed in Linux Key Retention
service while secure key blobs can be stored on any non-volatile storage.
NXP Semiconductors
Overview
i.MX Encrypted Storage Using CAAM Secure Keys, Rev. 0, 25 February 2020
Application Note 3 / 11