From patchwork Mon Aug 5 17:00:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 170596 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp4538239ile; Mon, 5 Aug 2019 10:02:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqxIPkr9Q3MzS7kF9HIQh+x8fJJ8vtWoq/b4Zzoc+LSgEOsfxu+EvzRuXq+vA3T8QYxIz/bd X-Received: by 2002:a17:902:2f:: with SMTP id 44mr147799606pla.5.1565024528586; Mon, 05 Aug 2019 10:02:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565024528; cv=none; d=google.com; s=arc-20160816; b=dR8diuHahAdnHXx07C9NszhTB6B14V4+oP0K6danbNZIQZJfmPxEWqutY5/einAqzf hQ51flUMbHBA3FqHtyPzDUwR8RIECdecvRBwLd+8hnTAsTjvOpKiSxw2YQPK6bwxDQ+b /JC4SGm0qQ3MUVXRY9ZY12Rd6J8CtXpDLFM3cTs455drzuQZpf8Ajt6Kv4zk7JAKiNOf 9ktj4FdumHkeK2CxnmT1OYCRyG9XjcmOt65cgInZQXOf18kfHMlGPrPAhdsk/xB3k+DZ iJfHYVbszFAxe1Yo0Ed4AFCuEiLQbJU+jUPjUqeQGLuhZS19QJgnUcWLSUwJZM2EWKUc OYiw== 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=wfAyMSI+isugVytbOn9ACte5k7G1Dq3BijffxGwub4E=; b=HRyGlvTHvRVM0xKq6INLC1iZw22B2zp7X6Q+t48VcLQw7lbWfNrPPZcMj9YcJXNUx9 3r7QMu+g2hE3AEy8X9jCIvKC5FwT5omr9IBYagYsXOF599DFrge1NZIKlVHca+XMNPUd BjyNn22PYxQXic47MZM6ayl7J/0Y/lfyKD35qssf0pt++Bi6IqwF9Q0/RisbrQElEZP7 SozDl7RieLCxBCfoziRYpRirD4IRRUd0YLtn9vGSWlCrVdU7qnGy+5JP1qp8444c25ZT vkUsJAEUtvhmgxuEO3OozcA8bGDYz/5JZdco5eiovx3u4iQjvgol/1AihrkuZmCOMRTo XjLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ts7v1viZ; 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 36si44243069pla.80.2019.08.05.10.02.08; Mon, 05 Aug 2019 10:02:08 -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=Ts7v1viZ; 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 S1729894AbfHERCI (ORCPT + 3 others); Mon, 5 Aug 2019 13:02:08 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:39334 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729780AbfHERCH (ORCPT ); Mon, 5 Aug 2019 13:02:07 -0400 Received: by mail-wm1-f68.google.com with SMTP id u25so63359138wmc.4 for ; Mon, 05 Aug 2019 10:02:06 -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=wfAyMSI+isugVytbOn9ACte5k7G1Dq3BijffxGwub4E=; b=Ts7v1viZxWFV0xstSX05mcvYZM/jVEHylW+yNIedZVv8Up56sI/xkesfTrKWtdnWvg LRZHulRy/K0KI7zZ/OtiZcWjdxtimzKtFfJFQHekltcErF1w+zTn+BEz9plQrQsJ2r8O vo6jIsjziYhPBJXHPqSDdSFcVyfv76S0mGhyxBU+eddUI6VRZRfzjWU2A1fw6jpeAB3r IUqJ2zpMOz6Ssgz/tkGMX9b4eci57MMGDNkzFlRce5MpgmI0WlmwTlPwsySYfJOXlKtp F30UpMbK1bxe63oh4Fpwv2/EfU/YPkWoJzHwo94zAQJqHbJqu2u8ZmZN5zYa5bDq9m45 BD1w== 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=wfAyMSI+isugVytbOn9ACte5k7G1Dq3BijffxGwub4E=; b=khvBW8PuaOytXJanNeMnOSva21blFRaQXcx5uN4Vt1USft9lKDNG0CnrMotvunL+sM J+G7p7GuOBjQb4omUU788Bw8pXW9C6W2ElFyokvIot7w2buGBGDPm8JRh0C3rTprwDpr YsxLvOEU3AHx/4X4uC4TnIfTJvXLLfei+p80OTRxCyjt9LsuIbs17pZqqnH3JD8Xc9En sy8XHfxzA/Budz7Q3LVaMcT1ZgdgWHwkkKxkin8ueSMqDxOlmkgrNeXSRjTaoMVmhkBy Ici64MMQqPdxthS41YdRCMd1nWOw7DJSEKXqeDpE7OJyss8tfe5W9S5tfe/CCFqTnaTu WGUQ== X-Gm-Message-State: APjAAAV+nYINglTmrl24hYpeNdrcNNoBfXXh0rwH0jQzHvdJFRcFjvtp 0pj4EfFJnv+7Mngjb7xUJNCazPfR1P69/A== X-Received: by 2002:a7b:c745:: with SMTP id w5mr19157602wmk.21.1565024525494; Mon, 05 Aug 2019 10:02:05 -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.02.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Aug 2019 10:02:04 -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 20/30] crypto: rk3288/des - switch to new verification routines Date: Mon, 5 Aug 2019 20:00:27 +0300 Message-Id: <20190805170037.31330-21-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/rockchip/rk3288_crypto.h | 2 +- drivers/crypto/rockchip/rk3288_crypto_ablkcipher.c | 21 +++++++------------- 2 files changed, 8 insertions(+), 15 deletions(-) -- 2.17.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 96078aaa2098..ec84c2374b90 100644 --- a/drivers/crypto/rockchip/rk3288_crypto_ablkcipher.c +++ b/drivers/crypto/rockchip/rk3288_crypto_ablkcipher.c @@ -46,15 +46,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 (err) + return err; ctx->keylen = keylen; memcpy_toio(ctx->dev->reg + RK_CRYPTO_TDES_KEY1_0, key, keylen); @@ -65,15 +62,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 (err) return err; - } ctx->keylen = keylen; memcpy_toio(ctx->dev->reg + RK_CRYPTO_TDES_KEY1_0, key, keylen);