From patchwork Thu Aug 15 09:00:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 171404 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1917918ily; Thu, 15 Aug 2019 02:01:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqwO7zFj1+lpSkMvp7zKpUfzdr7ItxZCg7Qpe1NfKaPxCr+e7HtDAjBKoYi1FS4UcdmmDLHE X-Received: by 2002:a63:c84d:: with SMTP id l13mr2728718pgi.154.1565859694046; Thu, 15 Aug 2019 02:01:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565859694; cv=none; d=google.com; s=arc-20160816; b=OKI2KqTIkQ35rAv4pfiNZeoiGmV4JOvOGxJ1W9o2a/Wnf0ylkSs4gItAx5yoh4pGFZ uC766j4LIjMw9mkUJKfLGhs5UecZP2nlvjfD7R5lOl80reHeAiO97c3i0vXoUrPmjSOm AYTWUwdT8bRD+sbFRBD1fxl5hsScnBhUqZI5vL1yhaDDLYr47VDj0+2OfZTrqy7aFS4v O5WHaln7MoeiJKySC2evaKzMhUQkqvzM0ONskkM7eyeoT5v54E+ipK243jaBbOp6BqGI zBmhDxmC5mj6FpMMlugziRSlYf4DcpFDItM3UxXWfn+OzFgs7a96msGMWNeI7MTXJJne tJgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=rdyePxh79O5cxOEfR+t7TLBYxhR+49UWEAWghHr6ZEw=; b=Tmc6Bkh0jgKGRUdq87z5Kooqh6hI9AP2xHgYHDx63S22ujy/AIkQAyfEtadgjgyn0x lQmQ/JjrX4Vhbzp8ulNXut2UN/VORsEmHeRyNYwsUlSnDzlfY58sLjG3TbOuTO0ucHLN yauL8mHTgTqDZ9Md+cA+RnxzU+Ac/YqOpFub+wKmg2A5ndMbg+2ZPLGLdYOkfVEDoVsF oLgz5blXUWwsIXdCmnqhIhdG4v2F6ndUADSitcOPqEmEV9/Q2IXalLZueEIfF0mEEKWZ 4JTMUto1ozZwwGAbz2ZUHSUYIdVuhKNar8Qnw8Ey8/QzdocqbZQeJFh9Nn4wWMox4gar dZcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rVFgaPdx; 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 g5si1559088plt.271.2019.08.15.02.01.33; Thu, 15 Aug 2019 02:01:34 -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=rVFgaPdx; 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 S1730789AbfHOJBd (ORCPT + 3 others); Thu, 15 Aug 2019 05:01:33 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:36272 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730786AbfHOJBd (ORCPT ); Thu, 15 Aug 2019 05:01:33 -0400 Received: by mail-wr1-f67.google.com with SMTP id r3so1598039wrt.3 for ; Thu, 15 Aug 2019 02:01:31 -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; bh=rdyePxh79O5cxOEfR+t7TLBYxhR+49UWEAWghHr6ZEw=; b=rVFgaPdx5jR/vH2Y8Q+hpDquwPjUatdPmd33Q88NnIHRtzOZY/gradDoPlbaaJzJkq Yxwfaw7I0NP3F3a3t37wwcQr6mpHX3xeL+dpakXYILjmRXYhjfPNX0ma/j2Wt+Fc5v1L jaJhYD09MFAtVBwuxByo/AoIgcO7E7PELP8yeziMJDTGRv63aiftpJX+QHdL7XHHPB46 FK5csTBPvtt5hBa3qAV4lm913/SX0RIkQrRLIAWKxH9o+zdtEoRpA0XR2wNI2Hls/qvj MeMKe29BH68imRAF1uPrCqAPGC++jM2gxO2NNolaMvF9vRtbTVhCiPtyguFLUtZ2Ee/x qJSw== 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; bh=rdyePxh79O5cxOEfR+t7TLBYxhR+49UWEAWghHr6ZEw=; b=LGWjDHPZUrjfD45V3PeHot6GJ/+X529cYKHdaJT7dCpIieHYostPHgNLSqtBN0rDNG FcV6RCczdEBZ6bTo5fU96/ofnnhXE4qVxvP2aB7fNcQshM3DBaI9rihEy+hRmiui3OUc FKpiROV9fbyw+Zb9Gvk8VyQxVLI0AOvNcS8DCp4i88LQ6blaac9Ko+kA1RpkE6nNEGkH xyDgDYblspgMDHLF7Ll3x5ZuY2gmvP4KauNh358/zjf1Kt8/2qEJbctrC9fAChQQbsUk pHpMGOH/azA8ppl+M3JmYT/NoPTm8Hn4j2aotT7zOHjCQ2FJWXVpi5D8/iI549JmlvW8 f1AA== X-Gm-Message-State: APjAAAWqNBpJNhYi/AjCWPB3Xjjid6+2eVfWpiPBFVs8QeQFIMmR7jyi UHCRsMM1l7HlfHi6z0OW9rZBIFxfPnkKQsB1 X-Received: by 2002:adf:dc03:: with SMTP id t3mr4127450wri.80.1565859690772; Thu, 15 Aug 2019 02:01:30 -0700 (PDT) Received: from localhost.localdomain ([2a02:587:a407:da00:f1b5:e68c:5f7f:79e7]) by smtp.gmail.com with ESMTPSA id x20sm3857533wrg.10.2019.08.15.02.01.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Aug 2019 02:01:29 -0700 (PDT) From: Ard Biesheuvel To: linux-crypto@vger.kernel.org Cc: herbert@gondor.apana.org.au, Ard Biesheuvel Subject: [PATCH v5 04/30] crypto: atmel/des - switch to new verification routines Date: Thu, 15 Aug 2019 12:00:46 +0300 Message-Id: <20190815090112.9377-5-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190815090112.9377-1-ard.biesheuvel@linaro.org> References: <20190815090112.9377-1-ard.biesheuvel@linaro.org> 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/atmel-tdes.c | 28 +++++--------------- 1 file changed, 7 insertions(+), 21 deletions(-) -- 2.17.1 diff --git a/drivers/crypto/atmel-tdes.c b/drivers/crypto/atmel-tdes.c index 6256883a89ed..1a6c86ae6148 100644 --- a/drivers/crypto/atmel-tdes.c +++ b/drivers/crypto/atmel-tdes.c @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include #include @@ -773,22 +773,12 @@ static void atmel_tdes_dma_cleanup(struct atmel_tdes_dev *dd) static int atmel_des_setkey(struct crypto_ablkcipher *tfm, const u8 *key, unsigned int keylen) { - u32 tmp[DES_EXPKEY_WORDS]; - int err; - struct crypto_tfm *ctfm = crypto_ablkcipher_tfm(tfm); - struct atmel_tdes_ctx *ctx = crypto_ablkcipher_ctx(tfm); + int err; - if (keylen != DES_KEY_SIZE) { - crypto_ablkcipher_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN); - return -EINVAL; - } - - err = des_ekey(tmp, key); - if (err == 0 && (ctfm->crt_flags & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) { - ctfm->crt_flags |= CRYPTO_TFM_RES_WEAK_KEY; - return -EINVAL; - } + err = verify_ablkcipher_des_key(tfm, key); + if (err) + return err; memcpy(ctx->key, key, keylen); ctx->keylen = keylen; @@ -800,15 +790,11 @@ static int atmel_tdes_setkey(struct crypto_ablkcipher *tfm, const u8 *key, unsigned int keylen) { struct atmel_tdes_ctx *ctx = crypto_ablkcipher_ctx(tfm); - u32 flags; int err; - flags = crypto_ablkcipher_get_flags(tfm); - err = __des3_verify_key(&flags, key); - if (unlikely(err)) { - crypto_ablkcipher_set_flags(tfm, flags); + err = verify_ablkcipher_des3_key(tfm, key); + if (err) return err; - } memcpy(ctx->key, key, keylen); ctx->keylen = keylen;