1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Copyright (c) 2008 Neil Horman <nhorman@tuxdriver.com>
8 #include <linux/export.h>
9 #include <linux/fips.h>
10 #include <linux/init.h>
11 #include <linux/module.h>
12 #include <linux/kernel.h>
13 #include <linux/sysctl.h>
14 #include <linux/notifier.h>
15 #include <generated/utsrelease.h>
18 EXPORT_SYMBOL_GPL(fips_enabled
);
20 ATOMIC_NOTIFIER_HEAD(fips_fail_notif_chain
);
21 EXPORT_SYMBOL_GPL(fips_fail_notif_chain
);
23 /* Process kernel command-line parameter at boot time. fips=0 or fips=1 */
24 static int fips_enable(char *str
)
26 fips_enabled
= !!simple_strtol(str
, NULL
, 0);
27 printk(KERN_INFO
"fips mode: %s\n",
28 fips_enabled
? "enabled" : "disabled");
32 __setup("fips=", fips_enable
);
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
38 #define FIPS_MODULE_VERSION UTS_RELEASE
41 static char fips_name
[] = FIPS_MODULE_NAME
;
42 static char fips_version
[] = FIPS_MODULE_VERSION
;
44 static struct ctl_table crypto_sysctl_table
[] = {
46 .procname
= "fips_enabled",
47 .data
= &fips_enabled
,
48 .maxlen
= sizeof(int),
50 .proc_handler
= proc_dointvec
53 .procname
= "fips_name",
57 .proc_handler
= proc_dostring
60 .procname
= "fips_version",
61 .data
= &fips_version
,
64 .proc_handler
= proc_dostring
68 static struct ctl_table_header
*crypto_sysctls
;
70 static void crypto_proc_fips_init(void)
72 crypto_sysctls
= register_sysctl("crypto", crypto_sysctl_table
);
75 static void crypto_proc_fips_exit(void)
77 unregister_sysctl_table(crypto_sysctls
);
80 void fips_fail_notify(void)
83 atomic_notifier_call_chain(&fips_fail_notif_chain
, 0, NULL
);
85 EXPORT_SYMBOL_GPL(fips_fail_notify
);
87 static int __init
fips_init(void)
89 crypto_proc_fips_init();
93 static void __exit
fips_exit(void)
95 crypto_proc_fips_exit();
98 subsys_initcall(fips_init
);
99 module_exit(fips_exit
);