From patchwork Sun Feb 7 14:39:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 378112 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp3953868jah; Sun, 7 Feb 2021 06:41:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJxByd/QCaup4aESxAydLG34PBMumdLqh5c7OHQ1UEDpDppmwaX53A4gJg6pdAXRRW6w7rKr X-Received: by 2002:a17:906:ad98:: with SMTP id la24mr13003091ejb.315.1612708918158; Sun, 07 Feb 2021 06:41:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612708918; cv=none; d=google.com; s=arc-20160816; b=URWlxhhnieBw52PrJdKF1OXtgBZNnVFNuZmHT20fvz1UyORaiAZQgnatcKww5ZH6Dw EkUrZBVYOwdahoilqjJBB4NfVd3IL5Fx3sE23yg5+1m3QymtMKyid70/ujILJd8/EFxO 5rDG0KeAIKJeaaMX0EP7prkkk1L81sWZFLMXQGbHO/vU28ta7dvaKDJ5ivD7SAKYuq0l c2iaEvD+g+PD+Bc1E8L+rU5ddWFu/0loyCUCjTAH8XXja1G7bQRm1U+mPHzsM60xnRZG RGK0Lv0+qFo2AfOeWJ93H6m1Wz9CmNXkg56Paccl7WST7RKbyUcF+aeuXIalh9IVzYgJ gAhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=JO1AHf4uhYw2ez6Ve3o7chTARaAb1KHfpJckn1suQ+U=; b=iwa/z3gP7wFVD2CaCBpRAL6n5lUUdN15txS8wG12HXiG/7y7Y7+RYJkTZUnwrrip6C zdRLASklze+UWIc/OtyvVCfM70xmMUstOJoim6yi6hAS5axWafQE/2uXztVFnlH4TbZs JISEIURw9bKVoM1hjDUCYoIExXeGdTuJPkGB286ZZKydJLz2U0z063GeJcUO7WZIP678 bqbHTZe62K0/Wa+TijZ3hnGNh8wqbLpKq2slCk6WDNqaMqfstRv7u3SPPZR/iSe87bMr /S3APbJ1L16ymxhZNwvqIIRic2ac4zk6KUptPzI82CKbQ6Qn011V1eGVOothMb0rv03Z eEAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lhxu4kBq; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id g26si9550734edy.55.2021.02.07.06.41.58; Sun, 07 Feb 2021 06:41:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lhxu4kBq; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 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 S229939AbhBGOlP (ORCPT + 2 others); Sun, 7 Feb 2021 09:41:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229815AbhBGOlL (ORCPT ); Sun, 7 Feb 2021 09:41:11 -0500 Received: from mail-qk1-x736.google.com (mail-qk1-x736.google.com [IPv6:2607:f8b0:4864:20::736]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 697D8C061794 for ; Sun, 7 Feb 2021 06:39:52 -0800 (PST) Received: by mail-qk1-x736.google.com with SMTP id o193so2404828qke.11 for ; Sun, 07 Feb 2021 06:39:52 -0800 (PST) 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=JO1AHf4uhYw2ez6Ve3o7chTARaAb1KHfpJckn1suQ+U=; b=lhxu4kBqKdBzeGuBV04S9k+Q7UatH4gOcWyETDNOIumzGqSrnfMDfX/2zGLr4o3YnB CY4JOFt0FUG8W6iCFTHLlPyF7WERXEuusCIixIwpUqGIsb2FjniEjtY+W1kwUz+/9n+k 4RAuVvpb3tkwZBTe3F01MdSqMYo7PEU7bh5Xvo9/kJynW54s5ddAkkjysk4AKB1QyIdC PBHxOV5fTxE1BRfPEirROMf7jSp0Clj3tuma/TFEKVL5TdpSLWSZqQFwjfpIyD2/+Jef yfTk+UtrQEQEYeP97c9YBgKLNJCdfMPdl9N/ztIVnEbH9l28R3uXSCUV8niAHEYyhpd5 eJSg== 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=JO1AHf4uhYw2ez6Ve3o7chTARaAb1KHfpJckn1suQ+U=; b=tv18ab1AnDbQpok9AQh+uTYTRQBY5eNWs+rRL2aqfhvy5YcC5vsPFjtP3+sQcHRtxk xdaaWcSnHL/jXBVj/E4pSF5j9KTnXlRmldJ4pyiGR7catyD9QYzJZ6SVPCD4EkQV8PVZ NBGRCYrU9gvtkhZh9aI4uMzESHDkLh4sZYBzoqOUpZRcCTKGU5LxTa+ko//VoeaHQZYx 9xNQ/Dx5CZEY8PSGOAOTLjyxnklVWD2yJ/WbnDyWnQKqAKg/iM7gs9dMnKb7ywHmKk08 HGG/ER/yPGKvqi020fIgQjqw6KLjKMWJofRXT6HHpf+qMaSdO0eyJHMxAJmROLReeu4v AQ6g== X-Gm-Message-State: AOAM530VHCzzggEVk4qn8kdBPX+NVh0VCuqSMS7E/B129EYKFYqbVIeG BYpPO/qmBUzre9gm71/zCUJjvg== X-Received: by 2002:a05:620a:e03:: with SMTP id y3mr13093718qkm.467.1612708791684; Sun, 07 Feb 2021 06:39:51 -0800 (PST) Received: from pop-os.fios-router.home (pool-71-163-245-5.washdc.fios.verizon.net. [71.163.245.5]) by smtp.googlemail.com with ESMTPSA id c81sm13941493qkb.88.2021.02.07.06.39.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Feb 2021 06:39:51 -0800 (PST) From: Thara Gopinath To: herbert@gondor.apana.org.au, davem@davemloft.net, bjorn.andersson@linaro.org Cc: ebiggers@google.com, ardb@kernel.org, sivaprak@codeaurora.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 04/11] crypto: qce: skcipher: Return unsupported if any three keys are same for DES3 algorithms Date: Sun, 7 Feb 2021 09:39:39 -0500 Message-Id: <20210207143946.2099859-5-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210207143946.2099859-1-thara.gopinath@linaro.org> References: <20210207143946.2099859-1-thara.gopinath@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Return unsupported if any three keys are same for DES3 algorithms since CE does not support this and the operation causes the engine to hang. Signed-off-by: Thara Gopinath --- drivers/crypto/qce/skcipher.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) -- 2.25.1 diff --git a/drivers/crypto/qce/skcipher.c b/drivers/crypto/qce/skcipher.c index 12955dcd53dd..de1f37ed4ee6 100644 --- a/drivers/crypto/qce/skcipher.c +++ b/drivers/crypto/qce/skcipher.c @@ -221,12 +221,27 @@ static int qce_des3_setkey(struct crypto_skcipher *ablk, const u8 *key, unsigned int keylen) { struct qce_cipher_ctx *ctx = crypto_skcipher_ctx(ablk); + u32 _key[6]; int err; err = verify_skcipher_des3_key(ablk, key); if (err) return err; + /* + * The crypto engine does not support any two keys + * being the same for triple des algorithms. The + * verify_skcipher_des3_key does not check for all the + * below conditions. Return -ENOKEY in case any two keys + * are the same. Revisit to see if a fallback cipher + * is needed to handle this condition. + */ + memcpy(_key, key, DES3_EDE_KEY_SIZE); + if (!((_key[0] ^ _key[2]) | (_key[1] ^ _key[3])) | + !((_key[2] ^ _key[4]) | (_key[3] ^ _key[5])) | + !((_key[0] ^ _key[4]) | (_key[1] ^ _key[5]))) + return -ENOKEY; + ctx->enc_keylen = keylen; memcpy(ctx->enc_key, key, keylen); return 0;