Linux-2.6.12-rc2
[linux-3.10.git] / arch / s390 / crypto / crypt_z990_query.c
1 /*
2  * Cryptographic API.
3  *
4  * Support for z990 cryptographic instructions.
5  * Testing module for querying processor crypto capabilities.
6  *
7  * Copyright (c) 2003 IBM Deutschland Entwicklung GmbH, IBM Corporation
8  * Author(s): Thomas Spatzier (tspat@de.ibm.com)
9  *
10  * This program is free software; you can redistribute it and/or modify it
11  * under the terms of the GNU General Public License as published by the Free
12  * Software Foundation; either version 2 of the License, or (at your option)
13  * any later version.
14  *
15  */
16 #include <linux/module.h>
17 #include <linux/init.h>
18 #include <linux/kernel.h>
19 #include <asm/errno.h>
20 #include "crypt_z990.h"
21
22 static void
23 query_available_functions(void)
24 {
25         printk(KERN_INFO "#####################\n");
26         //query available KM functions
27         printk(KERN_INFO "KM_QUERY: %d\n",
28                         crypt_z990_func_available(KM_QUERY));
29         printk(KERN_INFO "KM_DEA: %d\n",
30                         crypt_z990_func_available(KM_DEA_ENCRYPT));
31         printk(KERN_INFO "KM_TDEA_128: %d\n",
32                         crypt_z990_func_available(KM_TDEA_128_ENCRYPT));
33         printk(KERN_INFO "KM_TDEA_192: %d\n",
34                         crypt_z990_func_available(KM_TDEA_192_ENCRYPT));
35         //query available KMC functions
36         printk(KERN_INFO "KMC_QUERY: %d\n",
37                         crypt_z990_func_available(KMC_QUERY));
38         printk(KERN_INFO "KMC_DEA: %d\n",
39                         crypt_z990_func_available(KMC_DEA_ENCRYPT));
40         printk(KERN_INFO "KMC_TDEA_128: %d\n",
41                         crypt_z990_func_available(KMC_TDEA_128_ENCRYPT));
42         printk(KERN_INFO "KMC_TDEA_192: %d\n",
43                         crypt_z990_func_available(KMC_TDEA_192_ENCRYPT));
44         //query available KIMD fucntions
45         printk(KERN_INFO "KIMD_QUERY: %d\n",
46                         crypt_z990_func_available(KIMD_QUERY));
47         printk(KERN_INFO "KIMD_SHA_1: %d\n",
48                         crypt_z990_func_available(KIMD_SHA_1));
49         //query available KLMD functions
50         printk(KERN_INFO "KLMD_QUERY: %d\n",
51                         crypt_z990_func_available(KLMD_QUERY));
52         printk(KERN_INFO "KLMD_SHA_1: %d\n",
53                         crypt_z990_func_available(KLMD_SHA_1));
54         //query available KMAC functions
55         printk(KERN_INFO "KMAC_QUERY: %d\n",
56                         crypt_z990_func_available(KMAC_QUERY));
57         printk(KERN_INFO "KMAC_DEA: %d\n",
58                         crypt_z990_func_available(KMAC_DEA));
59         printk(KERN_INFO "KMAC_TDEA_128: %d\n",
60                         crypt_z990_func_available(KMAC_TDEA_128));
61         printk(KERN_INFO "KMAC_TDEA_192: %d\n",
62                         crypt_z990_func_available(KMAC_TDEA_192));
63 }
64
65 static int
66 init(void)
67 {
68         struct crypt_z990_query_status status = {
69                 .high = 0,
70                 .low = 0
71         };
72
73         printk(KERN_INFO "crypt_z990: querying available crypto functions\n");
74         crypt_z990_km(KM_QUERY, &status, NULL, NULL, 0);
75         printk(KERN_INFO "KM: %016llx %016llx\n",
76                         (unsigned long long) status.high,
77                         (unsigned long long) status.low);
78         status.high = status.low = 0;
79         crypt_z990_kmc(KMC_QUERY, &status, NULL, NULL, 0);
80         printk(KERN_INFO "KMC: %016llx %016llx\n",
81                         (unsigned long long) status.high,
82                         (unsigned long long) status.low);
83         status.high = status.low = 0;
84         crypt_z990_kimd(KIMD_QUERY, &status, NULL, 0);
85         printk(KERN_INFO "KIMD: %016llx %016llx\n",
86                         (unsigned long long) status.high,
87                         (unsigned long long) status.low);
88         status.high = status.low = 0;
89         crypt_z990_klmd(KLMD_QUERY, &status, NULL, 0);
90         printk(KERN_INFO "KLMD: %016llx %016llx\n",
91                         (unsigned long long) status.high,
92                         (unsigned long long) status.low);
93         status.high = status.low = 0;
94         crypt_z990_kmac(KMAC_QUERY, &status, NULL, 0);
95         printk(KERN_INFO "KMAC: %016llx %016llx\n",
96                         (unsigned long long) status.high,
97                         (unsigned long long) status.low);
98
99         query_available_functions();
100         return -1;
101 }
102
103 static void __exit
104 cleanup(void)
105 {
106 }
107
108 module_init(init);
109 module_exit(cleanup);
110
111 MODULE_LICENSE("GPL");