Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

crypto: omap/des - switch to new verification routines

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Ard Biesheuvel and committed by
Herbert Xu
304daa4f d4b90dbc

+8 -19
+8 -19
drivers/crypto/omap-des.c
··· 33 33 #include <linux/crypto.h> 34 34 #include <linux/interrupt.h> 35 35 #include <crypto/scatterwalk.h> 36 - #include <crypto/des.h> 36 + #include <crypto/internal/des.h> 37 37 #include <crypto/algapi.h> 38 38 #include <crypto/engine.h> 39 39 ··· 650 650 unsigned int keylen) 651 651 { 652 652 struct omap_des_ctx *ctx = crypto_ablkcipher_ctx(cipher); 653 - struct crypto_tfm *tfm = crypto_ablkcipher_tfm(cipher); 653 + int err; 654 654 655 655 pr_debug("enter, keylen: %d\n", keylen); 656 656 657 - /* Do we need to test against weak key? */ 658 - if (tfm->crt_flags & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS) { 659 - u32 tmp[DES_EXPKEY_WORDS]; 660 - int ret = des_ekey(tmp, key); 661 - 662 - if (!ret) { 663 - tfm->crt_flags |= CRYPTO_TFM_RES_WEAK_KEY; 664 - return -EINVAL; 665 - } 666 - } 657 + err = verify_ablkcipher_des_key(cipher, key); 658 + if (err) 659 + return err; 667 660 668 661 memcpy(ctx->key, key, keylen); 669 662 ctx->keylen = keylen; ··· 665 672 } 666 673 667 674 static int omap_des3_setkey(struct crypto_ablkcipher *cipher, const u8 *key, 668 - unsigned int keylen) 675 + unsigned int keylen) 669 676 { 670 677 struct omap_des_ctx *ctx = crypto_ablkcipher_ctx(cipher); 671 - u32 flags; 672 678 int err; 673 679 674 680 pr_debug("enter, keylen: %d\n", keylen); 675 681 676 - flags = crypto_ablkcipher_get_flags(cipher); 677 - err = __des3_verify_key(&flags, key); 678 - if (unlikely(err)) { 679 - crypto_ablkcipher_set_flags(cipher, flags); 682 + err = verify_ablkcipher_des3_key(cipher, key); 683 + if (err) 680 684 return err; 681 - } 682 685 683 686 memcpy(ctx->key, key, keylen); 684 687 ctx->keylen = keylen;