From patchwork Thu Apr 29 15:07:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 429264 Delivered-To: patch@linaro.org Received: by 2002:a02:c901:0:0:0:0:0 with SMTP id t1csp1668530jao; Thu, 29 Apr 2021 08:07:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz7UWNTsYoi2zncEG5GMtoUvxhyNunJea3VNMyhb1J6B2NhCpL01F8fMIATI/NOMzRykTYm X-Received: by 2002:a7b:c006:: with SMTP id c6mr487113wmb.129.1619708864747; Thu, 29 Apr 2021 08:07:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619708864; cv=none; d=google.com; s=arc-20160816; b=unkQ298mq0KtO7N7adVdmkuPRb4Bp2rMEVEv/XvcO/xxwqA2Mldc5FDMeKYrGvk4aq iVPlzuUoE1aVsqwfHJ+TLDrZo8bxOxDI5/4kJx/Ssukm2DibzrZnt2T2FOV3PYiExuMP 39AVET6gaEF1DkT5eXTQ7oxOblwMRWpBd1xk/JB8Ezx+8LVZGm9ridtAMvu9pwLzrFDT UOniOobrl2D5RtjgXCAFYy8QL3B2asFZUDgIYAQOb3iFFRX4NOEhHGPF/XmArpYe4o/7 bGBJFVLqnju9+iVzgRMsUkAQXlOlTLowEWCtNWi0SrvdhDeesrCZCr7HXiHz68VqAlYC 9Lrw== 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=wHIdoU8gmuAA7x+QZ3612OOOxooCO7GWN9KlzMj4N6o=; b=Zs0ICm3Ym2Bqlj4kyR1veBXwb5M6bCDnJZpVJcTP/9GrR5Z/1A73gTKyf58Ngb7GIF lRIhT5Rw0qFxvT+PonCA2u0T5EejRJ8NXpfBnUpte2+inrZSYDiFcm+lNIgNTaEKUwgL EvIGCXfIYviIg8jnWxUVqK1t96N6ju8jogoSnOF89tjQlKlpfEajErb+O2M9kTpzXv3P x9Wo8n0HnrbcsXfEPomfmM1Kejeshd2AKSUf+0irWgwZngT0U+xQaM8tUTELg/E5moXq DNiyYankSvCyuhJfYtE+llbwuTv3+XUnc+OGtV90UR2AQDFNV0kFiL3UsBfvC77XRIAP bcXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Eo/0W8k3"; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-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 b13si3443068ede.27.2021.04.29.08.07.44; Thu, 29 Apr 2021 08:07:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-msm-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="Eo/0W8k3"; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-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 S240756AbhD2PIM (ORCPT + 17 others); Thu, 29 Apr 2021 11:08:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240546AbhD2PIC (ORCPT ); Thu, 29 Apr 2021 11:08:02 -0400 Received: from mail-qt1-x82c.google.com (mail-qt1-x82c.google.com [IPv6:2607:f8b0:4864:20::82c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D228C06134A for ; Thu, 29 Apr 2021 08:07:15 -0700 (PDT) Received: by mail-qt1-x82c.google.com with SMTP id o21so21231338qtp.7 for ; Thu, 29 Apr 2021 08:07:15 -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=wHIdoU8gmuAA7x+QZ3612OOOxooCO7GWN9KlzMj4N6o=; b=Eo/0W8k3MDkCy/5T8LYxOiJ5zzg//aKA86ek1qmqe6/Qx3qbvqYEXvUfnDGpUj04rM D66xFlNx0QVzc/PjY9hkywdCUc/5HhB6ULrEHhUcItF3GlgE2hpvFvDWGZBENhAxXmqT 9o0Ht774VeqIOxWGjXzDJ1VYWlc9Yhp1H6O+X8uaujkYpjBxSYcv+OTLVmaZR1atP57z KXbLXoHZ8SS8DRvm8tRbzFc5r4pzgi1Dfw88lrWIoPddngPnOhNb9tg9q570LMekBkub EqYhQG79TxzGcpVn9lfwecXn088EMtbLAUT+HNosabN84WvTEH009DO2tmwA0KsQ5g6S JvKw== 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=wHIdoU8gmuAA7x+QZ3612OOOxooCO7GWN9KlzMj4N6o=; b=sTw7XwuS0pi6OH0/WjzPgJ71+u/lmBmtRjWXmICY876uVvE8GBkOmrR2Bo8DAQGMDA wXRULyuHcgeFnDTquCffykXJ1eweshXAa80Rkr9CLggaclVi/ELzbUYk0mISY/c2Vtn4 a3JgubWnZE3vi2zexbKfivus4L+dV08F7/6+RP6QIQuVn/DhXMKEvK6U6vyQzkjO2Fei 73JLKvFV8+PSDXzcwAI012/2W+saxgZpcjJAr3skLhdHVcF58jdVURoLPwJ1679y7jQu 8gz2Tja87kmnxzDd9qQygdI4lbt/pnfNCXXx7mpmpTaJzvAWEXW3zmwkLoVfHOTfKlA0 cQJg== X-Gm-Message-State: AOAM5328rR4kLGn+6+nd9EcE8lI4pqzMYETtDrPROOOJnlbgmP4Eek/h Wz19r77Qq9GZ+ZCmzpVRVAwPFg== X-Received: by 2002:ac8:4e52:: with SMTP id e18mr32024005qtw.297.1619708834201; Thu, 29 Apr 2021 08:07:14 -0700 (PDT) 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 j191sm2223822qke.131.2021.04.29.08.07.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Apr 2021 08:07:13 -0700 (PDT) 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, linux-arm-msm@vger.kernel.org Subject: [Patch v4 5/7] crypto: qce: common: Clean up qce_auth_cfg Date: Thu, 29 Apr 2021 11:07:05 -0400 Message-Id: <20210429150707.3168383-6-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210429150707.3168383-1-thara.gopinath@linaro.org> References: <20210429150707.3168383-1-thara.gopinath@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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 7b5bc5a6ae81..7b3d6caec1b2 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);