diff options
Diffstat (limited to 'arch/s390/crypto/crypt_s390.h')
-rw-r--r-- | arch/s390/crypto/crypt_s390.h | 280 |
1 files changed, 138 insertions, 142 deletions
diff --git a/arch/s390/crypto/crypt_s390.h b/arch/s390/crypto/crypt_s390.h index 2b137089f625..2b92c2fd12d4 100644 --- a/arch/s390/crypto/crypt_s390.h +++ b/arch/s390/crypto/crypt_s390.h | |||
@@ -3,8 +3,9 @@ | |||
3 | * | 3 | * |
4 | * Support for s390 cryptographic instructions. | 4 | * Support for s390 cryptographic instructions. |
5 | * | 5 | * |
6 | * Copyright (C) 2003 IBM Deutschland GmbH, IBM Corporation | 6 | * Copyright IBM Corp. 2003,2007 |
7 | * Author(s): Thomas Spatzier (tspat@de.ibm.com) | 7 | * Author(s): Thomas Spatzier |
8 | * Jan Glauber (jan.glauber@de.ibm.com) | ||
8 | * | 9 | * |
9 | * This program is free software; you can redistribute it and/or modify it | 10 | * This program is free software; you can redistribute it and/or modify it |
10 | * under the terms of the GNU General Public License as published by the Free | 11 | * under the terms of the GNU General Public License as published by the Free |
@@ -32,7 +33,8 @@ enum crypt_s390_operations { | |||
32 | CRYPT_S390_KMAC = 0x0500 | 33 | CRYPT_S390_KMAC = 0x0500 |
33 | }; | 34 | }; |
34 | 35 | ||
35 | /* function codes for KM (CIPHER MESSAGE) instruction | 36 | /* |
37 | * function codes for KM (CIPHER MESSAGE) instruction | ||
36 | * 0x80 is the decipher modifier bit | 38 | * 0x80 is the decipher modifier bit |
37 | */ | 39 | */ |
38 | enum crypt_s390_km_func { | 40 | enum crypt_s390_km_func { |
@@ -51,7 +53,8 @@ enum crypt_s390_km_func { | |||
51 | KM_AES_256_DECRYPT = CRYPT_S390_KM | 0x14 | 0x80, | 53 | KM_AES_256_DECRYPT = CRYPT_S390_KM | 0x14 | 0x80, |
52 | }; | 54 | }; |
53 | 55 | ||
54 | /* function codes for KMC (CIPHER MESSAGE WITH CHAINING) | 56 | /* |
57 | * function codes for KMC (CIPHER MESSAGE WITH CHAINING) | ||
55 | * instruction | 58 | * instruction |
56 | */ | 59 | */ |
57 | enum crypt_s390_kmc_func { | 60 | enum crypt_s390_kmc_func { |
@@ -70,7 +73,8 @@ enum crypt_s390_kmc_func { | |||
70 | KMC_AES_256_DECRYPT = CRYPT_S390_KMC | 0x14 | 0x80, | 73 | KMC_AES_256_DECRYPT = CRYPT_S390_KMC | 0x14 | 0x80, |
71 | }; | 74 | }; |
72 | 75 | ||
73 | /* function codes for KIMD (COMPUTE INTERMEDIATE MESSAGE DIGEST) | 76 | /* |
77 | * function codes for KIMD (COMPUTE INTERMEDIATE MESSAGE DIGEST) | ||
74 | * instruction | 78 | * instruction |
75 | */ | 79 | */ |
76 | enum crypt_s390_kimd_func { | 80 | enum crypt_s390_kimd_func { |
@@ -79,7 +83,8 @@ enum crypt_s390_kimd_func { | |||
79 | KIMD_SHA_256 = CRYPT_S390_KIMD | 2, | 83 | KIMD_SHA_256 = CRYPT_S390_KIMD | 2, |
80 | }; | 84 | }; |
81 | 85 | ||
82 | /* function codes for KLMD (COMPUTE LAST MESSAGE DIGEST) | 86 | /* |
87 | * function codes for KLMD (COMPUTE LAST MESSAGE DIGEST) | ||
83 | * instruction | 88 | * instruction |
84 | */ | 89 | */ |
85 | enum crypt_s390_klmd_func { | 90 | enum crypt_s390_klmd_func { |
@@ -88,7 +93,8 @@ enum crypt_s390_klmd_func { | |||
88 | KLMD_SHA_256 = CRYPT_S390_KLMD | 2, | 93 | KLMD_SHA_256 = CRYPT_S390_KLMD | 2, |
89 | }; | 94 | }; |
90 | 95 | ||
91 | /* function codes for KMAC (COMPUTE MESSAGE AUTHENTICATION CODE) | 96 | /* |
97 | * function codes for KMAC (COMPUTE MESSAGE AUTHENTICATION CODE) | ||
92 | * instruction | 98 | * instruction |
93 | */ | 99 | */ |
94 | enum crypt_s390_kmac_func { | 100 | enum crypt_s390_kmac_func { |
@@ -98,229 +104,219 @@ enum crypt_s390_kmac_func { | |||
98 | KMAC_TDEA_192 = CRYPT_S390_KMAC | 3 | 104 | KMAC_TDEA_192 = CRYPT_S390_KMAC | 3 |
99 | }; | 105 | }; |
100 | 106 | ||
101 | /* status word for s390 crypto instructions' QUERY functions */ | 107 | /** |
102 | struct crypt_s390_query_status { | 108 | * crypt_s390_km: |
103 | u64 high; | 109 | * @func: the function code passed to KM; see crypt_s390_km_func |
104 | u64 low; | 110 | * @param: address of parameter block; see POP for details on each func |
105 | }; | 111 | * @dest: address of destination memory area |
106 | 112 | * @src: address of source memory area | |
107 | /* | 113 | * @src_len: length of src operand in bytes |
114 | * | ||
108 | * Executes the KM (CIPHER MESSAGE) operation of the CPU. | 115 | * Executes the KM (CIPHER MESSAGE) operation of the CPU. |
109 | * @param func: the function code passed to KM; see crypt_s390_km_func | 116 | * |
110 | * @param param: address of parameter block; see POP for details on each func | 117 | * Returns -1 for failure, 0 for the query func, number of processed |
111 | * @param dest: address of destination memory area | 118 | * bytes for encryption/decryption funcs |
112 | * @param src: address of source memory area | ||
113 | * @param src_len: length of src operand in bytes | ||
114 | * @returns < zero for failure, 0 for the query func, number of processed bytes | ||
115 | * for encryption/decryption funcs | ||
116 | */ | 119 | */ |
117 | static inline int | 120 | static inline int crypt_s390_km(long func, void *param, |
118 | crypt_s390_km(long func, void* param, u8* dest, const u8* src, long src_len) | 121 | u8 *dest, const u8 *src, long src_len) |
119 | { | 122 | { |
120 | register long __func asm("0") = func & CRYPT_S390_FUNC_MASK; | 123 | register long __func asm("0") = func & CRYPT_S390_FUNC_MASK; |
121 | register void* __param asm("1") = param; | 124 | register void *__param asm("1") = param; |
122 | register const u8* __src asm("2") = src; | 125 | register const u8 *__src asm("2") = src; |
123 | register long __src_len asm("3") = src_len; | 126 | register long __src_len asm("3") = src_len; |
124 | register u8* __dest asm("4") = dest; | 127 | register u8 *__dest asm("4") = dest; |
125 | int ret; | 128 | int ret; |
126 | 129 | ||
127 | asm volatile( | 130 | asm volatile( |
128 | "0: .insn rre,0xb92e0000,%3,%1 \n" /* KM opcode */ | 131 | "0: .insn rre,0xb92e0000,%3,%1 \n" /* KM opcode */ |
129 | "1: brc 1,0b \n" /* handle partial completion */ | 132 | "1: brc 1,0b \n" /* handle partial completion */ |
130 | " ahi %0,%h7\n" | 133 | " la %0,0\n" |
131 | "2: ahi %0,%h8\n" | 134 | "2:\n" |
132 | "3:\n" | 135 | EX_TABLE(0b,2b) EX_TABLE(1b,2b) |
133 | EX_TABLE(0b,3b) EX_TABLE(1b,2b) | ||
134 | : "=d" (ret), "+a" (__src), "+d" (__src_len), "+a" (__dest) | 136 | : "=d" (ret), "+a" (__src), "+d" (__src_len), "+a" (__dest) |
135 | : "d" (__func), "a" (__param), "0" (-EFAULT), | 137 | : "d" (__func), "a" (__param), "0" (-1) : "cc", "memory"); |
136 | "K" (ENOSYS), "K" (-ENOSYS + EFAULT) : "cc", "memory"); | ||
137 | if (ret < 0) | 138 | if (ret < 0) |
138 | return ret; | 139 | return ret; |
139 | return (func & CRYPT_S390_FUNC_MASK) ? src_len - __src_len : __src_len; | 140 | return (func & CRYPT_S390_FUNC_MASK) ? src_len - __src_len : __src_len; |
140 | } | 141 | } |
141 | 142 | ||
142 | /* | 143 | /** |
144 | * crypt_s390_kmc: | ||
145 | * @func: the function code passed to KM; see crypt_s390_kmc_func | ||
146 | * @param: address of parameter block; see POP for details on each func | ||
147 | * @dest: address of destination memory area | ||
148 | * @src: address of source memory area | ||
149 | * @src_len: length of src operand in bytes | ||
150 | * | ||
143 | * Executes the KMC (CIPHER MESSAGE WITH CHAINING) operation of the CPU. | 151 | * Executes the KMC (CIPHER MESSAGE WITH CHAINING) operation of the CPU. |
144 | * @param func: the function code passed to KM; see crypt_s390_kmc_func | 152 | * |
145 | * @param param: address of parameter block; see POP for details on each func | 153 | * Returns -1 for failure, 0 for the query func, number of processed |
146 | * @param dest: address of destination memory area | 154 | * bytes for encryption/decryption funcs |
147 | * @param src: address of source memory area | ||
148 | * @param src_len: length of src operand in bytes | ||
149 | * @returns < zero for failure, 0 for the query func, number of processed bytes | ||
150 | * for encryption/decryption funcs | ||
151 | */ | 155 | */ |
152 | static inline int | 156 | static inline int crypt_s390_kmc(long func, void *param, |
153 | crypt_s390_kmc(long func, void* param, u8* dest, const u8* src, long src_len) | 157 | u8 *dest, const u8 *src, long src_len) |
154 | { | 158 | { |
155 | register long __func asm("0") = func & CRYPT_S390_FUNC_MASK; | 159 | register long __func asm("0") = func & CRYPT_S390_FUNC_MASK; |
156 | register void* __param asm("1") = param; | 160 | register void *__param asm("1") = param; |
157 | register const u8* __src asm("2") = src; | 161 | register const u8 *__src asm("2") = src; |
158 | register long __src_len asm("3") = src_len; | 162 | register long __src_len asm("3") = src_len; |
159 | register u8* __dest asm("4") = dest; | 163 | register u8 *__dest asm("4") = dest; |
160 | int ret; | 164 | int ret; |
161 | 165 | ||
162 | asm volatile( | 166 | asm volatile( |
163 | "0: .insn rre,0xb92f0000,%3,%1 \n" /* KMC opcode */ | 167 | "0: .insn rre,0xb92f0000,%3,%1 \n" /* KMC opcode */ |
164 | "1: brc 1,0b \n" /* handle partial completion */ | 168 | "1: brc 1,0b \n" /* handle partial completion */ |
165 | " ahi %0,%h7\n" | 169 | " la %0,0\n" |
166 | "2: ahi %0,%h8\n" | 170 | "2:\n" |
167 | "3:\n" | 171 | EX_TABLE(0b,2b) EX_TABLE(1b,2b) |
168 | EX_TABLE(0b,3b) EX_TABLE(1b,2b) | ||
169 | : "=d" (ret), "+a" (__src), "+d" (__src_len), "+a" (__dest) | 172 | : "=d" (ret), "+a" (__src), "+d" (__src_len), "+a" (__dest) |
170 | : "d" (__func), "a" (__param), "0" (-EFAULT), | 173 | : "d" (__func), "a" (__param), "0" (-1) : "cc", "memory"); |
171 | "K" (ENOSYS), "K" (-ENOSYS + EFAULT) : "cc", "memory"); | ||
172 | if (ret < 0) | 174 | if (ret < 0) |
173 | return ret; | 175 | return ret; |
174 | return (func & CRYPT_S390_FUNC_MASK) ? src_len - __src_len : __src_len; | 176 | return (func & CRYPT_S390_FUNC_MASK) ? src_len - __src_len : __src_len; |
175 | } | 177 | } |
176 | 178 | ||
177 | /* | 179 | /** |
180 | * crypt_s390_kimd: | ||
181 | * @func: the function code passed to KM; see crypt_s390_kimd_func | ||
182 | * @param: address of parameter block; see POP for details on each func | ||
183 | * @src: address of source memory area | ||
184 | * @src_len: length of src operand in bytes | ||
185 | * | ||
178 | * Executes the KIMD (COMPUTE INTERMEDIATE MESSAGE DIGEST) operation | 186 | * Executes the KIMD (COMPUTE INTERMEDIATE MESSAGE DIGEST) operation |
179 | * of the CPU. | 187 | * of the CPU. |
180 | * @param func: the function code passed to KM; see crypt_s390_kimd_func | 188 | * |
181 | * @param param: address of parameter block; see POP for details on each func | 189 | * Returns -1 for failure, 0 for the query func, number of processed |
182 | * @param src: address of source memory area | 190 | * bytes for digest funcs |
183 | * @param src_len: length of src operand in bytes | ||
184 | * @returns < zero for failure, 0 for the query func, number of processed bytes | ||
185 | * for digest funcs | ||
186 | */ | 191 | */ |
187 | static inline int | 192 | static inline int crypt_s390_kimd(long func, void *param, |
188 | crypt_s390_kimd(long func, void* param, const u8* src, long src_len) | 193 | const u8 *src, long src_len) |
189 | { | 194 | { |
190 | register long __func asm("0") = func & CRYPT_S390_FUNC_MASK; | 195 | register long __func asm("0") = func & CRYPT_S390_FUNC_MASK; |
191 | register void* __param asm("1") = param; | 196 | register void *__param asm("1") = param; |
192 | register const u8* __src asm("2") = src; | 197 | register const u8 *__src asm("2") = src; |
193 | register long __src_len asm("3") = src_len; | 198 | register long __src_len asm("3") = src_len; |
194 | int ret; | 199 | int ret; |
195 | 200 | ||
196 | asm volatile( | 201 | asm volatile( |
197 | "0: .insn rre,0xb93e0000,%1,%1 \n" /* KIMD opcode */ | 202 | "0: .insn rre,0xb93e0000,%1,%1 \n" /* KIMD opcode */ |
198 | "1: brc 1,0b \n" /* handle partial completion */ | 203 | "1: brc 1,0b \n" /* handle partial completion */ |
199 | " ahi %0,%h6\n" | 204 | " la %0,0\n" |
200 | "2: ahi %0,%h7\n" | 205 | "2:\n" |
201 | "3:\n" | 206 | EX_TABLE(0b,2b) EX_TABLE(1b,2b) |
202 | EX_TABLE(0b,3b) EX_TABLE(1b,2b) | ||
203 | : "=d" (ret), "+a" (__src), "+d" (__src_len) | 207 | : "=d" (ret), "+a" (__src), "+d" (__src_len) |
204 | : "d" (__func), "a" (__param), "0" (-EFAULT), | 208 | : "d" (__func), "a" (__param), "0" (-1) : "cc", "memory"); |
205 | "K" (ENOSYS), "K" (-ENOSYS + EFAULT) : "cc", "memory"); | ||
206 | if (ret < 0) | 209 | if (ret < 0) |
207 | return ret; | 210 | return ret; |
208 | return (func & CRYPT_S390_FUNC_MASK) ? src_len - __src_len : __src_len; | 211 | return (func & CRYPT_S390_FUNC_MASK) ? src_len - __src_len : __src_len; |
209 | } | 212 | } |
210 | 213 | ||
211 | /* | 214 | /** |
215 | * crypt_s390_klmd: | ||
216 | * @func: the function code passed to KM; see crypt_s390_klmd_func | ||
217 | * @param: address of parameter block; see POP for details on each func | ||
218 | * @src: address of source memory area | ||
219 | * @src_len: length of src operand in bytes | ||
220 | * | ||
212 | * Executes the KLMD (COMPUTE LAST MESSAGE DIGEST) operation of the CPU. | 221 | * Executes the KLMD (COMPUTE LAST MESSAGE DIGEST) operation of the CPU. |
213 | * @param func: the function code passed to KM; see crypt_s390_klmd_func | 222 | * |
214 | * @param param: address of parameter block; see POP for details on each func | 223 | * Returns -1 for failure, 0 for the query func, number of processed |
215 | * @param src: address of source memory area | 224 | * bytes for digest funcs |
216 | * @param src_len: length of src operand in bytes | ||
217 | * @returns < zero for failure, 0 for the query func, number of processed bytes | ||
218 | * for digest funcs | ||
219 | */ | 225 | */ |
220 | static inline int | 226 | static inline int crypt_s390_klmd(long func, void *param, |
221 | crypt_s390_klmd(long func, void* param, const u8* src, long src_len) | 227 | const u8 *src, long src_len) |
222 | { | 228 | { |
223 | register long __func asm("0") = func & CRYPT_S390_FUNC_MASK; | 229 | register long __func asm("0") = func & CRYPT_S390_FUNC_MASK; |
224 | register void* __param asm("1") = param; | 230 | register void *__param asm("1") = param; |
225 | register const u8* __src asm("2") = src; | 231 | register const u8 *__src asm("2") = src; |
226 | register long __src_len asm("3") = src_len; | 232 | register long __src_len asm("3") = src_len; |
227 | int ret; | 233 | int ret; |
228 | 234 | ||
229 | asm volatile( | 235 | asm volatile( |
230 | "0: .insn rre,0xb93f0000,%1,%1 \n" /* KLMD opcode */ | 236 | "0: .insn rre,0xb93f0000,%1,%1 \n" /* KLMD opcode */ |
231 | "1: brc 1,0b \n" /* handle partial completion */ | 237 | "1: brc 1,0b \n" /* handle partial completion */ |
232 | " ahi %0,%h6\n" | 238 | " la %0,0\n" |
233 | "2: ahi %0,%h7\n" | 239 | "2:\n" |
234 | "3:\n" | 240 | EX_TABLE(0b,2b) EX_TABLE(1b,2b) |
235 | EX_TABLE(0b,3b) EX_TABLE(1b,2b) | ||
236 | : "=d" (ret), "+a" (__src), "+d" (__src_len) | 241 | : "=d" (ret), "+a" (__src), "+d" (__src_len) |
237 | : "d" (__func), "a" (__param), "0" (-EFAULT), | 242 | : "d" (__func), "a" (__param), "0" (-1) : "cc", "memory"); |
238 | "K" (ENOSYS), "K" (-ENOSYS + EFAULT) : "cc", "memory"); | ||
239 | if (ret < 0) | 243 | if (ret < 0) |
240 | return ret; | 244 | return ret; |
241 | return (func & CRYPT_S390_FUNC_MASK) ? src_len - __src_len : __src_len; | 245 | return (func & CRYPT_S390_FUNC_MASK) ? src_len - __src_len : __src_len; |
242 | } | 246 | } |
243 | 247 | ||
244 | /* | 248 | /** |
249 | * crypt_s390_kmac: | ||
250 | * @func: the function code passed to KM; see crypt_s390_klmd_func | ||
251 | * @param: address of parameter block; see POP for details on each func | ||
252 | * @src: address of source memory area | ||
253 | * @src_len: length of src operand in bytes | ||
254 | * | ||
245 | * Executes the KMAC (COMPUTE MESSAGE AUTHENTICATION CODE) operation | 255 | * Executes the KMAC (COMPUTE MESSAGE AUTHENTICATION CODE) operation |
246 | * of the CPU. | 256 | * of the CPU. |
247 | * @param func: the function code passed to KM; see crypt_s390_klmd_func | 257 | * |
248 | * @param param: address of parameter block; see POP for details on each func | 258 | * Returns -1 for failure, 0 for the query func, number of processed |
249 | * @param src: address of source memory area | 259 | * bytes for digest funcs |
250 | * @param src_len: length of src operand in bytes | ||
251 | * @returns < zero for failure, 0 for the query func, number of processed bytes | ||
252 | * for digest funcs | ||
253 | */ | 260 | */ |
254 | static inline int | 261 | static inline int crypt_s390_kmac(long func, void *param, |
255 | crypt_s390_kmac(long func, void* param, const u8* src, long src_len) | 262 | const u8 *src, long src_len) |
256 | { | 263 | { |
257 | register long __func asm("0") = func & CRYPT_S390_FUNC_MASK; | 264 | register long __func asm("0") = func & CRYPT_S390_FUNC_MASK; |
258 | register void* __param asm("1") = param; | 265 | register void *__param asm("1") = param; |
259 | register const u8* __src asm("2") = src; | 266 | register const u8 *__src asm("2") = src; |
260 | register long __src_len asm("3") = src_len; | 267 | register long __src_len asm("3") = src_len; |
261 | int ret; | 268 | int ret; |
262 | 269 | ||
263 | asm volatile( | 270 | asm volatile( |
264 | "0: .insn rre,0xb91e0000,%1,%1 \n" /* KLAC opcode */ | 271 | "0: .insn rre,0xb91e0000,%1,%1 \n" /* KLAC opcode */ |
265 | "1: brc 1,0b \n" /* handle partial completion */ | 272 | "1: brc 1,0b \n" /* handle partial completion */ |
266 | " ahi %0,%h6\n" | 273 | " la %0,0\n" |
267 | "2: ahi %0,%h7\n" | 274 | "2:\n" |
268 | "3:\n" | 275 | EX_TABLE(0b,2b) EX_TABLE(1b,2b) |
269 | EX_TABLE(0b,3b) EX_TABLE(1b,2b) | ||
270 | : "=d" (ret), "+a" (__src), "+d" (__src_len) | 276 | : "=d" (ret), "+a" (__src), "+d" (__src_len) |
271 | : "d" (__func), "a" (__param), "0" (-EFAULT), | 277 | : "d" (__func), "a" (__param), "0" (-1) : "cc", "memory"); |
272 | "K" (ENOSYS), "K" (-ENOSYS + EFAULT) : "cc", "memory"); | ||
273 | if (ret < 0) | 278 | if (ret < 0) |
274 | return ret; | 279 | return ret; |
275 | return (func & CRYPT_S390_FUNC_MASK) ? src_len - __src_len : __src_len; | 280 | return (func & CRYPT_S390_FUNC_MASK) ? src_len - __src_len : __src_len; |
276 | } | 281 | } |
277 | 282 | ||
278 | /** | 283 | /** |
284 | * crypt_s390_func_available: | ||
285 | * @func: the function code of the specific function; 0 if op in general | ||
286 | * | ||
279 | * Tests if a specific crypto function is implemented on the machine. | 287 | * Tests if a specific crypto function is implemented on the machine. |
280 | * @param func: the function code of the specific function; 0 if op in general | 288 | * |
281 | * @return 1 if func available; 0 if func or op in general not available | 289 | * Returns 1 if func available; 0 if func or op in general not available |
282 | */ | 290 | */ |
283 | static inline int | 291 | static inline int crypt_s390_func_available(int func) |
284 | crypt_s390_func_available(int func) | ||
285 | { | 292 | { |
293 | unsigned char status[16]; | ||
286 | int ret; | 294 | int ret; |
287 | 295 | ||
288 | struct crypt_s390_query_status status = { | 296 | switch (func & CRYPT_S390_OP_MASK) { |
289 | .high = 0, | 297 | case CRYPT_S390_KM: |
290 | .low = 0 | 298 | ret = crypt_s390_km(KM_QUERY, &status, NULL, NULL, 0); |
291 | }; | 299 | break; |
292 | switch (func & CRYPT_S390_OP_MASK){ | 300 | case CRYPT_S390_KMC: |
293 | case CRYPT_S390_KM: | 301 | ret = crypt_s390_kmc(KMC_QUERY, &status, NULL, NULL, 0); |
294 | ret = crypt_s390_km(KM_QUERY, &status, NULL, NULL, 0); | 302 | break; |
295 | break; | 303 | case CRYPT_S390_KIMD: |
296 | case CRYPT_S390_KMC: | 304 | ret = crypt_s390_kimd(KIMD_QUERY, &status, NULL, 0); |
297 | ret = crypt_s390_kmc(KMC_QUERY, &status, NULL, NULL, 0); | 305 | break; |
298 | break; | 306 | case CRYPT_S390_KLMD: |
299 | case CRYPT_S390_KIMD: | 307 | ret = crypt_s390_klmd(KLMD_QUERY, &status, NULL, 0); |
300 | ret = crypt_s390_kimd(KIMD_QUERY, &status, NULL, 0); | 308 | break; |
301 | break; | 309 | case CRYPT_S390_KMAC: |
302 | case CRYPT_S390_KLMD: | 310 | ret = crypt_s390_kmac(KMAC_QUERY, &status, NULL, 0); |
303 | ret = crypt_s390_klmd(KLMD_QUERY, &status, NULL, 0); | 311 | break; |
304 | break; | 312 | default: |
305 | case CRYPT_S390_KMAC: | 313 | return 0; |
306 | ret = crypt_s390_kmac(KMAC_QUERY, &status, NULL, 0); | ||
307 | break; | ||
308 | default: | ||
309 | ret = 0; | ||
310 | return ret; | ||
311 | } | ||
312 | if (ret >= 0){ | ||
313 | func &= CRYPT_S390_FUNC_MASK; | ||
314 | func &= 0x7f; //mask modifier bit | ||
315 | if (func < 64){ | ||
316 | ret = (status.high >> (64 - func - 1)) & 0x1; | ||
317 | } else { | ||
318 | ret = (status.low >> (128 - func - 1)) & 0x1; | ||
319 | } | ||
320 | } else { | ||
321 | ret = 0; | ||
322 | } | 314 | } |
323 | return ret; | 315 | if (ret < 0) |
316 | return 0; | ||
317 | func &= CRYPT_S390_FUNC_MASK; | ||
318 | func &= 0x7f; /* mask modifier bit */ | ||
319 | return (status[func >> 3] & (0x80 >> (func & 7))) != 0; | ||
324 | } | 320 | } |
325 | 321 | ||
326 | #endif // _CRYPTO_ARCH_S390_CRYPT_S390_H | 322 | #endif /* _CRYPTO_ARCH_S390_CRYPT_S390_H */ |