Commit 7226bc877a22244e8003924031435a4bffd52654

Authored by Herbert Xu
1 parent 03fd9cee7f

[CRYPTO] api: Mark parts of cipher interface as deprecated

Mark the parts of the cipher interface that have been replaced by
block ciphers as deprecated.  Thanks to Andrew Morton for suggesting
doing this before removing them completely.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Showing 2 changed files with 64 additions and 18 deletions Side-by-side Diff

... ... @@ -23,6 +23,28 @@
23 23 #include "internal.h"
24 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 48 static inline void xor_64(u8 *a, const u8 *b)
27 49 {
28 50 ((u32 *)a)[0] ^= ((u32 *)b)[0];
... ... @@ -276,7 +298,7 @@
276 298 struct scatterlist *src, unsigned int nbytes)
277 299 {
278 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 303 desc.tfm = tfm;
282 304 desc.crfn = cipher->cia_encrypt;
... ... @@ -291,7 +313,7 @@
291 313 unsigned int nbytes)
292 314 {
293 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 318 desc.tfm = tfm;
297 319 desc.crfn = cipher->cia_decrypt;
... ... @@ -306,7 +328,7 @@
306 328 unsigned int nbytes)
307 329 {
308 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 333 desc.tfm = tfm;
312 334 desc.crfn = cipher->cia_encrypt;
... ... @@ -322,7 +344,7 @@
322 344 unsigned int nbytes, u8 *iv)
323 345 {
324 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 349 desc.tfm = tfm;
328 350 desc.crfn = cipher->cia_encrypt;
... ... @@ -338,7 +360,7 @@
338 360 unsigned int nbytes)
339 361 {
340 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 365 desc.tfm = tfm;
344 366 desc.crfn = cipher->cia_decrypt;
... ... @@ -354,7 +376,7 @@
354 376 unsigned int nbytes, u8 *iv)
355 377 {
356 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 381 desc.tfm = tfm;
360 382 desc.crfn = cipher->cia_decrypt;
include/linux/crypto.h
... ... @@ -20,7 +20,6 @@
20 20 #include <asm/atomic.h>
21 21 #include <linux/module.h>
22 22 #include <linux/kernel.h>
23   -#include <linux/types.h>
24 23 #include <linux/list.h>
25 24 #include <linux/slab.h>
26 25 #include <linux/string.h>
27 26  
28 27  
29 28  
... ... @@ -137,16 +136,16 @@
137 136  
138 137 unsigned int (*cia_encrypt_ecb)(const struct cipher_desc *desc,
139 138 u8 *dst, const u8 *src,
140   - unsigned int nbytes);
  139 + unsigned int nbytes) __deprecated;
141 140 unsigned int (*cia_decrypt_ecb)(const struct cipher_desc *desc,
142 141 u8 *dst, const u8 *src,
143   - unsigned int nbytes);
  142 + unsigned int nbytes) __deprecated;
144 143 unsigned int (*cia_encrypt_cbc)(const struct cipher_desc *desc,
145 144 u8 *dst, const u8 *src,
146   - unsigned int nbytes);
  145 + unsigned int nbytes) __deprecated;
147 146 unsigned int (*cia_decrypt_cbc)(const struct cipher_desc *desc,
148 147 u8 *dst, const u8 *src,
149   - unsigned int nbytes);
  148 + unsigned int nbytes) __deprecated;
150 149 };
151 150  
152 151 struct digest_alg {
153 152  
154 153  
... ... @@ -358,18 +357,23 @@
358 357 return tfm->__crt_alg->cra_flags & CRYPTO_ALG_TYPE_MASK;
359 358 }
360 359  
  360 +static unsigned int crypto_tfm_alg_min_keysize(struct crypto_tfm *tfm)
  361 + __deprecated;
361 362 static inline unsigned int crypto_tfm_alg_min_keysize(struct crypto_tfm *tfm)
362 363 {
363 364 BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
364 365 return tfm->__crt_alg->cra_cipher.cia_min_keysize;
365 366 }
366 367  
  368 +static unsigned int crypto_tfm_alg_max_keysize(struct crypto_tfm *tfm)
  369 + __deprecated;
367 370 static inline unsigned int crypto_tfm_alg_max_keysize(struct crypto_tfm *tfm)
368 371 {
369 372 BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
370 373 return tfm->__crt_alg->cra_cipher.cia_max_keysize;
371 374 }
372 375  
  376 +static unsigned int crypto_tfm_alg_ivsize(struct crypto_tfm *tfm) __deprecated;
