From patchwork Thu Jun 27 12:03:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 167951 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2249856ilk; Thu, 27 Jun 2019 05:03:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqwIlIN8uSg6XLOS32UFDkD4xY6lSIuCLHxxSmToX79ynI33SeOD31/r0N+Z0W6YpYaIsl5J X-Received: by 2002:a65:6401:: with SMTP id a1mr64568pgv.42.1561637034050; Thu, 27 Jun 2019 05:03:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561637034; cv=none; d=google.com; s=arc-20160816; b=As19v2TegEXaAtr6ahqTfgzHJ2brNJTG5W3qsAdeABprb5xPgclD+5qj92H6BfX2xW lAvXOzMvo150sVD2ftfITaaV1jbYaAlfr3nXfG4i5hOvZcoRQv8nbtld1eZsfOouu8rL I6/awxAAQO58HfiFsbSS2lhBwRNrU0QQxmR2wAeR06G/eqW/10EsWrJB4Bzn5NHGTKY+ 8zMz4BR5hH5HujKT45q6ERWlCyPFtF61cAhfK7qejDr3liwWftTsTww906FL8vH9A4RX g3mfM22OCNAFkz8dexfBkA3tMde2W2djJCoia4xKZ/d8nvhRRA6tJ/DUiQlXNU9D0FVt riYw== 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=T/RYEPQWF2x5irsNjj88sVD+R/k06WJQGdA2A6mcj7A=; b=1LWQFT7O3TDiB29OUqUPHoXuPKnRIQ+fR6KD7XwIObIf84pTu3IwV/bYBSj7RniJrD p+d2KCB2cQ+mTmu6n/ChTaq++95JNT2k73Hl84+kwx29bkYEeu6ghsTDJbx9pSp78WMk uTHF1cQ4DcyQStNMLoLXGMXVjz+NIz943XQOFD7AfccilmENQNY7vY99PIbOd1hVY/6t PCdaUSqDpLFwc0MkA68E3V26PJamCYB5uQcrQ9oaOuh/QhT54fgRsLKtZtuvF/hZhoaF eKUGRcx9bezdy4bVJ+2Ng/ztYZYTiJhNVrmtIbEecPjXmTIjM6ZczxBwwXRPSyuST6uR r6qA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KdfJVun+; 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 100si2163460pla.158.2019.06.27.05.03.53; Thu, 27 Jun 2019 05:03:54 -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=KdfJVun+; 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 S1726816AbfF0MDw (ORCPT + 3 others); Thu, 27 Jun 2019 08:03:52 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:42826 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726867AbfF0MDw (ORCPT ); Thu, 27 Jun 2019 08:03:52 -0400 Received: by mail-wr1-f67.google.com with SMTP id x17so2242081wrl.9 for ; Thu, 27 Jun 2019 05:03:51 -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=T/RYEPQWF2x5irsNjj88sVD+R/k06WJQGdA2A6mcj7A=; b=KdfJVun+quBw9qR4nnbl3wKtXzuyxIXQwcGvKS41w51CnAbrVpOafWkopLjSzh/Vfr U2aohhPdP605iXjBgOH9ufQpojNiTHQ1ITv4JUqnRek1pq+FOosn2EUkojqan9Yvfr2a WUmGy3zl1iosLZIv13192esmORPRPdx6ua2AigC7mYu1yZUOm1Yl6wuY1LoIJszO7e/9 7OjTdeUZhoFeEyESJYNCKSzyRoUGkgbYpNpPvuRbuvj5vh/7yaEMzGTE4ZkHwJO/mG+C 8xCQpmZv2wS78ynWlEVVcmm27DcsUQRHcjaY/zxjOPglYROh7hpUj17SCjQlPqxe2DuS Mfqw== 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=T/RYEPQWF2x5irsNjj88sVD+R/k06WJQGdA2A6mcj7A=; b=PEuIrRg15Y00NtsS80ikXVNv95h85s05zqym3eCm74TfdgdTkx2KjY/jR6HxJaURgQ IASzvtYvkwKPDA5rkzZBwFDpgDKDfM8zhAC5Xot3up2zYgDtqlYUlPnsqDM4a1S/sS8Q 4Vkasa28i5AycFC5dADt+CiAssj+eQEwha+cWSp8ydezReEsrmWW43/KUZR6njWiFqBq kH8v7rXikhDnhEeBU3sB96/Q2xkF7JbIAyJRT/kox0gNh6X1r80G42Fm01Yc7OAYEBOe lkYW60dyc6WXHU6kFxoR2AydZx6jCSVqBSVlajjHshMhMSta7GdvHdtNx29tBIgk5O6V RJuA== X-Gm-Message-State: APjAAAWvmnwPpOkopez4J/jJgTjIhJDrXsJevgX29AJ0c6gfDRczXZG8 dSi4yHw16JxXQsplUBVjrukwjo02cx0HWw== X-Received: by 2002:adf:f649:: with SMTP id x9mr2787180wrp.86.1561637030056; Thu, 27 Jun 2019 05:03:50 -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.49 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 27 Jun 2019 05:03:49 -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 22/30] crypto: sun4i/des - switch to new verification routines Date: Thu, 27 Jun 2019 14:03:06 +0200 Message-Id: <20190627120314.7197-23-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/sunxi-ss/sun4i-ss-cipher.c | 22 ++++---------------- drivers/crypto/sunxi-ss/sun4i-ss.h | 2 +- 2 files changed, 5 insertions(+), 19 deletions(-) -- 2.20.1 diff --git a/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c b/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c index b060a0810934..93b383654af0 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); - - 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 (unlikely(err)) + return err; op->keylen = keylen; memcpy(op->key, key, keylen); @@ -569,7 +555,7 @@ 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); + err = crypto_des3_ede_verify_key(crypto_skcipher_tfm(tfm), key); if (unlikely(err)) return err; 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