From patchwork Sat Jun 22 00:30:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 167443 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp1376759ilk; Fri, 21 Jun 2019 17:32:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqwCQBsExcJ+tBsfmgRao1Sf/oTQrOPVwAVyM1yyW3KmJEpYIiUX/EFrgOKZbyV+i0ooOtMy X-Received: by 2002:a17:902:7603:: with SMTP id k3mr27476164pll.245.1561163526767; Fri, 21 Jun 2019 17:32:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561163526; cv=none; d=google.com; s=arc-20160816; b=rusYmqcQI/G1EXf9+HOCNvmBHnvDLwc6KrzmngeRiSmoDVHNVDoc7uNqMfetAVS9Z9 AtLsKL6JIjGP5S0Li2Ci37M+mKbmA6vDD015xamJQF9B99uFmOszUZSi4WCqIlr2LC5S tfLeBAEg9CN63u0a1xZ0ouUvUn7dCL5KizEfsgXD+lFgYctXa4HMEQqEXtCNGGjansBP RVLDn1HHOU47zt7C9VWvLjcBB7rNJczVK6w9+b/2HcHzPhSWct8PIbRKtAVi57XW3VU0 BrFaOJpbYZrPeOn5vUw/ynZFNRArP99Pu5uGK0sSZ+XIhgrgevC/lZYEJIq6up4IXEet J5AA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=O7DR5C/lWiSweuqmSJBPrK6JFLnDeOwIB42xolmC51s=; b=aDQKhQBdA65EjDLy+6Tm8+IXZbGxzxo7yU8FpIL/840n6UoSK/sRMwy4VUCq2aFjHr HrKnvzxCt3AMRW8MNv3OuP0xIqNqa2T+iQrFGVSsd9SGKOhxlCwDCXSUr5DxJyhB92sj mfEswvNeDTNBBjizDaOb7s1YWlkC0xzvbEVwaD+0znxVHZjZ49oKaHsEjqDKTMvBiyn0 WTDY7SBSjRtIQc/dNp8fMXJ9K5mAkvCbwUiXJL5b1UfPNjrZ2j97AzzdAs3z+jGo3TsO 58Pxuue0uHpC+cR8wCbDHmDa03UMhv+nLZ6TdgvIMVoqLDi5JQvPzu0jKUAImQazl0Hp 4/6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dHIp3gjX; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v10si4096271plg.320.2019.06.21.17.32.06; Fri, 21 Jun 2019 17:32:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dHIp3gjX; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726141AbfFVAcF (ORCPT + 3 others); Fri, 21 Jun 2019 20:32:05 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:53124 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726219AbfFVAcE (ORCPT ); Fri, 21 Jun 2019 20:32:04 -0400 Received: by mail-wm1-f66.google.com with SMTP id s3so7718125wms.2 for ; Fri, 21 Jun 2019 17:32:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=O7DR5C/lWiSweuqmSJBPrK6JFLnDeOwIB42xolmC51s=; b=dHIp3gjX/z7+mIYEOuoLvCOZyhf2x5f+wfiTkWOmMoFBidLm8ShD2jXDNHxtHJkoFH /pFxc5PNQx6rc3j4dXWqe4pHns+Rm+p83YzbxLW3i5Dga3YuuomAxoAJxN279rLkObs3 GEJ9kHGiv9GBNmhldAfcMiSAiIU/14uFG3z/tNbjRFQv9F2fs15Pbm459rX+redPSeUH Y0S8yZl1rxXr6a+ZbYZibGVnnfokFvFkBItTqveIFkbrZNkii4Hoew7h3XEWnvFTJtGE 8xjIdndoyf/f1O4BnddjM2rG4DM/VzKw2kYnuN/2gjKWtP7idkbHYq6pzZfHdHhE+H0W vwzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=O7DR5C/lWiSweuqmSJBPrK6JFLnDeOwIB42xolmC51s=; b=NyPWRYDuJ1JFEtbS4/uMDPMgO9hYjT5DGOuMY83WPYsROaOanJmyA5M/oVCFC1eMBx 0BxLtrM/9Q4+JWE4XFT4684LJrCAAgHSHBBHuaD20khXxqET5SHDzhlg3zazfRO8vU7H DPwoXXHVy+QFoHwJiqCpU2KwVmF5OywJ60vDEpMyJI2p3Uh4K1fjO+4vylCuuwY+AFFN lMo/FXtK9MP9cfkmRDjSGKPSg1Es4MCsnchpwjPvMBDNLqPKoqaZdCT3TtcsNRI3OBnx oVa4oqblfErmk6DCT97bWet5j/ARIYdpv7VqKyFB5g/xhVXNoBrezsHzsbgjUTqy38Uc hD0g== X-Gm-Message-State: APjAAAVlDHExTEOl6KzcbHSof3K2C6MFFLuuSrwHMAbb49dXATWsJMSg rC7R3OMQS6zNCoaTcFzVA+4EgiWt3mCTLJ0/ X-Received: by 2002:a1c:7408:: with SMTP id p8mr5305899wmc.161.1561163522048; Fri, 21 Jun 2019 17:32:02 -0700 (PDT) Received: from sudo.home ([2a01:cb1d:112:6f00:99d4:1ff0:ed6:dfbb]) by smtp.gmail.com with ESMTPSA id v18sm4792019wrd.51.2019.06.21.17.32.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Jun 2019 17:32:01 -0700 (PDT) From: Ard Biesheuvel To: linux-crypto@vger.kernel.org Cc: herbert@gondor.apana.org.au, ebiggers@google.com, Ard Biesheuvel Subject: [RFC PATCH 17/30] crypto: omap/des - switch to new verification routines Date: Sat, 22 Jun 2019 02:30:59 +0200 Message-Id: <20190622003112.31033-18-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190622003112.31033-1-ard.biesheuvel@linaro.org> References: <20190622003112.31033-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Signed-off-by: Ard Biesheuvel --- drivers/crypto/omap-des.c | 26 ++++++-------------- 1 file changed, 8 insertions(+), 18 deletions(-) -- 2.20.1 diff --git a/drivers/crypto/omap-des.c b/drivers/crypto/omap-des.c index 3d82d18ff810..260fe83b8a7b 100644 --- a/drivers/crypto/omap-des.c +++ b/drivers/crypto/omap-des.c @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include #include @@ -654,20 +654,13 @@ static int omap_des_setkey(struct crypto_ablkcipher *cipher, const u8 *key, unsigned int keylen) { struct omap_des_ctx *ctx = crypto_ablkcipher_ctx(cipher); - struct crypto_tfm *tfm = crypto_ablkcipher_tfm(cipher); + int err; pr_debug("enter, keylen: %d\n", keylen); - /* Do we need to test against weak key? */ - if (tfm->crt_flags & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS) { - u32 tmp[DES_EXPKEY_WORDS]; - int ret = des_ekey(tmp, key); - - if (!ret) { - tfm->crt_flags |= CRYPTO_TFM_RES_WEAK_KEY; - return -EINVAL; - } - } + err = crypto_des_verify_key(crypto_ablkcipher_tfm(cipher), key, keylen); + if (unlikely(err)) + return err; memcpy(ctx->key, key, keylen); ctx->keylen = keylen; @@ -679,17 +672,14 @@ static int omap_des3_setkey(struct crypto_ablkcipher *cipher, const u8 *key, unsigned int keylen) { struct omap_des_ctx *ctx = crypto_ablkcipher_ctx(cipher); - u32 flags; int err; pr_debug("enter, keylen: %d\n", keylen); - flags = crypto_ablkcipher_get_flags(cipher); - err = __des3_verify_key(&flags, key); - if (unlikely(err)) { - crypto_ablkcipher_set_flags(cipher, flags); + err = crypto_des3_ede_verify_key(crypto_ablkcipher_tfm(cipher), key, + keylen); + if (unlikely(err)) return err; - } memcpy(ctx->key, key, keylen); ctx->keylen = keylen;