Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp3086704ybd; Fri, 28 Jun 2019 02:36:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqw7B2ftxpjPq8iGBuzBumVKjRTSGZTMF9F+hAIBDLGkQHeSjAEqeld2nOdMvtadJEQT3Apl X-Received: by 2002:a63:6883:: with SMTP id d125mr8465094pgc.281.1561714616822; Fri, 28 Jun 2019 02:36:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561714616; cv=none; d=google.com; s=arc-20160816; b=qGUqa0JoP0ZmZmvH870eqcjm1jwxN+LQRQKLI5OJx8ssphMwyfh3WJPmQAvG2NSjpK va/3YZUZ4GwphWC/3quswI3yLHDDdhT1Coo2HhwXJTPty4GtGQ9BhwhI0cB6ReuLUkh4 vvA4WZSJqGoXfEJJ2z5rMvegViqXWn+1QJYTJ8wzOjPYSoi09k/Y35YtX+s3pTo6hBpW L7801mVNfDnlwEKr2njj+1Jm6I8JRzuf+Ni1moPCeb3ryatFbyNjgH//MRSyLVVYIAV5 GDy1uPFwuSHJNBL43MEClInwED4KGMHE0TB18kq7P9Paarmr3yt4fHrJhwRpWZcZy5Q1 Wu1A== 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=UJ/qjCXMkjgSxlng7j9T2B4eqrY2mnAGmeyjbF9pJ4k=; b=n9xkPItyHtfkanGXAXGnrtZ46hQTnXSOm9SoxQFARJAyvaJxV1HmWbWeIUuZMcrWMh UkprNKPyCzY0t4g3MGe9tiLFGOMsSflvYXsJwbWDhYBy71G/A6NMdv9ras3VtgHCZWzD 5u45Qf1wu1uopjUqJK0ev2Bv0/x6kPDcxL4tyYJGOKLKNel4A82UnZe9FzNqFM3UunUU zXvkJ2ZTn2++//z/njozkw4WoHDqqu+qOnExYt876AMOCfBcxJEGK/k5nL5reFlQelXZ hYGwF6RCfGfUWTX6fwWNeaZJeSBwqgJto6cCOZ+PLNCGbzjd0WeFoZG31W68rzT8zLLm oHZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=A9K4xomB; 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 d37si1635672plb.351.2019.06.28.02.36.43; Fri, 28 Jun 2019 02:36:56 -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=A9K4xomB; 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 S1726707AbfF1JgF (ORCPT + 99 others); Fri, 28 Jun 2019 05:36:05 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:35049 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726596AbfF1JgF (ORCPT ); Fri, 28 Jun 2019 05:36:05 -0400 Received: by mail-wr1-f66.google.com with SMTP id f15so5565462wrp.2 for ; Fri, 28 Jun 2019 02:36: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=UJ/qjCXMkjgSxlng7j9T2B4eqrY2mnAGmeyjbF9pJ4k=; b=A9K4xomBg+iTOR/Eq5qF7qW4h9XqJZ3hJ5BM4s4KOsGYaTrEDi+pRLenn+4aFcAAm/ UE744VQAGd4JU3xKoI0oHNL6/fI1mvzTrSdLUiRWlk++FxUN4nLRRP51o3XBu73AsIk4 juaPMakKepZsbyf2gPje2JzVHMiISNDH4jc2cWcjeF4NN7fDLVScOGudzDF2UWeBNQ5L bMg8YjSkrcZrS+OUsXoAqI+EcKvyDwW0dECtH968o1RYZtaaA9aT2WSjyQUraEBfSosL 0loWSiSFVseNOcMyZq6wWbQpDFGICV+chUejx1BKX+bMu2HPo/w1/9pDw26rwPuLCpw5 enfw== 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=UJ/qjCXMkjgSxlng7j9T2B4eqrY2mnAGmeyjbF9pJ4k=; b=qj1wflr3+plehkd+0Gq+cLSLorP5NhKaFDVQx7JmeXPdNwSKLiS3qH6KO2Z3a2WNyp 5J0bEOD+wG+6klsC5wJf0VdBTbUmGaD7Tec8dh9m3G1KH2DX04ng6sxcBhsAoEUXwRYy I3yxYa8JMptWHG0k9MhOEnjBcWe4WVidBNNzcj3jbtYEqnghZc1Rma4VPKsYbVEXseLH SdtFn7i5LTGfhCdCuUHTdYHUF3IZroxkBYrtdaMOwkUuiaLrKLbZma2rburUwtID8DP0 gIuj9vYWiu6Ts7PKZnW4q3cCHXcE2ScSTI0JWGKtoiwCmTrFrSokd4A2QD6sXd6TqvQP vKiQ== X-Gm-Message-State: APjAAAVve2uSlOd01vkIvn/dUzevfc+vK0xXzxWh6gv5N9QqBeSnGRKk qwxmA3M1cFjlOlAsNSLoT4f1sJKtBSxv5Q== X-Received: by 2002:adf:dec3:: with SMTP id i3mr7056107wrn.74.1561714563008; Fri, 28 Jun 2019 02:36:03 -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.02 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 28 Jun 2019 02:36:02 -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 23/30] crypto: talitos/des - switch to new verification routines Date: Fri, 28 Jun 2019 11:35:22 +0200 Message-Id: <20190628093529.12281-24-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/talitos.c | 34 ++++---------------- 1 file changed, 7 insertions(+), 27 deletions(-) diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c index c865f5d5eaba..3ad97e42fafb 100644 --- a/drivers/crypto/talitos.c +++ b/drivers/crypto/talitos.c @@ -30,7 +30,7 @@ #include #include -#include +#include #include #include #include @@ -923,12 +923,9 @@ static int aead_des3_setkey(struct crypto_aead *authenc, if (keys.enckeylen != DES3_EDE_KEY_SIZE) goto badkey; - flags = crypto_aead_get_flags(authenc); - err = __des3_verify_key(&flags, keys.enckey); - if (unlikely(err)) { - crypto_aead_set_flags(authenc, flags); + err = crypto_des3_ede_verify_key(crypto_aead_tfm(authenc), keys.enckey); + if (err) goto out; - } if (ctx->keylen) dma_unmap_single(dev, ctx->dma_key, ctx->keylen, DMA_TO_DEVICE); @@ -1538,32 +1535,15 @@ static int ablkcipher_setkey(struct crypto_ablkcipher *cipher, static int ablkcipher_des_setkey(struct crypto_ablkcipher *cipher, const u8 *key, unsigned int keylen) { - u32 tmp[DES_EXPKEY_WORDS]; - - if (unlikely(crypto_ablkcipher_get_flags(cipher) & - CRYPTO_TFM_REQ_FORBID_WEAK_KEYS) && - !des_ekey(tmp, key)) { - crypto_ablkcipher_set_flags(cipher, CRYPTO_TFM_RES_WEAK_KEY); - return -EINVAL; - } - - return ablkcipher_setkey(cipher, key, keylen); + return crypto_des_verify_key(crypto_ablkcipher_tfm(cipher), key) ?: + ablkcipher_setkey(cipher, key, keylen); } static int ablkcipher_des3_setkey(struct crypto_ablkcipher *cipher, const u8 *key, unsigned int keylen) { - u32 flags; - int err; - - flags = crypto_ablkcipher_get_flags(cipher); - err = __des3_verify_key(&flags, key); - if (unlikely(err)) { - crypto_ablkcipher_set_flags(cipher, flags); - return err; - } - - return ablkcipher_setkey(cipher, key, keylen); + return crypto_des3_ede_verify_key(crypto_ablkcipher_tfm(cipher), key) ?: + ablkcipher_setkey(cipher, key, keylen); } static int ablkcipher_aes_setkey(struct crypto_ablkcipher *cipher, -- 2.20.1