67081b81a4a3c003278d146b6b0f78f1508f89f9
[linux-2.6.git] / arch / s390 / crypto / crypt_s390_query.c
1 /*
2  * Cryptographic API.
3  *
4  * Support for s390 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_s390.h"
21
22 static void query_available_functions(void)
23 {
24         printk(KERN_INFO "#####################\n");
25
26         /* query available KM functions */
27         printk(KERN_INFO "KM_QUERY: %d\n",
28                 crypt_s390_func_available(KM_QUERY));
29         printk(KERN_INFO "KM_DEA: %d\n",
30                 crypt_s390_func_available(KM_DEA_ENCRYPT));
31         printk(KERN_INFO "KM_TDEA_128: %d\n",
32                 crypt_s390_func_available(KM_TDEA_128_ENCRYPT));
33         printk(KERN_INFO "KM_TDEA_192: %d\n",
34                 crypt_s390_func_available(KM_TDEA_192_ENCRYPT));
35
36         /* query available KMC functions */
37         printk(KERN_INFO "KMC_QUERY: %d\n",
38                 crypt_s390_func_available(KMC_QUERY));
39         printk(KERN_INFO "KMC_DEA: %d\n",
40                 crypt_s390_func_available(KMC_DEA_ENCRYPT));
41         printk(KERN_INFO "KMC_TDEA_128: %d\n",
42                 crypt_s390_func_available(KMC_TDEA_128_ENCRYPT));
43         printk(KERN_INFO "KMC_TDEA_192: %d\n",
44                 crypt_s390_func_available(KMC_TDEA_192_ENCRYPT));
45
46         /* query available KIMD fucntions */
47         printk(KERN_INFO "KIMD_QUERY: %d\n",
48                 crypt_s390_func_available(KIMD_QUERY));
49         printk(KERN_INFO "KIMD_SHA_1: %d\n",
50                 crypt_s390_func_available(KIMD_SHA_1));
51         printk(KERN_INFO "KIMD_SHA_256: %d\n",
52                 crypt_s390_func_available(KIMD_SHA_256));
53
54         /* query available KLMD functions */
55         printk(KERN_INFO "KLMD_QUERY: %d\n",
56                 crypt_s390_func_available(KLMD_QUERY));
57         printk(KERN_INFO "KLMD_SHA_1: %d\n",
58                 crypt_s390_func_available(KLMD_SHA_1));
59         printk(KERN_INFO "KLMD_SHA_256: %d\n",
60                 crypt_s390_func_available(KLMD_SHA_256));
61
62         /* query available KMAC functions */
63         printk(KERN_INFO "KMAC_QUERY: %d\n",
64                 crypt_s390_func_available(KMAC_QUERY));
65         printk(KERN_INFO "KMAC_DEA: %d\n",
66                 crypt_s390_func_available(KMAC_DEA));
67         printk(KERN_INFO "KMAC_TDEA_128: %d\n",
68                 crypt_s390_func_available(KMAC_TDEA_128));
69         printk(KERN_INFO "KMAC_TDEA_192: %d\n",
70                 crypt_s390_func_available(KMAC_TDEA_192));
71 }
72
73 static int init(void)
74 {
75         struct crypt_s390_query_status status = {
76                 .high = 0,
77                 .low = 0
78         };
79
80         printk(KERN_INFO "crypt_s390: querying available crypto functions\n");
81         crypt_s390_km(KM_QUERY, &status, NULL, NULL, 0);
82         printk(KERN_INFO "KM:\t%016llx %016llx\n",
83                         (unsigned long long) status.high,
84                         (unsigned long long) status.low);
85         status.high = status.low = 0;
86         crypt_s390_kmc(KMC_QUERY, &status, NULL, NULL, 0);
87         printk(KERN_INFO "KMC:\t%016llx %016llx\n",
88                         (unsigned long long) status.high,
89                         (unsigned long long) status.low);
90         status.high = status.low = 0;
91         crypt_s390_kimd(KIMD_QUERY, &status, NULL, 0);
92         printk(KERN_INFO "KIMD:\t%016llx %016llx\n",
93                         (unsigned long long) status.high,
94                         (unsigned long long) status.low);
95         status.high = status.low = 0;
96         crypt_s390_klmd(KLMD_QUERY, &status, NULL, 0);
97         printk(KERN_INFO "KLMD:\t%016llx %016llx\n",
98                         (unsigned long long) status.high,
99                         (unsigned long long) status.low);
100         status.high = status.low = 0;
101         crypt_s390_kmac(KMAC_QUERY, &status, NULL, 0);
102         printk(KERN_INFO "KMAC:\t%016llx %016llx\n",
103                         (unsigned long long) status.high,
104                         (unsigned long long) status.low);
105
106         query_available_functions();
107         return -ECANCELED;
108 }
109
110 static void __exit cleanup(void)
111 {
112 }
113
114 module_init(init);
115 module_exit(cleanup);
116
117 MODULE_LICENSE("GPL");