From patchwork Mon Aug 5 17:00:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 170588 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp4537863ile; Mon, 5 Aug 2019 10:01:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqz4Ydl+11x+7879aQ5A/fwNvlMh1XvxYg42Nc2K2XJ7E6dRnpcyCHZY24s1KwHuJTMjfNxl X-Received: by 2002:a62:584:: with SMTP id 126mr74442394pff.73.1565024510013; Mon, 05 Aug 2019 10:01:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565024510; cv=none; d=google.com; s=arc-20160816; b=JQ2YVCsf1BGKNvowAMRj7WPMPoQ55tVEpBDjfiz7xh0j52JjLJXhp41EhL+ctYs1GS LLVuwAcZVFM6Dj4/rcjS4MQxkxOzVdYXN/dEQZoQ3GWjkS/9GF+MYdTI+urlhmzjj/oA AgTHWINLMygFaj6I1o0RLEasWfxlcCHV1AAOKew36O/H2l1rX1sTWaAVdxWhuxbEGY7O +XDwmQ1syWll+R31ngkzuZkeAzFNvji9+APQFwWnxOVFjyY7qYYG2hAvVgXdcGQ8By6f EK0i5T5yHRn1pQyMnEAYPTegaZUmu57sm4MqyL6EEYr/P0pqsa9E970Xyi8mQstMg547 TMPQ== 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=iZePgyWlwagKGC4cLYF5LyS9ZbP+9Htyh4OOtwgxfUY=; b=zGjMRz3yHALi2n435AnryCpwrfSXp6AdUeTSbMkhHktOAwa48ZDQD3io68JwNi3vov qLO4KpwQhBKhV+xCieSgbtXXxYftMit1eIqjvSxS/GJg4r01kQt6HIaJweux5MriGUKv lnZurKVm5lKKqKYHpan3lTFcFPTYvOtEAEWexcE0TwOmIQkFae4vnGEm8xI4ETtiVJhZ jkXKX6QhGUTCpoJvytO6+hW0moNeo5BA9tdemdnxJEPI5f0Ophlp8gLogXFnuQwdv+oc 83gTNorh9QIFkrhou0CMfJEZzUWD4Q0u3NWTVA9h8U9UUnMYMGlC9IkjOz7avV/vevZc BlTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yZuVlaQX; 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 w10si41995852plq.403.2019.08.05.10.01.49; Mon, 05 Aug 2019 10:01:50 -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=yZuVlaQX; 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 S1729788AbfHERBt (ORCPT + 3 others); Mon, 5 Aug 2019 13:01:49 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:39283 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728871AbfHERBr (ORCPT ); Mon, 5 Aug 2019 13:01:47 -0400 Received: by mail-wm1-f66.google.com with SMTP id u25so63358038wmc.4 for ; Mon, 05 Aug 2019 10:01:46 -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=iZePgyWlwagKGC4cLYF5LyS9ZbP+9Htyh4OOtwgxfUY=; b=yZuVlaQXLmVsGGsrTvzOj+3iYDHS/MpO9DXST0pfKu/a8BJMF95uQJz0EQa+28t/mH mdtqkXqDXwwLphYrt9QGOxggqn0hHp+dbe2r0qrKBPpY9xAXlW/OemWYywo/gxRp6iTf anV0Ju9q0/SZ23Et50GrEJXg1JVmvJsl8w4Tx5jKHUbDAqaE/hPiLxdecWPcjNrgcCrf 90SwuX+Qh3OG9Psn6IhmdWpuvxxeCkctCAKXmPvDaIbA+Y7lhyZz+ZX/eBCyKREFpXqM 1Ruv3JevhsqBQOx5OkO3t7A+fsJQTjcOTx7bSRfqz92XzduwTqn1AZMwFO7kQG+NcbaW IwvQ== 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=iZePgyWlwagKGC4cLYF5LyS9ZbP+9Htyh4OOtwgxfUY=; b=dqbJCfHEtgUQF7ZBAOEgIHL6hxW/OZvi761+t536W8YJ6q8oJq3Z/QsUhMMMiOwDvi G6TEgQOwNnO+O+1arn7HB6yaIdHoNbvID0shrXOb7HjDcTvVfONGI3MttzGCyA60YeSD uVlxd0gKQ8iiUBVbqm64zJOJK9+kxdSJSLJRlH5SJ3wX2GemHp1gKMqucP5kOU6afotH bnLn6ssAApSusDUCMUyC9WDpj1TvcBBIKIVl8YFFbdxXpdKE+l5rZV4W8jOG6NaJRexO 1SoznMYyJrRXoBnzOQalzKT7eptMgUwr5bbVG2RsniTazJw8xl/pvJV2JmYQM+nkf/MD m4lA== X-Gm-Message-State: APjAAAWK0s7nTCLAu8avmRftjEeZPDkGOX6/ACI3hpXzjePvXGEBI9zj I9BqXf5xoGmNxSk9VwKsdJMctJuJwIxJ9A== X-Received: by 2002:a7b:cc0c:: with SMTP id f12mr19232885wmh.100.1565024505234; Mon, 05 Aug 2019 10:01:45 -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.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Aug 2019 10:01:44 -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 12/30] crypto: hisilicon/des - switch to new verification routines Date: Mon, 5 Aug 2019 20:00:19 +0300 Message-Id: <20190805170037.31330-13-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/hisilicon/sec/sec_algs.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) -- 2.17.1 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); }