mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
zkey: Support EP11 AES keys with prepended header to retain EP11 session
The pkey kernel module supports two key blob formats for EP11 AES keys. The first one (PKEY_TYPE_EP11) contains a 16 bytes header that overlays the first 32 bytes of the key blob which usually contain the ID of the EP11 session to which the key is bound. For zkey/dm-crypt that session ID used to be all zeros. The second blob format (PKEY_TYPE_EP11_AES) prepends the 16 bytes header to the blob, an thus does not overlay the blob. This format can be used for key blobs that are session-bound, i.e. have a non-zero session ID in the first 32 bytes. Change zkey to generate EP11 keys using the new format (i.e. pkey type PKEY_TYPE_EP11_AES), but existing key blobs using the old format can still be used. Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com> Reviewed-by: Joerg Schmidbauer <jschmidb@de.ibm.com> Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
This commit is contained in:
committed by
Steffen Eiden
parent
f46f6d34d3
commit
1b044b8a40
@@ -2175,7 +2175,7 @@ int generate_kms_key(struct kms_info *kms_info, const char *name,
|
||||
else if (strcasecmp(key_type, KEY_TYPE_CCA_AESCIPHER) == 0)
|
||||
key_size = AESCIPHER_KEY_SIZE;
|
||||
else if (strcasecmp(key_type, KEY_TYPE_EP11_AES) == 0)
|
||||
key_size = EP11_KEY_SIZE;
|
||||
key_size = EP11_AES_KEY_SIZE;
|
||||
else
|
||||
return -ENOTSUP;
|
||||
|
||||
@@ -2248,6 +2248,9 @@ int generate_kms_key(struct kms_info *kms_info, const char *name,
|
||||
if (verbose)
|
||||
util_hexdump_grp(stderr, NULL, key_blob, 4, key_blob_size, 0);
|
||||
|
||||
if (is_ep11_aes_key(key_blob, key_blob_size))
|
||||
key_size = EP11_KEY_SIZE;
|
||||
|
||||
/* Save ID and label of 1st key */
|
||||
rc = properties_set(key_props, xts ? PROP_NAME_KMS_XTS_KEY1_ID :
|
||||
PROP_NAME_KMS_KEY_ID, key1_id);
|
||||
@@ -3132,6 +3135,8 @@ int import_kms_key(struct kms_info *kms_info, const char *key1_id,
|
||||
key_size = AESCIPHER_KEY_SIZE;
|
||||
else if (is_ep11_aes_key(key_blob, key_blob_size))
|
||||
key_size = EP11_KEY_SIZE;
|
||||
else if (is_ep11_aes_key_with_header(key_blob, key_blob_size))
|
||||
key_size = EP11_AES_KEY_SIZE;
|
||||
|
||||
if (key_size == 0 || key_blob_size > key_size) {
|
||||
pr_verbose(verbose, "Key '%s' has an unknown or unsupported "
|
||||
@@ -3366,6 +3371,8 @@ int refresh_kms_key(struct kms_info *kms_info, struct properties *key_props,
|
||||
key_size = AESCIPHER_KEY_SIZE;
|
||||
else if (is_ep11_aes_key(key_blob, key_blob_size))
|
||||
key_size = EP11_KEY_SIZE;
|
||||
else if (is_ep11_aes_key_with_header(key_blob, key_blob_size))
|
||||
key_size = EP11_AES_KEY_SIZE;
|
||||
|
||||
if (key_size == 0 || key_blob_size > key_size) {
|
||||
pr_verbose(verbose, "Key '%s' has an unknown or unsupported "
|
||||
|
||||
Reference in New Issue
Block a user