Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp3086246ybd; Fri, 28 Jun 2019 02:36:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqzXsDNJK6vgmGKo7vVWuUUE4wVjMGpl/vNWGcyQsT6MoOfACiGc5xYv9BLC9Et5vKEmUMbj X-Received: by 2002:a17:902:112a:: with SMTP id d39mr10818pla.254.1561714586538; Fri, 28 Jun 2019 02:36:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561714586; cv=none; d=google.com; s=arc-20160816; b=DK1UweAlXvnOyVZfrBKnyaiOxLCKdE4KDnn1PvBnBtP7vesSjj8bnJXoTeHHVkeGlx NHLp/dRAiBKLIQ53N5+zedTQMTEnZxrvVVb//SjFqP5eP/yxloMlw/LpUz5MbV422XI0 aiDv0VCrCf4wR0ryNjwRqXBWhMMc4mzt0GLQYn54HfjBKolqgsgeqOwZubrMhJpQNi3I +iUuNvsiPPHLolN2yMuLo/IiI36APEk9a44/hemiYWDmVCCwY5CIqACtKhWPuk/QDfI0 O5qVOgWJVxN3RfZSndL77JYeGqPmsOv0gW8MGHMtV8bcwrEDyuna9W1BFbGNqARVG/rb aWcg== 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=gU5XdhRzqh4V0nFMyqKcG3tn/WS8nvCNXfGNVcUotfs=; b=CYCZgjORpc/DFlhcm+jEQn3C3BWGLSvmr3pa1mr/0U18Sef+dbRx30tQhCF8e0sGsm OYgsaM95GqDtekHjmW3GKoQXb0q49lNhJCEkOy2D5fYT87a00V/O37i66+gZLAhxeRFw ZezV+3A4oDeDvmtWea9gQY4ciqgPL93cRwB6x1RmireIxxiuWv13NxTnIf7/bRlNXRoh e/wcHqOx5M9AJw5GEspVmANRs88Hcht1Y6dgbZB/I4eid+trU/+/h2fI1O5sIKvGCgRz XJQynRcaYLsExqVxtG1NnujoJ8DPzLeFr2f/kEhOBTH/Tc70YcXCGMjaVDxi/Y3ESzg0 ImkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="lRlNEV/2"; 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 m71si1788135pjb.26.2019.06.28.02.36.12; Fri, 28 Jun 2019 02:36:26 -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="lRlNEV/2"; 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 S1726686AbfF1Jfy (ORCPT + 99 others); Fri, 28 Jun 2019 05:35:54 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:44123 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726632AbfF1Jfy (ORCPT ); Fri, 28 Jun 2019 05:35:54 -0400 Received: by mail-wr1-f68.google.com with SMTP id r16so3671806wrl.11 for ; Fri, 28 Jun 2019 02:35:52 -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=gU5XdhRzqh4V0nFMyqKcG3tn/WS8nvCNXfGNVcUotfs=; b=lRlNEV/2sRpjhiJeMx2zbCYFRDJrVrCUoAOTiplP2+y8lRfQOJiZfphcDrfEnJA4gJ sUrOZTSmP7VxnnKbJ+/AD6Kfwp4sdggkbe1/ubgXsI9vSuYGphY6ck8FGHzK1KHGBJhx Rsf2ZVoDbcIrs8m8EJkiY1jRm8HeuliCwX+Ct5nHtP+0erln8+45qfGbsLaG7dpOHUmi ArvUnGWQ/E9v5jVzkhjZ8kbPd96Urp1sbyUhUKa6EeAh3G61s9qAS/aMaSUdW9m/nWz2 VJitbroa30lxft527cdaILMHYAHyupN9jCuC/rGMUnUbt5AeQ4a49iUtFGjYiOJUTxHi BQwg== 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=gU5XdhRzqh4V0nFMyqKcG3tn/WS8nvCNXfGNVcUotfs=; b=axWAsW745Nn2Jkvg72XV8Lsgr51GTVEn7tshnCGkr7K3t4ypcGFAcfQKGA5YEFdhrm hKEM+XqjiZG9PTgrl+OMGG2WDBlY8XqJJulc5CGOeO9D4DeZ0o8GAcEiIvV/vgtzzUvR WuhBzI2NavWqzn0C1CDP/BbXa63Or3ARcdPpYQ++chFP1F3lsG5mFv4W/Y97+b+Qj89m R3dVXHaFEJQujJrJv+tgz25jdk9w1nMlM/U7SHlCWegHpbmsZPYZLhvqeGAI3u8fD8E1 Oq0edh/NHIusH++LzboGtA3qdwV0S8rLwj0Cbzyi+JJyIFfzt8VfrC+76CCAkqP9zUqo v+bA== X-Gm-Message-State: APjAAAXpfHfeGbVbMVCBxr5xY9s7lV0+MfM30QZmCrsfMmXkURLpr7hj e7ixgEv+zFKWskvK4D9Ets10YjyK/6z1vQ== X-Received: by 2002:a5d:5342:: with SMTP id t2mr7653990wrv.126.1561714551541; Fri, 28 Jun 2019 02:35:51 -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 m24sm1709910wmi.39.2019.06.28.02.35.50 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 28 Jun 2019 02:35:50 -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 v3 12/30] crypto: hisilicon/des - switch to new verification routines Date: Fri, 28 Jun 2019 11:35:11 +0200 Message-Id: <20190628093529.12281-13-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190628093529.12281-1-ard.biesheuvel@linaro.org> References: <20190628093529.12281-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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/hisilicon/sec/sec_algs.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/crypto/hisilicon/sec/sec_algs.c b/drivers/crypto/hisilicon/sec/sec_algs.c index 02768af0dccd..4a9fae297b0f 100644 --- a/drivers/crypto/hisilicon/sec/sec_algs.c +++ b/drivers/crypto/hisilicon/sec/sec_algs.c @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include #include @@ -347,25 +347,21 @@ static int sec_alg_skcipher_setkey_aes_xts(struct crypto_skcipher *tfm, static int sec_alg_skcipher_setkey_des_ecb(struct crypto_skcipher *tfm, const u8 *key, unsigned int keylen) { - if (keylen != DES_KEY_SIZE) - return -EINVAL; - - return sec_alg_skcipher_setkey(tfm, key, keylen, SEC_C_DES_ECB_64); + return crypto_des_verify_key(crypto_skcipher_tfm(tfm), key) ?: + sec_alg_skcipher_setkey(tfm, key, keylen, SEC_C_DES_ECB_64); } static int sec_alg_skcipher_setkey_des_cbc(struct crypto_skcipher *tfm, const u8 *key, unsigned int keylen) { - if (keylen != DES_KEY_SIZE) - return -EINVAL; - - return sec_alg_skcipher_setkey(tfm, key, keylen, SEC_C_DES_CBC_64); + return crypto_des_verify_key(crypto_skcipher_tfm(tfm), key) ?: + sec_alg_skcipher_setkey(tfm, key, keylen, SEC_C_DES_CBC_64); } static int sec_alg_skcipher_setkey_3des_ecb(struct crypto_skcipher *tfm, const u8 *key, unsigned int keylen) { - return unlikely(des3_verify_key(tfm, key)) ?: + return crypto_des3_ede_verify_key(crypto_skcipher_tfm(tfm), key) ?: sec_alg_skcipher_setkey(tfm, key, keylen, SEC_C_3DES_ECB_192_3KEY); } @@ -373,7 +369,7 @@ static int sec_alg_skcipher_setkey_3des_ecb(struct crypto_skcipher *tfm, static int sec_alg_skcipher_setkey_3des_cbc(struct crypto_skcipher *tfm, const u8 *key, unsigned int keylen) { - return unlikely(des3_verify_key(tfm, key)) ?: + return crypto_des3_ede_verify_key(crypto_skcipher_tfm(tfm), key) ?: sec_alg_skcipher_setkey(tfm, key, keylen, SEC_C_3DES_CBC_192_3KEY); } -- 2.20.1