From patchwork Thu Aug 15 09:00:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 171415 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1918245ily; Thu, 15 Aug 2019 02:01:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqw5laPzNeASe/EtAwMU7qjp7F5JqP+5FAdtPwkXeGGgwjb6fmFvU10uL39djT7q6/WWNgr+ X-Received: by 2002:a63:2cd4:: with SMTP id s203mr2542426pgs.19.1565859713533; Thu, 15 Aug 2019 02:01:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565859713; cv=none; d=google.com; s=arc-20160816; b=N28WYtF2mngR7YZBHByve+bLBlV3T4Dkitas0O/rhPySo81S1vjc9rh+193qXyi6kk 1QOnqOfHhydy28txJYcpdZkoV9ma0xZRzDd2qMEVFbGNbtdM6t4DN3vrC1IPE3XcsHIF GtADFyYdxgErpzwsKSeLEgcSucTCXWXla8tAAc1NZqrk8vbDpa1mG9PKTbm86mIaIGNu VVLlV2lQQIbnFQWW+r61AscS7S7NFZYIzVGPvlsAgFmyfhtSdAW+qqvQwFkDNx0O/aFb GhfXT2bKpAqSagTAzPOVFa50P4QKQrvWTrwsw7S5nD2vZipTtZMcbEFFZO+Noi9s59ur e7XQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=tzS9LGpq6ZYGPr0TCVhTbC0UKoF/48plVxVUkivfzi8=; b=RLultn7RVf+DI3t+519Vm1vIl40RNstY2jozFF/asNARCANUF+gUX1miWaWmMgCQaA 2q+5ZhpCH+Up4Qq5xmablDCGeO3eDj0p37tmAh9oTspG/d/0PQC7DsCf2Yfrnqoh9YuZ bCqFigbCHk7bae6EiJLyf0MMJvpeRci0psYujSYLLsrdGkcEK7stRK1ooo9UKSLpMlXM rXQcOCYNlSzEoJHHbtjqPjC4dByJrk4AGqzAzBvg14wqakyQx1rEBXMWByvJdtslimCv Qgsz69Me7nJcVAuc/F/PelCDj7P3r1SIAyPj90gNOh0yIAt0CiiBYgLMiu9UuZGXUS05 l4Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xDReowXW; 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 g5si1559088plt.271.2019.08.15.02.01.53; Thu, 15 Aug 2019 02:01:53 -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=xDReowXW; 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 S1730793AbfHOJBw (ORCPT + 3 others); Thu, 15 Aug 2019 05:01:52 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:55958 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726120AbfHOJBw (ORCPT ); Thu, 15 Aug 2019 05:01:52 -0400 Received: by mail-wm1-f68.google.com with SMTP id f72so673500wmf.5 for ; Thu, 15 Aug 2019 02:01: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; bh=tzS9LGpq6ZYGPr0TCVhTbC0UKoF/48plVxVUkivfzi8=; b=xDReowXWvAHMKgAX26p+WjLOlTeUj3+QhLfKzEve2e3YZasi7clWMcSEBNGiT6k41q 1E16c9DmCHlUcrW/m/fvpzxfaFihfJMdrd/hFhuV13/u1gggXpYdZfMNcI1CEvR2O00r 9PAHdS9mBMv74GyivxORGOxGb5hmBHMrnoMpzZRERjZXFGhsqCRd4I0hZDc0dstdLOSl GBpyn2Ah1wsry1EdfAIDHy+yGZ8jAw6W8AN6R3OkplcrfCt3O6eXTFpyTH+UtFuv2QE0 swR5ah5suCeE3Q4wQNcufx5BRyenNaaWHdbLKO6ry9WLOn0KdrcLS99Gr33DmB3dl/4G h5Qg== 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; bh=tzS9LGpq6ZYGPr0TCVhTbC0UKoF/48plVxVUkivfzi8=; b=ns6LLclGaxMGxNrqu9AOi9t8i8bbwtkFpUi+7I1QEsRFRcZgbhOCedcr4n4hNWmqK/ Wz+Yv6s94rdGot89zj54iO2lNUFmL2yuPSY+B4VQh953GLHcv0OYzsrW4n0C9Ufcr2Au xqvv/51dYY7O+QrLMYFzZ/KfBUpvdAJIzc8JFSkkEUVT4v85/qtGxUm3cR5BNQuQ6KFV IvS4bafPfaAsi0HZOnfs0C/hg0QjdEZpiZNw9pX+88mZqVn2W/coOOGW3Rnia7glF13V v6LibUOoqi29AvIAGib3t7yWU3SMjRSr43RZcstpYi8pl3CpUzhpsOQ8SpJO3kkfRnVK NgfA== X-Gm-Message-State: APjAAAU1ibdbi6E6mPcxA7rsWIafpHu3eNTgroW4wEZVgLXSphTGUubg o4OvzlP7aGoiRAeP7Kk7qAJLa8gKD4lBzDpm X-Received: by 2002:a1c:a852:: with SMTP id r79mr1641225wme.36.1565859710358; Thu, 15 Aug 2019 02:01:50 -0700 (PDT) Received: from localhost.localdomain ([2a02:587:a407:da00:f1b5:e68c:5f7f:79e7]) by smtp.gmail.com with ESMTPSA id x20sm3857533wrg.10.2019.08.15.02.01.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Aug 2019 02:01:49 -0700 (PDT) From: Ard Biesheuvel To: linux-crypto@vger.kernel.org Cc: herbert@gondor.apana.org.au, Ard Biesheuvel Subject: [PATCH v5 15/30] crypto: cesa/des - switch to new verification routines Date: Thu, 15 Aug 2019 12:00:57 +0300 Message-Id: <20190815090112.9377-16-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190815090112.9377-1-ard.biesheuvel@linaro.org> References: <20190815090112.9377-1-ard.biesheuvel@linaro.org> 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/marvell/cipher.c | 25 +++++++------------- 1 file changed, 8 insertions(+), 17 deletions(-) -- 2.17.1 diff --git a/drivers/crypto/marvell/cipher.c b/drivers/crypto/marvell/cipher.c index fa1997e70b63..84ceddfee76b 100644 --- a/drivers/crypto/marvell/cipher.c +++ b/drivers/crypto/marvell/cipher.c @@ -10,7 +10,7 @@ */ #include -#include +#include #include "cesa.h" @@ -272,21 +272,12 @@ static int mv_cesa_aes_setkey(struct crypto_skcipher *cipher, const u8 *key, static int mv_cesa_des_setkey(struct crypto_skcipher *cipher, const u8 *key, unsigned int len) { - struct crypto_tfm *tfm = crypto_skcipher_tfm(cipher); - struct mv_cesa_des_ctx *ctx = crypto_tfm_ctx(tfm); - u32 tmp[DES_EXPKEY_WORDS]; - int ret; - - if (len != DES_KEY_SIZE) { - crypto_skcipher_set_flags(cipher, CRYPTO_TFM_RES_BAD_KEY_LEN); - return -EINVAL; - } + struct mv_cesa_des_ctx *ctx = crypto_skcipher_ctx(cipher); + int err; - ret = des_ekey(tmp, key); - if (!ret && (tfm->crt_flags & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) { - tfm->crt_flags |= CRYPTO_TFM_RES_WEAK_KEY; - return -EINVAL; - } + err = verify_skcipher_des_key(cipher, key); + if (err) + return err; memcpy(ctx->key, key, DES_KEY_SIZE); @@ -299,8 +290,8 @@ static int mv_cesa_des3_ede_setkey(struct crypto_skcipher *cipher, struct mv_cesa_des_ctx *ctx = crypto_skcipher_ctx(cipher); int err; - err = des3_verify_key(cipher, key); - if (unlikely(err)) + err = verify_skcipher_des3_key(cipher, key); + if (err) return err; memcpy(ctx->key, key, DES3_EDE_KEY_SIZE);