From patchwork Thu Aug 15 09:00:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 171407 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1918016ily; Thu, 15 Aug 2019 02:01:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqyEcSANek8PFRKIr1HrQWtNEHyELXsnOAm/ZeE/bIPvB8cPy3GsdnLWWb9+X/L+gzINhaVY X-Received: by 2002:a17:90a:23c5:: with SMTP id g63mr1285149pje.124.1565859700764; Thu, 15 Aug 2019 02:01:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565859700; cv=none; d=google.com; s=arc-20160816; b=RIZjP6biQPcGmmdeyhX9NsQzsTUSyUp0PhmzxxvEUZjPJsMDyPlKaTKYXhC2LV/udp TRMKVjilQ+H126WDVkdovZ6wFMKDy3APJXfrxdpapYzVVrW4GEr4bxOdouzbs92U3oHO 2D6SXocoZS67uS6avTOIL4Nbz9Qn1Tv9Q1Vg70ngtATvm/ycSpVuwBdl5tN/YxZseuGn BQhpzGNjLvPHfzjrYvP4DSg2bh54GZRCTVVUWaRb6gOVffBXG8BoOqYsMs22kCYGX5hG YvFokHLZPMp+gPtsULPuznz06x1PT0UoXrMtVP3rKbIuxN4FQZpDDsS2XJtTdu9GEGcU 79hg== 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=BOt7PVw9lWqBCV/+RL+9xpeVpvumzg35vFF4tN3Fxn0=; b=qfIHBYoS2kI9T5TDvNEt0+EF3ZMfGm9enisBfNQRTFdd36ZQbCaknrGgve9Y2b6if6 lozHvLypcxT08HTMO52FmrqV1fwKcBbIDtDGUqFEvBv5CifIGicdT8h1QyNRsJXnHAEV JHWNAX1uknhi1s0JkJNwZW0h/XzijRLpOmglMG7bTpbSGdEKEQ82Prr7nlRsBOTDAKlk IiCnW533k1//XhkBn7pzsfM1Mh3d0Lhik816IEk7K2OyFkhyNE6CLQN8l/8xjp89krlW kkSrFvrmFoiTSoy+O7CxxWdkt9GEe8tCe+g1RbECHj6J+wZOmJygp7MJkBMqvsbgOvu+ /rFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Q1hGRZPa; 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 g5si1559088plt.271.2019.08.15.02.01.40; Thu, 15 Aug 2019 02:01:40 -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=Q1hGRZPa; 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 S1730774AbfHOJBk (ORCPT + 3 others); Thu, 15 Aug 2019 05:01:40 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:33064 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726120AbfHOJBj (ORCPT ); Thu, 15 Aug 2019 05:01:39 -0400 Received: by mail-wm1-f68.google.com with SMTP id p77so591983wme.0 for ; Thu, 15 Aug 2019 02:01:38 -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=BOt7PVw9lWqBCV/+RL+9xpeVpvumzg35vFF4tN3Fxn0=; b=Q1hGRZPa6MRZjoPqKHWUGdpI7Q5tqXwYt0eUeNtFXgtbmAP+3ZtZs9IejBKZZtwBG4 w2YnHDcj2Kl/htWCg5En5YEgXSC1dT/iv4r3wmMD3kUFHRKAZX2txkAGMpQBQJpOK2J1 eBSQkYVVh8Q37ZJiQoMrbX3UNzlVGfetZ7CALx6+xLxOi9Al49CF+jNXii6/0bVFLu2e /KPQBQsiAiU3JStCN9am/r7Ce8kGLNGULdYHHjaDkovis63wHi4wrAGPrdzmKeOWAhqp 23Ug43NOxQPs98WFtq76VVholamwkwtzbMz7VUe1yb2LZMg+rVOnGSlKCbnC7EtNp8Ig LlbQ== 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=BOt7PVw9lWqBCV/+RL+9xpeVpvumzg35vFF4tN3Fxn0=; b=nHn0M4CO1YH47KlloVganH+/wDohngGTjmHhh4Fg1j23oK24QjOmUAQy1O64g3CTKY g5QZK+rhRxHTxVpE6AHraqVRvsUEQbhXS0OpoNjj1y5xJZ3Shw/GcHjyfnWZ91w+MZyl fRr5ZMd8R3TwQ3axuTPOBxP6LfN9MmtfjR/V69pUF173nxh9QhLnflNrgWu86emSA/3k B1wxufeVCOqEt8Cg1PcsVSt1dW4AScV/Pd/Z35tQf8MO8oqmlNNCMTd21Xr9BfJQngxa Woa+Kmh6LoDlftia9YdiJWlEU3lGjzkCX9UmrCagUBUIG1UP3g9sOXKnmzL4yfO2bswk /gEA== X-Gm-Message-State: APjAAAV4jtKYLoC400aAmuDX7qZVFM/7rcLcTTe4x3GmmFQDrDVGqNWA 6lV/znZRiCPC6EatbMGOcjhJnIpP7nWUTbCz X-Received: by 2002:a7b:c157:: with SMTP id z23mr1696966wmi.104.1565859697490; Thu, 15 Aug 2019 02:01:37 -0700 (PDT) Received: from localhost.localdomain ([2a02:587:a407:da00:f1b5:e68c:5f7f:79e7]) by smtp.gmail.com with ESMTPSA id x20sm3857533wrg.10.2019.08.15.02.01.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Aug 2019 02:01:36 -0700 (PDT) From: Ard Biesheuvel To: linux-crypto@vger.kernel.org Cc: herbert@gondor.apana.org.au, Ard Biesheuvel Subject: [PATCH v5 07/30] crypto: cpt/des - switch to new verification routines Date: Thu, 15 Aug 2019 12:00:49 +0300 Message-Id: <20190815090112.9377-8-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190815090112.9377-1-ard.biesheuvel@linaro.org> References: <20190815090112.9377-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..596ce28b957d 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 verify_ablkcipher_des3_key(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 verify_ablkcipher_des3_key(cipher, key) ?: + cvm_setkey(cipher, key, keylen, DES3_ECB); } static int cvm_enc_dec_init(struct crypto_tfm *tfm)