From patchwork Wed Feb 3 14:33:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 375418 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp388988jah; Wed, 3 Feb 2021 06:35:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJwixXUtNxXVC3sEYsRyS8Oyc/EjCVcOiqRihPswDwtTEVhFpm8KiglSSZEVjCpvkP7z6wfb X-Received: by 2002:a17:906:854f:: with SMTP id h15mr3402600ejy.2.1612362921656; Wed, 03 Feb 2021 06:35:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612362921; cv=none; d=google.com; s=arc-20160816; b=L8Xlasc1NTXaEBoq4aYRmDaMoHpElq4wm0FvqgoIeS3g7oRd1MSUzSupMykFj9u5NX p8TnAgVclpicuns9rD33qOA44fpxORXRwoZFkFJov1Lj+53cTQREo4itIDg+8YD7frst X0ijE/LfnYQOIr4SBfEdRX0I90wa4g5N8lRAKYgpsmm3xwnDTkm0cF9kIn3l/TfzGs6r Ly8kuDRLG0PZRN/mYMpRHTFDC/hmcxUZE/gOyWo5heXdYMXOuP/Rjf249XyfXp1WeUOJ SfDUKYxsNaGJOMlKHdr3c2M1jPjobxHdV7ceRZ9gzv2eNrY88qIFJ5z0PHRGx/dtxTCV ExpQ== 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=oCP8Ao4Cl02o2t3IrCglTqQeJMmXZKZ48KKWdaRXvgpeHNlsYeF4fbTiZbq3hiiNq5 NGOoJQIGz0OwQckCmh1El+fIBkUUJTEgRPItSmcTL8Kc+OGt6rDmyK19+wVI5CpI3nBw HtTHR4ezUuI+BQhPBwiy+4thxta9MJSlaRdYYpI3EixFX30buuf918g3nMsMxX6s3pmX fGp3QfgMM/fFc/Gnx6l4Oxs3Nmy7fEt6MjZlU7Jv4q6vBAwKK+14Ogpp2w1SPK3UITSg bM+8f3xoOku3jEobEUA0p3PtFdyJ1Ozah7HkHf2TqJvOW2jXAev6XYnpSKo7fXNwxdCz 3MuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kPOqAcmA; 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 s18si1533688ejd.741.2021.02.03.06.35.21; Wed, 03 Feb 2021 06:35:21 -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=kPOqAcmA; 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 S233017AbhBCOfO (ORCPT + 2 others); Wed, 3 Feb 2021 09:35:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232876AbhBCOec (ORCPT ); Wed, 3 Feb 2021 09:34:32 -0500 Received: from mail-qt1-x82f.google.com (mail-qt1-x82f.google.com [IPv6:2607:f8b0:4864:20::82f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 494A1C061794 for ; Wed, 3 Feb 2021 06:33:14 -0800 (PST) Received: by mail-qt1-x82f.google.com with SMTP id l23so17612508qtq.13 for ; Wed, 03 Feb 2021 06:33:14 -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=kPOqAcmA58UbfVRbvNMjoHECsWtumzrZSpGgU3OVn6nAv7G3Mcwpo0l+v0TDHgHAWq h/3BO0P+bxsfqZkNmnHmGmweFpyD4vjIrWXBtUm7k7AZWH3gqle4hZH7MoFG5pTyunyd al4uvKnxvyQXsFTivJR+zaQLomfR3lHculQ3m+SZ82wQ+/3ByuMFJPmZyteIH8SA7AHy FHd7dsnE3YZt0ujmgRYVqUWrb5wxGhhzhK/QMteP1fmmAXyzpj3HOS4t9SnecMr2eClR u5zFvvjB2wpsidS+sXwejCau6hQUlEB7wv476PurAmJeBu9dFpwkd+6NOElZMQINjU3Y gQ5Q== 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=LRDbUigYUb57bjvRvOBcVMeDp+kgoC8tvjaE3mC695vdPWH8Zcdmra0BE3jQQGo9w5 e6Gtp5DL0s7APkgI1KSFH1HH+YZr7cqWN8bxwddEEPX5kOFnhm0BFHEXUCmWhFt8EXWQ whr7r3NHfyX4AZeh6eOzFRVKbziLUV+IBiz4o2sOTBtLTnzdFQyJYfhuKk0G+tD9CW/h 76+9Vy93kofelGdo1/U+UFAAAwRMYaEnO7Hf2xmpvvTG4rhteASiWDzW6r9nomFTJMES c/Wemx6PJvBmtaUura5zB56GB+fOFAOMPEfkGnvJACKC8tEISl/6A9Wh3Zz+z+ovNxfE Uv3w== X-Gm-Message-State: AOAM532US95fXIoSnpWWdvj6Fbx1pbWXUhxaSIoA5B7hIiPJpUP3TR8A 0vG+2Bzu3+B403PmTyk0UthlrA== X-Received: by 2002:a05:622a:1d4:: with SMTP id t20mr2577064qtw.281.1612362793478; Wed, 03 Feb 2021 06:33:13 -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 v15sm1775433qkv.36.2021.02.03.06.33.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Feb 2021 06:33:12 -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 v4 04/11] crypto: qce: skcipher: Return unsupported if any three keys are same for DES3 algorithms Date: Wed, 3 Feb 2021 09:33:00 -0500 Message-Id: <20210203143307.1351563-5-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210203143307.1351563-1-thara.gopinath@linaro.org> References: <20210203143307.1351563-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;