From patchwork Sat Dec 19 03:30:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 345965 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp2710231jai; Fri, 18 Dec 2020 19:32:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJw+0bBS+DB5cM/WGoLFbnLU7XSvh3FWgRrf8v+AtxrUgT6Eguzs+cetrzr40ZzhXxwPpNr8 X-Received: by 2002:a50:e786:: with SMTP id b6mr7204170edn.242.1608348731958; Fri, 18 Dec 2020 19:32:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608348731; cv=none; d=google.com; s=arc-20160816; b=yt25Up8VKC6m6TOokYRaCZfHocrKAuDR0Le8npPtaxFgcjl8S75j9GUmK9htU+gSin kYutqPLFD4jCtLX+kmqZhk2A5P3KVcVvFgCGGL1KY8RaUAE2VdUpDdCkseksNSgK8ft8 4ji2yNSaaYCV1/1WRx7LNF6pIO+7z/ejBlM2aE5Yz4hDt0uZ7zIP8ILdsPV7G+j9FZO2 FXaE71O/gj3SI+Grkf/d2eJcAglO3zCMPGUpqbyfqfDxSW4n6hS2CUBpXQgh/LWH6xws eyyq3zHZkaEgpbG9ZTlhRyqBoIW3Om4/GhI02q9Qyx0G2rHX0RPnI+ulHPMVhMJEcGk5 ZMUQ== 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=NWmBSI3rgfXH89T9/wbJKTlTi6fOQblntPYf8aTknog=; b=SyNqE6kzIp1cUdoCUw1wxa+xUhfReimGWoaviAWsso7rGtTiXfbZRiSrXfGBbdqFyp CuCrU3M3w1/zIBxgTaQ6LWvodQy0jyfG++OWpCSHPD3oGptrryf3fMzDkQannsnTm1WI 3KG5NnAbu/P2/0VK01r+U5B5tifoQ8mPUckXNvgLwsMQ2WTTBm8o1sH9iUnGZqp2dyQC 0Qc4Vr3KPZOau/2XKr7Gv0czCz+xew8GDigHEP6YPVMj8hpedtn0EVyzEcK5pwFKVQmO Rsp0OLs3JdPKt76TnVfXziphG1XIcXrV7idfrJA+jNexarFTEsMtctMRzpucWC8yWMJ7 hsmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fdfkMeEb; 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 s2si7383558eds.424.2020.12.18.19.32.11; Fri, 18 Dec 2020 19:32:11 -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=fdfkMeEb; 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 S1726381AbgLSDbL (ORCPT + 2 others); Fri, 18 Dec 2020 22:31:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726177AbgLSDbL (ORCPT ); Fri, 18 Dec 2020 22:31:11 -0500 Received: from mail-qk1-x72f.google.com (mail-qk1-x72f.google.com [IPv6:2607:f8b0:4864:20::72f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B72B1C061282 for ; Fri, 18 Dec 2020 19:30:30 -0800 (PST) Received: by mail-qk1-x72f.google.com with SMTP id 186so4168794qkj.3 for ; Fri, 18 Dec 2020 19:30:30 -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=NWmBSI3rgfXH89T9/wbJKTlTi6fOQblntPYf8aTknog=; b=fdfkMeEbIF/ogIka6MkRNPRsKkbNsk6RNyKoC4E4EK6Nef87HL3SvZ7TgxCXWBP2yc yZqRgWMBsiixbHchFzD4Y/ifoUdwXPGH+5IPVRF7T7J7t8uuBXj7g3c0shCyXZB3qtoU 2wv1RxWdOJnN8vjm3R175fy/bk3vw3oHbyJSfNiZBJZrFdMzEtApq90hBagEr7LJOrgT orC8CHJK3Mbj7A5+dlp/Cyt+0f82X4Wvz7Ouv0FRJM+w3rY1TTyzaRskZQz9FuRk2YyC h90sq2e22Kwmy3ORYOYADjYI58Vy0M9JEgleHoaPkpIUbRJnM94f6sXl10eZosgXb4rX 5Jng== 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=NWmBSI3rgfXH89T9/wbJKTlTi6fOQblntPYf8aTknog=; b=CQVl+qt4x2pZasuKtWPnJq9+8fFLjm0AmmE1uiMuHByW175tILycOIh9MvNPcotGlA rIIx2dsbzmxDTRH9Y8UDekGWQ39Pfz7elT74u8qkeLIBQDxofaqG84OPX+9pLGHWZDxp VThl8KeaxeFeAjpo1EhGqhps79VfiOd5H8otjK3XUdnI2s2ugI1Ji4HuksP5ouHAIakw I9wvkXC6D0uHSV14sfoyKAaWCR43fKvK6Ft9gVShFshR65UDDe+JwsRnimwOOM1kzxOs gjDNKsEpNIz0ZCkUh+5G4yHj3iXBuRYGyN5Cg7AfS4Vit/TMxx54j1wZxGU1HZ6QRU8f 5Plw== X-Gm-Message-State: AOAM530o+iUzEEUXa6wUsvcpQQYb8KlLWo1ML/9lWXpmuMABMPCy1AJ6 6HeZ57sTCodKzCfl+kQH8GEk+Q== X-Received: by 2002:a05:620a:13a6:: with SMTP id m6mr7935004qki.319.1608348629959; Fri, 18 Dec 2020 19:30:29 -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 y16sm4376045qki.132.2020.12.18.19.30.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Dec 2020 19:30:29 -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 1/6] drivers: crypto: qce: sha: Restore/save sha1_state/sha256_state with qce_sha_reqctx in export/import Date: Fri, 18 Dec 2020 22:30:22 -0500 Message-Id: <20201219033027.3066042-2-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201219033027.3066042-1-thara.gopinath@linaro.org> References: <20201219033027.3066042-1-thara.gopinath@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Export and import interfaces save and restore partial transformation states. The partial states were being stored and restored in struct sha1_state for sha1/hmac(sha1) transformations and sha256_state for sha256/hmac(sha256) transformations.This led to a bunch of corner cases where improper state was being stored and restored. A few of the corner cases that turned up during testing are: - wrong byte_count restored if export/import is called twice without h/w transaction in between - wrong buflen restored back if the pending buffer length is exactly the block size. - wrong state restored if buffer length is 0. To fix these issues, save and restore the entire qce_sha_rctx structure instead of parts of it in sha1_state and sha256_state structures. This in turn simplifies the export and import apis. Signed-off-by: Thara Gopinath --- drivers/crypto/qce/sha.c | 93 ++++------------------------------------ 1 file changed, 8 insertions(+), 85 deletions(-) -- 2.25.1 diff --git a/drivers/crypto/qce/sha.c b/drivers/crypto/qce/sha.c index 61c418c12345..b8428da6716d 100644 --- a/drivers/crypto/qce/sha.c +++ b/drivers/crypto/qce/sha.c @@ -139,97 +139,20 @@ static int qce_ahash_init(struct ahash_request *req) static int qce_ahash_export(struct ahash_request *req, void *out) { - struct crypto_ahash *ahash = crypto_ahash_reqtfm(req); - struct qce_sha_reqctx *rctx = ahash_request_ctx(req); - unsigned long flags = rctx->flags; - unsigned int digestsize = crypto_ahash_digestsize(ahash); - unsigned int blocksize = - crypto_tfm_alg_blocksize(crypto_ahash_tfm(ahash)); - - if (IS_SHA1(flags) || IS_SHA1_HMAC(flags)) { - struct sha1_state *out_state = out; - - out_state->count = rctx->count; - qce_cpu_to_be32p_array((__be32 *)out_state->state, - rctx->digest, digestsize); - memcpy(out_state->buffer, rctx->buf, blocksize); - } else if (IS_SHA256(flags) || IS_SHA256_HMAC(flags)) { - struct sha256_state *out_state = out; - - out_state->count = rctx->count; - qce_cpu_to_be32p_array((__be32 *)out_state->state, - rctx->digest, digestsize); - memcpy(out_state->buf, rctx->buf, blocksize); - } else { - return -EINVAL; - } - - return 0; -} - -static int qce_import_common(struct ahash_request *req, u64 in_count, - const u32 *state, const u8 *buffer, bool hmac) -{ - struct crypto_ahash *ahash = crypto_ahash_reqtfm(req); struct qce_sha_reqctx *rctx = ahash_request_ctx(req); - unsigned int digestsize = crypto_ahash_digestsize(ahash); - unsigned int blocksize; - u64 count = in_count; - - blocksize = crypto_tfm_alg_blocksize(crypto_ahash_tfm(ahash)); - rctx->count = in_count; - memcpy(rctx->buf, buffer, blocksize); - - if (in_count <= blocksize) { - rctx->first_blk = 1; - } else { - rctx->first_blk = 0; - /* - * For HMAC, there is a hardware padding done when first block - * is set. Therefore the byte_count must be incremened by 64 - * after the first block operation. - */ - if (hmac) - count += SHA_PADDING; - } - rctx->byte_count[0] = (__force __be32)(count & ~SHA_PADDING_MASK); - rctx->byte_count[1] = (__force __be32)(count >> 32); - qce_cpu_to_be32p_array((__be32 *)rctx->digest, (const u8 *)state, - digestsize); - rctx->buflen = (unsigned int)(in_count & (blocksize - 1)); + memcpy(out, rctx, sizeof(struct qce_sha_reqctx)); return 0; } static int qce_ahash_import(struct ahash_request *req, const void *in) { - struct qce_sha_reqctx *rctx; - unsigned long flags; - bool hmac; - int ret; - - ret = qce_ahash_init(req); - if (ret) - return ret; - - rctx = ahash_request_ctx(req); - flags = rctx->flags; - hmac = IS_SHA_HMAC(flags); - - if (IS_SHA1(flags) || IS_SHA1_HMAC(flags)) { - const struct sha1_state *state = in; + struct qce_sha_reqctx *rctx = ahash_request_ctx(req); - ret = qce_import_common(req, state->count, state->state, - state->buffer, hmac); - } else if (IS_SHA256(flags) || IS_SHA256_HMAC(flags)) { - const struct sha256_state *state = in; + memcpy(rctx, in, sizeof(struct qce_sha_reqctx)); - ret = qce_import_common(req, state->count, state->state, - state->buf, hmac); - } - - return ret; + return 0; } static int qce_ahash_update(struct ahash_request *req) @@ -450,7 +373,7 @@ static const struct qce_ahash_def ahash_def[] = { .drv_name = "sha1-qce", .digestsize = SHA1_DIGEST_SIZE, .blocksize = SHA1_BLOCK_SIZE, - .statesize = sizeof(struct sha1_state), + .statesize = sizeof(struct qce_sha_reqctx), .std_iv = std_iv_sha1, }, { @@ -459,7 +382,7 @@ static const struct qce_ahash_def ahash_def[] = { .drv_name = "sha256-qce", .digestsize = SHA256_DIGEST_SIZE, .blocksize = SHA256_BLOCK_SIZE, - .statesize = sizeof(struct sha256_state), + .statesize = sizeof(struct qce_sha_reqctx), .std_iv = std_iv_sha256, }, { @@ -468,7 +391,7 @@ static const struct qce_ahash_def ahash_def[] = { .drv_name = "hmac-sha1-qce", .digestsize = SHA1_DIGEST_SIZE, .blocksize = SHA1_BLOCK_SIZE, - .statesize = sizeof(struct sha1_state), + .statesize = sizeof(struct qce_sha_reqctx), .std_iv = std_iv_sha1, }, { @@ -477,7 +400,7 @@ static const struct qce_ahash_def ahash_def[] = { .drv_name = "hmac-sha256-qce", .digestsize = SHA256_DIGEST_SIZE, .blocksize = SHA256_BLOCK_SIZE, - .statesize = sizeof(struct sha256_state), + .statesize = sizeof(struct qce_sha_reqctx), .std_iv = std_iv_sha256, }, }; From patchwork Sat Dec 19 03:30:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 345964 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp2710225jai; Fri, 18 Dec 2020 19:32:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJzVA6hXNhH6uZYju60sy1GHtXWP3U4W4hpJrLLTIQzBY731UI2+ED5szR4VanePAS5SQxmw X-Received: by 2002:a17:906:68d1:: with SMTP id y17mr6937469ejr.447.1608348731600; Fri, 18 Dec 2020 19:32:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608348731; cv=none; d=google.com; s=arc-20160816; b=k93nceM85GMoRFG9wBSNoGcyAZnA7Ie4krGlc3MS8efk7ddqG2A/81tSL6VQh40sid 3GJxjbmfCswYef31oliXP3jwWhFkgJzWLo7TfmCubMzkbsrWJnyO1wv9/ilJcLT1v9Ym S76KRdahgi3o06TV4dV4hEyM4bw9Qxa8gx3j7mNOUISyrIXhzfyUyjzpJF4NWIrdrn68 EL/QVFYRBo9zTqXOFZbhhd6cahDppq90W4eZQ2o7qkdkU2hGfq83vEC33mezxx6eOGJ2 Uo/SMv9qqxUZE8mtRO3otcuyEYNdx3ixIspqFXewDUAOiaMrQIpF87DddUZrDZB+Ahg8 5XPA== 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=G+dMsLBrY99BUWGLKr1cRQ/g1Fbgha5c1iEnYj8qjJo=; b=Qh4ABDSwZC8uB7xkrNriNXKZCgdbO/44Ly6uxeTQIoBAVbBDOT6eEUdawn1e+x6ot7 r3hy/dUVUhpjmgL7W50rnmY3LLI0gIYENQ3gSraMEiBJ1nglFDu6YioHOW2OKiEtST4D Juym3R6Sf0Rdex7VirsyQKuPn0yrraSm6EKDNNSwSJU6JerXyf9V2uykN/7EDkHP5ytT KAObcvnkzwWU7vzbPnQDjJHHw02SeOxlyAJ7iHCi8eHy3a/V2GX74AKxZS6ogRk5jQtV ITlaks6kLDgHqoKSaPPHETEzU84BOcyZpUrwwpMMM4u0kFYj5dxgn62SsNtu3iTD/4OI I87w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vT8jy5Mp; 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 s2si7383558eds.424.2020.12.18.19.32.11; Fri, 18 Dec 2020 19:32:11 -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=vT8jy5Mp; 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 S1726411AbgLSDbM (ORCPT + 2 others); Fri, 18 Dec 2020 22:31:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726177AbgLSDbM (ORCPT ); Fri, 18 Dec 2020 22:31:12 -0500 Received: from mail-qk1-x72f.google.com (mail-qk1-x72f.google.com [IPv6:2607:f8b0:4864:20::72f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9F29C061248 for ; Fri, 18 Dec 2020 19:30:31 -0800 (PST) Received: by mail-qk1-x72f.google.com with SMTP id f26so2508959qka.0 for ; Fri, 18 Dec 2020 19:30:31 -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=G+dMsLBrY99BUWGLKr1cRQ/g1Fbgha5c1iEnYj8qjJo=; b=vT8jy5MptC7VW2zdcTnk29uYgSz67EeJOfAP4ek4gPwzqbeurSmmjfcUW9xpmBn2zf hTEOcc7PR7X0O2TeTsexiKHG9k7tD3TG4JxiBSlLhgOIITNcdWgbN1zcYBWPsIrA1vU4 iA47XFB35EOXuYsPkWL2ovbUfR9QYXKe9n+jgBrlCHKyFkNs3GAodS1ifcuFiasH47GU FPvErgetFEvolLBB6MDR2N58MQRkRrWbZyHi1hFj2cV5u/bO0RajCqxCYNeUMD14jty7 qYM26i6S9bL9TuKw5tLRlM6MN+Mhf5boMygkj9QzbexJ6JwbaKicCUkbYMCt3BUCzwyJ B5Cw== 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=G+dMsLBrY99BUWGLKr1cRQ/g1Fbgha5c1iEnYj8qjJo=; b=f1tkX8eVa1WX6jE0gEj5nGs5rzPsBJ9T0QtlAHOpSKH6VzzzCHwc75hvsU4F2tq3PB vpejdphIH4xW4gPMSyuQqN49+a4YLK7kIHh6oZQlYz3vnoLpEhJCPCsu3xAvcXQrhq1Q AGlELkHPn76gBTv0S++ib2zdXxb2xlBGhr9PO5GLk0DfGW5VlwGnR/MGEQ2N2NM0gxrp uaCvUFg/FL6GcSvlUO4gYmciyD00dy0cgDuBO1op2i8y9+moMG3D3n0YDRJedPfYJKOI qgLUsWDOwh1NIoz7mafmgHTZrwhRiNjgQbX2SRs8fXOBQ+3hMuZzU52+/AKuVEuPQcFd sN1Q== X-Gm-Message-State: AOAM5306rjbnJIXaG0fjykUKWu2lX0BYLy2fca/Kzgr/2XE6fO8PjGpH cVXnoEg/FEtbFYoyJ6pqHHKr1g== X-Received: by 2002:a05:620a:10b7:: with SMTP id h23mr8222309qkk.249.1608348631006; Fri, 18 Dec 2020 19:30:31 -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 y16sm4376045qki.132.2020.12.18.19.30.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Dec 2020 19:30:30 -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 2/6] drivers: crypto: qce: sha: Hold back a block of data to be transferred as part of final Date: Fri, 18 Dec 2020 22:30:23 -0500 Message-Id: <20201219033027.3066042-3-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201219033027.3066042-1-thara.gopinath@linaro.org> References: <20201219033027.3066042-1-thara.gopinath@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org If the available data to transfer is exactly a multiple of block size, save the last block to be transferred in qce_ahash_final (with the last block bit set) if this is indeed the end of data stream. If not this saved block will be transferred as part of next update. If this block is not held back and if this is indeed the end of data stream, the digest obtained will be wrong since qce_ahash_final will see that rctx->buflen is 0 and return doing nothing which in turn means that a digest will not be copied to the destination result buffer. qce_ahash_final cannot be made to alter this behavior and allowed to proceed if rctx->buflen is 0 because the crypto engine BAM does not allow for zero length transfers. Signed-off-by: Thara Gopinath --- drivers/crypto/qce/sha.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) -- 2.25.1 diff --git a/drivers/crypto/qce/sha.c b/drivers/crypto/qce/sha.c index b8428da6716d..02d89267a806 100644 --- a/drivers/crypto/qce/sha.c +++ b/drivers/crypto/qce/sha.c @@ -193,6 +193,25 @@ static int qce_ahash_update(struct ahash_request *req) /* calculate how many bytes will be hashed later */ hash_later = total % blocksize; + + /* + * At this point, there is more than one block size of data. If + * the available data to transfer is exactly a multiple of block + * size, save the last block to be transferred in qce_ahash_final + * (with the last block bit set) if this is indeed the end of data + * stream. If not this saved block will be transferred as part of + * next update. If this block is not held back and if this is + * indeed the end of data stream, the digest obtained will be wrong + * since qce_ahash_final will see that rctx->buflen is 0 and return + * doing nothing which in turn means that a digest will not be + * copied to the destination result buffer. qce_ahash_final cannot + * be made to alter this behavior and allowed to proceed if + * rctx->buflen is 0 because the crypto engine BAM does not allow + * for zero length transfers. + */ + if (!hash_later) + hash_later = blocksize; + if (hash_later) { unsigned int src_offset = req->nbytes - hash_later; scatterwalk_map_and_copy(rctx->buf, req->src, src_offset, From patchwork Sat Dec 19 03:30:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 345966 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp2710246jai; Fri, 18 Dec 2020 19:32:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJw6ss+N/vZH0puK8cA6JEN0K1BF9+L09DRK+Vj1Ffx2a8PCieaPJt3T/y+ujKMhrr8yY+fO X-Received: by 2002:a17:906:118c:: with SMTP id n12mr7024423eja.167.1608348733499; Fri, 18 Dec 2020 19:32:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608348733; cv=none; d=google.com; s=arc-20160816; b=xSLRWyUQ+TOgiM1kBI2tKPg2886M0y4m2cvgL/Oh1pm+K6E4zhACf5xuP3BUxUP1Mi 66Pl6hulzi8z8YbryIyq8PB9R5n/OajmGR1hNncFIQtHIpIZHvTH1/qZkmzEJnESlXsR KVkKmxdCK8Ph0qP9tcZ8T76bgrJZWeRd830J+xfoqsRNv5qRo9neCJ/uX9vQHfXeg+Ag mXMR+j/IERWXylS4pgneOnXn35Xcaa5jUe2g+V4dhxqOdDD/UM+TayjUUhogmItS09YB 053DuSgGDsTunfKtxaW8QSijQSyRpU7axkpnLPgewvdJ4u6qbA1Ebfk3tbe8B/eIrkAu Hu1Q== 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=bZGjT91YJf1hHkSmJvXhKwaeMO0DjPBWpAMf7imhySA=; b=NZE3ChcUvYp9GrprUYT+vIyQcgceKv9Miv1x0GN+Vm+Y+1KtHSoc2sFYqgaON6zzoS zdtLN7vw0VAipDx1GApG+hQRoc9VNfuMzrzss0M5BOi2833cgxnukruDTBAfEldfgFyK 8vQ/+XZMuMWyhJejNLJd5IxMmdO/v4OqI8GS76V+EqG1xRbSamY0GWCYcJp/0oADjTR6 H6Z9KQnx4stVS9/JqalGpjcGEEJqa1dZfB0XUsYZgke5F3+at/xMBpuNDy6weyMt1UN9 D+4h+Ce7y1HynUjSymrTX1b66yDUmI3VnemgPq02TrUp1md4hqsZ4gRMrYrWZCFJ6Lfg mROg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NEZrJXeG; 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 s2si7383558eds.424.2020.12.18.19.32.13; Fri, 18 Dec 2020 19:32:13 -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=NEZrJXeG; 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 S1726216AbgLSDbu (ORCPT + 2 others); Fri, 18 Dec 2020 22:31:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726132AbgLSDbu (ORCPT ); Fri, 18 Dec 2020 22:31:50 -0500 Received: from mail-qt1-x82e.google.com (mail-qt1-x82e.google.com [IPv6:2607:f8b0:4864:20::82e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FB66C0611CA for ; Fri, 18 Dec 2020 19:30:33 -0800 (PST) Received: by mail-qt1-x82e.google.com with SMTP id z9so2902250qtn.4 for ; Fri, 18 Dec 2020 19:30:33 -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=bZGjT91YJf1hHkSmJvXhKwaeMO0DjPBWpAMf7imhySA=; b=NEZrJXeG2hjCpLFDoS6wspfHNBQW3U7bK2mfIPyudAunW8Aha0vsICIkkB9HseUh25 L7Yj6UfY/BJvD/9UhqZZg70j6zdmDdOlrSf0OvOfr026YxwJnJCwrzJRqh96dLW8mzXR lHdppUcv9D1EuylMSSsnNBZ4jzYYxerJVy4q8xNTrcbuQuJrXaWF0YpO+QWzzlJQnJWs eE14CszJZUhYhzRHE/3k7H/b9MNkTkpL3ixGA1gn04EOScb/YzbhGxUwZ7Q7fnVzy7go Hh/GwQsZHpSk0+1A4u1kpahARxzesStefZjyUHiv6EjvxaVtl836mC869cbkYtK6npQs LVDQ== 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=bZGjT91YJf1hHkSmJvXhKwaeMO0DjPBWpAMf7imhySA=; b=D8ohFRBJafAryLro8xfdPbSwCShGmFn1fw3mGnJOcxCvhFF/ywlVqVznpXglq8b91+ Pxk6y96RYug1RsBYS9SNd06qxOkVAdycX0m835SwxS0dl9Clu+smjcL/fLNT5S2rvZ1m hfsPOsbGpPy3rtqdgyb2Rz/BnGRYB/gQGgkXJ9Cuh7Jrt9fjud1WZJSfwQw1/tRTM8rV PJmD959rY6SQCArr6cdmWdL3JcR50pa+FCK+okJBFulMi25hFwzKjMjrv1ygb9VnoPTJ UQsfF3DVyalaKrWgxFhTcwpl14QYDbNuLZ3Vh1lPD+SGny/xkPhU1IAzxAxyyuUEiYvD NLZw== X-Gm-Message-State: AOAM5329X8sb6gACCXkjfNhFHmP8vtCcXYe+v1WVSjEELn5MtktW9gcU JbH1KhtlTgMa+4cnmZarFNJrHA== X-Received: by 2002:ac8:5747:: with SMTP id 7mr7042392qtx.177.1608348632261; Fri, 18 Dec 2020 19:30:32 -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 y16sm4376045qki.132.2020.12.18.19.30.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Dec 2020 19:30:31 -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 3/6] drivers: crypto: qce: skcipher: Fix regressions found during fuzz testing Date: Fri, 18 Dec 2020 22:30:24 -0500 Message-Id: <20201219033027.3066042-4-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201219033027.3066042-1-thara.gopinath@linaro.org> References: <20201219033027.3066042-1-thara.gopinath@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org This patch contains the following fixes for the supported encryption algorithms in the Qualcomm crypto engine(CE) 1. Return unsupported if key1 = key2 for AES XTS algorithm since CE does not support this and the operation causes the engine to hang. 2. Return unsupprted if any three keys are same for DES3 algorithms since CE does not support this and the operation causes the engine to hang. 3. Return unsupported for 0 length plain texts since crypto engine BAM dma does not support 0 length data. 4. ECB messages do not have an IV and hence set the ivsize to 0. 5. Ensure that the data passed for ECB/CBC encryption/decryption is blocksize aligned. Otherwise the CE hangs on the operation. 6. Allow messages of length less that 512 bytes for all other encryption algorithms other than AES XTS. The recommendation is only for AES XTS to have data size greater than 512 bytes. Signed-off-by: Thara Gopinath --- drivers/crypto/qce/skcipher.c | 68 ++++++++++++++++++++++++++++++----- 1 file changed, 60 insertions(+), 8 deletions(-) -- 2.25.1 diff --git a/drivers/crypto/qce/skcipher.c b/drivers/crypto/qce/skcipher.c index a2d3da0ad95f..936bfb7c769b 100644 --- a/drivers/crypto/qce/skcipher.c +++ b/drivers/crypto/qce/skcipher.c @@ -167,16 +167,32 @@ static int qce_skcipher_setkey(struct crypto_skcipher *ablk, const u8 *key, struct crypto_tfm *tfm = crypto_skcipher_tfm(ablk); struct qce_cipher_ctx *ctx = crypto_tfm_ctx(tfm); unsigned long flags = to_cipher_tmpl(ablk)->alg_flags; + unsigned int __keylen; int ret; if (!key || !keylen) return -EINVAL; - switch (IS_XTS(flags) ? keylen >> 1 : keylen) { + /* + * AES XTS key1 = key2 not supported by crypto engine. + * Revisit to request a fallback cipher in this case. + */ + if (IS_XTS(flags)) { + __keylen = keylen >> 1; + if (!memcmp(key, key + __keylen, __keylen)) + return -EINVAL; + } else { + __keylen = keylen; + } + switch (__keylen) { case AES_KEYSIZE_128: case AES_KEYSIZE_256: memcpy(ctx->enc_key, key, keylen); break; + case AES_KEYSIZE_192: + break; + default: + return -EINVAL; } ret = crypto_skcipher_setkey(ctx->fallback, key, keylen); @@ -204,12 +220,27 @@ static int qce_des3_setkey(struct crypto_skcipher *ablk, const u8 *key, unsigned int keylen) { struct qce_cipher_ctx *ctx = crypto_skcipher_ctx(ablk); + u32 _key[6]; int err; err = verify_skcipher_des3_key(ablk, key); if (err) return err; + /* + * The crypto engine does not support any two keys + * being the same for triple des algorithms. The + * verify_skcipher_des3_key does not check for all the + * below conditions. Return -ENOKEY in case any two keys + * are the same. Revisit to see if a fallback cipher + * is needed to handle this condition. + */ + memcpy(_key, key, DES3_EDE_KEY_SIZE); + if (!((_key[0] ^ _key[2]) | (_key[1] ^ _key[3])) || + !((_key[2] ^ _key[4]) | (_key[3] ^ _key[5])) || + !((_key[0] ^ _key[4]) | (_key[1] ^ _key[5]))) + return -ENOKEY; + ctx->enc_keylen = keylen; memcpy(ctx->enc_key, key, keylen); return 0; @@ -221,6 +252,7 @@ static int qce_skcipher_crypt(struct skcipher_request *req, int encrypt) struct qce_cipher_ctx *ctx = crypto_skcipher_ctx(tfm); struct qce_cipher_reqctx *rctx = skcipher_request_ctx(req); struct qce_alg_template *tmpl = to_cipher_tmpl(tfm); + unsigned int blocksize = crypto_skcipher_blocksize(tfm); int keylen; int ret; @@ -228,14 +260,34 @@ static int qce_skcipher_crypt(struct skcipher_request *req, int encrypt) rctx->flags |= encrypt ? QCE_ENCRYPT : QCE_DECRYPT; keylen = IS_XTS(rctx->flags) ? ctx->enc_keylen >> 1 : ctx->enc_keylen; - /* qce is hanging when AES-XTS request len > QCE_SECTOR_SIZE and - * is not a multiple of it; pass such requests to the fallback + /* CE does not handle 0 length messages */ + if (!req->cryptlen) + return -EINVAL; + + /* + * ECB and CBC algorithms require message lengths to be + * multiples of block size. + * TODO: The spec says AES CBC mode for certain versions + * of crypto engine can handle partial blocks as well. + * Test and enable such messages. + */ + if (IS_ECB(rctx->flags) || IS_CBC(rctx->flags)) + if (!IS_ALIGNED(req->cryptlen, blocksize)) + return -EINVAL; + + /* + * Conditions for requesting a fallback cipher + * AES-192 (not supported by crypto engine (CE)) + * AES-XTS request with len <= 512 byte (not recommended to use CE) + * AES-XTS request with len > QCE_SECTOR_SIZE and + * is not a multiple of it.(Revisit this condition to check if it is + * needed in all versions of CE) */ if (IS_AES(rctx->flags) && - (((keylen != AES_KEYSIZE_128 && keylen != AES_KEYSIZE_256) || - req->cryptlen <= aes_sw_max_len) || - (IS_XTS(rctx->flags) && req->cryptlen > QCE_SECTOR_SIZE && - req->cryptlen % QCE_SECTOR_SIZE))) { + ((keylen != AES_KEYSIZE_128 && keylen != AES_KEYSIZE_256) || + (IS_XTS(rctx->flags) && ((req->cryptlen <= aes_sw_max_len) || + (req->cryptlen > QCE_SECTOR_SIZE && + req->cryptlen % QCE_SECTOR_SIZE))))) { skcipher_request_set_tfm(&rctx->fallback_req, ctx->fallback); skcipher_request_set_callback(&rctx->fallback_req, req->base.flags, @@ -307,7 +359,7 @@ static const struct qce_skcipher_def skcipher_def[] = { .name = "ecb(aes)", .drv_name = "ecb-aes-qce", .blocksize = AES_BLOCK_SIZE, - .ivsize = AES_BLOCK_SIZE, + .ivsize = 0, .min_keysize = AES_MIN_KEY_SIZE, .max_keysize = AES_MAX_KEY_SIZE, }, From patchwork Sat Dec 19 03:30:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 345969 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp2710291jai; Fri, 18 Dec 2020 19:32:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJz+sXibPWOhBVt4zPnH6lk0sIvDUDGtAp3GnTyFpdcHq4N4CZijQehusGJW18RiC4TuOeEU X-Received: by 2002:aa7:db14:: with SMTP id t20mr7325815eds.158.1608348738332; Fri, 18 Dec 2020 19:32:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608348738; cv=none; d=google.com; s=arc-20160816; b=NC0aKgTjNaPGnTYQhs36x2qbTREONvj18B0+avfvD2YrHGfr4hPdHu4xa2utbdU5r2 0Ss8W6dv3dOUvsZlAhbzPdVso+YY1c+A9bZvfgbDnkyT9iZOmPRciMLJoQ5WHDUMSkfh gKKhhfNgIi2VzqAuqJOsCehJxyMWbJDhR0PX/LqLQEo3Ez+jsboiSn3rHTdnUOQc4HnR osntNfOvP/Clc8aoz9CvY4mB0btGCUvVs4bKq5z/tqBypaMjiSNZgJHcRc21AJKZraye pXOytpmh28L6FEP+o8orKx/O00WR1vl5O5s+UN4rtwWcPmdQHV/Vs3WA6D2fFYiedQqT 1iRA== 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=LrTDV1JC3FHqRkPuc+wq4o33QEiL82RGRHhUmIGgN6s=; b=H/pvfJTuP3nToSF0FbaEFqzh254YfGaWgrGppVD7xqk5D7bh0aMm+b82v1lchSWGIs 6fRPyX/sj/3fg1zOS+EBMkdrF1gq4wvPl+7zTuebVaS/IttPpFFditq3V7/yLMPvT4Bg Gc51dKkq/Jp0J3Nsc3p1E7nSSmb0eWWyTsr3J+loU+/Z1Q4Klz2+omhMI5nlPk4cwfnF qGy3mEhOV9QwxJJN4zsuTJxNQXQO2f01XXcVRFq/BoDQNRXw1t+aY8B56VoCpQGRhcjY 4ht8BaqV+Wkj+9QPYVWQ0KbIH7v4prdM+0NbDEi/CDVFHzyjnhJwLmkiIQrrG6zW/Epz r7rA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="FV0bA/gl"; 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 s2si7383558eds.424.2020.12.18.19.32.18; Fri, 18 Dec 2020 19:32:18 -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="FV0bA/gl"; 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 S1726221AbgLSDcM (ORCPT + 2 others); Fri, 18 Dec 2020 22:32:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725966AbgLSDbv (ORCPT ); Fri, 18 Dec 2020 22:31:51 -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 16771C0611CC for ; Fri, 18 Dec 2020 19:30:34 -0800 (PST) Received: by mail-qt1-x831.google.com with SMTP id 7so2926112qtp.1 for ; Fri, 18 Dec 2020 19:30:34 -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=LrTDV1JC3FHqRkPuc+wq4o33QEiL82RGRHhUmIGgN6s=; b=FV0bA/glG6mM2oq/0OIUCIVCj6ovoytZ5Qj/7e+wkIWZ2ELS8XCIiKnF6W4r6i7jRT CFWxHpAaKVstazgf50GOecmqvoxJ2c/3Af0zFXqfBCUnWWXQ3csgizyva8ZTedaBRUyp SlbsXze46vnkooO1wMFJVXrx/DLreGecZ7HHnYRpDtxesRsJPbyQiaUGm95dmA1Sa3dj UwcPkuerUDLJjuvenqZZs+gD6LhbxVI9wf19i/Lu9hfL5LGveHHuUCxxb05T7GkrQavn jjMUfR3lwsQfMjOjnOV+SrD3sgnnXrTlpuBtEZawPuKmA0uTzkWQNSg7GdlQ1D/LA+6q iT4A== 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=LrTDV1JC3FHqRkPuc+wq4o33QEiL82RGRHhUmIGgN6s=; b=IyjVbPp9hEYwz3wrrlz8penJ5eHzpyfr8QaTbpVwIVo0nbaObOeWNAmVkXnu7Gv3TP NVeXBn9wBWMl1bIGW4LJzJIQMyyO7dpaZ+zb71uL+giXBw9bz+VTDvQ+7XbZQsEDYl8c +bavyGfPvee1NSIOBBHFrE+dj/3lDVfd5e6S6CsqV3cfYkZeEFM9h7zcW9rbuRLv4TDF BXYUs+ITR6MO8/KEAzJpiL7ZcSu908PVASCH2Eis4fc5Uhevrfl/X5DMENFjGs9IlxFX EE+F8mg5jWOcjAP+Zldb8Um3muA1rbkfrN66W9e7uSW4w5tk6ZZoX0LkzWmuXsbAl5jj p+6w== X-Gm-Message-State: AOAM5318a1TsIRlvQak2mIc+NPTR6QsQCmWzpFiOB/cpzs6frIFdd2tV Q+ho5NRPH8Opvcb/NZF/PSObhg== X-Received: by 2002:ac8:5b82:: with SMTP id a2mr7248502qta.215.1608348633318; Fri, 18 Dec 2020 19:30:33 -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 y16sm4376045qki.132.2020.12.18.19.30.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Dec 2020 19:30:32 -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 4/6] drivers: crypto: qce: common: Set data unit size to message length for AES XTS transformation Date: Fri, 18 Dec 2020 22:30:25 -0500 Message-Id: <20201219033027.3066042-5-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201219033027.3066042-1-thara.gopinath@linaro.org> References: <20201219033027.3066042-1-thara.gopinath@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Set the register REG_ENCR_XTS_DU_SIZE to cryptlen for AES XTS transformation. Anything else causes the engine to return back wrong results. Signed-off-by: Thara Gopinath --- drivers/crypto/qce/common.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) -- 2.25.1 diff --git a/drivers/crypto/qce/common.c b/drivers/crypto/qce/common.c index 5006e74c40cd..7ae0b779563f 100644 --- a/drivers/crypto/qce/common.c +++ b/drivers/crypto/qce/common.c @@ -294,15 +294,15 @@ static void qce_xtskey(struct qce_device *qce, const u8 *enckey, { u32 xtskey[QCE_MAX_CIPHER_KEY_SIZE / sizeof(u32)] = {0}; unsigned int xtsklen = enckeylen / (2 * sizeof(u32)); - unsigned int xtsdusize; qce_cpu_to_be32p_array((__be32 *)xtskey, enckey + enckeylen / 2, enckeylen / 2); qce_write_array(qce, REG_ENCR_XTS_KEY0, xtskey, xtsklen); - /* xts du size 512B */ - xtsdusize = min_t(u32, QCE_SECTOR_SIZE, cryptlen); - qce_write(qce, REG_ENCR_XTS_DU_SIZE, xtsdusize); + /* Set data unit size to cryptlen. Anything else causes + * crypto engine to return back incorrect results. + */ + qce_write(qce, REG_ENCR_XTS_DU_SIZE, cryptlen); } static int qce_setup_regs_skcipher(struct crypto_async_request *async_req, From patchwork Sat Dec 19 03:30:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 345967 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp2710282jai; Fri, 18 Dec 2020 19:32:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJx6pqRPwZd0ITgAIFM14ip0SZl22if2a1LVYCi0Ev4KsHHykV+koFxQ22cJrfDGk7Vxxk1/ X-Received: by 2002:a05:6402:1d13:: with SMTP id dg19mr7309259edb.111.1608348736811; Fri, 18 Dec 2020 19:32:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608348736; cv=none; d=google.com; s=arc-20160816; b=mUYYxS6IM0RSeQy582hNKPxkR2qFhs4kJ9HZX841WhLugd9IDAsZSXT12qGiRHCYmc gyXA1CYaGbcOGSbd7sbVnzsMq3hWqUPFamGtbj3zz4HL1ca4LhSD7b9FK/92Y/GOr64h vlxXf63oQixDQf7RUWrY+v5oUQb7UhGZfdUzb2ym9J2zycvhhKXW/5ubwZWsmi5fFjan lAyNHKRagEARsUNFKgURd7aWxw/sMsxHE9bh8NJIo+BeF1iR9c8OfedItvqQDjVIpVVT rJiMDwCoNHwO02qmY0wp7fGLapnMDA5cLp8DbTtT1XHTqbq/Mufa2bFRLSkOUrSUq3U+ 9tJQ== 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=YJE2aPOEkLIKEj61l27Ctrd7+4+SFwAw4jzWQDD0G1c=; b=jKA5B+VUcwdPT3reKfjbCLj8FEmUpJN2kyciqISUhCUQFRZ168kGR1FeQiyjGDV49f RlIGni51VBR+mmP2UZ1bzKYrIkJkRyns3BwE++j/a/Lkj9SiYMuT6GR+bt2fnkCHt+9T uKTjR88di4vWfK5dfgnrCT2igy39zJcFPUt+0xI1GtCWqbhA2HcIXGaIaLuh033xZbNs M+bhY72S5S7iRSnFOOOgBByEuzuufGo1+e/w6BxJIOh3YsXtuvnwchB4d3NegcmCnvyq yodY7pVmyld8dEQdMRs9XzE3g4Y0XrvO/T3qOEJCuW+O5nteLR77UkzSw/n7qNwFVMau lP+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K77tGdpS; 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 s2si7383558eds.424.2020.12.18.19.32.16; Fri, 18 Dec 2020 19:32:16 -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=K77tGdpS; 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 S1726299AbgLSDcC (ORCPT + 2 others); Fri, 18 Dec 2020 22:32:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726476AbgLSDbv (ORCPT ); Fri, 18 Dec 2020 22:31:51 -0500 Received: from mail-qv1-xf32.google.com (mail-qv1-xf32.google.com [IPv6:2607:f8b0:4864:20::f32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 273C5C0611CE for ; Fri, 18 Dec 2020 19:30:35 -0800 (PST) Received: by mail-qv1-xf32.google.com with SMTP id p12so1936223qvj.13 for ; Fri, 18 Dec 2020 19:30:35 -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=YJE2aPOEkLIKEj61l27Ctrd7+4+SFwAw4jzWQDD0G1c=; b=K77tGdpSQ+xMM14yYMq1WYAAXE96zJ8N41hgJgBFYB3OEpifFIWHJuYoP/PJyhtstG H4aeCDacaVtKytY/VskSNfQEjIij2QkgzN2ym3MHhIE3xK6FOk2/wJTB5r490i7jTjOW 3KxOsLG/fA2f1oizKJiKhYnqyCmnTWkZ2ya/TNv2rLl6a83I1j8Zuu4s/U+VoIy0ZjJr IFFk5/ogPUTi63Pqs7Wpkbot9i5z71+XNuAGxVzff9D5gN2zGzw4YOAiEEZyczIl3I85 YuZFH5WxHP2hB3BnmoNyiLJPYWLhIDdftVqZsOG5RZxGKj83OuvAE/W7DAdnZNXt4Iit tJlA== 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=YJE2aPOEkLIKEj61l27Ctrd7+4+SFwAw4jzWQDD0G1c=; b=W1wJc/P+AexidnXy6odlaEMXxsXOb44JL0bIge0d+Bbb+LfNaioHpXOZqp2FIr/Ioz 8I3ZsdrYpHGVVDpk/sKV7nucEEc1IKdTqlKyMNfayKWpgB32jRC04rmIS45EkMQP7Rq+ eYv1hJ7v+jxMyJC0Qt1h0BaXuJwVZU9oRefM6W34HxAej+D3DTHVsKf+tUpF/h+wUNJA s4ovlxbs/t2vv8TbB6qn2SI2EWq/8QliHW5IaHP4gV0zfpHg9KNTc+af43VyDCg1YQyK bmdFYVgdcSJQikqy5cbiFLZp0GLZL+qHGAs7t1UKeW8mnotQH9bjOQjEpgmFV1TOqEBl GSyA== X-Gm-Message-State: AOAM532U2gEojzHf9zYNmffrAt4WLWC944x3LiwFOooqzW0gYyIBbvxU z7Upr3A9gARZabvfoTg57aftUA== X-Received: by 2002:a0c:b48c:: with SMTP id c12mr7632370qve.9.1608348634463; Fri, 18 Dec 2020 19:30:34 -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 y16sm4376045qki.132.2020.12.18.19.30.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Dec 2020 19:30:33 -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/6] drivers: crypto: qce: Remover src_tbl from qce_cipher_reqctx Date: Fri, 18 Dec 2020 22:30:26 -0500 Message-Id: <20201219033027.3066042-6-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201219033027.3066042-1-thara.gopinath@linaro.org> References: <20201219033027.3066042-1-thara.gopinath@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org src_table is unused and hence remove it from struct qce_cipher_reqctx Signed-off-by: Thara Gopinath --- drivers/crypto/qce/cipher.h | 1 - 1 file changed, 1 deletion(-) -- 2.25.1 diff --git a/drivers/crypto/qce/cipher.h b/drivers/crypto/qce/cipher.h index cffa9fc628ff..850f257d00f3 100644 --- a/drivers/crypto/qce/cipher.h +++ b/drivers/crypto/qce/cipher.h @@ -40,7 +40,6 @@ struct qce_cipher_reqctx { struct scatterlist result_sg; struct sg_table dst_tbl; struct scatterlist *dst_sg; - struct sg_table src_tbl; struct scatterlist *src_sg; unsigned int cryptlen; struct skcipher_request fallback_req; // keep at the end From patchwork Sat Dec 19 03:30:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 345968 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp2710277jai; Fri, 18 Dec 2020 19:32:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJydaKycH+J8pAudoToD2khol3hj2NJpvAzld0KzXtZwBUV2QKZiQ2t2O7h/es/5nhzPoPkH X-Received: by 2002:a17:906:39d5:: with SMTP id i21mr6719714eje.339.1608348736481; Fri, 18 Dec 2020 19:32:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608348736; cv=none; d=google.com; s=arc-20160816; b=OMEyXfmnFM/wDqulCh5NrF0JdwBaa6CyY/2SPte8FfidZrgmzUguDBLw/fLPPMGIzL 6JbMQF8YOgsVmcMe+P6V2gVlU3tOoaiVcATWWAAgZrGJ9h6VqyrZ5C1Yr3Xj8gjZqdLW QIf2q7w5Lz+ruWk1ulSIMxUhEaPkoKCN0pjUDkmwLiGFo6OqYK9owzj/+g3ASDxAKW0k UpCY+j8UJASwD8yxlkK76tZOfvGVeUFiMlg+T6nvTutKwkEdKvFnUuUy+tXE1uehwxWE 3vlSjBxwAhMsZNKLF9REUvvFiJZtYvPJCAKOvjG00cSVdXhqD+Psi2QFSFAESVdBldED K3vw== 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=vm+9qcF9rEIBSxmXyE4c8CtzzHn6VqYs01p3AiQrvhM=; b=upfljBoG4zyNMPHfZVKfh3pGuO4Kbcv6QV1uT4L112SMmEhm2Fp2NlosBeerzYQHLM CV591oo5JEK7aroHiQR1/WOekNTd0lvnH502HR43a3talETcQ2o4xzVx3Xqt3SZSJD3M qsd6PbHKyffN3fS05hDi8mAED9x1QhWRyXjXkxnPXwNNrCD90slWy8cEx+sGqWXM6bwF JxLnxARc3FKBaZ7WMFv9dxI5ucwQX8at0ecN606wo64VLUW2fHlI/+afSEMUWpormUkk 5YK51igBHMq9upySnllvrL/yWqJ1ZEC/5YQdbDU9gX54l0h8ChODzUkpE6hzjivkhpRZ KJjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WmRig25O; 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 s2si7383558eds.424.2020.12.18.19.32.16; Fri, 18 Dec 2020 19:32:16 -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=WmRig25O; 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 S1726288AbgLSDcB (ORCPT + 2 others); Fri, 18 Dec 2020 22:32:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726478AbgLSDbv (ORCPT ); Fri, 18 Dec 2020 22:31:51 -0500 Received: from mail-qt1-x830.google.com (mail-qt1-x830.google.com [IPv6:2607:f8b0:4864:20::830]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41D58C0611CF for ; Fri, 18 Dec 2020 19:30:36 -0800 (PST) Received: by mail-qt1-x830.google.com with SMTP id c14so2921755qtn.0 for ; Fri, 18 Dec 2020 19:30:36 -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=vm+9qcF9rEIBSxmXyE4c8CtzzHn6VqYs01p3AiQrvhM=; b=WmRig25OaCsRJ99xFfK78CHrKjJIOl6awPj8EWWovr/HiqgKw+BM3VA4F781QEXA6N zKJpgC6gCIZv4Y0IU/w6pCQ75INjpeNX5+QwGFMiaxcbU8HdoCxteLafRGMa+Dl8B3E3 LzCUo4k0ZhFn2FeAl0CLQKk5kTtpCoWxaksrQ8PELgRYyWKMa3UhMWEgF7cte9kBEJil lTlz74K9NhUUN8/vfKPEEy9b+mkCfINIOqMXkPN2GSthb542YqC/jrO2NJ7YtuIzQgCU auJi3hknIu4lhzEOkAV/gomLjCsHALqjbCkYEUSwDGJrOm4vFh6j0PUSINi1TdYbD3y6 FTvw== 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=vm+9qcF9rEIBSxmXyE4c8CtzzHn6VqYs01p3AiQrvhM=; b=HcnA99iCZBYiv2YMCKPXQgAhUCUza1RCmQ7HHNzHS8IKmEdeIYK0vdmn9/xLUfOVHM ruJokolTpDsz5cWxJzc9a1Q/I88kb6XdflC/5uoBq3pi89Gvtukn0FqWWCBcmtCTBcKw 3wfFuXiqs5lnXMbb8dM1X2CiwkMYjS5W/JcmZa+I7BDedCw4DWt2bpH1gZQrfMaOhYSy GtbtWCG73Py7djvemQbJhszFRgx++wv8AiVwFTa5U+Petz4MQlu3hIuMycqUzePKcfGj 93oO6JH8d06oIQ6h/bGlBYPH2o23NlFanv/ALnub3Hgey5g1LqUwmuycm1QClLjM5h5v XxbA== X-Gm-Message-State: AOAM5323yWgLRstHlMq/cMtK49ytx/z/t6WolHZiaHPdrDLigE6+Bt7g ATzYpbDPCEDmmDRDPpQcXcVeKA== X-Received: by 2002:ac8:6f77:: with SMTP id u23mr7328806qtv.118.1608348635518; Fri, 18 Dec 2020 19:30:35 -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 y16sm4376045qki.132.2020.12.18.19.30.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Dec 2020 19:30:34 -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 6/6] drivers: crypto: qce: Remove totallen and offset in qce_start Date: Fri, 18 Dec 2020 22:30:27 -0500 Message-Id: <20201219033027.3066042-7-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201219033027.3066042-1-thara.gopinath@linaro.org> References: <20201219033027.3066042-1-thara.gopinath@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org totallen is used to get the size of the data to be transformed. This is also available via nbytes or cryptlen in the qce_sha_reqctx and qce_cipher_ctx. Similarly offset convey nothing for the supported encryption and authentication transformations and is always 0. Remove these two redundant parameters in qce_start. Signed-off-by: Thara Gopinath --- drivers/crypto/qce/common.c | 17 +++++++---------- drivers/crypto/qce/common.h | 3 +-- drivers/crypto/qce/sha.c | 2 +- drivers/crypto/qce/skcipher.c | 2 +- 4 files changed, 10 insertions(+), 14 deletions(-) -- 2.25.1 diff --git a/drivers/crypto/qce/common.c b/drivers/crypto/qce/common.c index 7ae0b779563f..e292d8453ef6 100644 --- a/drivers/crypto/qce/common.c +++ b/drivers/crypto/qce/common.c @@ -139,8 +139,7 @@ static u32 qce_auth_cfg(unsigned long flags, u32 key_size) return cfg; } -static int qce_setup_regs_ahash(struct crypto_async_request *async_req, - u32 totallen, u32 offset) +static int qce_setup_regs_ahash(struct crypto_async_request *async_req) { struct ahash_request *req = ahash_request_cast(async_req); struct crypto_ahash *ahash = __crypto_ahash_cast(async_req->tfm); @@ -305,8 +304,7 @@ static void qce_xtskey(struct qce_device *qce, const u8 *enckey, qce_write(qce, REG_ENCR_XTS_DU_SIZE, cryptlen); } -static int qce_setup_regs_skcipher(struct crypto_async_request *async_req, - u32 totallen, u32 offset) +static int qce_setup_regs_skcipher(struct crypto_async_request *async_req) { struct skcipher_request *req = skcipher_request_cast(async_req); struct qce_cipher_reqctx *rctx = skcipher_request_ctx(req); @@ -366,7 +364,7 @@ static int qce_setup_regs_skcipher(struct crypto_async_request *async_req, qce_write(qce, REG_ENCR_SEG_CFG, encr_cfg); qce_write(qce, REG_ENCR_SEG_SIZE, rctx->cryptlen); - qce_write(qce, REG_ENCR_SEG_START, offset & 0xffff); + qce_write(qce, REG_ENCR_SEG_START, 0); if (IS_CTR(flags)) { qce_write(qce, REG_CNTR_MASK, ~0); @@ -375,7 +373,7 @@ static int qce_setup_regs_skcipher(struct crypto_async_request *async_req, qce_write(qce, REG_CNTR_MASK2, ~0); } - qce_write(qce, REG_SEG_SIZE, totallen); + qce_write(qce, REG_SEG_SIZE, rctx->cryptlen); /* get little endianness */ config = qce_config_reg(qce, 1); @@ -387,17 +385,16 @@ static int qce_setup_regs_skcipher(struct crypto_async_request *async_req, } #endif -int qce_start(struct crypto_async_request *async_req, u32 type, u32 totallen, - u32 offset) +int qce_start(struct crypto_async_request *async_req, u32 type) { switch (type) { #ifdef CONFIG_CRYPTO_DEV_QCE_SKCIPHER case CRYPTO_ALG_TYPE_SKCIPHER: - return qce_setup_regs_skcipher(async_req, totallen, offset); + return qce_setup_regs_skcipher(async_req); #endif #ifdef CONFIG_CRYPTO_DEV_QCE_SHA case CRYPTO_ALG_TYPE_AHASH: - return qce_setup_regs_ahash(async_req, totallen, offset); + return qce_setup_regs_ahash(async_req); #endif default: return -EINVAL; diff --git a/drivers/crypto/qce/common.h b/drivers/crypto/qce/common.h index 85ba16418a04..3bc244bcca2d 100644 --- a/drivers/crypto/qce/common.h +++ b/drivers/crypto/qce/common.h @@ -94,7 +94,6 @@ struct qce_alg_template { void qce_cpu_to_be32p_array(__be32 *dst, const u8 *src, unsigned int len); int qce_check_status(struct qce_device *qce, u32 *status); void qce_get_version(struct qce_device *qce, u32 *major, u32 *minor, u32 *step); -int qce_start(struct crypto_async_request *async_req, u32 type, u32 totallen, - u32 offset); +int qce_start(struct crypto_async_request *async_req, u32 type); #endif /* _COMMON_H_ */ diff --git a/drivers/crypto/qce/sha.c b/drivers/crypto/qce/sha.c index 02d89267a806..141cfe14574d 100644 --- a/drivers/crypto/qce/sha.c +++ b/drivers/crypto/qce/sha.c @@ -107,7 +107,7 @@ static int qce_ahash_async_req_handle(struct crypto_async_request *async_req) qce_dma_issue_pending(&qce->dma); - ret = qce_start(async_req, tmpl->crypto_alg_type, 0, 0); + ret = qce_start(async_req, tmpl->crypto_alg_type); if (ret) goto error_terminate; diff --git a/drivers/crypto/qce/skcipher.c b/drivers/crypto/qce/skcipher.c index 936bfb7c769b..2f327640b4de 100644 --- a/drivers/crypto/qce/skcipher.c +++ b/drivers/crypto/qce/skcipher.c @@ -143,7 +143,7 @@ qce_skcipher_async_req_handle(struct crypto_async_request *async_req) qce_dma_issue_pending(&qce->dma); - ret = qce_start(async_req, tmpl->crypto_alg_type, req->cryptlen, 0); + ret = qce_start(async_req, tmpl->crypto_alg_type); if (ret) goto error_terminate;