Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp2984530ybh; Mon, 5 Aug 2019 10:02:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqym/fWhR3gxYoW24mNO93qq0yZijL4zc5xyVjMilXLn4pR2nMqXZnFRkUKocn9QuNpMh854 X-Received: by 2002:a63:7a06:: with SMTP id v6mr21907321pgc.115.1565024540290; Mon, 05 Aug 2019 10:02:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565024540; cv=none; d=google.com; s=arc-20160816; b=tSO11xKlayNTqXr3I1bmXFM5R/LA09FQGoElBlCklR/kG/9Zg96hjjh+/Fi0joUxCq 5P74LSihDg9b5dChWCRIeX4YdAmABAuWRKiiKVWLfjsYsvxLV0GhxAkdA52ql3ym+/UX ZTUqj6SIjE3ik9pvfYq/WT4QAPTzLVznp51UJinepYFEwwCgZ0WhECtFEBAUpUg1LhUq JAfGZ/RiadBDnd9G0S2Q3tNRPuCXNr7nmwPQzdr4eSF0QSOC6Y9T+qOzvE7mCUZ0734Y sAuFE8qcfTJkbDSfz5rzR9QAheY6Df1QEPCD4JOOCdqp6xgQf+gaX9jKQOmsg11ZG7AH NLYg== 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=WC3A3IO1SDn1jU7zjFN6JA5UEhD6hCSAXMtuWmVsFZY=; b=Ay/DFXhaLS8Kcxvc39mpseenUraVp0d9yv5guFB5zLwDuDs72Au4vG+kzCl/nAOEKc 5y/Coee/FEF2aTYOlcr+zcD9vBq+W7Nw1oYnbQeYiF6sAt5rt0/WnatQ8yv0fhVSLD8B a7tcGHt37g0ud2zQAv78QTXoBxH/NtTkjOJS1qr+C1Wb90MDX+q6TBcEGZOI3V9RYgv6 +4+dcK6s6IzA+pNNh1V9YoBrMfgXLxuJC5Fdx0e0NwMvUDEFlO3vxFpGaHXsDiGr0DgB vjIt84N2/sGKdZYig0k3XocbAhqaF0ELL7vMnnGIdypPmVHW8AlWI7fpQq4y51siWtRw NTdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=o7vVTgzE; 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 k22si14340036pfi.289.2019.08.05.10.02.07; Mon, 05 Aug 2019 10:02:20 -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=o7vVTgzE; 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 S1729882AbfHERBz (ORCPT + 99 others); Mon, 5 Aug 2019 13:01:55 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:51046 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729780AbfHERBy (ORCPT ); Mon, 5 Aug 2019 13:01:54 -0400 Received: by mail-wm1-f68.google.com with SMTP id v15so75463953wml.0 for ; Mon, 05 Aug 2019 10:01:53 -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=WC3A3IO1SDn1jU7zjFN6JA5UEhD6hCSAXMtuWmVsFZY=; b=o7vVTgzE/5LzN9VPuGrusL6KDb9nCeJKy46BD4YaR9yg/sO5wleM46K0KM27h/ZN8J E+C6u+dKuesfWdHwVw8+RFxI4BWuDRMIDgHAckN2KhKirdxGFE9q0heB4KL2AV5wkhUp ISItX1KD6C31qJ0DZ2wdFqsQbuCbMR19iMFxnw3tPyEhipRmYvLlLR11BhDZTZ7/F9k5 LXiS9/pmIvk9zP71NYwZtNOOJ8L7cUwqbrszmMLIujJSICBaP333cxJvFuDLNDEbL9k2 pWZYGDhOHSwIJZIDB5T8z09nteJyzkGnVO+w+iKowiUzElXs8AqJOHjCg1JJw8K4TPkp Tmsw== 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=WC3A3IO1SDn1jU7zjFN6JA5UEhD6hCSAXMtuWmVsFZY=; b=IhY1zlIezYOblfmRvvTe5pR5lCgvSCJCopf1mQmDgJJF9iM9e73IqrsgnjW+NMht8/ A5z9n/qNi/Qr0VOa2vDsGteGpTygUHe5Nkvj0wcek4I8PrnCJQbNu8ZGpGxBlwQfNSGs 5Dnt551fbwUuaPYkmScb2yec25w4ElpkF517hgKgOluv64fzg2U5f+Vl9njEc9LXDQsq R8ga1XswJa+XnVOizWPn3nQAnSrMXq18zJvScSBzpvY9Wa6BhhDeqQAcyYcGwtU2E7Ee wof1YlPSrRj3cDviudDOGQM5jEMBCMlmAasM+LvtEzlIc9goTO/6We+5jO8rXKMZcFPv GSaQ== X-Gm-Message-State: APjAAAWdUTD3PmHIK54b3VlvX7+r0AKYKImIRuN2rdltjOJh02mreSB0 N5ZrfCHkDqbYF2pl641y4wn2ubMPKKEj/Q== X-Received: by 2002:a7b:c745:: with SMTP id w5mr19156972wmk.21.1565024512948; Mon, 05 Aug 2019 10:01:52 -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.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Aug 2019 10:01:52 -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 15/30] crypto: cesa/des - switch to new verification routines Date: Mon, 5 Aug 2019 20:00:22 +0300 Message-Id: <20190805170037.31330-16-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/marvell/cipher.c | 22 +++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/drivers/crypto/marvell/cipher.c b/drivers/crypto/marvell/cipher.c index fa1997e70b63..6e9c390314d7 100644 --- a/drivers/crypto/marvell/cipher.c +++ b/drivers/crypto/marvell/cipher.c @@ -10,7 +10,7 @@ */ #include -#include +#include #include "cesa.h" @@ -274,19 +274,11 @@ static int mv_cesa_des_setkey(struct crypto_skcipher *cipher, const u8 *key, { 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; - } + 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 = crypto_des_verify_key(tfm, key); + if (err) + return err; memcpy(ctx->key, key, DES_KEY_SIZE); @@ -299,8 +291,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 = crypto_des3_ede_verify_key(crypto_skcipher_tfm(cipher), key); + if (err) return err; memcpy(ctx->key, key, DES3_EDE_KEY_SIZE); -- 2.17.1