blob: 9d627c1cf8bc78a173248e82ce58135c1f306d44 [file] [log] [blame]
Neil Hormanccb778e2008-08-05 14:13:08 +08001/*
2 * FIPS 200 support.
3 *
4 * Copyright (c) 2008 Neil Horman <nhorman@tuxdriver.com>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2 of the License, or (at your option)
9 * any later version.
10 *
11 */
12
Herbert Xu76450f92015-04-22 13:25:54 +080013#include <linux/export.h>
14#include <linux/fips.h>
15#include <linux/init.h>
Herbert Xu94072cb2015-04-22 13:25:56 +080016#include <linux/module.h>
Herbert Xu76450f92015-04-22 13:25:54 +080017#include <linux/kernel.h>
Herbert Xu94072cb2015-04-22 13:25:56 +080018#include <linux/sysctl.h>
Neil Hormanccb778e2008-08-05 14:13:08 +080019
20int fips_enabled;
21EXPORT_SYMBOL_GPL(fips_enabled);
22
23/* Process kernel command-line parameter at boot time. fips=0 or fips=1 */
24static int fips_enable(char *str)
25{
26 fips_enabled = !!simple_strtol(str, NULL, 0);
27 printk(KERN_INFO "fips mode: %s\n",
28 fips_enabled ? "enabled" : "disabled");
29 return 1;
30}
31
32__setup("fips=", fips_enable);
Herbert Xu94072cb2015-04-22 13:25:56 +080033
34static struct ctl_table crypto_sysctl_table[] = {
35 {
36 .procname = "fips_enabled",
37 .data = &fips_enabled,
38 .maxlen = sizeof(int),
39 .mode = 0444,
40 .proc_handler = proc_dointvec
41 },
42 {}
43};
44
45static struct ctl_table crypto_dir_table[] = {
46 {
47 .procname = "crypto",
48 .mode = 0555,
49 .child = crypto_sysctl_table
50 },
51 {}
52};
53
54static struct ctl_table_header *crypto_sysctls;
55
56static void crypto_proc_fips_init(void)
57{
58 crypto_sysctls = register_sysctl_table(crypto_dir_table);
59}
60
61static void crypto_proc_fips_exit(void)
62{
63 unregister_sysctl_table(crypto_sysctls);
64}
65
66static int __init fips_init(void)
67{
68 crypto_proc_fips_init();
69 return 0;
70}
71
72static void __exit fips_exit(void)
73{
74 crypto_proc_fips_exit();
75}
76
77module_init(fips_init);
78module_exit(fips_exit);