From patchwork Mon Aug 5 17:00:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 170583 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp4537376ile; Mon, 5 Aug 2019 10:01:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqwyzukctMf9dkK+5IDNAkrKGtMO3PlIMENsWzdVbB67kGXDDXqN2a8iZD2mdBRLUmJSLZ0U X-Received: by 2002:a17:902:6ac6:: with SMTP id i6mr146082202plt.233.1565024487468; Mon, 05 Aug 2019 10:01:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565024487; cv=none; d=google.com; s=arc-20160816; b=U/XcXkxcTOe2GESa6+B8wbhAF0z8gqKlBWOe7WHT6uJK4c9NelAGNNM6cuVlDhEIxm TerDDPQsPymUv6CDYlUGnig26OXrvzZr0Bx/OqG1/QSkJZPHa0JPU92Sfo7KpYDQf+zM IfGXAGT4vPOqcpLkASfUfjL1IqPOAL5U54x+nuons6U4/9XxOplDAzrYcIqmIVDVlOoc RuwGIZfael8aySUKVQ+SAcv/IomsH1YcE5YocBuX4w5oAoPU172aoF0lr6kssAOxYmVE ek4YC2GWImFTcSk2eYqxR3dkgeRJpcXXzF6Er3gSgZFIJg9nxpMydIM5y7YczEoY2rdp xI+w== 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=d/q+PwBQn82PwNRadEPbRZlT98TrFpoVZO1F6BU3qYI=; b=M2W2oYn3b7urkYCZGVhbUOcw3W5uU2KWeEsCF0qgZta6shb+Gz4IlsIHEtbHWVbXt5 qV76c1/DTJG1itWPwkH6aSrrQmYwS34wr80EatPaLjfW2ajJONO0hd+BavvwVuKzywFH NUYD34GDmGENsav3a92u1ttoMgNI7rmcpsU7AzElry3waF7AeAoflOj69J+qrZkS7V5h Od0UQWoW9B0+1RkbCumU0G5tnfqp+k1FgL+alZc1NeRGy9eXl1TcOb0hB85OrMhTnqxA 4Zi25yx6UItN/ue+b/yPGTk2w6gpqLv8m7Re1LvIVUMizhv+Mz113WjFVTAh6v1gYK5N 94OA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NFTi5Ft8; 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 b61si41087117plb.401.2019.08.05.10.01.27; Mon, 05 Aug 2019 10:01:27 -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=NFTi5Ft8; 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 S1728797AbfHERB0 (ORCPT + 3 others); Mon, 5 Aug 2019 13:01:26 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:39240 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728935AbfHERBZ (ORCPT ); Mon, 5 Aug 2019 13:01:25 -0400 Received: by mail-wm1-f66.google.com with SMTP id u25so63356959wmc.4 for ; Mon, 05 Aug 2019 10:01:23 -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=d/q+PwBQn82PwNRadEPbRZlT98TrFpoVZO1F6BU3qYI=; b=NFTi5Ft8w1d17W5i86cJTf0YRanGNjWsoNOMmVrybgokPa+SItmv6eq2nCPL124cKQ 3gTnlpdPjlgvoDE1xCg2mCUdEAZSTN9XPlnvjWd5+CTWIDfi1BdztBRWNVkssUJ2fgvk bPS6idypXkSrTtZg5oRzCGUVzp6B8EOo6G4ZJn2IK4T3GpYbbhWN9KvTEGS9amD+M6Lc 9x9B3llP3bOzJF2zhK0EFfzUjxC9zH44+JiL9mlMbDhK0vhRyWlUrdRDPpFTw0WW9h6G xgI+ZqFN88XF1zz5R9V26adZ8KwkI8yCPkgAO0f+2REPzNEFgMiLIyCzqB0nCh5S/j+B npMQ== 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=d/q+PwBQn82PwNRadEPbRZlT98TrFpoVZO1F6BU3qYI=; b=mRPrsv9xrGe5yDoyamvnepgfvKSxVFdFte+UU5wpNrs+raLuA9StqFZTyY6+quPDmF VxHAmRxzwJ4FRnhT5cSD9weMRje0oMF8tBA32JzWUBJv9z/SdpVUm1wTbqAbT94yLaqM rAe0Cp3N7ZEy2LwB+qw9Z3NY5qGFjCtZhPoyzmShqKJXfp3ZXgsAyBAR5yQJkOZgCZCt lpuG7f5XHH9oGFKi3ux+ZLpdd0KLG8G+3ahssXyahXtxGaNm/LTLyc8mrA/bykKkWJV3 6Keg78P0lzcXTJ/oHvGre0wn6G+UBoyXY8hFyXfYe5YJty1IaWtalqL4JkMGI1Pnk+D5 7jAQ== X-Gm-Message-State: APjAAAUWxr0bqXLY9EPWXpg4MrR338L6f+7LVQjnvtl8b2iSXqJrr4Jc FDxPMo1qA9RXdBiqZPopa0RqlnJetrSqwg== X-Received: by 2002:a1c:5f87:: with SMTP id t129mr20675862wmb.150.1565024482968; Mon, 05 Aug 2019 10:01:22 -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.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Aug 2019 10:01:22 -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 07/30] crypto: cpt/des - switch to new verification routines Date: Mon, 5 Aug 2019 20:00:14 +0300 Message-Id: <20190805170037.31330-8-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/cavium/cpt/cptvf_algs.c | 26 ++++---------------- 1 file changed, 5 insertions(+), 21 deletions(-) -- 2.17.1 diff --git a/drivers/crypto/cavium/cpt/cptvf_algs.c b/drivers/crypto/cavium/cpt/cptvf_algs.c index ff3cb1f8f2b6..aa349d95cc2c 100644 --- a/drivers/crypto/cavium/cpt/cptvf_algs.c +++ b/drivers/crypto/cavium/cpt/cptvf_algs.c @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include #include @@ -322,31 +322,15 @@ static int cvm_cfb_aes_setkey(struct crypto_ablkcipher *cipher, const u8 *key, static int cvm_cbc_des3_setkey(struct crypto_ablkcipher *cipher, const u8 *key, u32 keylen) { - u32 flags = crypto_ablkcipher_get_flags(cipher); - int err; - - err = __des3_verify_key(&flags, key); - if (unlikely(err)) { - crypto_ablkcipher_set_flags(cipher, flags); - return err; - } - - return cvm_setkey(cipher, key, keylen, DES3_CBC); + return crypto_des3_ede_verify_key(crypto_ablkcipher_tfm(cipher), key) ?: + cvm_setkey(cipher, key, keylen, DES3_CBC); } static int cvm_ecb_des3_setkey(struct crypto_ablkcipher *cipher, const u8 *key, u32 keylen) { - u32 flags = crypto_ablkcipher_get_flags(cipher); - int err; - - err = __des3_verify_key(&flags, key); - if (unlikely(err)) { - crypto_ablkcipher_set_flags(cipher, flags); - return err; - } - - return cvm_setkey(cipher, key, keylen, DES3_ECB); + return crypto_des3_ede_verify_key(crypto_ablkcipher_tfm(cipher), key) ?: + cvm_setkey(cipher, key, keylen, DES3_ECB); } static int cvm_enc_dec_init(struct crypto_tfm *tfm)