zkey: Add key checks when importing a CCA-AESCIPHER key

Perform extended checks on a secure key that is imported into
the key repository. Warn the user if the imported key is by
any means insecure, e.g. has been originally created in an
insecure way. Prompt the user to continue the import if a
potential insecurity is detected.

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-07-31 16:34:15 +02:00
committed by Jan Höppner
parent 7fede7021e
commit 0d9e42264d
6 changed files with 85 additions and 12 deletions
+24
View File
@@ -793,3 +793,27 @@ int cross_check_apqns(const char *apqns, u64 mkvp, int min_level,
return rc;
}
/*
* Prompts for yes or no. Returns true if 'y' or 'yes' was entered.
*
* @param[in] verbose if true, verbose messages are printed
*
* @returns true if 'y' or 'yes' was entered (case insensitive). Returns false
* otherwise.
*/
bool prompt_for_yes(bool verbose)
{
char str[20];
if (fgets(str, sizeof(str), stdin) == NULL)
return false;
if (str[strlen(str) - 1] == '\n')
str[strlen(str) - 1] = '\0';
pr_verbose(verbose, "Prompt reply: '%s'", str);
if (strcasecmp(str, "y") == 0 || strcasecmp(str, "yes") == 0)
return true;
return false;
}