From patchwork Thu Jun 27 12:02:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 167944 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2249635ilk; Thu, 27 Jun 2019 05:03:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqynm9TGSOw9SEJIKIvwuDFsycoUckj1USCzNf+cD2A4UBAQ+GxWitRxyRiuTpLnN2/TnWmI X-Received: by 2002:a65:5b43:: with SMTP id y3mr3482337pgr.346.1561637025542; Thu, 27 Jun 2019 05:03:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561637025; cv=none; d=google.com; s=arc-20160816; b=IWf8NXpuHd0Lpv39fXTCIv33Gm5zN+pQPt5mc6nmL9n9FG90rx8RrCszmfZj6TP6CP TfJXwHFUZMLXto1tGOIP+RqlD5X7kdKhMyqogUKLuocbPx6gZTzdpbFgZXlG9N580svP ZC8NTsPN4OdW0hWv6H/gbASp4Uirz7jSwVcKWiYWPocbgby4tMZgP2czr3g5zLaHSTMC oDChD47dfSWG9Fyih8rxoYL3g/lH0vfGHDNOf1l9/bOkx6kHTClBuWNos5B068w0EYsB bpEB/CLhp+2MTfRqI/ixVeOhpG4rlmErrTq9jQ8HmNvjqaAa9u0iwnj/Oavv9BBUkB6K TjnQ== 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=nrs4B81hCM9/q01U+UWQiaDxCfGgsj9EqtgRRqSeyuA=; b=0U6B0SVWEEZSAZEYC/r0FQGT85wXjvuVbufnnIpIdxFOFLFyisWnDFyoISJ/wUwwd4 +Im+aGVBqMU07JWXJPmJVgo5cyL4krOIc4twxerEGc+TmbSQg21m48/zxaw5WXTQoPPO 66L8HQj+XF59cnqnVc7H7pOLxSNkQ6W/gVmzrw7UUgO9A8g56wEGnB4tszb4Quom06yJ KkVsje/6qkAXwibNQ/tWIsgZAWPSxqde/qLnx4xRqNZboYi3RoU7KiLwck3orT/cL/PZ IKVvv1y1BRaL47OJkXylawC406yK8G3igpPZFP1XBYvxgPV5y9BbYxNRv2fB4b2IeUmj hbDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kNHW3hqr; 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 m39si2229121plg.155.2019.06.27.05.03.45; Thu, 27 Jun 2019 05:03:45 -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=kNHW3hqr; 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 S1726425AbfF0MDo (ORCPT + 3 others); Thu, 27 Jun 2019 08:03:44 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:43631 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726798AbfF0MDn (ORCPT ); Thu, 27 Jun 2019 08:03:43 -0400 Received: by mail-wr1-f65.google.com with SMTP id p13so2235827wru.10 for ; Thu, 27 Jun 2019 05:03:42 -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=nrs4B81hCM9/q01U+UWQiaDxCfGgsj9EqtgRRqSeyuA=; b=kNHW3hqrFhAgO6KQp6qVROcqY+QRGLDp8O9vZdpQrsbW+4kdXs9ha0nTT74ZR8CKMM qZKoJHcRcQ6KQKUf2u+E4nFSg6wXZwjIgxFKL2hH3r+U1/ol4xPijth//D4F5itXLv/+ PsfBnFurbsaElezKrdSNiAsrCzTxg1dneIRCP+tOOkUYvp+TugVEMkdrhHrRVOJmI6pV 2JrdI+lnoFdBHalq7VexnvAlSgHazj9k+M7wH4EG94MIpbCkV77x+tPifJ+FDnkeWd7H nXUPaEE+xZ66MjtkbSAZuR/BpOta7xd+jQsz1XUZgfrbA2x3driw5h0s05r3+HGK4uvZ QFag== 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=nrs4B81hCM9/q01U+UWQiaDxCfGgsj9EqtgRRqSeyuA=; b=rzRr8m3h2nC9Oqb2wXfNYlVoXIXGfgBPaoDo+i0q5agfsZVCZsLxlWMHy64hdzqzC5 BSdbShkaG5g33MRzaBQbWjxWjAjypgJc8ca6ntPASDTftyLGOP/Yd3oftxkPtXarH2je WzP6oVEXgp4uEGBAw8CpvpHpv1NJPhwgnwlfs/M0ZgMk2h0v/WuoJxfpj1BriJg87i8c u/R7UA3h1ZyybtKP4jSEgCFw7FVX5D4ToF8iOplbhulS0Wh0BCDtxRLcz2HYOvVY5YBj BDTZYNG9zndLbps16W/AMPyCk/FugzIu/D/veV0REb+SBQFNOBvo1ktOXR1m5NEp/Y+f 2ClQ== X-Gm-Message-State: APjAAAX5rHjIWgxTVopeVbaKiyiCnI6HuYAXSOBCco7K3ifpch5RbL50 jl1Re/gach/0lrmraFbB/lCTwSG5JPuNpQ== X-Received: by 2002:a5d:4302:: with SMTP id h2mr2730993wrq.137.1561637021834; Thu, 27 Jun 2019 05:03:41 -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.40 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 27 Jun 2019 05:03:41 -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 14/30] crypto: ixp4xx/des - switch to new verification routines Date: Thu, 27 Jun 2019 14:02:58 +0200 Message-Id: <20190627120314.7197-15-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/ixp4xx_crypto.c | 21 ++++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) -- 2.20.1 diff --git a/drivers/crypto/ixp4xx_crypto.c b/drivers/crypto/ixp4xx_crypto.c index 3f40be34ac95..f7642e3848b8 100644 --- a/drivers/crypto/ixp4xx_crypto.c +++ b/drivers/crypto/ixp4xx_crypto.c @@ -21,7 +21,7 @@ #include #include -#include +#include #include #include #include @@ -760,10 +760,7 @@ static int setup_cipher(struct crypto_tfm *tfm, int encrypt, } cipher_cfg |= keylen_cfg; } else { - u32 tmp[DES_EXPKEY_WORDS]; - if (des_ekey(tmp, key) == 0) { - *flags |= CRYPTO_TFM_RES_WEAK_KEY; - } + crypto_des_verify_key(tfm, key, key_len); } /* write cfg word to cryptinfo */ *(u32*)cinfo = cpu_to_be32(cipher_cfg); @@ -855,12 +852,11 @@ static int ablk_setkey(struct crypto_ablkcipher *tfm, const u8 *key, static int ablk_des3_setkey(struct crypto_ablkcipher *tfm, const u8 *key, unsigned int key_len) { - u32 flags = crypto_ablkcipher_get_flags(tfm); int err; - err = __des3_verify_key(&flags, key); + err = crypto_des3_ede_verify_key(crypto_ablkcipher_tfm(tfm), key); if (unlikely(err)) - crypto_ablkcipher_set_flags(tfm, flags); + return err; return ablk_setkey(tfm, key, key_len); } @@ -1185,7 +1181,6 @@ static int des3_aead_setkey(struct crypto_aead *tfm, const u8 *key, unsigned int keylen) { struct ixp_ctx *ctx = crypto_aead_ctx(tfm); - u32 flags = CRYPTO_TFM_RES_BAD_KEY_LEN; struct crypto_authenc_keys keys; int err; @@ -1197,11 +1192,12 @@ static int des3_aead_setkey(struct crypto_aead *tfm, const u8 *key, if (keys.authkeylen > sizeof(ctx->authkey)) goto badkey; - if (keys.enckeylen != DES3_EDE_KEY_SIZE) + if (keys.enckeylen != DES3_EDE_KEY_SIZE) { + crypto_aead_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN); goto badkey; + } - flags = crypto_aead_get_flags(tfm); - err = __des3_verify_key(&flags, keys.enckey); + err = crypto_des3_ede_verify_key(crypto_aead_tfm(tfm), keys.enckey); if (unlikely(err)) goto badkey; @@ -1213,7 +1209,6 @@ static int des3_aead_setkey(struct crypto_aead *tfm, const u8 *key, memzero_explicit(&keys, sizeof(keys)); return aead_setup(tfm, crypto_aead_authsize(tfm)); badkey: - crypto_aead_set_flags(tfm, flags); memzero_explicit(&keys, sizeof(keys)); return err; }