zkey: Add function to obtain the mkvp of a secure key

A secure AES key token contains the master key verification pattern
of the master key it is encrypted with. Add a function to obtain the
master key verification pattern of a secure key token.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Harald Freudenberger <freude@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Ingo Franzki
2019-06-14 09:48:45 +02:00
committed by Jan Höppner
parent b32c031474
commit ea7cc9ea60
2 changed files with 25 additions and 0 deletions

View File

@@ -769,3 +769,24 @@ out:
return rc;
}
int get_master_key_verification_pattern(const u8 *secure_key,
size_t secure_key_size, u64 *mkvp,
bool verbose)
{
struct secaeskeytoken *token = (struct secaeskeytoken *)secure_key;
util_assert(secure_key != NULL, "Internal error: secure_key is NULL");
util_assert(mkvp != NULL, "Internal error: mkvp is NULL");
if (secure_key_size < SECURE_KEY_SIZE) {
pr_verbose(verbose, "Size of secure key is too small: "
"%lu expected %lu", secure_key_size,
SECURE_KEY_SIZE);
return -EINVAL;
}
*mkvp = token->mkvp;
return 0;
}

View File

@@ -112,4 +112,8 @@ int validate_secure_key(int pkey_fd,
int generate_key_verification_pattern(const char *key, size_t key_size,
char *vp, size_t vp_len, bool verbose);
int get_master_key_verification_pattern(const u8 *secure_key,
size_t secure_key_size, u64 *mkvp,
bool verbose);
#endif