[PATCH] s390: aes support
[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         printk(KERN_INFO "KM_AES_128: %d\n",
36                 crypt_s390_func_available(KM_AES_128_ENCRYPT));
37         printk(KERN_INFO "KM_AES_192: %d\n",
38                 crypt_s390_func_available(KM_AES_192_ENCRYPT));
39         printk(KERN_INFO "KM_AES_256: %d\n",
40                 crypt_s390_func_available(KM_AES_256_ENCRYPT));
41
42         /* query available KMC functions */
43         printk(KERN_INFO "KMC_QUERY: %d\n",
44                 crypt_s390_func_available(KMC_QUERY));
45         printk(KERN_INFO "KMC_DEA: %d\n",
46                 crypt_s390_func_available(KMC_DEA_ENCRYPT));
47         printk(KERN_INFO "KMC_TDEA_128: %d\n",
48                 crypt_s390_func_available(KMC_TDEA_128_ENCRYPT));
49         printk(KERN_INFO "KMC_TDEA_192: %d\n",
50                 crypt_s390_func_available(KMC_TDEA_192_ENCRYPT));
51         printk(KERN_INFO "KMC_AES_128: %d\n",
52                 crypt_s390_func_available(KMC_AES_128_ENCRYPT));
53         printk(KERN_INFO "KMC_AES_192: %d\n",
54                 crypt_s390_func_available(KMC_AES_192_ENCRYPT));
55         printk(KERN_INFO "KMC_AES_256: %d\n",
56                 crypt_s390_func_available(KMC_AES_256_ENCRYPT));
57
58         /* query available KIMD fucntions */
59         printk(KERN_INFO "KIMD_QUERY: %d\n",
60                 crypt_s390_func_available(KIMD_QUERY));
61         printk(KERN_INFO "KIMD_SHA_1: %d\n",
62                 crypt_s390_func_available(KIMD_SHA_1));
63         printk(KERN_INFO "KIMD_SHA_256: %d\n",
64                 crypt_s390_func_available(KIMD_SHA_256));
65
66         /* query available KLMD functions */
67         printk(KERN_INFO "KLMD_QUERY: %d\n",
68                 crypt_s390_func_available(KLMD_QUERY));
69         printk(KERN_INFO "KLMD_SHA_1: %d\n",
70                 crypt_s390_func_available(KLMD_SHA_1));
71         printk(KERN_INFO "KLMD_SHA_256: %d\n",
72                 crypt_s390_func_available(KLMD_SHA_256));
73
74         /* query available KMAC functions */
75         printk(KERN_INFO "KMAC_QUERY: %d\n",
76                 crypt_s390_func_available(KMAC_QUERY));
77         printk(KERN_INFO "KMAC_DEA: %d\n",
78                 crypt_s390_func_available(KMAC_DEA));
79         printk(KERN_INFO "KMAC_TDEA_128: %d\n",
80                 crypt_s390_func_available(KMAC_TDEA_128));
81         printk(KERN_INFO "KMAC_TDEA_192: %d\n",
82                 crypt_s390_func_available(KMAC_TDEA_192));
83 }
84
85 static int init(void)
86 {
87         struct crypt_s390_query_status status = {
88                 .high = 0,
89                 .low = 0
90         };
91
92         printk(KERN_INFO "crypt_s390: querying available crypto functions\n");
93         crypt_s390_km(KM_QUERY, &status, NULL, NULL, 0);
94         printk(KERN_INFO "KM:\t%016llx %016llx\n",
95                         (unsigned long long) status.high,
96                         (unsigned long long) status.low);
97         status.high = status.low = 0;
98         crypt_s390_kmc(KMC_QUERY, &status, NULL, NULL, 0);
99         printk(KERN_INFO "KMC:\t%016llx %016llx\n",
100                         (unsigned long long) status.high,
101                         (unsigned long long) status.low);
102         status.high = status.low = 0;
103         crypt_s390_kimd(KIMD_QUERY, &status, NULL, 0);
104         printk(KERN_INFO "KIMD:\t%016llx %016llx\n",
105                         (unsigned long long) status.high,
106                         (unsigned long long) status.low);
107         status.high = status.low = 0;
108         crypt_s390_klmd(KLMD_QUERY, &status, NULL, 0);
109         printk(KERN_INFO "KLMD:\t%016llx %016llx\n",
110                         (unsigned long long) status.high,
111                         (unsigned long long) status.low);
112         status.high = status.low = 0;
113         crypt_s390_kmac(KMAC_QUERY, &status, NULL, 0);
114         printk(KERN_INFO "KMAC:\t%016llx %016llx\n",
115                         (unsigned long long) status.high,
116                         (unsigned long long) status.low);
117
118         query_available_functions();
119         return -ECANCELED;
120 }
121
122 static void __exit cleanup(void)
123 {
124 }
125
126 module_init(init);
127 module_exit(cleanup);
128
129 MODULE_LICENSE("GPL");