Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp3086277ybd; Fri, 28 Jun 2019 02:36:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqwlTQVgHi6wBZuFnjw7+Rv274bZsMn0gkjhvml/qa6dO4SRGacUf1nlAdCuH/U1Ezh9L4w3 X-Received: by 2002:a17:902:8490:: with SMTP id c16mr10638026plo.1.1561714588955; Fri, 28 Jun 2019 02:36:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561714588; cv=none; d=google.com; s=arc-20160816; b=0yW1zthFCQhtZiDMB2BUyWOuQBb9LyHzJ+tDUJvDcu3kbZyzSJdiYNoNtS3yZO0W0U 12XEGxa456dbp5XGIt1bOsbG0lLHPxNpLsu5ok1WTKthcn6h95ysKzpIbfHHSDWXz2bz XySEKBBpMIyYyIdVcW8sftdFdE0DEykxO/OgeViBXUu1PH3Uv6CNRe0ITEZgTmMrkYXN kYOHRfX26HFcxeXBcbn3Xm0sPyuwdByw/h3U80m4UKCaX93rofYQYYttGlIG23bCBGec CNbcNjh+8oAG2XU2rJ9NMJnZpboosGEnL98d+K5TmUAJqk1ObilqxksAz0k0CPvt/Jph WLlQ== 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=4e2vCsDLC/D+HtFHHDcivLxV8v5dwxrs/R/yXpuJqQM=; b=RmWa0byI8dJAenTwVxW5HCs1sMvSYv81D9aF6Jpg57dl6X9CcdGQ5l6fajUf8MCJSF dCPB2Wy8KJ0OHjOqbpgHJv895E5mIHAlrTWl8sXx0FF8rvE353rHSqzWI/XCV554fJoG FLOfYHVtFx+QX6reeaJYouwlsa0wzeyOy9anyOW6kB+1fWBUbSJUgiAyt/caBD9pfSCe u1U48e696WGpveVjQWpQD+SxGkxahHOficXFpDnVFlNDfrU30gOvyN0PQZHBtB+hmFfu kbAVuI8iMWpQ5gpUkkMNehRu5leR5P7kB0lStP0gmKa4DuUsJcmlAo5ya3F5w0N6K9xG kZyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zsRlaaMn; 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 g6si1670878plm.94.2019.06.28.02.36.14; Fri, 28 Jun 2019 02:36:28 -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=zsRlaaMn; 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 S1726708AbfF1Jf6 (ORCPT + 99 others); Fri, 28 Jun 2019 05:35:58 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:34551 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726702AbfF1Jf6 (ORCPT ); Fri, 28 Jun 2019 05:35:58 -0400 Received: by mail-wm1-f65.google.com with SMTP id w9so8925610wmd.1 for ; Fri, 28 Jun 2019 02:35:56 -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=4e2vCsDLC/D+HtFHHDcivLxV8v5dwxrs/R/yXpuJqQM=; b=zsRlaaMn8QpdkCWBEuPLhk91f/IG1UyceM1ZPzL8dPCR81LoV/UJ3YAm8vvgVlk/2g rppWPjoq1L2lXsvvU9rENpkvFap4FryBD2E1R0MyPgFIe+hFXu4R3zQ1b0LIQI/9Xw/E 8Gww3qh3f1v0KcHL+aR5epYfBuAO6hZd8ixwvvXMkcL/tgW9Ivk7HSs/PD2Cu8vQyWBA VSS2/Otkg7TXrOkMbRznuUxeMz9d9RazzpMSBuCIv0WBRGHsXXyU0dJzqO6MaxpVUGlv LgmYMun6Vt3XwhLXBqycdNw7JCnuuPkGMIV3ERbWn1Ej3L43H8Gd7lc9o7DfyiCThWj+ pq2w== 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=4e2vCsDLC/D+HtFHHDcivLxV8v5dwxrs/R/yXpuJqQM=; b=hl3VPMYmpEkiFgcVjR9dKjRZfgKnvebcTjaEERS10El1mRGzkm1pJEz8ELC9Me67DW qJId/hkPHNYUvTX/ut9lbp3e3S35PEzwOPf2+ZslD58/+2rRGObfQUuT7QmvPPXFgtXJ pNPQfybXAyw9dxkdZwbN0gxnRanJEDMWis6UGZDfyrGcByLfmUL3ig1R3TV//XgNmaBe ndebzFYf0HfHBsetom+/Kbe3as8LjfEguR+W+FE0kmWi1E1aYCXFsLCT6NSeFz26pr7S kTH42lpJSykEM5d1NuaDLLs0biWQAPNoSmTRUR8Ri8TO2xhVB0FSSibkKH1JK1pLdi2F lvXA== X-Gm-Message-State: APjAAAUvnoLYzwGOfgDtjFqibtZE/2oNYW0+ZxE84x4BCU1RQi4V7Aic 1gd9EEfEWIgwnrZBixEtEAHueuifHqdUrQ== X-Received: by 2002:a1c:c706:: with SMTP id x6mr6466496wmf.162.1561714555772; Fri, 28 Jun 2019 02:35:55 -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.35.54 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 28 Jun 2019 02:35:55 -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 16/30] crypto: n2/des - switch to new verification routines Date: Fri, 28 Jun 2019 11:35:15 +0200 Message-Id: <20190628093529.12281-17-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/n2_core.c | 26 ++++++-------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/drivers/crypto/n2_core.c b/drivers/crypto/n2_core.c index 0d5d3d8eb680..de48512d054c 100644 --- a/drivers/crypto/n2_core.c +++ b/drivers/crypto/n2_core.c @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include #include @@ -759,21 +759,13 @@ static int n2_des_setkey(struct crypto_ablkcipher *cipher, const u8 *key, struct crypto_tfm *tfm = crypto_ablkcipher_tfm(cipher); struct n2_cipher_context *ctx = crypto_tfm_ctx(tfm); struct n2_cipher_alg *n2alg = n2_cipher_alg(tfm); - u32 tmp[DES_EXPKEY_WORDS]; int err; - ctx->enc_type = n2alg->enc_type; - - if (keylen != DES_KEY_SIZE) { - crypto_ablkcipher_set_flags(cipher, CRYPTO_TFM_RES_BAD_KEY_LEN); - return -EINVAL; - } + err = crypto_des_verify_key(tfm, key); + if (err) + return err; - err = des_ekey(tmp, key); - if (err == 0 && (tfm->crt_flags & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) { - tfm->crt_flags |= CRYPTO_TFM_RES_WEAK_KEY; - return -EINVAL; - } + ctx->enc_type = n2alg->enc_type; ctx->key_len = keylen; memcpy(ctx->key.des, key, keylen); @@ -786,15 +778,11 @@ static int n2_3des_setkey(struct crypto_ablkcipher *cipher, const u8 *key, struct crypto_tfm *tfm = crypto_ablkcipher_tfm(cipher); struct n2_cipher_context *ctx = crypto_tfm_ctx(tfm); struct n2_cipher_alg *n2alg = n2_cipher_alg(tfm); - 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); + err = crypto_des3_ede_verify_key(tfm, key); + if (err) return err; - } ctx->enc_type = n2alg->enc_type; -- 2.20.1