zkey: Add PVSECRET-HMAC key type and general HMAC support

Add the definitions and utility functions for the PVSECRET-HMAC key type.
A PVSECRET-HMAC key token contains the secret id of a protected
virtualization secret. It does not contain the key material, just a
reference to the key in the ultravisor.

When such a key token is used to perform HMAC operations later on, the
PHMAC kernel cipher will obtain the protected key belonging to this secret
id with the help of the pkey kernel module.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Ingo Franzki
2024-03-11 17:17:58 +01:00
committed by Jan Höppner
parent c3d8208a57
commit a9059449b9
9 changed files with 493 additions and 304 deletions

View File

@@ -302,6 +302,7 @@ struct pkey_apqns4keytype {
#define KEY_TYPE_CCA_AESCIPHER "CCA-AESCIPHER"
#define KEY_TYPE_EP11_AES "EP11-AES"
#define KEY_TYPE_PVSECRET_AES "PVSECRET-AES"
#define KEY_TYPE_PVSECRET_HMAC "PVSECRET-HMAC"
#define DEFAULT_KEYBITS 256
#define PAES_BLOCK_SIZE 16
@@ -367,11 +368,16 @@ bool is_ep11_aes_key(const u8 *key, size_t key_size);
bool is_ep11_aes_key_with_header(const u8 *key, size_t key_size);
bool is_ep11_key_session_bound(const u8 *key, size_t key_size);
bool is_pvsecret_aes_key(const u8 *key, size_t key_size);
bool is_pvsecret_hmac_key(const u8 *key, size_t key_size);
bool is_xts_key(const u8 *key, size_t key_size);
bool is_secure_key(const u8 *key, size_t key_size);
bool is_aes_key(const u8 *key, size_t key_size);
bool is_hmac_key(const u8 *key, size_t key_size);
int get_key_bit_size(const u8 *key, size_t key_size, size_t *bitsize);
const char *get_key_type(const u8 *key, size_t key_size);
bool is_secure_key_type(const char *key_type);
bool is_aes_key_type(const char *key_type);
bool is_hmac_key_type(const char *key_type);
int get_min_card_level_for_keytype(const char *key_type);
const struct fw_version *get_min_fw_version_for_keytype(const char *key_type);
enum card_type get_card_type_for_keytype(const char *key_type);