zkey: Fix convert command to accept only keys of type CCA-AESDATA

Reject conversion of other key types with a proper error message.
Also fix a typo in another error message of the convert command.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
This commit is contained in:
Ingo Franzki
2024-02-19 12:57:22 +01:00
committed by Steffen Eiden
parent b27b8e3cd3
commit cd822cb770

View File

@@ -2471,7 +2471,7 @@ static int command_convert_file(void)
if (g.name != NULL) {
warnx("Option '--name|-N' is not valid for "
"re-enciphering a key outside of the repository");
"converting a key outside of the repository");
util_prg_print_parse_error();
return EXIT_FAILURE;
}
@@ -2504,6 +2504,15 @@ static int command_convert_file(void)
if (secure_key == NULL)
return EXIT_FAILURE;
if (!is_cca_aes_data_key(secure_key, secure_key_size)) {
warnx("Only secure keys of type %s can "
"be converted. The secure key '%s' is of type %s",
KEY_TYPE_CCA_AESDATA, g.pos_arg,
get_key_type(secure_key, secure_key_size));
rc = EXIT_FAILURE;
goto out;
}
rc = validate_secure_key(g.pkey_fd, secure_key, secure_key_size, NULL,
&is_old_mk, NULL, g.verbose);
if (rc != 0) {