From patchwork Thu Jun 27 12:03:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 167948 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2249732ilk; Thu, 27 Jun 2019 05:03:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqzzFNsoMVj1XM+CimuA4kiJPajxJPk2Vbp0vdNVXqQcCUgwafKGT3WnEC9UXH/Ul+DrBbh0 X-Received: by 2002:a17:90a:1904:: with SMTP id 4mr5795231pjg.116.1561637029686; Thu, 27 Jun 2019 05:03:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561637029; cv=none; d=google.com; s=arc-20160816; b=s7tokDgV1kG8PXY1gD0wf6eBWkQ2TO0jOy7Htp2EQNmBBETV/W1dOmW7w/MwBQZO4X uxcQJnypXiCRlw5DUKNrtIbeoRIlLypbtZziTqX/BME6k5Og9368quIL1WgiKIzNupa6 wDWv7Y+PS/VGkmUfic5+sqPm2VICMGFvZG1aD7qDzkGFLinB30YH3VcHLBFUrq9jxDZv JTVqSwSQ1FmKD7LlxnsQN9VqSJxEYBLYp8m7yU4ZRFtdo5piMNK/sq2Nymn5jQjbFmFC bsfu08R6bw3IYgDOJmmazudktxSneLINlolnfMXejjh5z8WBI77OGhWKF5nf2AsvwoES /16w== 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=Oh1/+FMGZflC6/DL3pe6jxXhkPYRcs3ldpzq2tGNxco=; b=b6hEIk70FNj7A/PXRhSnZvcWlQtUiLHLZ218pfkxc3hczWiX9h8crhvblrXni6zUvn keqHFM+HwTv/iYn2NUqcuLdA9qfNhUt/SPh3QGPoViODOS2NyObiWcUkkshlUjBkqAcQ mN/h4+QF4y6asLr0kVfQKa+mEqJud6fshHS5Iu46naLfu2z/S541ype4d4koyF/ExdHQ htqz0Y178+klzbzBDhZ852VU0wCMSan81Nr/CfjR6W1gbFLHiDOlI6Y+OkQS23HMxuEk booSP37fDKH9KLhqXW4LD5xsikJrZuVoqBgtJykFLpg72otrLMXdWHhWLca7uOA/rcC/ JYnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Cncw1z/5"; 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 m39si2229121plg.155.2019.06.27.05.03.49; Thu, 27 Jun 2019 05:03:49 -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="Cncw1z/5"; 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 S1726809AbfF0MDr (ORCPT + 3 others); Thu, 27 Jun 2019 08:03:47 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:38022 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726816AbfF0MDq (ORCPT ); Thu, 27 Jun 2019 08:03:46 -0400 Received: by mail-wm1-f67.google.com with SMTP id s15so5396883wmj.3 for ; Thu, 27 Jun 2019 05:03:45 -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=Oh1/+FMGZflC6/DL3pe6jxXhkPYRcs3ldpzq2tGNxco=; b=Cncw1z/5KJG2n52yi9NLffCPP8LW3dkFAn8f7GZXrSwKtH8qbQrV9FGNuh2TI2MFhd UAiiQksV6AnjMUXE7Cg78nceiP2HscxigSb2REn9ObbdYnLpygoo2ESfPrQVCf9FATiy ZOnl7CBYJn94IvpFqaEgNOgZ6hvG1eKNdL/3Qri/C5+O5tORKcSiW1jp8Q/F5aMFYtC7 fMb3MQNGI3y+vciYpM0Ot9PPm2jqo8ygf/jpPOGPBjUYw6dVi2DoAhmxcaBnx5/SM03X tPTmn1t4roldIELIqJNXhBACGpjr9AylYgU40lNK3ccOSq5HOxw7dBrPqHoD3VYxrnPL Oxbg== 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=Oh1/+FMGZflC6/DL3pe6jxXhkPYRcs3ldpzq2tGNxco=; b=hdf80zw45hcV76vuZDoIzZH37zH+TeSbuoIKv6ZkD5C8SXxEMgkxVm8yHOHhkGGsfE MCVXRxoqHu6MZNS/6FtvFEDB0anGNs8jeIS/eK7TTUF9J7/czUnBKvPsw7KN/4tHfVGM 12/TeOT6phWOOkY2N3yq+LkpV80LPvKUhTSQHqa1bs+G2PXk61xwbHbrVveXMZbCYEfZ eP3SXJ0dmMeT6vzRu/7Ua22EOS8cSlPNj8UNkdfJQ7W8fapZaq+kFUrnyVwULvwckcn1 eppRBsp8iMNJAa2hBKTvS1HGsJwgm5HBND6aIQTg4++D7dnxnNwkMTj7LByhAsGdsnL5 EGpw== X-Gm-Message-State: APjAAAUqfCHhWabBkbgSwYlG3pUltmFreCAh37upg0K/fMmGXts8oebm p88dOsSIPARGX7Qv5vDAPkDknOou80gQvQ== X-Received: by 2002:a7b:c776:: with SMTP id x22mr2951521wmk.55.1561637024969; Thu, 27 Jun 2019 05:03:44 -0700 (PDT) Received: from localhost.localdomain (laubervilliers-657-1-83-120.w92-154.abo.wanadoo.fr. [92.154.90.120]) by smtp.gmail.com with ESMTPSA id z126sm7732431wmb.32.2019.06.27.05.03.43 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 27 Jun 2019 05:03:44 -0700 (PDT) From: Ard Biesheuvel To: linux-crypto@vger.kernel.org Cc: herbert@gondor.apana.org.au, ebiggers@kernel.org, horia.geanta@nxp.com, Ard Biesheuvel Subject: [PATCH v2 17/30] crypto: omap/des - switch to new verification routines Date: Thu, 27 Jun 2019 14:03:01 +0200 Message-Id: <20190627120314.7197-18-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190627120314.7197-1-ard.biesheuvel@linaro.org> References: <20190627120314.7197-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 | 25 ++++++-------------- 1 file changed, 7 insertions(+), 18 deletions(-) -- 2.20.1 diff --git a/drivers/crypto/omap-des.c b/drivers/crypto/omap-des.c index 3d82d18ff810..103b3293c113 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); + if (unlikely(err)) + return err; memcpy(ctx->key, key, keylen); ctx->keylen = keylen; @@ -679,17 +672,13 @@ 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); + if (unlikely(err)) return err; - } memcpy(ctx->key, key, keylen); ctx->keylen = keylen;