Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp3087127ybd; Fri, 28 Jun 2019 02:37:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqz43n2c/Zp9ATIvaR5FcE7/lQdJxAC7wEj0x9kDAraQvWxKcWwhrTMmsy8RT0bv+vy5Ds1W X-Received: by 2002:a63:6a49:: with SMTP id f70mr8196150pgc.55.1561714643702; Fri, 28 Jun 2019 02:37:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561714643; cv=none; d=google.com; s=arc-20160816; b=ZpADfTUbU69NNHm68HAzBVOwuKI2oBO9Ycno6nWDxn0h2yaJYIacJOerF0u+FnWXD5 dAu34QVKHwM+hK7e8FrMGpl0PXtF1N+6GVxDNyEhRhkvruaDwXtY6jy6dn/xz91t0kmz OYiJeMJrayaVaGoGTwcnl675UVlz1wwWyCXOBt0nM6Pu4qp7E/+HWo07xxaAkGt359Yp rHF6gBRH5WffD+8s37wSRh4xH3cfsMYzgQQl406jyYnWGv6DeJUv8e5UclEj7HG5IhjE 4hVSnSjJAJ6RrMYQKjINWSQjP2BQDkQZ48XaE3+m0hUS/QNUVgD5qSTke/QEw9IL+Ya9 gyYQ== 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=rVlh1Yczl6sEDbe95/BJ5uyaoNfIyJkGyJuhu4iyLn8=; b=Xh3oDjtXTvFx7Aio6Wqc8m9nvKk32JwTGA9Djti5v+mC6gnmh3Ra0W1ICq799SDASe uBdIJTQ0d2tGsXoaIYKC1ewQ8zauUbqhw4k/C629aEaD83MQ6pbeXcl/NIC57feDLaie fV8khmtsYBqgwDqnw0BSOFNG7ScMZrnR1PaBOWpL2/tynHMPVxaptLDmXRG3RyLQYrz5 s0d3ODp8aJUUmQSpFv9LTwVQ1jA4ChiEgSoua81sT8aBmzJsRwem9UlWll89zWCGE+r4 EjhS26bxmZomWlRdfROlq3kNlyZU86NmN3jgnbCTEZnbhI/QdKTfuhn2Ns6G0zFUgI/1 aKzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LEoOcOlV; 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 g8si1678852plt.273.2019.06.28.02.37.10; Fri, 28 Jun 2019 02:37:23 -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=LEoOcOlV; 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 S1726706AbfF1JgF (ORCPT + 99 others); Fri, 28 Jun 2019 05:36:05 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:53618 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726707AbfF1JgE (ORCPT ); Fri, 28 Jun 2019 05:36:04 -0400 Received: by mail-wm1-f67.google.com with SMTP id x15so8414954wmj.3 for ; Fri, 28 Jun 2019 02:36:02 -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=rVlh1Yczl6sEDbe95/BJ5uyaoNfIyJkGyJuhu4iyLn8=; b=LEoOcOlV3MBIF5uJSvChY6dqUdWsQ2mTxr/mCy7kEUfroHNmwHpI8Z+TXC3QqNCFtI ZnUoqIOanuaJVV95EZAMi+obJzNe838yU5c9wF+dVmzJq6c1y9QZA+/Mz3DBydxf68zN k16Ch/qNAoLxjQkWrGP+IoKWEMrN6sfcLa5zbfobGm30VF3L8pin+y6YXqb7GQSVKvG6 +2YeacTP6P/OEk7u44SDrCfo815IB5RLVgujd+eHsx1E19aG03sECCpe962skvDq7AS9 2Rpxdc/Eg8mK5kKTvhZU736uCytrZb7XR/9QgXzSwOkmKbdETL/8K8ZwhktC1FsLv1OC rPIA== 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=rVlh1Yczl6sEDbe95/BJ5uyaoNfIyJkGyJuhu4iyLn8=; b=JTPkgYc4Er+3O60LRLzBfPmOBKHZs/yrX6IPg0QyIIq/s2fABePQU5pejaSdIMAtPw scP6/owj5/idnCDYXjKEC29dzPMMf2HGEPUR+JeNsEvKo5bpjPpIAV3GKNiAbwcmaC9F 8YS9VQfZZiYsYYofU5awyBh11XMKNibNgqFxFo9rkgyokPVpvYCMXPGWhy55aSnp+tHG dHQY6C2hnX2mpKYg/6dX8u12BuE2osbuYZCgi4qlgoH4EVsCE8e0X4Jdc13Y8bQ1E2HL nVFgH/4ZakXO5uMrFSrkSFxJFkkdcT82zIQN+aIZTkbrNhUQJJ44EJY8gDTSQTJQxFgY F0tA== X-Gm-Message-State: APjAAAVY0gLLw2t46Ob+JLR2E7B5EPgPzsG2rjlSDRWhE+w+ZNF2bbuj 7cZ6av846wm8CHlycUrYmYeUpvQgK0nhcQ== X-Received: by 2002:a7b:ce8a:: with SMTP id q10mr6140646wmj.109.1561714562029; Fri, 28 Jun 2019 02:36:02 -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 m24sm1709910wmi.39.2019.06.28.02.36.01 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 28 Jun 2019 02:36:01 -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 v3 22/30] crypto: sun4i/des - switch to new verification routines Date: Fri, 28 Jun 2019 11:35:21 +0200 Message-Id: <20190628093529.12281-23-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190628093529.12281-1-ard.biesheuvel@linaro.org> References: <20190628093529.12281-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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/sunxi-ss/sun4i-ss-cipher.c | 26 +++++--------------- drivers/crypto/sunxi-ss/sun4i-ss.h | 2 +- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c b/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c index b060a0810934..a1942850913e 100644 --- a/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c +++ b/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c @@ -533,25 +533,11 @@ int sun4i_ss_des_setkey(struct crypto_skcipher *tfm, const u8 *key, unsigned int keylen) { struct sun4i_tfm_ctx *op = crypto_skcipher_ctx(tfm); - struct sun4i_ss_ctx *ss = op->ss; - u32 flags; - u32 tmp[DES_EXPKEY_WORDS]; - int ret; - - if (unlikely(keylen != DES_KEY_SIZE)) { - dev_err(ss->dev, "Invalid keylen %u\n", keylen); - crypto_skcipher_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN); - return -EINVAL; - } - - flags = crypto_skcipher_get_flags(tfm); + int err; - ret = des_ekey(tmp, key); - if (unlikely(!ret) && (flags & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) { - crypto_skcipher_set_flags(tfm, CRYPTO_TFM_RES_WEAK_KEY); - dev_dbg(ss->dev, "Weak key %u\n", keylen); - return -EINVAL; - } + err = crypto_des_verify_key(crypto_skcipher_tfm(tfm), key); + if (err) + return err; op->keylen = keylen; memcpy(op->key, key, keylen); @@ -569,8 +555,8 @@ int sun4i_ss_des3_setkey(struct crypto_skcipher *tfm, const u8 *key, struct sun4i_tfm_ctx *op = crypto_skcipher_ctx(tfm); int err; - err = des3_verify_key(tfm, key); - if (unlikely(err)) + err = crypto_des3_ede_verify_key(crypto_skcipher_tfm(tfm), key); + if (err) return err; op->keylen = keylen; diff --git a/drivers/crypto/sunxi-ss/sun4i-ss.h b/drivers/crypto/sunxi-ss/sun4i-ss.h index 8c4ec9e93565..3c62624d8faa 100644 --- a/drivers/crypto/sunxi-ss/sun4i-ss.h +++ b/drivers/crypto/sunxi-ss/sun4i-ss.h @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include -- 2.20.1