From patchwork Thu Jun 27 12:03:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 167949 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2249829ilk; Thu, 27 Jun 2019 05:03:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqxmhZKTxomyIDYcVdvqUo8HdvQ29gLykx9Mf90jxp+izzb1pAm6EiwqBCmS1NbkMtP0dIda X-Received: by 2002:a17:90a:c596:: with SMTP id l22mr5734587pjt.46.1561637033337; Thu, 27 Jun 2019 05:03:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561637033; cv=none; d=google.com; s=arc-20160816; b=F2H6EdDXATK3OV+xc6idUOgzxbmjpdGkTlnFew6YHUHwg8TEdPb5mGcan4WBCj2Hp1 B4tPfUJcvvb8TLZ+Xwsn2x8sEapbUT0bMokC+4xbisIWpWMcgsVTMmhis411kSKxPpI9 6eWQFUgUVvBkfKki7DJsU6h/5m5Uj9HnAjw1G5sbJHIXYAWDbvRoV8AP5fHtPdBqvheA qdsH63DTFjcxPLSnHM9sGjXGnZgm8tGJ4SSWamIbAOXSS78dQbzJiH2zsuOL1vpbJn5x heR6zZj9NX9p1nXrcVsa2YGOLDdvgHE7uyzAwcqCpKPLyAg3hCX7X30PeCS3IVW5Sc61 KC3A== 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=Q25PpZzJYl69vPoE9WmxVzLyhHRn/eQiQv/nA2MhMqo=; b=TSDXTqONfNEWF1tUrCSxiGPoHEdt8hruKMZeVYpB3+hiz4KlYmCItOxmLcRPYAyMv9 AcxTZTH4CNRK2ZwQYVrPDHliJeH1Gasg41fwQZpYsHONEH8d5gqxACAtHauHCr49oyx7 8Op2ewadIemwk0fCdwH3ndq4b/4n/bQQtOkQCNIxY54PsyfPCu67Jt5KDMseM5+bRC5k gOpPJPfkKi9AORUV1kLjKlI5yf0Du5uUcjw1BOYCL81o3dHAIoyRYEGV/9iZvCuou/ud /QKbREd0yeR+TOf4ZbBeVRnFOOTzKenmxkiNErj2F5TVOrJBcTTlqOC2Q2t+32+OvTAo nd9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WqbQsLf4; 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 100si2163460pla.158.2019.06.27.05.03.53; Thu, 27 Jun 2019 05:03: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=WqbQsLf4; 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 S1726872AbfF0MDv (ORCPT + 3 others); Thu, 27 Jun 2019 08:03:51 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:56154 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726832AbfF0MDu (ORCPT ); Thu, 27 Jun 2019 08:03:50 -0400 Received: by mail-wm1-f65.google.com with SMTP id a15so5465893wmj.5 for ; Thu, 27 Jun 2019 05:03:49 -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=Q25PpZzJYl69vPoE9WmxVzLyhHRn/eQiQv/nA2MhMqo=; b=WqbQsLf4i+Zc+IfQ5qJfmnEXS5HvXVLHPBm6UR9r5wy7sLYF8HuKSR3XB2oT6CQulv QS5DD3LmlrbO/mJ15O0jot0DvvBHcaeFhW7z+biSDf+YGFaitpteHi8SfT0RMrbPqcz0 QW/uumO4uMKrqQ7Ffx7m3q0VJz6d64orRTVmPchUKPy7pllC64aKSZSsZozlaggH0a+9 o3j1obGiUkUopsJip/gpWOqjB2/mp52jY+oTz19zwPS+lgyEnnHycY1X2Yz0WBoXXND0 9mJChZmRgsaO2cyF9Ww3PvuqD/sSqtCnC5kfDXbPJLndGHSWlD4UzM3sR+LwgPTwnYew jTrA== 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=Q25PpZzJYl69vPoE9WmxVzLyhHRn/eQiQv/nA2MhMqo=; b=iPrp8MJs7mD5fYVWe0nZ37kh4qtni8HzQRtkZE0ZBswwDEEwehC0GYQi4ONPV92Nh6 uMsaKAQBb68dMxUZzBSzLp8ULV2/C2z4rhCzpK16UW5X7iqn9+sKdI/eHM+pXDVIbONT lnUGxWF3z6q1KhR1tdqK6qbWBux7U4a0aiwTQompiXESJDjislqnQYy0rzQtwBOgws3U 3p8c8zcoH0XURzAtlQN4qmw42wyLSZuYnTBojq9xIVBmD+qHLdMbLYumD3R6m86HTk4q 6n5WAM9DApTHnn5sg7mk6LDLjYHc44P3j6bJRaUszE88FadP2jYIFyDgrCKqKWUB8jet C36A== X-Gm-Message-State: APjAAAXZA4nDx+oaN/GBkI5l/boylmkJqjU/3+ZwuRNptxywZieFa9qK rhtsKO28fXs6jYuCI7YLjmMWlsti1dOjAw== X-Received: by 2002:a7b:c148:: with SMTP id z8mr3079238wmi.142.1561637028191; Thu, 27 Jun 2019 05:03:48 -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 z126sm7732431wmb.32.2019.06.27.05.03.46 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 27 Jun 2019 05:03:47 -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 v2 20/30] crypto: rk3288/des - switch to new verification routines Date: Thu, 27 Jun 2019 14:03:04 +0200 Message-Id: <20190627120314.7197-21-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190627120314.7197-1-ard.biesheuvel@linaro.org> References: <20190627120314.7197-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/rockchip/rk3288_crypto.h | 2 +- drivers/crypto/rockchip/rk3288_crypto_ablkcipher.c | 21 +++++++------------- 2 files changed, 8 insertions(+), 15 deletions(-) -- 2.20.1 diff --git a/drivers/crypto/rockchip/rk3288_crypto.h b/drivers/crypto/rockchip/rk3288_crypto.h index 54ee5b3ed9db..18e2b3f29336 100644 --- a/drivers/crypto/rockchip/rk3288_crypto.h +++ b/drivers/crypto/rockchip/rk3288_crypto.h @@ -3,7 +3,7 @@ #define __RK3288_CRYPTO_H__ #include -#include +#include #include #include #include diff --git a/drivers/crypto/rockchip/rk3288_crypto_ablkcipher.c b/drivers/crypto/rockchip/rk3288_crypto_ablkcipher.c index 313759521a0f..c4ddabb7bc5e 100644 --- a/drivers/crypto/rockchip/rk3288_crypto_ablkcipher.c +++ b/drivers/crypto/rockchip/rk3288_crypto_ablkcipher.c @@ -49,15 +49,12 @@ static int rk_aes_setkey(struct crypto_ablkcipher *cipher, static int rk_des_setkey(struct crypto_ablkcipher *cipher, const u8 *key, unsigned int keylen) { - struct crypto_tfm *tfm = crypto_ablkcipher_tfm(cipher); - struct rk_cipher_ctx *ctx = crypto_tfm_ctx(tfm); - u32 tmp[DES_EXPKEY_WORDS]; + struct rk_cipher_ctx *ctx = crypto_ablkcipher_ctx(cipher); + int err; - if (!des_ekey(tmp, key) && - (tfm->crt_flags & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) { - tfm->crt_flags |= CRYPTO_TFM_RES_WEAK_KEY; - return -EINVAL; - } + err = crypto_des_verify_key(crypto_ablkcipher_tfm(cipher), key); + if (unlikely(err)) + return err; ctx->keylen = keylen; memcpy_toio(ctx->dev->reg + RK_CRYPTO_TDES_KEY1_0, key, keylen); @@ -68,15 +65,11 @@ static int rk_tdes_setkey(struct crypto_ablkcipher *cipher, const u8 *key, unsigned int keylen) { struct rk_cipher_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 (unlikely(err)) return err; - } ctx->keylen = keylen; memcpy_toio(ctx->dev->reg + RK_CRYPTO_TDES_KEY1_0, key, keylen);