Message ID | 20211214005212.20588-1-chang.seok.bae@intel.com |
---|---|
Headers | show |
Series | x86: Support Key Locker | expand |
On Mon, Dec 13, 2021 at 04:51:59PM -0800, Chang S. Bae wrote: > == Disk Encryption Use Case == > > Disk encryption uses Key Locker to mitigate key exfiltration as follows: > > 1. Configuration for Key Locker: AES-KL shows up in /proc/crypto as a > distinct cipher option. From there, tools like cryptsetup [5] can select > AES-KL vs AES-NI. For example, > > $ cryptsetup luksFormat --cipher="capi:xts-aes-aeskl-plain" <device> plain64 is supposed to be used these days, not plain. > Note: AES-KL has a performance tradeoff. See details in 'Performance' > below. > > 2. Disk encryption flow with key protection: > > * The cryptsetup utility is responsible for loading the volume key into the > kernel's keyring and passing a reference of the key. Once dm-crypt [6] > has set up the volume, user space is responsible for invalidating the key > material so that only the key handle remains in memory. Cryptsetup does > this, e.g. via crypt_free_volume_key() and crypt_safe_free(). > > * The AES-KL code in the kernel's crypto library uses the key handle > instead of the actual clear text key. > > == Non Use Cases == > > Bare metal disk encryption is the only use case intended by these patches. Since dm-crypt is the use case for these patches, you probably should CC this patchset to dm-devel@redhat.com so that the dm-crypt developers are aware of it. > +-----------+---------------+---------------+ > | Cipher | Encryption | Decryption | > | (AES-KL) | (MiB/s) | (MiB/s) | > +-----------+---------------+---------------+ > | AES-CBC | 505.3 | 2097.8 | > | AES-XTS | 1130 | 696.4 | > +-----------+-------------------------------+ Why is AES-XTS decryption so much slower than AES-XTS encryption? They should be about the same. Also, is the AES-CBC support really useful, given that for disk encryption, AES-XTS is recommended over AES-CBC these days? - Eric
On 12/13/21 16:52, Chang S. Bae wrote: > Key Locker is a CPU feature to reduce key exfiltration opportunities while > maintaining a programming interface similar to AES-NI. It converts the AES > key into an encoded form, called the 'key handle'. > > The key handle is a wrapped version of the clear-text key where the > wrapping key has limited exposure. Once converted via setkey(), all > subsequent data encryption using new AES instructions ('AES-KL') uses this > key handle, reducing the exposure of private key material in memory. > > AES-KL is analogous to that of AES-NI. Most assembly code is translated > from the AES-NI code. They are operational in both 32-bit and 64-bit modes > like AES-NI. However, users need to be aware of the following differences: > > == Key Handle == > > AES-KL may fail with an invalid key handle. It could be corrupted or fail > with handle restriction. A key handle may be encoded with some > restrictions. The implementation restricts every handle only available > in kernel mode via setkey(). > I find it a bit bizarre that this tries to be a drop-in replacement for normal AES. Is this actually what we want, or do we want users to opt in to the KL implementation? It seems like it might make more sense for tools like cryptsetup (or dm-crypt -- the actual layer is subject to some degree of debate) to explicitly create a key handle and then ask the kernel to use that key handle, not for the kernel to do this by magic. What happens when someone applies your patches and runs dmsetup table --showkeys? Why should the use of keylocker be part of the luksFormat operation? Surely a non-KL machine should still be able to decrypt a nominally KL-using volume in a pinch, for recovery purposes if nothing else. --Andy
On Dec 15, 2021, at 17:09, Eric Biggers <ebiggers@kernel.org> wrote: > On Mon, Dec 13, 2021 at 04:51:59PM -0800, Chang S. Bae wrote: >> == Disk Encryption Use Case == <snip> >> $ cryptsetup luksFormat --cipher="capi:xts-aes-aeskl-plain" <device> > > plain64 is supposed to be used these days, not plain. I see. >> == Non Use Cases == >> >> Bare metal disk encryption is the only use case intended by these patches. > > Since dm-crypt is the use case for these patches, you probably should CC this > patchset to dm-devel@redhat.com so that the dm-crypt developers are aware of it. Oh, I should have included them. I was not aware of this mailing address. Hi DM-crypt folks, Here is the patch series: https://lore.kernel.org/lkml/20211214005212.20588-1-chang.seok.bae@intel.com/t/ I would appreciate if you give any feedback on this feature’s use case with yours. >> +-----------+---------------+---------------+ >> | Cipher | Encryption | Decryption | >> | (AES-KL) | (MiB/s) | (MiB/s) | >> +-----------+---------------+---------------+ >> | AES-CBC | 505.3 | 2097.8 | >> | AES-XTS | 1130 | 696.4 | >> +-----------+-------------------------------+ > > Why is AES-XTS decryption so much slower than AES-XTS encryption? They should > be about the same. Analyzing and understanding this with specific hardware implementation takes time for us. Will come back and update you when we have anything to share here. > Also, is the AES-CBC support really useful, given that for disk encryption, > AES-XTS is recommended over AES-CBC these days? Yes, we understand that AES-XTS is the primary option for disk encryption. But it seems that AES-CBC had been used for disk encryption, [1]: Comparing XTS to CBC for hard disk encryption If a storage device vendor is seeking FIPS 140-2 certification today, they will typically use CBC encryption, or even ECB. CBC is a good mode, ... As long as it is factual that the mode was once popular, it can help somebody who wants to use Key Locker for an old disk image I think. Thanks, Chang [1] https://csrc.nist.gov/CSRC/media/Projects/Block-Cipher-Techniques/documents/BCM/Comments/XTS/XTS_comments-Ball.pdf
On Dec 24, 2021, at 09:42, Andy Lutomirski <luto@kernel.org> wrote: > > I find it a bit bizarre that this tries to be a drop-in replacement for normal > AES. Is this actually what we want, or do we want users to opt in to the KL > implementation? > > It seems like it might make more sense for tools like cryptsetup (or dm-crypt > -- the actual layer is subject to some degree of debate) to explicitly create > a key handle and then ask the kernel to use that key handle, not for the > kernel to do this by magic. Yeah, it is ideal to encode a key early but it was considered less significant in terms of key protection versus doing it via setkey(). This opt-in looks to be the --cipher option specific and cryptsetup even allows users to directly choose kernel’s crypto API via “capi:”. I suspect in case a user wants to pick a specific crypto implementation via “capi:”, one should have studied it. But indeed, such question deserves more discussion here. > What happens when someone applies your patches and runs dmsetup table > --showkeys? "dmsetup table --showkeys" [1] shows UUID that could be found when dumping the master key by giving the passphrase, like [2]. The volume key in LUKS header is under the user key. > Why should the use of keylocker be part of the luksFormat operation? Surely a > non-KL machine should still be able to decrypt a nominally KL-using volume in > a pinch, for recovery purposes if nothing else. I was trying to directly update cipher information in LUKS. But it was not that smooth. But if it is possible in an acceptable way, decoding KL-volume with a generic AES (or vice versa) should work. They both are AES data transformations so compatible with each other. This was also tested by setting the default AES cipher in the LUKS then switching each other by tweaking the priority. On the bottom, the "reencrypt" option [3] allows updating a cipher in the LUKS format. But maybe a better option like the above is possible. Thanks, Chang [1] $ sudo dmsetup table --showkeys /dev/mapper/volume 0 491520 crypt capi:xts-aes-aeskl-plain64 :32:logon:cryptsetup:8c12bfda-3570-406a-b4fe-5ecf1e91eecd-d0 0 7:17 32768 [2] $ sudo cryptsetup luksDump --dump-master-key ./test WARNING! ======== Header dump with volume key is sensitive information which allows access to encrypted partition without passphrase. This dump should be always stored encrypted on safe place. Are you sure? (Type uppercase yes): YES Enter passphrase for ./test: LUKS header information for ./test Cipher name: capi:xts Cipher mode: aes-aeskl-plain64 Payload offset: 32768 UUID: 8c12bfda-3570-406a-b4fe-5ecf1e91eecd MK bits: 256 MK dump: 3a 51 37 60 37 d2 58 9f 48 a7 ce 44 f7 ff de 34 4d b9 6f eb f2 e7 d6 bc e0 c9 76 b6 3d b1 e6 24 [3] https://man7.org/linux/man-pages/man8/cryptsetup-reencrypt.8.html