Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp2985322ybh; Mon, 5 Aug 2019 10:02:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqwXxH5xOSJJox/yR5DyhZgKO0QJgDB/Ys/s0BPFrhXRo7Vvu1J9guP2lsCjZpBEoYrIRyMz X-Received: by 2002:a17:902:2983:: with SMTP id h3mr146473546plb.45.1565024579214; Mon, 05 Aug 2019 10:02:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565024579; cv=none; d=google.com; s=arc-20160816; b=sPIQVMB29TW6z0MWDA12WeHSRjA3Kzuc4elQSlQ2V1BammpkJhvW01ZffrGRzKcOXN 1bVdG2uZNfL7koBHuds8De22WKuHvFdz1Gydlp5pbObFDhkYd4ZOom4G8jAsH8owBoLR zyarTLSV7UwhvQoh2ey/pxuj1kEIHuTPtWDBkpLwaC0Yn30Z3j6JX3FNCXFl1vHemRG6 gQkq71N+hSdMbb75sMIlqC0FA28ykNFjUPCZyUfinlbkcBkYABp5kCxrR3sPke7/pqtm UFBoSm9muO/mit744YiYdsIePglQ/b8ZIpOGXK72YxFAzrrGO2SZmc1McdST/DAu3LTc vtJg== 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=W3vNwIhXLNgACliJVrtBW/D/smBMFzEqLx93l3SRBW8=; b=NFZJqoPmAvxrxZAwHxgSL0wkQAq3PLJ/XEHgBSEREkl730qEBUKm++/fMY5gGk5zxT pVuF1dG9r6EjCqJeyDl9i9tkZtlxd8ONhmW7DE9SbZGkzR88+OS74OZCADSxa1mee0IL ELNH5QlEtaiyV4K3j/8kFhS6Jn+BgcgoiGgxYHTmVbpM8D5/cP49SS5Ez2Y1z9Lf6tOM RRVr8s7RlcvDl8eLDIlfaSXcl5w72KS/AI6m6ytUYRPc7k+hA1sdRT7/my6AzuRpZsvS g+Va8F2cfyQgyEGutOg5uB3A4eNtTI8SGu9WuUWeuuq9B7O7BO4JobylQPFNPGY4RKdE IZGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LENfMPKn; 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 i4si7055678pgq.219.2019.08.05.10.02.46; Mon, 05 Aug 2019 10:02:59 -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=LENfMPKn; 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 S1729816AbfHERCC (ORCPT + 99 others); Mon, 5 Aug 2019 13:02:02 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:38295 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729780AbfHERCC (ORCPT ); Mon, 5 Aug 2019 13:02:02 -0400 Received: by mail-wr1-f68.google.com with SMTP id g17so85137151wrr.5 for ; Mon, 05 Aug 2019 10:02:01 -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=W3vNwIhXLNgACliJVrtBW/D/smBMFzEqLx93l3SRBW8=; b=LENfMPKnLiGaYd4uovNDK8IU6dHZqoS1OXh9EqeQDSFX2BozB0USGjFjVeohaxgP0y 664koh/5D5iIESznW2xnaAEBPJ05O7M6C3XLZFfMG2VeWE4lXfnkwLFegdhU0xTATdrx TzKZOpanLBQcc33HZpVZetTCws1KsQ/FE4MV2nJNSlFs4I8gArIJARMNj8O8jnFaF5L8 n2SUwzk5eokZEfzo8kOcA9RbsqVOXP+tfzktJXZ6yUn/+8yyDXWTUYPBQB9VqSQ919bm VGzT1d7irRZLjVdAO+gxYslWjA+k+PLJRvf36WA4aGq77m8vzbz51P0lLLWjeR6nUzQj ymcQ== 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=W3vNwIhXLNgACliJVrtBW/D/smBMFzEqLx93l3SRBW8=; b=EpNMo2+nVY0AH5FN2Ztgi4Zz+i0KDPb9k88N8A9SKFCuYj2nWx13XyP7M39zqHTWus O1zN1uZjJgd2kEkECdj+zg8ywxTf7glesJvdB8v91qFU+EFnVE827wuxUkDVva3vLXbU aC1QyxWGrwYr3IVsTwe1H0IYz88jtu+MLLv6clXgHNDN8gVIvfHQFNs1Pt+M/xQxPNOT 0iJsXx6yZEosNHlJLdznj1U+DVCY9oa+D+wmYZTzfqcuzmxwMMVvxt8t0W68UeCLYxuq CmFtAsIYNRngwcabN8oQnefnXF1FMPR/d29qV3MX+IbQoKJxvxqw0FKs7dj3Jy4Jfaqq lx7A== X-Gm-Message-State: APjAAAVo+Hy1uSHbVN67HctE7S6U/vito0sDAGI70VlwhQ2m2tuksfLB qinCBbTY9lHgBR+onnaFMSuqIk6Snxc+Ww== X-Received: by 2002:a05:6000:42:: with SMTP id k2mr41127827wrx.80.1565024520249; Mon, 05 Aug 2019 10:02:00 -0700 (PDT) Received: from localhost.localdomain ([2a02:587:a407:da00:582f:8334:9cd9:7241]) by smtp.gmail.com with ESMTPSA id j9sm95669383wrn.81.2019.08.05.10.01.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Aug 2019 10:01:59 -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 v4 18/30] crypto: picoxcell/des - switch to new verification routines Date: Mon, 5 Aug 2019 20:00:25 +0300 Message-Id: <20190805170037.31330-19-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190805170037.31330-1-ard.biesheuvel@linaro.org> References: <20190805170037.31330-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/picoxcell_crypto.c | 21 +++++++------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/drivers/crypto/picoxcell_crypto.c b/drivers/crypto/picoxcell_crypto.c index b985cb85c9bc..c43c0b183f02 100644 --- a/drivers/crypto/picoxcell_crypto.c +++ b/drivers/crypto/picoxcell_crypto.c @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include #include @@ -738,14 +738,11 @@ static int spacc_des_setkey(struct crypto_ablkcipher *cipher, const u8 *key, { struct crypto_tfm *tfm = crypto_ablkcipher_tfm(cipher); struct spacc_ablk_ctx *ctx = crypto_tfm_ctx(tfm); - u32 tmp[DES_EXPKEY_WORDS]; + int err; - if (unlikely(!des_ekey(tmp, key)) && - (crypto_ablkcipher_get_flags(cipher) & - CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) { - tfm->crt_flags |= CRYPTO_TFM_RES_WEAK_KEY; - return -EINVAL; - } + err = crypto_des_verify_key(tfm, key); + if (err) + return err; memcpy(ctx->key, key, len); ctx->key_len = len; @@ -761,15 +758,11 @@ static int spacc_des3_setkey(struct crypto_ablkcipher *cipher, const u8 *key, unsigned int len) { struct spacc_ablk_ctx *ctx = crypto_ablkcipher_ctx(cipher); - 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(crypto_ablkcipher_tfm(cipher), key); + if (err) return err; - } memcpy(ctx->key, key, len); ctx->key_len = len; -- 2.17.1