dm-inlinecrypt: add support for hardware-wrapped keys
Subsystems (2)
v3 cover dm-inlinecrypt: add support for hardware-wrapped keys
dm-inlinecrypt currently assumes that all keys are raw software keys. That does not work for platforms where inline encryption expects hardware-wrapped key material managed by secure firmware/hardware.
This series adds support for hardware-wrapped keys in dm-inlinecrypt by introducing an optional <key_type> target argument. The flag lets dm-inlinecrypt select the proper blk-crypto key type at key initialization time:
- 1: BLK_CRYPTO_KEY_TYPE_RAW
- 2: BLK_CRYPTO_KEY_TYPE_HW_WRAPPED
With this change, dm-inlinecrypt can support both raw and wrapped key deployment models without hardcoding one key ownership model. The series also:
- updates target argument parsing to include the new required flag
- propagates the wrapped/raw state in target status output
- updates dm-inlinecrypt documentation and examples accordingly Linlin Zhang (1):
dm-inlinecrypt: add support for hardware-wrapped keys
.../device-mapper/dm-inlinecrypt.rst | 20 +++--- drivers/md/dm-inlinecrypt.c | 63 ++++++++++++------- 2 files changed, 54 insertions(+), 29 deletions(-)
Signature · 1 line
2.34.1
PATCH v3 1/1 dm-inlinecrypt: add support for hardware-wrapped keys
Add support for hardware-wrapped encryption keys to the dm-inlinecrypt target.
Introduce a new optional argument <key_type> to indicate whether the provided key is a raw key or a hardware-wrapped key. Based on this flag, the appropriate blk-crypto key type is selected when initializing the key.
This allows dm-inlinecrypt to work with hardware that requires keys to be wrapped and managed by the underlying inline encryption engine.
Update the target argument parsing accordingly and pass the key type to blk_crypto_init_key(). Documentation is also updated to reflect the new parameter and usage.
--- .../device-mapper/dm-inlinecrypt.rst | 20 +++--- drivers/md/dm-inlinecrypt.c | 63 ++++++++++++------- 2 files changed, 54 insertions(+), 29 deletions(-)
Documentation/admin-guide/device-mapper/dm-inlinecrypt.rst +13 -7
@@ -39,18 +39,19 @@ Parameters:: <key_string> The kernel keyring key is identified by string in following format: - <key_size>:<key_type>:<key_description>. + <key_size>:<keyring_type>:<key_description>. <key_size> The encryption key size in bytes. The kernel key payload size must match the value passed in <key_size>. -<key_type> - Either 'logon', or 'trusted' kernel key type. +<keyring_type> + The type of the key inside the kernel keyring. It can be either 'logon', + or 'trusted' kernel key type. <key_description> The kernel keyring key description inlinecrypt target should look for - when loading key of <key_type>. + when loading key of <keyring_type>. <iv_offset> The IV offset is a sector count that is added to the sector number
@@ -70,7 +71,12 @@ Parameters:: Otherwise #opt_params is the number of following arguments. Example of optional parameters section: - allow_discards sector_size:4096 iv_large_sectors + keytype:raw allow_discards sector_size:4096 iv_large_sectors + +<key_type> + The type of the key as seen by the block layer, either standard or + hardware-wrapped. The string is supplied in the table as <keytype:raw> + or <keytype:hw-wrapped>. allow_discards Block discard requests (a.k.a. TRIM) are passed through the inlinecrypt
@@ -113,11 +119,11 @@ using dmsetup #!/bin/sh # Create a inlinecrypt device using dmsetup - dmsetup create inlinecrypt1 --table "0 `blockdev --getsz $1` inlinecrypt aes-xts-plain64 babebabebabebabebabebabebabebabebabebabebabebabebabebabebabebabe 0 $1 0" + dmsetup create inlinecrypt1 --table "0 `blockdev --getsz $1` inlinecrypt aes-xts-plain64 babebabebabebabebabebabebabebabebabebabebabebabebabebabebabebabe 0 0 $1 0 1 keytype:raw" :: #!/bin/sh # Create a inlinecrypt device using dmsetup when encryption key is stored in keyring service - dmsetup create inlinecrypt2 --table "0 `blockdev --getsz $1` inlinecrypt aes-xts-plain64 :64:logon:fde:dminlinecrypt_test_key 0 $1 0" + dmsetup create inlinecrypt2 --table "0 `blockdev --getsz $1` inlinecrypt aes-xts-plain64 :64:logon:fde:dminlinecrypt_test_key 0 0 $1 0 1 keytype:raw"
drivers/md/dm-inlinecrypt.c +41 -22
158 lines not on this page · raw message
Signature · 1 line
2.34.1
drivers/md/dm-inlinecrypt.c static void inlinecrypt_status(struct dm_target *ti, status_type_t type, · line 526
Quoted 10 lines · Linlin Zhang
drivers/md/dm-inlinecrypt.c +3
-2@@ -502,8 +520,9 @@ static void inlinecrypt_status(struct dm_target *ti, status_type_t type,* the returned table. Userspace is responsible for redacting * the key when needed. */ -DMEMIT ("%s %*phN %llu %s %llu" , ctx->cipher_string, - ctx->key.size, ctx->key.bytes, ctx->iv_offset, +DMEMIT ("%s %*phN %u %llu %s %llu" , ctx->cipher_string, + ctx->key.size, ctx->key.bytes, + ctx->key_type, ctx->iv_offset, ctx->dev->name, ctx->start);
I think you forgot to update this when adding support for keyring keys. The point of the keyring keys (to the extent they have a point at all) is that their contents can't be read back from userspace. But this just returns the contents. Take a look at how dm-crypt.c handles this.
- Eric
Hi Milan, Eric and Mikulas,
Do you have a chance to help review this patch?
I'm appreciated if you can help give some comments or accept and help merge this patch.
Thanks,
Linlin
Quoted 25 lines · Linlin Zhang
dm-inlinecrypt currently assumes that all keys are raw software keys. That does not work for platforms where inline encryption expects hardware-wrapped key material managed by secure
firmware/hardware.This series adds support for hardware-wrapped keys in dm-inlinecrypt by introducing an optional <
key_type> target argument. The flag lets dm-inlinecrypt select the proper blk-crypto key type at key initialization time:- 1:
BLK_CRYPTO_KEY_TYPE_RAW
- 2:BLK_CRYPTO_KEY_TYPE_HW_WRAPPEDWith this change, dm-inlinecrypt can support both raw and wrapped key deployment models without hardcoding one key ownership model. The series also:
- updates target argument parsing to include the new required flag
- propagates the wrapped/raw state in target status output
- updates dm-inlinecrypt documentation and examples accordingly Linlin Zhang (1):
dm-inlinecrypt: add support for hardware-wrapped keys.../device-mapper/dm-inlinecrypt.rst | 20 +++--- drivers/md/dm-inlinecrypt.c | 63 ++++++++++++------- 2 files changed, 54 insertions(+), 29 deletions(-)
Mikulas Patocka
maintainerQuoted 8 lines · Linlin Zhang
Hi Milan, Eric and Mikulas,
Do you have a chance to help review this patch?
I'm appreciated if you can help give some comments or accept and help merge this patch.
Thanks,
Linlin
Hi
I already accepted this patch, I will send it to Linus in this merge window.
Mikulas
Quoted 27 lines · Linlin Zhang
Quoted 25 lines
dm-inlinecrypt currently assumes that all keys are raw software keys. That does not work for platforms where inline encryption expects hardware-wrapped key material managed by secure
firmware/hardware.This series adds support for hardware-wrapped keys in dm-inlinecrypt by introducing an optional <
key_type> target argument. The flag lets dm-inlinecrypt select the proper blk-crypto key type at key initialization time:- 1:
BLK_CRYPTO_KEY_TYPE_RAW
- 2:BLK_CRYPTO_KEY_TYPE_HW_WRAPPEDWith this change, dm-inlinecrypt can support both raw and wrapped key deployment models without hardcoding one key ownership model. The series also:
- updates target argument parsing to include the new required flag
- propagates the wrapped/raw state in target status output
- updates dm-inlinecrypt documentation and examples accordingly Linlin Zhang (1):
dm-inlinecrypt: add support for hardware-wrapped keys.../device-mapper/dm-inlinecrypt.rst | 20 +++--- drivers/md/dm-inlinecrypt.c | 63 ++++++++++++------- 2 files changed, 54 insertions(+), 29 deletions(-)