From patchwork Thu Feb 25 18:27:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 387236 Delivered-To: patch@linaro.org Received: by 2002:a02:290e:0:0:0:0:0 with SMTP id p14csp545353jap; Thu, 25 Feb 2021 10:30:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJy8NAaEmnRiHHyoyAsbKk6u6eDEsn2So36q/57D3uh7Cyzx6qAFpbiTSCD43aVYRqMk/Gni X-Received: by 2002:a17:906:380c:: with SMTP id v12mr3906979ejc.65.1614277809302; Thu, 25 Feb 2021 10:30:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614277809; cv=none; d=google.com; s=arc-20160816; b=bG1Q+AVSzhQS5C0L3sr14YNaQCEydE3lfrfhe2QWkTPaiQCKKBhsSYCUXGEyloD0uw opXsn6yGhPW0AtLZy2r+LbhZPN6/U+Sd2a0d8LkzkWePrK4azraNn+90+dejYUoUdo15 M3xPShqS9c8jUEbiyQQZA/sGAvfxoTLSqaHWeKFWUNU+XcCZq0nsQYAWfkzRKQJ93OTz XetPZ3JemSfWUEijWISy4y05OAKkuBoYsimLITk484TllyRYRdod2Pxh6qRAjYY04kP6 ilWLhZdWqt9JiJUdGsTyAEP2ZF+PnvOjkxUTHras1nyFVq1CIaOZsp8ODKer4+m/nRNH QqfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=GAQ7mJYjum/vJpvXxz96AjXoLhaENBWrKzXJpZF6Wpc=; b=s1CsENiOf7QQVkZ8fKYAz+M/gp9bz3z75W4dUuXpy22NsZeb3jGGR7Otb7J3afi7Rl 7FUovohZKr8KOn4yy+S4x4UU++fA8IaNHWRLFRM6am1SR8GxNXaMWPRAFEfzPG+Ba+iV +V47OM6bK2lp2GvHu1LZmLBEbWQIfI326T7e5NodFX8BIGmvgwBoegFIL+5Hyly98Abz qu5/qF+WbZyquV1KTD1bdG9XQeGMMyXfafTuSUFOahGyLaAtv6i+hEnJYz4r4+w+Pgys 5t5688gBdbH/nfKcemWitmxxfgCoCzupQUtKz52Tu7VPtocv6KXTeLBpQka9rCrqfpSx 0rDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Xm9ESYbM; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id a22si445986edv.24.2021.02.25.10.30.09; Thu, 25 Feb 2021 10:30:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Xm9ESYbM; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 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 S233313AbhBYS3i (ORCPT + 2 others); Thu, 25 Feb 2021 13:29:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233329AbhBYS3A (ORCPT ); Thu, 25 Feb 2021 13:29:00 -0500 Received: from mail-qt1-x831.google.com (mail-qt1-x831.google.com [IPv6:2607:f8b0:4864:20::831]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C5DDC0617AB for ; Thu, 25 Feb 2021 10:27:24 -0800 (PST) Received: by mail-qt1-x831.google.com with SMTP id b3so4796207qtj.10 for ; Thu, 25 Feb 2021 10:27:24 -0800 (PST) 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=GAQ7mJYjum/vJpvXxz96AjXoLhaENBWrKzXJpZF6Wpc=; b=Xm9ESYbMwNOE9d/S9JmjWwMQHdzA3z/nIxKsXy8gYGkLDEspN18hoo9Gg+YLcR7F5I 9RTdXgBd+E1pV26DsDLCd0Y+Iad5pbS/lOktAImnzW1/rihvkwAWN8NBUu7BYevRSIdk 5rUES/n/jujaK1YKrTTrDtmfXS5KM+Xdz4Gc5HUrB5OK7RAaVtiSKn27rcmFgcjOJsP+ Z9Fd15Mh3XcCcgsl+ReyQ4VlmqbuvItEMQwxRixASWUQJEI2VOe0khPyGpqL7bQB7xby cxy49D6ejeI4lft6DCZEGc1c8DMZ8CW5C1VXgOlMXBwS8iKXf8cB8g2AGp8TNoroaVXv UJZw== 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=GAQ7mJYjum/vJpvXxz96AjXoLhaENBWrKzXJpZF6Wpc=; b=UXhqSjCy83WB3RPd4R4TEoO5B6aJZSA3wYXK4WfTKvA8b0jivrMCZtAj8J3iHGBZ1a 51kWWSNa3hjA/IckZ2bqfk7f24Ha4DW5woTAXFeQbeECAMR0uAoqOBAiCYsxmW3bixfV 2dlkfQA1Sw6jf068Hf8SIDTc5x5dXuJR6Fmu+tMtFBKCZRUPv4AXcYMrQzeR1LXN/Dn+ hKfMGQuVZIlPwauKI5FpcLjCTy5alF688Frt7eveg8DcurD9t2n5UIUCEtr22UAr0jo2 2Yl0a+pa4zEIRYuwjehOwOSubOUiKSzI8bWGZqDUJx8JJl5HyKl9ZqiRzXXhIYOvCdtW 3OXw== X-Gm-Message-State: AOAM5337C7k/UZWT7/uwN2wg9rlvyNFxy3/R0X7sE+bE+nRLTHcASFEs +glw/H4VSMwx0d0xw4f2N7eIvg== X-Received: by 2002:ac8:45d3:: with SMTP id e19mr3686016qto.232.1614277641834; Thu, 25 Feb 2021 10:27:21 -0800 (PST) Received: from pop-os.fios-router.home (pool-71-163-245-5.washdc.fios.verizon.net. [71.163.245.5]) by smtp.googlemail.com with ESMTPSA id l65sm4519678qkf.113.2021.02.25.10.27.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Feb 2021 10:27:21 -0800 (PST) From: Thara Gopinath To: herbert@gondor.apana.org.au, davem@davemloft.net, bjorn.andersson@linaro.org Cc: ebiggers@google.com, ardb@kernel.org, sivaprak@codeaurora.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/7] crypto: qce: common: Clean up qce_auth_cfg Date: Thu, 25 Feb 2021 13:27:14 -0500 Message-Id: <20210225182716.1402449-6-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210225182716.1402449-1-thara.gopinath@linaro.org> References: <20210225182716.1402449-1-thara.gopinath@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Remove various redundant checks in qce_auth_cfg. Also allow qce_auth_cfg to take auth_size as a parameter which is a required setting for ccm(aes) algorithms Signed-off-by: Thara Gopinath --- drivers/crypto/qce/common.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) -- 2.25.1 diff --git a/drivers/crypto/qce/common.c b/drivers/crypto/qce/common.c index 2485aa371d83..05a71c5ecf61 100644 --- a/drivers/crypto/qce/common.c +++ b/drivers/crypto/qce/common.c @@ -97,11 +97,11 @@ static inline void qce_crypto_go(struct qce_device *qce, bool result_dump) } #ifdef CONFIG_CRYPTO_DEV_QCE_SHA -static u32 qce_auth_cfg(unsigned long flags, u32 key_size) +static u32 qce_auth_cfg(unsigned long flags, u32 key_size, u32 auth_size) { u32 cfg = 0; - if (IS_AES(flags) && (IS_CCM(flags) || IS_CMAC(flags))) + if (IS_CCM(flags) || IS_CMAC(flags)) cfg |= AUTH_ALG_AES << AUTH_ALG_SHIFT; else cfg |= AUTH_ALG_SHA << AUTH_ALG_SHIFT; @@ -119,15 +119,16 @@ static u32 qce_auth_cfg(unsigned long flags, u32 key_size) cfg |= AUTH_SIZE_SHA256 << AUTH_SIZE_SHIFT; else if (IS_CMAC(flags)) cfg |= AUTH_SIZE_ENUM_16_BYTES << AUTH_SIZE_SHIFT; + else if (IS_CCM(flags)) + cfg |= (auth_size - 1) << AUTH_SIZE_SHIFT; if (IS_SHA1(flags) || IS_SHA256(flags)) cfg |= AUTH_MODE_HASH << AUTH_MODE_SHIFT; - else if (IS_SHA1_HMAC(flags) || IS_SHA256_HMAC(flags) || - IS_CBC(flags) || IS_CTR(flags)) + else if (IS_SHA1_HMAC(flags) || IS_SHA256_HMAC(flags)) cfg |= AUTH_MODE_HMAC << AUTH_MODE_SHIFT; - else if (IS_AES(flags) && IS_CCM(flags)) + else if (IS_CCM(flags)) cfg |= AUTH_MODE_CCM << AUTH_MODE_SHIFT; - else if (IS_AES(flags) && IS_CMAC(flags)) + else if (IS_CMAC(flags)) cfg |= AUTH_MODE_CMAC << AUTH_MODE_SHIFT; if (IS_SHA(flags) || IS_SHA_HMAC(flags)) @@ -136,10 +137,6 @@ static u32 qce_auth_cfg(unsigned long flags, u32 key_size) if (IS_CCM(flags)) cfg |= QCE_MAX_NONCE_WORDS << AUTH_NONCE_NUM_WORDS_SHIFT; - if (IS_CBC(flags) || IS_CTR(flags) || IS_CCM(flags) || - IS_CMAC(flags)) - cfg |= BIT(AUTH_LAST_SHIFT) | BIT(AUTH_FIRST_SHIFT); - return cfg; } @@ -171,7 +168,7 @@ static int qce_setup_regs_ahash(struct crypto_async_request *async_req) qce_clear_array(qce, REG_AUTH_KEY0, 16); qce_clear_array(qce, REG_AUTH_BYTECNT0, 4); - auth_cfg = qce_auth_cfg(rctx->flags, rctx->authklen); + auth_cfg = qce_auth_cfg(rctx->flags, rctx->authklen, digestsize); } if (IS_SHA_HMAC(rctx->flags) || IS_CMAC(rctx->flags)) { @@ -199,7 +196,7 @@ static int qce_setup_regs_ahash(struct crypto_async_request *async_req) qce_write_array(qce, REG_AUTH_BYTECNT0, (u32 *)rctx->byte_count, 2); - auth_cfg = qce_auth_cfg(rctx->flags, 0); + auth_cfg = qce_auth_cfg(rctx->flags, 0, digestsize); if (rctx->last_blk) auth_cfg |= BIT(AUTH_LAST_SHIFT);