Skip to content

Commit 5a44749

Browse files
nefigtutherbertx
authored andcommitted
crypto: fips - make proc files report fips module name and version
FIPS 140-3 introduced a requirement for the FIPS module to return information about itself, specifically a name and a version. These values must match the values reported on FIPS certificates. This patch adds two files to read a name and a version from: /proc/sys/crypto/fips_name /proc/sys/crypto/fips_version v2: removed redundant parentheses in config entries. v3: move FIPS_MODULE_* defines to fips.c where they are used. v4: return utsrelease.h inclusion Signed-off-by: Simo Sorce <[email protected]> Signed-off-by: Vladis Dronov <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 1353e57 commit 5a44749

File tree

2 files changed

+51
-5
lines changed

2 files changed

+51
-5
lines changed

crypto/Kconfig

+21
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,27 @@ config CRYPTO_FIPS
3333
certification. You should say no unless you know what
3434
this is.
3535

36+
config CRYPTO_FIPS_NAME
37+
string "FIPS Module Name"
38+
default "Linux Kernel Cryptographic API"
39+
depends on CRYPTO_FIPS
40+
help
41+
This option sets the FIPS Module name reported by the Crypto API via
42+
the /proc/sys/crypto/fips_name file.
43+
44+
config CRYPTO_FIPS_CUSTOM_VERSION
45+
bool "Use Custom FIPS Module Version"
46+
depends on CRYPTO_FIPS
47+
default n
48+
49+
config CRYPTO_FIPS_VERSION
50+
string "FIPS Module Version"
51+
default "(none)"
52+
depends on CRYPTO_FIPS_CUSTOM_VERSION
53+
help
54+
This option provides the ability to override the FIPS Module Version.
55+
By default the KERNELRELEASE value is used.
56+
3657
config CRYPTO_ALGAPI
3758
tristate
3859
select CRYPTO_ALGAPI2

crypto/fips.c

+30-5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <linux/kernel.h>
1313
#include <linux/sysctl.h>
1414
#include <linux/notifier.h>
15+
#include <generated/utsrelease.h>
1516

1617
int fips_enabled;
1718
EXPORT_SYMBOL_GPL(fips_enabled);
@@ -30,13 +31,37 @@ static int fips_enable(char *str)
3031

3132
__setup("fips=", fips_enable);
3233

34+
#define FIPS_MODULE_NAME CONFIG_CRYPTO_FIPS_NAME
35+
#ifdef CONFIG_CRYPTO_FIPS_CUSTOM_VERSION
36+
#define FIPS_MODULE_VERSION CONFIG_CRYPTO_FIPS_VERSION
37+
#else
38+
#define FIPS_MODULE_VERSION UTS_RELEASE
39+
#endif
40+
41+
static char fips_name[] = FIPS_MODULE_NAME;
42+
static char fips_version[] = FIPS_MODULE_VERSION;
43+
3344
static struct ctl_table crypto_sysctl_table[] = {
3445
{
35-
.procname = "fips_enabled",
36-
.data = &fips_enabled,
37-
.maxlen = sizeof(int),
38-
.mode = 0444,
39-
.proc_handler = proc_dointvec
46+
.procname = "fips_enabled",
47+
.data = &fips_enabled,
48+
.maxlen = sizeof(int),
49+
.mode = 0444,
50+
.proc_handler = proc_dointvec
51+
},
52+
{
53+
.procname = "fips_name",
54+
.data = &fips_name,
55+
.maxlen = 64,
56+
.mode = 0444,
57+
.proc_handler = proc_dostring
58+
},
59+
{
60+
.procname = "fips_version",
61+
.data = &fips_version,
62+
.maxlen = 64,
63+
.mode = 0444,
64+
.proc_handler = proc_dostring
4065
},
4166
{}
4267
};

0 commit comments

Comments
 (0)