diff options
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/cipher.c | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/crypto/cipher.c b/crypto/cipher.c index 326461780673..9e03701cfdcc 100644 --- a/crypto/cipher.c +++ b/crypto/cipher.c | |||
@@ -23,6 +23,28 @@ | |||
23 | #include "internal.h" | 23 | #include "internal.h" |
24 | #include "scatterwalk.h" | 24 | #include "scatterwalk.h" |
25 | 25 | ||
26 | struct cipher_alg_compat { | ||
27 | unsigned int cia_min_keysize; | ||
28 | unsigned int cia_max_keysize; | ||
29 | int (*cia_setkey)(struct crypto_tfm *tfm, const u8 *key, | ||
30 | unsigned int keylen); | ||
31 | void (*cia_encrypt)(struct crypto_tfm *tfm, u8 *dst, const u8 *src); | ||
32 | void (*cia_decrypt)(struct crypto_tfm *tfm, u8 *dst, const u8 *src); | ||
33 | |||
34 | unsigned int (*cia_encrypt_ecb)(const struct cipher_desc *desc, | ||
35 | u8 *dst, const u8 *src, | ||
36 | unsigned int nbytes); | ||
37 | unsigned int (*cia_decrypt_ecb)(const struct cipher_desc *desc, | ||
38 | u8 *dst, const u8 *src, | ||
39 | unsigned int nbytes); | ||
40 | unsigned int (*cia_encrypt_cbc)(const struct cipher_desc *desc, | ||
41 | u8 *dst, const u8 *src, | ||
42 | unsigned int nbytes); | ||
43 | unsigned int (*cia_decrypt_cbc)(const struct cipher_desc *desc, | ||
44 | u8 *dst, const u8 *src, | ||
45 | unsigned int nbytes); | ||
46 | }; | ||
47 | |||
26 | static inline void xor_64(u8 *a, const u8 *b) | 48 | static inline void xor_64(u8 *a, const u8 *b) |
27 | { | 49 | { |
28 | ((u32 *)a)[0] ^= ((u32 *)b)[0]; | 50 | ((u32 *)a)[0] ^= ((u32 *)b)[0]; |
@@ -276,7 +298,7 @@ static int ecb_encrypt(struct crypto_tfm *tfm, | |||
276 | struct scatterlist *src, unsigned int nbytes) | 298 | struct scatterlist *src, unsigned int nbytes) |
277 | { | 299 | { |
278 | struct cipher_desc desc; | 300 | struct cipher_desc desc; |
279 | struct cipher_alg *cipher = &tfm->__crt_alg->cra_cipher; | 301 | struct cipher_alg_compat *cipher = (void *)&tfm->__crt_alg->cra_cipher; |
280 | 302 | ||
281 | desc.tfm = tfm; | 303 | desc.tfm = tfm; |
282 | desc.crfn = cipher->cia_encrypt; | 304 | desc.crfn = cipher->cia_encrypt; |
@@ -291,7 +313,7 @@ static int ecb_decrypt(struct crypto_tfm *tfm, | |||
291 | unsigned int nbytes) | 313 | unsigned int nbytes) |
292 | { | 314 | { |
293 | struct cipher_desc desc; | 315 | struct cipher_desc desc; |
294 | struct cipher_alg *cipher = &tfm->__crt_alg->cra_cipher; | 316 | struct cipher_alg_compat *cipher = (void *)&tfm->__crt_alg->cra_cipher; |
295 | 317 | ||
296 | desc.tfm = tfm; | 318 | desc.tfm = tfm; |
297 | desc.crfn = cipher->cia_decrypt; | 319 | desc.crfn = cipher->cia_decrypt; |
@@ -306,7 +328,7 @@ static int cbc_encrypt(struct crypto_tfm *tfm, | |||
306 | unsigned int nbytes) | 328 | unsigned int nbytes) |
307 | { | 329 | { |
308 | struct cipher_desc desc; | 330 | struct cipher_desc desc; |
309 | struct cipher_alg *cipher = &tfm->__crt_alg->cra_cipher; | 331 | struct cipher_alg_compat *cipher = (void *)&tfm->__crt_alg->cra_cipher; |
310 | 332 | ||
311 | desc.tfm = tfm; | 333 | desc.tfm = tfm; |
312 | desc.crfn = cipher->cia_encrypt; | 334 | desc.crfn = cipher->cia_encrypt; |
@@ -322,7 +344,7 @@ static int cbc_encrypt_iv(struct crypto_tfm *tfm, | |||
322 | unsigned int nbytes, u8 *iv) | 344 | unsigned int nbytes, u8 *iv) |
323 | { | 345 | { |
324 | struct cipher_desc desc; | 346 | struct cipher_desc desc; |
325 | struct cipher_alg *cipher = &tfm->__crt_alg->cra_cipher; | 347 | struct cipher_alg_compat *cipher = (void *)&tfm->__crt_alg->cra_cipher; |
326 | 348 | ||
327 | desc.tfm = tfm; | 349 | desc.tfm = tfm; |
328 | desc.crfn = cipher->cia_encrypt; | 350 | desc.crfn = cipher->cia_encrypt; |
@@ -338,7 +360,7 @@ static int cbc_decrypt(struct crypto_tfm *tfm, | |||
338 | unsigned int nbytes) | 360 | unsigned int nbytes) |
339 | { | 361 | { |
340 | struct cipher_desc desc; | 362 | struct cipher_desc desc; |
341 | struct cipher_alg *cipher = &tfm->__crt_alg->cra_cipher; | 363 | struct cipher_alg_compat *cipher = (void *)&tfm->__crt_alg->cra_cipher; |
342 | 364 | ||
343 | desc.tfm = tfm; | 365 | desc.tfm = tfm; |
344 | desc.crfn = cipher->cia_decrypt; | 366 | desc.crfn = cipher->cia_decrypt; |
@@ -354,7 +376,7 @@ static int cbc_decrypt_iv(struct crypto_tfm *tfm, | |||
354 | unsigned int nbytes, u8 *iv) | 376 | unsigned int nbytes, u8 *iv) |
355 | { | 377 | { |
356 | struct cipher_desc desc; | 378 | struct cipher_desc desc; |
357 | struct cipher_alg *cipher = &tfm->__crt_alg->cra_cipher; | 379 | struct cipher_alg_compat *cipher = (void *)&tfm->__crt_alg->cra_cipher; |
358 | 380 | ||
359 | desc.tfm = tfm; | 381 | desc.tfm = tfm; |
360 | desc.crfn = cipher->cia_decrypt; | 382 | desc.crfn = cipher->cia_decrypt; |