373 377 static inline unsigned int crypto_tfm_alg_ivsize(struct crypto_tfm *tfm)
374 378 {
375 379 BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
... ... @@ -622,6 +626,13 @@
622 626 crypto_tfm_clear_flags(crypto_cipher_tfm(tfm), flags);
623 627 }
624 628  
  629 +static inline int crypto_cipher_setkey(struct crypto_cipher *tfm,
  630 + const u8 *key, unsigned int keylen)
  631 +{
  632 + return crypto_cipher_crt(tfm)->cit_setkey(crypto_cipher_tfm(tfm),
  633 + key, keylen);
  634 +}
  635 +
625 636 static inline void crypto_cipher_encrypt_one(struct crypto_cipher *tfm,
626 637 u8 *dst, const u8 *src)
627 638 {
... ... @@ -671,13 +682,10 @@
671 682 return tfm->crt_digest.dit_setkey(tfm, key, keylen);
672 683 }
673 684  
674   -static inline int crypto_cipher_setkey(struct crypto_tfm *tfm,
675   - const u8 *key, unsigned int keylen)
676   -{
677   - BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
678   - return tfm->crt_cipher.cit_setkey(tfm, key, keylen);
679   -}
680   -
  685 +static int crypto_cipher_encrypt(struct crypto_tfm *tfm,
  686 + struct scatterlist *dst,
  687 + struct scatterlist *src,
  688 + unsigned int nbytes) __deprecated;
681 689 static inline int crypto_cipher_encrypt(struct crypto_tfm *tfm,
682 690 struct scatterlist *dst,
683 691 struct scatterlist *src,
... ... @@ -687,6 +695,10 @@
687 695 return tfm->crt_cipher.cit_encrypt(tfm, dst, src, nbytes);
688 696 }
689 697  
  698 +static int crypto_cipher_encrypt_iv(struct crypto_tfm *tfm,
  699 + struct scatterlist *dst,
  700 + struct scatterlist *src,
  701 + unsigned int nbytes, u8 *iv) __deprecated;
690 702 static inline int crypto_cipher_encrypt_iv(struct crypto_tfm *tfm,
691 703 struct scatterlist *dst,
692 704 struct scatterlist *src,
... ... @@ -696,6 +708,10 @@
696 708 return tfm->crt_cipher.cit_encrypt_iv(tfm, dst, src, nbytes, iv);
697 709 }
698 710  
  711 +static int crypto_cipher_decrypt(struct crypto_tfm *tfm,
  712 + struct scatterlist *dst,
  713 + struct scatterlist *src,
  714 + unsigned int nbytes) __deprecated;
699 715 static inline int crypto_cipher_decrypt(struct crypto_tfm *tfm,
700 716 struct scatterlist *dst,
701 717 struct scatterlist *src,
... ... @@ -705,6 +721,10 @@
705 721 return tfm->crt_cipher.cit_decrypt(tfm, dst, src, nbytes);
706 722 }
707 723  
  724 +static int crypto_cipher_decrypt_iv(struct crypto_tfm *tfm,
  725 + struct scatterlist *dst,
  726 + struct scatterlist *src,
  727 + unsigned int nbytes, u8 *iv) __deprecated;
708 728 static inline int crypto_cipher_decrypt_iv(struct crypto_tfm *tfm,
709 729 struct scatterlist *dst,
710 730 struct scatterlist *src,
... ... @@ -714,6 +734,8 @@
714 734 return tfm->crt_cipher.cit_decrypt_iv(tfm, dst, src, nbytes, iv);
715 735 }
716 736  
  737 +static void crypto_cipher_set_iv(struct crypto_tfm *tfm,
  738 + const u8 *src, unsigned int len) __deprecated;
717 739 static inline void crypto_cipher_set_iv(struct crypto_tfm *tfm,
718 740 const u8 *src, unsigned int len)
719 741 {
... ... @@ -721,6 +743,8 @@
721 743 memcpy(tfm->crt_cipher.cit_iv, src, len);
722 744 }
723 745  
  746 +static void crypto_cipher_get_iv(struct crypto_tfm *tfm,
  747 + u8 *dst, unsigned int len) __deprecated;
724 748 static inline void crypto_cipher_get_iv(struct crypto_tfm *tfm,
725 749 u8 *dst, unsigned int len)
726 750 {