-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
swtpm: Modify custom profile when FIPS is enabled
When FIPS is enabled on the host and the 'custom' profile is chosen then remove all (currently) known algorithms disabled by FIPS so that FIPS does not need to be disabled in the OpenSSL instance. Also set or adjust minimum key sizes for EC and RSA keys. Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
- Loading branch information
1 parent
5677f2c
commit f373b17
Showing
8 changed files
with
273 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* SPDX-License-Identifier: BSD-3-Clause */ | ||
|
||
/* | ||
* profile.c: Functions for handling profiles | ||
* | ||
* Author: Stefan Berger, stefanb@linux.ibm.com | ||
* | ||
* Copyright (c) IBM Corporation, 2024 | ||
*/ | ||
|
||
#include "config.h" | ||
|
||
#include <stdio.h> | ||
|
||
#include "profile.h" | ||
#include "utils.h" | ||
#include "swtpm_utils.h" | ||
#include "check_algos.h" | ||
|
||
/* | ||
* Remove algorithms disabled by FIPS from the given JSON profile but only do | ||
* this if this is the 'custom' profile. | ||
* | ||
* @json_profile: Pointer to the string with the JSON profile | ||
* | ||
* Return values: | ||
* 0 : no error | ||
* 1 : fatal error | ||
* 2 : this is not the 'custom' profile | ||
*/ | ||
int profile_remove_fips_disabled_algorithms(char **json_profile) | ||
{ | ||
g_autofree gchar *info_data = NULL; | ||
g_autofree gchar *value = NULL; | ||
g_auto(GStrv) algorithms = NULL; | ||
int ret; | ||
|
||
ret = json_get_map_key_value(*json_profile, "Name", &value); | ||
if (ret || !value || strcmp(value, "custom")) | ||
return 2; | ||
|
||
SWTPM_G_FREE(value); | ||
ret = json_get_map_key_value(*json_profile, "Algorithms", &value); | ||
if (ret == 1) | ||
return 1; | ||
|
||
if (ret == 2) { | ||
info_data = TPMLIB_GetInfo(TPMLIB_INFO_RUNTIME_ALGORITHMS); | ||
|
||
ret = json_get_submap_value(info_data, "RuntimeAlgorithms", "Implemented", | ||
&value); | ||
if (ret) | ||
return 1; | ||
} | ||
algorithms = g_strsplit(value, ",", -1); | ||
if (ossl_remove_fips_disabled_algorithms(&algorithms)) | ||
return 1; | ||
|
||
g_free(value); | ||
value = g_strjoinv(",", algorithms); | ||
|
||
/* put algorithms into JSON */ | ||
ret = json_set_map_key_value(json_profile, "Algorithms", value); | ||
if (ret) | ||
return 1; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* SPDX-License-Identifier: BSD-3-Clause */ | ||
|
||
/* | ||
* profile.h: Header for profile.c | ||
* | ||
* Author: Stefan Berger, stefanb@linux.ibm.com | ||
* | ||
* Copyright (c) IBM Corporation, 2024 | ||
*/ | ||
|
||
#ifndef SWTPM_PROFILE_H | ||
#define SWTPM_PROFILE_H | ||
|
||
int profile_remove_fips_disabled_algorithms(char **json_profile); | ||
|
||
#endif /* SWTPM_PROFILE_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters