blob: 9d627c1cf8bc78a173248e82ce58135c1f306d44
1 | /* |
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 | |
13 | #include <linux/export.h> |
14 | #include <linux/fips.h> |
15 | #include <linux/init.h> |
16 | #include <linux/module.h> |
17 | #include <linux/kernel.h> |
18 | #include <linux/sysctl.h> |
19 | |
20 | int fips_enabled; |
21 | EXPORT_SYMBOL_GPL(fips_enabled); |
22 | |
23 | /* Process kernel command-line parameter at boot time. fips=0 or fips=1 */ |
24 | static 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); |
33 | |
34 | static 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 | |
45 | static struct ctl_table crypto_dir_table[] = { |
46 | { |
47 | .procname = "crypto", |
48 | .mode = 0555, |
49 | .child = crypto_sysctl_table |
50 | }, |
51 | {} |
52 | }; |
53 | |
54 | static struct ctl_table_header *crypto_sysctls; |
55 | |
56 | static void crypto_proc_fips_init(void) |
57 | { |
58 | crypto_sysctls = register_sysctl_table(crypto_dir_table); |
59 | } |
60 | |
61 | static void crypto_proc_fips_exit(void) |
62 | { |
63 | unregister_sysctl_table(crypto_sysctls); |
64 | } |
65 | |
66 | static int __init fips_init(void) |
67 | { |
68 | crypto_proc_fips_init(); |
69 | return 0; |
70 | } |
71 | |
72 | static void __exit fips_exit(void) |
73 | { |
74 | crypto_proc_fips_exit(); |
75 | } |
76 | |
77 | module_init(fips_init); |
78 | module_exit(fips_exit); |
79 |