diff options
Diffstat (limited to 'arch/s390/crypto/des_s390.c')
-rw-r--r-- | arch/s390/crypto/des_s390.c | 360 |
1 files changed, 271 insertions, 89 deletions
diff --git a/arch/s390/crypto/des_s390.c b/arch/s390/crypto/des_s390.c index a38bb2a3eef6..e3c37aa0a199 100644 --- a/arch/s390/crypto/des_s390.c +++ b/arch/s390/crypto/des_s390.c | |||
@@ -15,10 +15,8 @@ | |||
15 | */ | 15 | */ |
16 | #include <linux/init.h> | 16 | #include <linux/init.h> |
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | #include <linux/mm.h> | ||
19 | #include <linux/errno.h> | ||
20 | #include <asm/scatterlist.h> | ||
21 | #include <linux/crypto.h> | 18 | #include <linux/crypto.h> |
19 | |||
22 | #include "crypt_s390.h" | 20 | #include "crypt_s390.h" |
23 | #include "crypto_des.h" | 21 | #include "crypto_des.h" |
24 | 22 | ||
@@ -46,38 +44,92 @@ struct crypt_s390_des3_192_ctx { | |||
46 | u8 key[DES3_192_KEY_SIZE]; | 44 | u8 key[DES3_192_KEY_SIZE]; |
47 | }; | 45 | }; |
48 | 46 | ||
49 | static int | 47 | static int des_setkey(void *ctx, const u8 *key, unsigned int keylen, |
50 | des_setkey(void *ctx, const u8 *key, unsigned int keylen, u32 *flags) | 48 | u32 *flags) |
51 | { | 49 | { |
52 | struct crypt_s390_des_ctx *dctx; | 50 | struct crypt_s390_des_ctx *dctx = ctx; |
53 | int ret; | 51 | int ret; |
54 | 52 | ||
55 | dctx = ctx; | 53 | /* test if key is valid (not a weak key) */ |
56 | //test if key is valid (not a weak key) | ||
57 | ret = crypto_des_check_key(key, keylen, flags); | 54 | ret = crypto_des_check_key(key, keylen, flags); |
58 | if (ret == 0){ | 55 | if (ret == 0) |
59 | memcpy(dctx->key, key, keylen); | 56 | memcpy(dctx->key, key, keylen); |
60 | } | ||
61 | return ret; | 57 | return ret; |
62 | } | 58 | } |
63 | 59 | ||
60 | static void des_encrypt(void *ctx, u8 *out, const u8 *in) | ||
61 | { | ||
62 | struct crypt_s390_des_ctx *dctx = ctx; | ||
63 | |||
64 | crypt_s390_km(KM_DEA_ENCRYPT, dctx->key, out, in, DES_BLOCK_SIZE); | ||
65 | } | ||
66 | |||
67 | static void des_decrypt(void *ctx, u8 *out, const u8 *in) | ||
68 | { | ||
69 | struct crypt_s390_des_ctx *dctx = ctx; | ||
70 | |||
71 | crypt_s390_km(KM_DEA_DECRYPT, dctx->key, out, in, DES_BLOCK_SIZE); | ||
72 | } | ||
73 | |||
74 | static unsigned int des_encrypt_ecb(const struct cipher_desc *desc, u8 *out, | ||
75 | const u8 *in, unsigned int nbytes) | ||
76 | { | ||
77 | struct crypt_s390_des_ctx *sctx = crypto_tfm_ctx(desc->tfm); | ||
78 | int ret; | ||
79 | |||
80 | /* only use complete blocks */ | ||
81 | nbytes &= ~(DES_BLOCK_SIZE - 1); | ||
82 | ret = crypt_s390_km(KM_DEA_ENCRYPT, sctx->key, out, in, nbytes); | ||
83 | BUG_ON((ret < 0) || (ret != nbytes)); | ||
84 | |||
85 | return nbytes; | ||
86 | } | ||
64 | 87 | ||
65 | static void | 88 | static unsigned int des_decrypt_ecb(const struct cipher_desc *desc, u8 *out, |
66 | des_encrypt(void *ctx, u8 *dst, const u8 *src) | 89 | const u8 *in, unsigned int nbytes) |
67 | { | 90 | { |
68 | struct crypt_s390_des_ctx *dctx; | 91 | struct crypt_s390_des_ctx *sctx = crypto_tfm_ctx(desc->tfm); |
92 | int ret; | ||
93 | |||
94 | /* only use complete blocks */ | ||
95 | nbytes &= ~(DES_BLOCK_SIZE - 1); | ||
96 | ret = crypt_s390_km(KM_DEA_DECRYPT, sctx->key, out, in, nbytes); | ||
97 | BUG_ON((ret < 0) || (ret != nbytes)); | ||
69 | 98 | ||
70 | dctx = ctx; | 99 | return nbytes; |
71 | crypt_s390_km(KM_DEA_ENCRYPT, dctx->key, dst, src, DES_BLOCK_SIZE); | ||
72 | } | 100 | } |
73 | 101 | ||
74 | static void | 102 | static unsigned int des_encrypt_cbc(const struct cipher_desc *desc, u8 *out, |
75 | des_decrypt(void *ctx, u8 *dst, const u8 *src) | 103 | const u8 *in, unsigned int nbytes) |
76 | { | 104 | { |
77 | struct crypt_s390_des_ctx *dctx; | 105 | struct crypt_s390_des_ctx *sctx = crypto_tfm_ctx(desc->tfm); |
106 | int ret; | ||
78 | 107 | ||
79 | dctx = ctx; | 108 | /* only use complete blocks */ |
80 | crypt_s390_km(KM_DEA_DECRYPT, dctx->key, dst, src, DES_BLOCK_SIZE); | 109 | nbytes &= ~(DES_BLOCK_SIZE - 1); |
110 | |||
111 | memcpy(sctx->iv, desc->info, DES_BLOCK_SIZE); | ||
112 | ret = crypt_s390_kmc(KMC_DEA_ENCRYPT, &sctx->iv, out, in, nbytes); | ||
113 | BUG_ON((ret < 0) || (ret != nbytes)); | ||
114 | |||
115 | memcpy(desc->info, sctx->iv, DES_BLOCK_SIZE); | ||
116 | return nbytes; | ||
117 | } | ||
118 | |||
119 | static unsigned int des_decrypt_cbc(const struct cipher_desc *desc, u8 *out, | ||
120 | const u8 *in, unsigned int nbytes) | ||
121 | { | ||
122 | struct crypt_s390_des_ctx *sctx = crypto_tfm_ctx(desc->tfm); | ||
123 | int ret; | ||
124 | |||
125 | /* only use complete blocks */ | ||
126 | nbytes &= ~(DES_BLOCK_SIZE - 1); | ||
127 | |||
128 | memcpy(&sctx->iv, desc->info, DES_BLOCK_SIZE); | ||
129 | ret = crypt_s390_kmc(KMC_DEA_DECRYPT, &sctx->iv, out, in, nbytes); | ||
130 | BUG_ON((ret < 0) || (ret != nbytes)); | ||
131 | |||
132 | return nbytes; | ||
81 | } | 133 | } |
82 | 134 | ||
83 | static struct crypto_alg des_alg = { | 135 | static struct crypto_alg des_alg = { |
@@ -87,12 +139,19 @@ static struct crypto_alg des_alg = { | |||
87 | .cra_ctxsize = sizeof(struct crypt_s390_des_ctx), | 139 | .cra_ctxsize = sizeof(struct crypt_s390_des_ctx), |
88 | .cra_module = THIS_MODULE, | 140 | .cra_module = THIS_MODULE, |
89 | .cra_list = LIST_HEAD_INIT(des_alg.cra_list), | 141 | .cra_list = LIST_HEAD_INIT(des_alg.cra_list), |
90 | .cra_u = { .cipher = { | 142 | .cra_u = { |
91 | .cia_min_keysize = DES_KEY_SIZE, | 143 | .cipher = { |
92 | .cia_max_keysize = DES_KEY_SIZE, | 144 | .cia_min_keysize = DES_KEY_SIZE, |
93 | .cia_setkey = des_setkey, | 145 | .cia_max_keysize = DES_KEY_SIZE, |
94 | .cia_encrypt = des_encrypt, | 146 | .cia_setkey = des_setkey, |
95 | .cia_decrypt = des_decrypt } } | 147 | .cia_encrypt = des_encrypt, |
148 | .cia_decrypt = des_decrypt, | ||
149 | .cia_encrypt_ecb = des_encrypt_ecb, | ||
150 | .cia_decrypt_ecb = des_decrypt_ecb, | ||
151 | .cia_encrypt_cbc = des_encrypt_cbc, | ||
152 | .cia_decrypt_cbc = des_decrypt_cbc, | ||
153 | } | ||
154 | } | ||
96 | }; | 155 | }; |
97 | 156 | ||
98 | /* | 157 | /* |
@@ -107,20 +166,18 @@ static struct crypto_alg des_alg = { | |||
107 | * Implementers MUST reject keys that exhibit this property. | 166 | * Implementers MUST reject keys that exhibit this property. |
108 | * | 167 | * |
109 | */ | 168 | */ |
110 | static int | 169 | static int des3_128_setkey(void *ctx, const u8 *key, unsigned int keylen, |
111 | des3_128_setkey(void *ctx, const u8 *key, unsigned int keylen, u32 *flags) | 170 | u32 *flags) |
112 | { | 171 | { |
113 | int i, ret; | 172 | int i, ret; |
114 | struct crypt_s390_des3_128_ctx *dctx; | 173 | struct crypt_s390_des3_128_ctx *dctx = ctx; |
115 | const u8* temp_key = key; | 174 | const u8* temp_key = key; |
116 | 175 | ||
117 | dctx = ctx; | ||
118 | if (!(memcmp(key, &key[DES_KEY_SIZE], DES_KEY_SIZE))) { | 176 | if (!(memcmp(key, &key[DES_KEY_SIZE], DES_KEY_SIZE))) { |
119 | |||
120 | *flags |= CRYPTO_TFM_RES_BAD_KEY_SCHED; | 177 | *flags |= CRYPTO_TFM_RES_BAD_KEY_SCHED; |
121 | return -EINVAL; | 178 | return -EINVAL; |
122 | } | 179 | } |
123 | for (i = 0; i < 2; i++, temp_key += DES_KEY_SIZE) { | 180 | for (i = 0; i < 2; i++, temp_key += DES_KEY_SIZE) { |
124 | ret = crypto_des_check_key(temp_key, DES_KEY_SIZE, flags); | 181 | ret = crypto_des_check_key(temp_key, DES_KEY_SIZE, flags); |
125 | if (ret < 0) | 182 | if (ret < 0) |
126 | return ret; | 183 | return ret; |
@@ -129,24 +186,85 @@ des3_128_setkey(void *ctx, const u8 *key, unsigned int keylen, u32 *flags) | |||
129 | return 0; | 186 | return 0; |
130 | } | 187 | } |
131 | 188 | ||
132 | static void | 189 | static void des3_128_encrypt(void *ctx, u8 *dst, const u8 *src) |
133 | des3_128_encrypt(void *ctx, u8 *dst, const u8 *src) | ||
134 | { | 190 | { |
135 | struct crypt_s390_des3_128_ctx *dctx; | 191 | struct crypt_s390_des3_128_ctx *dctx = ctx; |
136 | 192 | ||
137 | dctx = ctx; | ||
138 | crypt_s390_km(KM_TDEA_128_ENCRYPT, dctx->key, dst, (void*)src, | 193 | crypt_s390_km(KM_TDEA_128_ENCRYPT, dctx->key, dst, (void*)src, |
139 | DES3_128_BLOCK_SIZE); | 194 | DES3_128_BLOCK_SIZE); |
140 | } | 195 | } |
141 | 196 | ||
142 | static void | 197 | static void des3_128_decrypt(void *ctx, u8 *dst, const u8 *src) |
143 | des3_128_decrypt(void *ctx, u8 *dst, const u8 *src) | ||
144 | { | 198 | { |
145 | struct crypt_s390_des3_128_ctx *dctx; | 199 | struct crypt_s390_des3_128_ctx *dctx = ctx; |
146 | 200 | ||
147 | dctx = ctx; | ||
148 | crypt_s390_km(KM_TDEA_128_DECRYPT, dctx->key, dst, (void*)src, | 201 | crypt_s390_km(KM_TDEA_128_DECRYPT, dctx->key, dst, (void*)src, |
149 | DES3_128_BLOCK_SIZE); | 202 | DES3_128_BLOCK_SIZE); |
203 | } | ||
204 | |||
205 | static unsigned int des3_128_encrypt_ecb(const struct cipher_desc *desc, | ||
206 | u8 *out, const u8 *in, | ||
207 | unsigned int nbytes) | ||
208 | { | ||
209 | struct crypt_s390_des3_128_ctx *sctx = crypto_tfm_ctx(desc->tfm); | ||
210 | int ret; | ||
211 | |||
212 | /* only use complete blocks */ | ||
213 | nbytes &= ~(DES3_128_BLOCK_SIZE - 1); | ||
214 | ret = crypt_s390_km(KM_TDEA_128_ENCRYPT, sctx->key, out, in, nbytes); | ||
215 | BUG_ON((ret < 0) || (ret != nbytes)); | ||
216 | |||
217 | return nbytes; | ||
218 | } | ||
219 | |||
220 | static unsigned int des3_128_decrypt_ecb(const struct cipher_desc *desc, | ||
221 | u8 *out, const u8 *in, | ||
222 | unsigned int nbytes) | ||
223 | { | ||
224 | struct crypt_s390_des3_128_ctx *sctx = crypto_tfm_ctx(desc->tfm); | ||
225 | int ret; | ||
226 | |||
227 | /* only use complete blocks */ | ||
228 | nbytes &= ~(DES3_128_BLOCK_SIZE - 1); | ||
229 | ret = crypt_s390_km(KM_TDEA_128_DECRYPT, sctx->key, out, in, nbytes); | ||
230 | BUG_ON((ret < 0) || (ret != nbytes)); | ||
231 | |||
232 | return nbytes; | ||
233 | } | ||
234 | |||
235 | static unsigned int des3_128_encrypt_cbc(const struct cipher_desc *desc, | ||
236 | u8 *out, const u8 *in, | ||
237 | unsigned int nbytes) | ||
238 | { | ||
239 | struct crypt_s390_des3_128_ctx *sctx = crypto_tfm_ctx(desc->tfm); | ||
240 | int ret; | ||
241 | |||
242 | /* only use complete blocks */ | ||
243 | nbytes &= ~(DES3_128_BLOCK_SIZE - 1); | ||
244 | |||
245 | memcpy(sctx->iv, desc->info, DES3_128_BLOCK_SIZE); | ||
246 | ret = crypt_s390_kmc(KMC_TDEA_128_ENCRYPT, &sctx->iv, out, in, nbytes); | ||
247 | BUG_ON((ret < 0) || (ret != nbytes)); | ||
248 | |||
249 | memcpy(desc->info, sctx->iv, DES3_128_BLOCK_SIZE); | ||
250 | return nbytes; | ||
251 | } | ||
252 | |||
253 | static unsigned int des3_128_decrypt_cbc(const struct cipher_desc *desc, | ||
254 | u8 *out, const u8 *in, | ||
255 | unsigned int nbytes) | ||
256 | { | ||
257 | struct crypt_s390_des3_128_ctx *sctx = crypto_tfm_ctx(desc->tfm); | ||
258 | int ret; | ||
259 | |||
260 | /* only use complete blocks */ | ||
261 | nbytes &= ~(DES3_128_BLOCK_SIZE - 1); | ||
262 | |||
263 | memcpy(&sctx->iv, desc->info, DES3_128_BLOCK_SIZE); | ||
264 | ret = crypt_s390_kmc(KMC_TDEA_128_DECRYPT, &sctx->iv, out, in, nbytes); | ||
265 | BUG_ON((ret < 0) || (ret != nbytes)); | ||
266 | |||
267 | return nbytes; | ||
150 | } | 268 | } |
151 | 269 | ||
152 | static struct crypto_alg des3_128_alg = { | 270 | static struct crypto_alg des3_128_alg = { |
@@ -156,12 +274,19 @@ static struct crypto_alg des3_128_alg = { | |||
156 | .cra_ctxsize = sizeof(struct crypt_s390_des3_128_ctx), | 274 | .cra_ctxsize = sizeof(struct crypt_s390_des3_128_ctx), |
157 | .cra_module = THIS_MODULE, | 275 | .cra_module = THIS_MODULE, |
158 | .cra_list = LIST_HEAD_INIT(des3_128_alg.cra_list), | 276 | .cra_list = LIST_HEAD_INIT(des3_128_alg.cra_list), |
159 | .cra_u = { .cipher = { | 277 | .cra_u = { |
160 | .cia_min_keysize = DES3_128_KEY_SIZE, | 278 | .cipher = { |
161 | .cia_max_keysize = DES3_128_KEY_SIZE, | 279 | .cia_min_keysize = DES3_128_KEY_SIZE, |
162 | .cia_setkey = des3_128_setkey, | 280 | .cia_max_keysize = DES3_128_KEY_SIZE, |
163 | .cia_encrypt = des3_128_encrypt, | 281 | .cia_setkey = des3_128_setkey, |
164 | .cia_decrypt = des3_128_decrypt } } | 282 | .cia_encrypt = des3_128_encrypt, |
283 | .cia_decrypt = des3_128_decrypt, | ||
284 | .cia_encrypt_ecb = des3_128_encrypt_ecb, | ||
285 | .cia_decrypt_ecb = des3_128_decrypt_ecb, | ||
286 | .cia_encrypt_cbc = des3_128_encrypt_cbc, | ||
287 | .cia_decrypt_cbc = des3_128_decrypt_cbc, | ||
288 | } | ||
289 | } | ||
165 | }; | 290 | }; |
166 | 291 | ||
167 | /* | 292 | /* |
@@ -177,50 +302,108 @@ static struct crypto_alg des3_128_alg = { | |||
177 | * property. | 302 | * property. |
178 | * | 303 | * |
179 | */ | 304 | */ |
180 | static int | 305 | static int des3_192_setkey(void *ctx, const u8 *key, unsigned int keylen, |
181 | des3_192_setkey(void *ctx, const u8 *key, unsigned int keylen, u32 *flags) | 306 | u32 *flags) |
182 | { | 307 | { |
183 | int i, ret; | 308 | int i, ret; |
184 | struct crypt_s390_des3_192_ctx *dctx; | 309 | struct crypt_s390_des3_192_ctx *dctx = ctx; |
185 | const u8* temp_key; | 310 | const u8* temp_key = key; |
186 | 311 | ||
187 | dctx = ctx; | ||
188 | temp_key = key; | ||
189 | if (!(memcmp(key, &key[DES_KEY_SIZE], DES_KEY_SIZE) && | 312 | if (!(memcmp(key, &key[DES_KEY_SIZE], DES_KEY_SIZE) && |
190 | memcmp(&key[DES_KEY_SIZE], &key[DES_KEY_SIZE * 2], | 313 | memcmp(&key[DES_KEY_SIZE], &key[DES_KEY_SIZE * 2], |
191 | DES_KEY_SIZE))) { | 314 | DES_KEY_SIZE))) { |
192 | 315 | ||
193 | *flags |= CRYPTO_TFM_RES_BAD_KEY_SCHED; | 316 | *flags |= CRYPTO_TFM_RES_BAD_KEY_SCHED; |
194 | return -EINVAL; | 317 | return -EINVAL; |
195 | } | 318 | } |
196 | for (i = 0; i < 3; i++, temp_key += DES_KEY_SIZE) { | 319 | for (i = 0; i < 3; i++, temp_key += DES_KEY_SIZE) { |
197 | ret = crypto_des_check_key(temp_key, DES_KEY_SIZE, flags); | 320 | ret = crypto_des_check_key(temp_key, DES_KEY_SIZE, flags); |
198 | if (ret < 0){ | 321 | if (ret < 0) |
199 | return ret; | 322 | return ret; |
200 | } | ||
201 | } | 323 | } |
202 | memcpy(dctx->key, key, keylen); | 324 | memcpy(dctx->key, key, keylen); |
203 | return 0; | 325 | return 0; |
204 | } | 326 | } |
205 | 327 | ||
206 | static void | 328 | static void des3_192_encrypt(void *ctx, u8 *dst, const u8 *src) |
207 | des3_192_encrypt(void *ctx, u8 *dst, const u8 *src) | ||
208 | { | 329 | { |
209 | struct crypt_s390_des3_192_ctx *dctx; | 330 | struct crypt_s390_des3_192_ctx *dctx = ctx; |
210 | 331 | ||
211 | dctx = ctx; | ||
212 | crypt_s390_km(KM_TDEA_192_ENCRYPT, dctx->key, dst, (void*)src, | 332 | crypt_s390_km(KM_TDEA_192_ENCRYPT, dctx->key, dst, (void*)src, |
213 | DES3_192_BLOCK_SIZE); | 333 | DES3_192_BLOCK_SIZE); |
214 | } | 334 | } |
215 | 335 | ||
216 | static void | 336 | static void des3_192_decrypt(void *ctx, u8 *dst, const u8 *src) |
217 | des3_192_decrypt(void *ctx, u8 *dst, const u8 *src) | ||
218 | { | 337 | { |
219 | struct crypt_s390_des3_192_ctx *dctx; | 338 | struct crypt_s390_des3_192_ctx *dctx = ctx; |
220 | 339 | ||
221 | dctx = ctx; | ||
222 | crypt_s390_km(KM_TDEA_192_DECRYPT, dctx->key, dst, (void*)src, | 340 | crypt_s390_km(KM_TDEA_192_DECRYPT, dctx->key, dst, (void*)src, |
223 | DES3_192_BLOCK_SIZE); | 341 | DES3_192_BLOCK_SIZE); |
342 | } | ||
343 | |||
344 | static unsigned int des3_192_encrypt_ecb(const struct cipher_desc *desc, | ||
345 | u8 *out, const u8 *in, | ||
346 | unsigned int nbytes) | ||
347 | { | ||
348 | struct crypt_s390_des3_192_ctx *sctx = crypto_tfm_ctx(desc->tfm); | ||
349 | int ret; | ||
350 | |||
351 | /* only use complete blocks */ | ||
352 | nbytes &= ~(DES3_192_BLOCK_SIZE - 1); | ||
353 | ret = crypt_s390_km(KM_TDEA_192_ENCRYPT, sctx->key, out, in, nbytes); | ||
354 | BUG_ON((ret < 0) || (ret != nbytes)); | ||
355 | |||
356 | return nbytes; | ||
357 | } | ||
358 | |||
359 | static unsigned int des3_192_decrypt_ecb(const struct cipher_desc *desc, | ||
360 | u8 *out, const u8 *in, | ||
361 | unsigned int nbytes) | ||
362 | { | ||
363 | struct crypt_s390_des3_192_ctx *sctx = crypto_tfm_ctx(desc->tfm); | ||
364 | int ret; | ||
365 | |||
366 | /* only use complete blocks */ | ||
367 | nbytes &= ~(DES3_192_BLOCK_SIZE - 1); | ||
368 | ret = crypt_s390_km(KM_TDEA_192_DECRYPT, sctx->key, out, in, nbytes); | ||
369 | BUG_ON((ret < 0) || (ret != nbytes)); | ||
370 | |||
371 | return nbytes; | ||
372 | } | ||
373 | |||
374 | static unsigned int des3_192_encrypt_cbc(const struct cipher_desc *desc, | ||
375 | u8 *out, const u8 *in, | ||
376 | unsigned int nbytes) | ||
377 | { | ||
378 | struct crypt_s390_des3_192_ctx *sctx = crypto_tfm_ctx(desc->tfm); | ||
379 | int ret; | ||
380 | |||
381 | /* only use complete blocks */ | ||
382 | nbytes &= ~(DES3_192_BLOCK_SIZE - 1); | ||
383 | |||
384 | memcpy(sctx->iv, desc->info, DES3_192_BLOCK_SIZE); | ||
385 | ret = crypt_s390_kmc(KMC_TDEA_192_ENCRYPT, &sctx->iv, out, in, nbytes); | ||
386 | BUG_ON((ret < 0) || (ret != nbytes)); | ||
387 | |||
388 | memcpy(desc->info, sctx->iv, DES3_192_BLOCK_SIZE); | ||
389 | return nbytes; | ||
390 | } | ||
391 | |||
392 | static unsigned int des3_192_decrypt_cbc(const struct cipher_desc *desc, | ||
393 | u8 *out, const u8 *in, | ||
394 | unsigned int nbytes) | ||
395 | { | ||
396 | struct crypt_s390_des3_192_ctx *sctx = crypto_tfm_ctx(desc->tfm); | ||
397 | int ret; | ||
398 | |||
399 | /* only use complete blocks */ | ||
400 | nbytes &= ~(DES3_192_BLOCK_SIZE - 1); | ||
401 | |||
402 | memcpy(&sctx->iv, desc->info, DES3_192_BLOCK_SIZE); | ||
403 | ret = crypt_s390_kmc(KMC_TDEA_192_DECRYPT, &sctx->iv, out, in, nbytes); | ||
404 | BUG_ON((ret < 0) || (ret != nbytes)); | ||
405 | |||
406 | return nbytes; | ||
224 | } | 407 | } |
225 | 408 | ||
226 | static struct crypto_alg des3_192_alg = { | 409 | static struct crypto_alg des3_192_alg = { |
@@ -230,44 +413,43 @@ static struct crypto_alg des3_192_alg = { | |||
230 | .cra_ctxsize = sizeof(struct crypt_s390_des3_192_ctx), | 413 | .cra_ctxsize = sizeof(struct crypt_s390_des3_192_ctx), |
231 | .cra_module = THIS_MODULE, | 414 | .cra_module = THIS_MODULE, |
232 | .cra_list = LIST_HEAD_INIT(des3_192_alg.cra_list), | 415 | .cra_list = LIST_HEAD_INIT(des3_192_alg.cra_list), |
233 | .cra_u = { .cipher = { | 416 | .cra_u = { |
234 | .cia_min_keysize = DES3_192_KEY_SIZE, | 417 | .cipher = { |
235 | .cia_max_keysize = DES3_192_KEY_SIZE, | 418 | .cia_min_keysize = DES3_192_KEY_SIZE, |
236 | .cia_setkey = des3_192_setkey, | 419 | .cia_max_keysize = DES3_192_KEY_SIZE, |
237 | .cia_encrypt = des3_192_encrypt, | 420 | .cia_setkey = des3_192_setkey, |
238 | .cia_decrypt = des3_192_decrypt } } | 421 | .cia_encrypt = des3_192_encrypt, |
422 | .cia_decrypt = des3_192_decrypt, | ||
423 | .cia_encrypt_ecb = des3_192_encrypt_ecb, | ||
424 | .cia_decrypt_ecb = des3_192_decrypt_ecb, | ||
425 | .cia_encrypt_cbc = des3_192_encrypt_cbc, | ||
426 | .cia_decrypt_cbc = des3_192_decrypt_cbc, | ||
427 | } | ||
428 | } | ||
239 | }; | 429 | }; |
240 | 430 | ||
241 | 431 | static int init(void) | |
242 | |||
243 | static int | ||
244 | init(void) | ||
245 | { | 432 | { |
246 | int ret; | 433 | int ret = 0; |
247 | 434 | ||
248 | if (!crypt_s390_func_available(KM_DEA_ENCRYPT) || | 435 | if (!crypt_s390_func_available(KM_DEA_ENCRYPT) || |
249 | !crypt_s390_func_available(KM_TDEA_128_ENCRYPT) || | 436 | !crypt_s390_func_available(KM_TDEA_128_ENCRYPT) || |
250 | !crypt_s390_func_available(KM_TDEA_192_ENCRYPT)){ | 437 | !crypt_s390_func_available(KM_TDEA_192_ENCRYPT)) |
251 | return -ENOSYS; | 438 | return -ENOSYS; |
252 | } | ||
253 | 439 | ||
254 | ret = 0; | 440 | ret |= (crypto_register_alg(&des_alg) == 0) ? 0:1; |
255 | ret |= (crypto_register_alg(&des_alg) == 0)? 0:1; | 441 | ret |= (crypto_register_alg(&des3_128_alg) == 0) ? 0:2; |
256 | ret |= (crypto_register_alg(&des3_128_alg) == 0)? 0:2; | 442 | ret |= (crypto_register_alg(&des3_192_alg) == 0) ? 0:4; |
257 | ret |= (crypto_register_alg(&des3_192_alg) == 0)? 0:4; | 443 | if (ret) { |
258 | if (ret){ | ||
259 | crypto_unregister_alg(&des3_192_alg); | 444 | crypto_unregister_alg(&des3_192_alg); |
260 | crypto_unregister_alg(&des3_128_alg); | 445 | crypto_unregister_alg(&des3_128_alg); |
261 | crypto_unregister_alg(&des_alg); | 446 | crypto_unregister_alg(&des_alg); |
262 | return -EEXIST; | 447 | return -EEXIST; |
263 | } | 448 | } |
264 | |||
265 | printk(KERN_INFO "crypt_s390: des_s390 loaded.\n"); | ||
266 | return 0; | 449 | return 0; |
267 | } | 450 | } |
268 | 451 | ||
269 | static void __exit | 452 | static void __exit fini(void) |
270 | fini(void) | ||
271 | { | 453 | { |
272 | crypto_unregister_alg(&des3_192_alg); | 454 | crypto_unregister_alg(&des3_192_alg); |
273 | crypto_unregister_alg(&des3_128_alg); | 455 | crypto_unregister_alg(&des3_128_alg); |