From patchwork Sat Jun 22 00:31:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 167445 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp1376818ilk; Fri, 21 Jun 2019 17:32:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqwrxJHbwKu1KTP4NOpndjb8SNRIlTWNeYPDMSwy08UbM3RmhMtCqEUBXv8ZheW6AyxkKf2d X-Received: by 2002:a63:1b66:: with SMTP id b38mr21055580pgm.54.1561163530160; Fri, 21 Jun 2019 17:32:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561163530; cv=none; d=google.com; s=arc-20160816; b=UZjKRWxcOMlvrpfezTEpmqVJ0HiqvnnaAeLMFqmOnGhNwkVVc51CQePtpiCpqZl/IL CO2RO7TYFozl+u/ebJrFabqwVefAhwj2Y9jFn+egPI3siOaDJKvKQx/M99XNwYgdHvRt qGkKqJwZryFr7xi7Pah9AyeB6mR8HUDhK97C8fk9cdNBYqfRjWYsk4uFhWIXkrKdxL4m JDuHoIjG6jE1EnPbQtv768zp+XYtMhgLb4Urb3RTNzmrvZfYpKzZKaC3wbyTT+xpTBNO 3EcXeuPYh0G4SHAuJsCVPi+oXnsD3G+5VnV8oBV+dwXpFTak3PIGqkCtfWwPvXclbJCh fd4Q== 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=UegmsAOjoNCHrQaB/W23ATKBTZ4x8N3x14/ck1Y1UZ8=; b=wBF4fCGUPwa+LEUA8cZYTHdIHX7e7HElP7xFg7FM6uIKMzMAPKfbgnadAWi8XjH+II +0fdvvLavlGyMy0vScyIoPDgLGzfSB7iCX5Dymh81jSFDivrVJD//UJm/0QnWqZzvo3Q OTDyIDvSzmQDhQyWqOnGGuLYUhOHZ4p60/jPmuby+YaHoufsipS169AfyIF0s2MTePlF NSsxiJG0OEwxK5FR4UcmwlqdA4RQS8GnhiNX0Ycieb4twufzVaM1RMcqRNeEZp9Acglh 79IJVbpQneQYUqupOAlecmst3ev0+lw5ZbZK5WKDjuVq9SMVXY1hYA+C7Nv7FHFNu2D+ w2AA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RMfB2j6C; 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 v10si4096271plg.320.2019.06.21.17.32.09; Fri, 21 Jun 2019 17:32:10 -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=RMfB2j6C; 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 S1726049AbfFVAcJ (ORCPT + 3 others); Fri, 21 Jun 2019 20:32:09 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:36787 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726212AbfFVAcG (ORCPT ); Fri, 21 Jun 2019 20:32:06 -0400 Received: by mail-wr1-f65.google.com with SMTP id n4so6915577wrs.3 for ; Fri, 21 Jun 2019 17:32:05 -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=UegmsAOjoNCHrQaB/W23ATKBTZ4x8N3x14/ck1Y1UZ8=; b=RMfB2j6Cb2sx1Rm9XYLCYM6p+siIEicTA5Ft5WqkGakiwcWqNRaGPagAeNuE9E+ORH xAE1jD8aAE1ykIjapFruNPPK7Wrns0s8VdPWdUbl/RA29MGyOZbvdaKPHOfY/Ovff7z8 dj4eLDKy+BXeNOclRGqgyOSb6yXGagY/11VGMhhsnEz7CRE86+4Phq+Iy1btjYlJWyjH qHaHe51FxfPtYNoigik2vd7OZKoTXjuz5ock/IW/LmRsEb+CZJW/g3MFj/UVY2hH75g4 4xGKiBtKGKip/9cMqTB3BCWv3jfLSv07V9HB1DejT34dgkikka+4NgPwuFCepU2EFoAQ 8b7w== 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=UegmsAOjoNCHrQaB/W23ATKBTZ4x8N3x14/ck1Y1UZ8=; b=S0gujvKIdV2O262FvLvqJxibtbZe3W0lgKvGm3AqGG4UO2c3nCqnil+LyMlltLwHTe ddKq0hzcP4FT0SQX1FL6qibJ/SIfeTs+/0badsza5JQlO1gCirWBY1F7P55nfVNEg2KJ ARFS47fjciTi2HMmDAd2f9lKXfuYEeniAb5orrlKv8Ve8QwzLsy40zu+hGkoaDTEVFoH Jc0y8ETsZ3QSovBoMOmLH8mjCl0w54MEtO/zS8d/n0Yb/Jb26SdPLXOCWsPALrh5B23t 1Vebkr7nB58SFxw8hUfIy/nJB/9TTZ06d9+q/6FCXPwwS5bGAD68cknCqZEEqwzeRaCk TU5g== X-Gm-Message-State: APjAAAXG7yHHEidkjo+6IT//cUWNulolN5sdbTF0P9foeDelC5rMdBnv HReHL5GyyvD3we2TXBojy3qNhlj8JSRh+Ffi X-Received: by 2002:adf:ce82:: with SMTP id r2mr35969812wrn.223.1561163524328; Fri, 21 Jun 2019 17:32:04 -0700 (PDT) Received: from sudo.home ([2a01:cb1d:112:6f00:99d4:1ff0:ed6:dfbb]) by smtp.gmail.com with ESMTPSA id v18sm4792019wrd.51.2019.06.21.17.32.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Jun 2019 17:32:03 -0700 (PDT) From: Ard Biesheuvel To: linux-crypto@vger.kernel.org Cc: herbert@gondor.apana.org.au, ebiggers@google.com, Ard Biesheuvel Subject: [RFC PATCH 19/30] crypto: qce/des - switch to new verification routines Date: Sat, 22 Jun 2019 02:31:01 +0200 Message-Id: <20190622003112.31033-20-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190622003112.31033-1-ard.biesheuvel@linaro.org> References: <20190622003112.31033-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 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/qce/ablkcipher.c | 23 ++++++-------------- 1 file changed, 7 insertions(+), 16 deletions(-) -- 2.20.1 diff --git a/drivers/crypto/qce/ablkcipher.c b/drivers/crypto/qce/ablkcipher.c index 8d3493855a70..e646e90f93ed 100644 --- a/drivers/crypto/qce/ablkcipher.c +++ b/drivers/crypto/qce/ablkcipher.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include "cipher.h" @@ -177,12 +177,9 @@ static int qce_ablkcipher_setkey(struct crypto_ablkcipher *ablk, const u8 *key, goto fallback; } } else if (IS_DES(flags)) { - u32 tmp[DES_EXPKEY_WORDS]; - - ret = des_ekey(tmp, key); - if (!ret && (crypto_ablkcipher_get_flags(ablk) & - CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) - goto weakkey; + if (crypto_des_verify_key(crypto_ablkcipher_tfm(ablk), key, + keylen)) + return -EINVAL; } ctx->enc_keylen = keylen; @@ -193,24 +190,18 @@ static int qce_ablkcipher_setkey(struct crypto_ablkcipher *ablk, const u8 *key, if (!ret) ctx->enc_keylen = keylen; return ret; -weakkey: - crypto_ablkcipher_set_flags(ablk, CRYPTO_TFM_RES_WEAK_KEY); - return -EINVAL; } static int qce_des3_setkey(struct crypto_ablkcipher *ablk, const u8 *key, unsigned int keylen) { struct qce_cipher_ctx *ctx = crypto_ablkcipher_ctx(ablk); - u32 flags; int err; - flags = crypto_ablkcipher_get_flags(ablk); - err = __des3_verify_key(&flags, key); - if (unlikely(err)) { - crypto_ablkcipher_set_flags(ablk, flags); + err = crypto_des3_ede_verify_key(crypto_ablkcipher_tfm(ablk), key, + keylen); + if (unlikely(err)) return err; - } ctx->enc_keylen = keylen; memcpy(ctx->enc_key, key, keylen);