From patchwork Sun Feb 7 14:39:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 378109 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp3953835jah; Sun, 7 Feb 2021 06:41:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJy1ngKJXz+Zn4ANziamijPAdQIhXgiaxJHveP/Ek4y561EOtFZHlKvznDhxJhIL0JFP7gIR X-Received: by 2002:a17:906:ae50:: with SMTP id lf16mr13220339ejb.66.1612708915599; Sun, 07 Feb 2021 06:41:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612708915; cv=none; d=google.com; s=arc-20160816; b=A3OoDdvvRkGUdiiQMZJQzBkCPUQujyBbnTb077GPHH2NIrgsHveC3gAR7+YiaYT7aY hmSd/vaKI/2vKHArXRh2lJ9IRnKkmSlDfdsMc/Hzxt9Y144dSUw3BWEkE9+eWakeGj6E HoFjElei/joD4T4PgbTHBEAfeegpN/k/G5LMtzInf0XgqYgguE0HXI4bhFf4sXSSZ0P5 U9FwbBgtjYsHd4s2ypfR44+ISZFowzeH3iCqC9Ciq0ouhb/XS8br1JWo6e7rdGBr6mzX hIbj3MkdFu0xDrwm8o+BB0vcMW8a/aD3MGFmf5h+eDjvh98QSgE9ZHqm5/stZqru442b 6P1g== 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=+LusXxwTertju33lCOw7SpWeXYclxlP8wqkw1UaGEms=; b=grSmjHFoThLarLXPLzPcnozAXK4bPv7OcY9r08a7cgat5cNYzEdol15ZXOSN2Qd/kY RU7BwpPoeEdJE7VbrtLuLtAlvCoQ1s0qYDltd3Qn33JuNPGupV7ZaXhDb4l6CqlTulLE JCZzaGliLq8s4wj2iuqXIkghkRElVosZJpSeUTc9wvsnYO8wO5SNqzQBCuNZZ7SrGtgl +tiU4Z/atS8HLAVOQuANSa6oZVnMsptP+cdlfaYXB8kokyOPwzWf0C2ME59oYR2Ak8MC AeC1084TFr3dlKOkf4V33ZwKceAnHig+XRdct4LCFZW2mkGPzx7LVvP0pZn6GqmtDJkn at4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Pk2ChJ3U; 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 g26si9550734edy.55.2021.02.07.06.41.55; Sun, 07 Feb 2021 06:41:55 -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=Pk2ChJ3U; 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 S229795AbhBGOkb (ORCPT + 2 others); Sun, 7 Feb 2021 09:40:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229491AbhBGOka (ORCPT ); Sun, 7 Feb 2021 09:40:30 -0500 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 B2D40C061786 for ; Sun, 7 Feb 2021 06:39:49 -0800 (PST) Received: by mail-qt1-x82c.google.com with SMTP id l23so8594340qtq.13 for ; Sun, 07 Feb 2021 06:39:49 -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=+LusXxwTertju33lCOw7SpWeXYclxlP8wqkw1UaGEms=; b=Pk2ChJ3U/b2gZjnWdoIqyc4QGBP/viM9zsxlIhS70TUHEj1xqiJhrlZZfH6U/z9sO5 tKZAJXYP3fPuHxs81grSQwkJyqE8zualh7FHBqYQi3w3zPfCSJFWGWeU92h8DoySfIfn qm6oy95p72+9geN9WqQkpEEO6m12GGfbNEdZ1sCz8WTWilhI8l58Js6rTyM2iwJ8o8a5 LImoaAJWr6aZOVeQBPGh2ibjpTRPI1b4TwnnNtxCuovyivjM/mQeefP34YLUx/zz/jrJ x/m/aW89nT/evYNiMxBFradQ/wA9momYKhyP5iU11jyGzj/uqjtT+xnrnOCYD6MYbW6d YT7Q== 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=+LusXxwTertju33lCOw7SpWeXYclxlP8wqkw1UaGEms=; b=sf4hyfPMgAceF95drQjjUN+I6gpsXhHR8jCfruhcMl9RYtaKwNrqmyu+EefbGtnT7y Sm1cDgqj/yBJ1j7mBgHhkDSPMrbOYmNVkOHqn5TS9khD85sle+uViV7PjU4R9tUBYLDK eU0XO1wBzG9SJLZDUX/LedanNIAg2DLWZIwNhixPI3D3HQ45xVg+rIiK5/gGU/VxkA0E DUDwTXEvqRMSvtIDo/vfJ1bZLXSf2m5GD1MUge0mAQ4c7afSCdBOD2umkUC9c5JN499m GoABW0zxM2MAeaZaOK171lNz4HkIaDIvFqlO+gQ2oQij+U4fzbW1oc6XierJB/X7VLQh vlfA== X-Gm-Message-State: AOAM533H73LZNWN30Qfu5xeeshSvQR2FtZU29JVQALTuOxdIPNHIgw8N Zt6DGFN07hh3oZ//i9P5yc8G5g== X-Received: by 2002:ac8:3759:: with SMTP id p25mr2286162qtb.203.1612708788930; Sun, 07 Feb 2021 06:39:48 -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 c81sm13941493qkb.88.2021.02.07.06.39.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Feb 2021 06:39:48 -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 v6 01/11] crypto: qce: sha: Restore/save ahash state with custom struct in export/import Date: Sun, 7 Feb 2021 09:39:36 -0500 Message-Id: <20210207143946.2099859-2-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210207143946.2099859-1-thara.gopinath@linaro.org> References: <20210207143946.2099859-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 partial transformation state using the newly introduced qce_sha_saved_state struct. This ensures that all the pieces required to properly restart the transformation is captured and restored back Signed-off-by: Thara Gopinath --- drivers/crypto/qce/sha.c | 122 +++++++++++---------------------------- 1 file changed, 34 insertions(+), 88 deletions(-) -- 2.25.1 diff --git a/drivers/crypto/qce/sha.c b/drivers/crypto/qce/sha.c index 61c418c12345..7da562dca740 100644 --- a/drivers/crypto/qce/sha.c +++ b/drivers/crypto/qce/sha.c @@ -12,9 +12,15 @@ #include "core.h" #include "sha.h" -/* crypto hw padding constant for first operation */ -#define SHA_PADDING 64 -#define SHA_PADDING_MASK (SHA_PADDING - 1) +struct qce_sha_saved_state { + u8 pending_buf[QCE_SHA_MAX_BLOCKSIZE]; + u8 partial_digest[QCE_SHA_MAX_DIGESTSIZE]; + __be32 byte_count[2]; + unsigned int pending_buflen; + unsigned int flags; + u64 count; + bool first_blk; +}; static LIST_HEAD(ahash_algs); @@ -139,97 +145,37 @@ 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; - } + struct qce_sha_saved_state *export_state = out; - 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(export_state->pending_buf, rctx->buf, rctx->buflen); + memcpy(export_state->partial_digest, rctx->digest, sizeof(rctx->digest)); + export_state->byte_count[0] = rctx->byte_count[0]; + export_state->byte_count[1] = rctx->byte_count[1]; + export_state->pending_buflen = rctx->buflen; + export_state->count = rctx->count; + export_state->first_blk = rctx->first_blk; + export_state->flags = rctx->flags; 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; - - 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; + struct qce_sha_reqctx *rctx = ahash_request_ctx(req); + const struct qce_sha_saved_state *import_state = in; - ret = qce_import_common(req, state->count, state->state, - state->buf, hmac); - } + memset(rctx, 0, sizeof(*rctx)); + rctx->count = import_state->count; + rctx->buflen = import_state->pending_buflen; + rctx->first_blk = import_state->first_blk; + rctx->flags = import_state->flags; + rctx->byte_count[0] = import_state->byte_count[0]; + rctx->byte_count[1] = import_state->byte_count[1]; + memcpy(rctx->buf, import_state->pending_buf, rctx->buflen); + memcpy(rctx->digest, import_state->partial_digest, sizeof(rctx->digest)); - return ret; + return 0; } static int qce_ahash_update(struct ahash_request *req) @@ -450,7 +396,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_saved_state), .std_iv = std_iv_sha1, }, { @@ -459,7 +405,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_saved_state), .std_iv = std_iv_sha256, }, { @@ -468,7 +414,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_saved_state), .std_iv = std_iv_sha1, }, { @@ -477,7 +423,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_saved_state), .std_iv = std_iv_sha256, }, }; From patchwork Sun Feb 7 14:39:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 378110 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp3953851jah; Sun, 7 Feb 2021 06:41:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJySeBaK31hb8bvpRaWeP1Z4cfWObSDpM97n6b/2QBM/dWuYH87tdCO24sjCQYYhNt14jcJ6 X-Received: by 2002:a17:906:c1d9:: with SMTP id bw25mr12568140ejb.452.1612708916998; Sun, 07 Feb 2021 06:41:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612708916; cv=none; d=google.com; s=arc-20160816; b=aaz5FEsML2W2iGENRhLT6Jck49dVDnL/QquCUUamiuEQ6oq1Se9BsUDUWnyzifas6R j0luFTJtwZAZWJEVMQXkgUzUMWgWwqJcQH6egeByu6juwvXHQ+PgCNXaELZVuuR7wOBN w0f633Bp7xbQCFI/7P6Muytjr7BSuODGWGrVccOjvBwPbIqobAVnvvhBETWO0RtXBN3T fj/Y+wOc1hpcZ3dyvlsBZ6BFN6ZZ9RNS0kL3koUPq68PvlbrNaXq0gwqjWo21VWJBtth e3eLABR/Sk6Szkg9kt6/SCJwZj79Z4pOB461VQSkwW3oy+kJ/kUQnsURKhz/8+AkikWa +kog== 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=QL7UCH32HRfcwYFo/OihKYejmQ9XVroK1tPKK/3bNQ0=; b=Hw5JiWngDfOuUjdoO4gTv+h7PJoLao8vhKub2P8JHASwogxdeYO1o23Zyx/iRMFI7b LDWODrPr6fF2xC4VWFBKyMTM/xK32ZI5IxHmbW0O8FS0F6PAODKD9+UxrZBVwwMIVrLK sDRQEJ4Qmt74LJXKQHh9GLNShnKKQNOCIRP9VQaeDBHuLA5TYJ2DO7MCn0KSkIR8jOLK HS3d8+4y1r66RMzlGLvLWCU0+Ptv/TMx1ZJk3yv/j1rtDB1MoOXED/iqcDhZKb1d4Fof HWBoqgdz+VbcKYIeucRsEb4+uk+n9UhybUSl0+xeYGgcfSgusw7BHXE1Q7rcuwGeKtkM 7LxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eJtteYal; 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 g26si9550734edy.55.2021.02.07.06.41.56; Sun, 07 Feb 2021 06:41:56 -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=eJtteYal; 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 S229927AbhBGOlO (ORCPT + 2 others); Sun, 7 Feb 2021 09:41:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229506AbhBGOlL (ORCPT ); Sun, 7 Feb 2021 09:41:11 -0500 Received: from mail-qk1-x72d.google.com (mail-qk1-x72d.google.com [IPv6:2607:f8b0:4864:20::72d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB933C06178B for ; Sun, 7 Feb 2021 06:39:50 -0800 (PST) Received: by mail-qk1-x72d.google.com with SMTP id u20so11932932qku.7 for ; Sun, 07 Feb 2021 06:39:50 -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=QL7UCH32HRfcwYFo/OihKYejmQ9XVroK1tPKK/3bNQ0=; b=eJtteYalWZ91+K2C6akaMpspY+GsXxbUfl6WHlqZ1i3V1Pptqdt0DQ3P/XOsoEZcBD DnqgzYnJa+D3tgBbR83rlgpoExPLwI3dzeDncD1789fOnUEvG3/WGybKDpwRoKmcwGdJ tgUa7PHaTa1Cutu9CFLSXuflvBMSCWFBkEkjFT3FX9Ma+zolZ34AadTJldj3XT5kiYlr wsS8ojdQTmZKVB2hsxgQbYC44dYLCiu4iqIRHAWfoBF/4qbZVhGJ7bUzE7apkTQcckp7 PuG+9+mUIcJKvOK5n7zSww0kRNNrRabR2DLdY/GrxBhYceJdGwrT55rSBZ+l+5eAS+PX ug9w== 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=QL7UCH32HRfcwYFo/OihKYejmQ9XVroK1tPKK/3bNQ0=; b=GntTc+wCgwLvakpiPrgm/sZj2nICWos+0PPfH1GiNQk9UdQDcN3lQD8zfEJx3yDs27 cM9G8NbV/Aal0JugPSFL9uyNsMyJ8f/i8DxtbacMxYAwEiYmzpuEgq95iPPMCaGdRMG4 /UBXcnix/swzif9Sh/1Y6yPKhaPy3+BH7oSYtAqv3luKqKKBJGVnnvLEMxX7KvAeCOC5 ToyeZuzzD3Dt8h3swBK40iME+CtdEJEEjqrf7/tHbNJKRSr/bT+GikIzfpgBj6ojl/9I OSKEgtt9k82JJ/u+3lHoVnziuB236jkaa9HTeuOIQDaUY+lB3I8rjvXP0fsQwc2yTt4n JPrg== X-Gm-Message-State: AOAM533IaG0BJ+2WQeWJJo+awl5EvtlJTWshtLf5OManiC5o2+1EAmvV MhJMqPkVlAgqrkJ2KoCW5JRwJA== X-Received: by 2002:a37:b56:: with SMTP id 83mr12927210qkl.355.1612708789990; Sun, 07 Feb 2021 06:39:49 -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 c81sm13941493qkb.88.2021.02.07.06.39.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Feb 2021 06:39:49 -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 v6 02/11] crypto: qce: sha: Hold back a block of data to be transferred as part of final Date: Sun, 7 Feb 2021 09:39:37 -0500 Message-Id: <20210207143946.2099859-3-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210207143946.2099859-1-thara.gopinath@linaro.org> References: <20210207143946.2099859-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. Reviewed-by: Bjorn Andersson 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 7da562dca740..2813c9a27a6e 100644 --- a/drivers/crypto/qce/sha.c +++ b/drivers/crypto/qce/sha.c @@ -216,6 +216,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 Sun Feb 7 14:39:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 378113 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp3953872jah; Sun, 7 Feb 2021 06:41:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJwQKv4+qYXePiivNwK2cbsIP3CV/qERpcDHbLbpXfrD6STbn1VU02npPBKEm5+jNoICMEde X-Received: by 2002:a17:906:a448:: with SMTP id cb8mr12750387ejb.174.1612708918499; Sun, 07 Feb 2021 06:41:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612708918; cv=none; d=google.com; s=arc-20160816; b=i4W36w4eOe12iwm1gBXw3nMlIPhGoVeaILeTqCXShUt+BEvUl1/OYWEwYSHUVSrWTO s5+da0gB0fGIDHizrbTZvYSOunbr/2TwQIBRAOGqNFy/GSuQGcQNvJYU4Sz+Rksm2ubI ZvvOqMRdDFtC9waV34sOTaOWkn42jfMavys6cdsZMU/WlmVLx3Xnc7mgeVHpSIg9o8Gu RP/bilY4Km3Kc0gEhu+5eBOZ8Zir5bjbwh1BewLxy1eaW+CuVGYIplEZ5BWQgz+VzIfY sZS3gckDfcSF1kswrQHJC2hDjXkY4qy5QxbChdQCLL7JNRaLt7640eQAsKteeHkoBJy5 oNWg== 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=qH6pF/G1SFg+K0bTJv0NKKhaRdQW632kFeXNuGpnkfE=; b=S32eqA1vN/Vl5dBrhU4OJJBjkvmwmaSiyavgAPvk1RzmJMyTyad1P5De+t1ISpMi7R U34FwyOycvXX6bJCfwJrig6ZV29LA6XUF7TipM6fq4xq5dLdDcAje1JOoZraYwf+pP6d gNhASiMnLjy2yqTC1YfVuglnirmgz1GvK/8IiHRDgfmuVjxyi5sYRAFq3AeqggpqBNbG jrEh533TbJzZHE6nBsh/mVi3ZqxEMm9FWhTC3bY8ksMu68d/QNAWyOsFW81y6j77YNic 2GsEssU5oNws++cf9cl4dmjJLB807gAdI0Hiin5K6Ua4TK6QhsluZ043Dy3Cz/aeoBm3 KizQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tK0RaRfl; 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 g26si9550734edy.55.2021.02.07.06.41.58; Sun, 07 Feb 2021 06:41:58 -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=tK0RaRfl; 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 S229959AbhBGOlP (ORCPT + 2 others); Sun, 7 Feb 2021 09:41:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229615AbhBGOlL (ORCPT ); Sun, 7 Feb 2021 09:41:11 -0500 Received: from mail-qk1-x730.google.com (mail-qk1-x730.google.com [IPv6:2607:f8b0:4864:20::730]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83D26C06178C for ; Sun, 7 Feb 2021 06:39:51 -0800 (PST) Received: by mail-qk1-x730.google.com with SMTP id a12so11908821qkh.10 for ; Sun, 07 Feb 2021 06:39:51 -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=qH6pF/G1SFg+K0bTJv0NKKhaRdQW632kFeXNuGpnkfE=; b=tK0RaRfltPOjC5dp1sHYm+mCxuY0YDjYZ6xk71WaUByyrhWJkhni3fjIOWgzPNwGIm Kjx+O+3rSilNy9OhM/DmTYZx/u7mkOwIkEVAyHkwTJzhH5xFJl53HXAdSEEMBZkfwQ9v 8rIqDKCdRS9j0tQWc48BmXN7gNBa6kR45kc9VAgYxAE5LFbBFusbHC4x17PSGK2s/qnq ngy3VQX+dYuCZ/8MP15Wz64Q/1j5JA8hGpEGuHQiFh6Mk26Zo1kqp62YbhHKNVGln0gv XD/utxdmryUpjmMmIK1I143ah6L59XvFux7JN6BbNEJI35q0eyo3rO2LGv5KY0rfJBhR FJ4A== 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=qH6pF/G1SFg+K0bTJv0NKKhaRdQW632kFeXNuGpnkfE=; b=hk+1rELJynklNDTXAkrhEqQDP1yt6B8b+OGuayqc+FADKacce830/oe8Rzm2HZSumH 3vUOnyJSWyRNmtkFGvstsx4qWFUQv6Y2GwMe1zO2E5Gk26YPMkR9+JG/MW0qt+TFwgnx T+/IyPYpr+yD1gHdmVA/SkXYH2PlxziLVnZ+tv8O4FZZEnSH14Xk7VF0VIaiQmHhnzwk zEGRwxKk63mRKTp9ghsabr1s3SaOhlGST4fVM4TvWr3LkOJ80v3GBa5WJ4LDwyPzJhMJ ZPIbd7R9BIHXvGLG5ocvEVMnMBSAh4ZLf/Zvd3AuZfwLfhRsWYbFKfmKc/jMi27BGHBZ u54w== X-Gm-Message-State: AOAM531+6Oi0/3xJqOHP9ezTaqJN+qGzQJm4QSx2hoH5Ap5vB5qAwhKW nK8xJL6gkZfdUiz+4kFga/32NYzoMPpLCg== X-Received: by 2002:a37:418d:: with SMTP id o135mr12805811qka.426.1612708790818; Sun, 07 Feb 2021 06:39:50 -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 c81sm13941493qkb.88.2021.02.07.06.39.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Feb 2021 06:39:50 -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 v6 03/11] crypto: qce: skcipher: Return unsupported if key1 and key 2 are same for AES XTS algorithm Date: Sun, 7 Feb 2021 09:39:38 -0500 Message-Id: <20210207143946.2099859-4-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210207143946.2099859-1-thara.gopinath@linaro.org> References: <20210207143946.2099859-1-thara.gopinath@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Crypto engine does not support key1 = key2 for AES XTS algorithm; the operation hangs the engines. Return -EINVAL in case key1 and key2 are the same. Signed-off-by: Thara Gopinath --- drivers/crypto/qce/skcipher.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) -- 2.25.1 diff --git a/drivers/crypto/qce/skcipher.c b/drivers/crypto/qce/skcipher.c index a2d3da0ad95f..12955dcd53dd 100644 --- a/drivers/crypto/qce/skcipher.c +++ b/drivers/crypto/qce/skcipher.c @@ -167,16 +167,33 @@ 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 -ENOKEY; + } 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); From patchwork Sun Feb 7 14:39:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 378112 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp3953868jah; Sun, 7 Feb 2021 06:41:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJxByd/QCaup4aESxAydLG34PBMumdLqh5c7OHQ1UEDpDppmwaX53A4gJg6pdAXRRW6w7rKr X-Received: by 2002:a17:906:ad98:: with SMTP id la24mr13003091ejb.315.1612708918158; Sun, 07 Feb 2021 06:41:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612708918; cv=none; d=google.com; s=arc-20160816; b=URWlxhhnieBw52PrJdKF1OXtgBZNnVFNuZmHT20fvz1UyORaiAZQgnatcKww5ZH6Dw EkUrZBVYOwdahoilqjJBB4NfVd3IL5Fx3sE23yg5+1m3QymtMKyid70/ujILJd8/EFxO 5rDG0KeAIKJeaaMX0EP7prkkk1L81sWZFLMXQGbHO/vU28ta7dvaKDJ5ivD7SAKYuq0l c2iaEvD+g+PD+Bc1E8L+rU5ddWFu/0loyCUCjTAH8XXja1G7bQRm1U+mPHzsM60xnRZG RGK0Lv0+qFo2AfOeWJ93H6m1Wz9CmNXkg56Paccl7WST7RKbyUcF+aeuXIalh9IVzYgJ gAhA== 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=JO1AHf4uhYw2ez6Ve3o7chTARaAb1KHfpJckn1suQ+U=; b=iwa/z3gP7wFVD2CaCBpRAL6n5lUUdN15txS8wG12HXiG/7y7Y7+RYJkTZUnwrrip6C zdRLASklze+UWIc/OtyvVCfM70xmMUstOJoim6yi6hAS5axWafQE/2uXztVFnlH4TbZs JISEIURw9bKVoM1hjDUCYoIExXeGdTuJPkGB286ZZKydJLz2U0z063GeJcUO7WZIP678 bqbHTZe62K0/Wa+TijZ3hnGNh8wqbLpKq2slCk6WDNqaMqfstRv7u3SPPZR/iSe87bMr /S3APbJ1L16ymxhZNwvqIIRic2ac4zk6KUptPzI82CKbQ6Qn011V1eGVOothMb0rv03Z eEAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lhxu4kBq; 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 g26si9550734edy.55.2021.02.07.06.41.58; Sun, 07 Feb 2021 06:41:58 -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=lhxu4kBq; 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 S229939AbhBGOlP (ORCPT + 2 others); Sun, 7 Feb 2021 09:41:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229815AbhBGOlL (ORCPT ); Sun, 7 Feb 2021 09:41:11 -0500 Received: from mail-qk1-x736.google.com (mail-qk1-x736.google.com [IPv6:2607:f8b0:4864:20::736]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 697D8C061794 for ; Sun, 7 Feb 2021 06:39:52 -0800 (PST) Received: by mail-qk1-x736.google.com with SMTP id o193so2404828qke.11 for ; Sun, 07 Feb 2021 06:39:52 -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=JO1AHf4uhYw2ez6Ve3o7chTARaAb1KHfpJckn1suQ+U=; b=lhxu4kBqKdBzeGuBV04S9k+Q7UatH4gOcWyETDNOIumzGqSrnfMDfX/2zGLr4o3YnB CY4JOFt0FUG8W6iCFTHLlPyF7WERXEuusCIixIwpUqGIsb2FjniEjtY+W1kwUz+/9n+k 4RAuVvpb3tkwZBTe3F01MdSqMYo7PEU7bh5Xvo9/kJynW54s5ddAkkjysk4AKB1QyIdC PBHxOV5fTxE1BRfPEirROMf7jSp0Clj3tuma/TFEKVL5TdpSLWSZqQFwjfpIyD2/+Jef yfTk+UtrQEQEYeP97c9YBgKLNJCdfMPdl9N/ztIVnEbH9l28R3uXSCUV8niAHEYyhpd5 eJSg== 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=JO1AHf4uhYw2ez6Ve3o7chTARaAb1KHfpJckn1suQ+U=; b=tv18ab1AnDbQpok9AQh+uTYTRQBY5eNWs+rRL2aqfhvy5YcC5vsPFjtP3+sQcHRtxk xdaaWcSnHL/jXBVj/E4pSF5j9KTnXlRmldJ4pyiGR7catyD9QYzJZ6SVPCD4EkQV8PVZ NBGRCYrU9gvtkhZh9aI4uMzESHDkLh4sZYBzoqOUpZRcCTKGU5LxTa+ko//VoeaHQZYx 9xNQ/Dx5CZEY8PSGOAOTLjyxnklVWD2yJ/WbnDyWnQKqAKg/iM7gs9dMnKb7ywHmKk08 HGG/ER/yPGKvqi020fIgQjqw6KLjKMWJofRXT6HHpf+qMaSdO0eyJHMxAJmROLReeu4v AQ6g== X-Gm-Message-State: AOAM530VHCzzggEVk4qn8kdBPX+NVh0VCuqSMS7E/B129EYKFYqbVIeG BYpPO/qmBUzre9gm71/zCUJjvg== X-Received: by 2002:a05:620a:e03:: with SMTP id y3mr13093718qkm.467.1612708791684; Sun, 07 Feb 2021 06:39:51 -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 c81sm13941493qkb.88.2021.02.07.06.39.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Feb 2021 06:39:51 -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 v6 04/11] crypto: qce: skcipher: Return unsupported if any three keys are same for DES3 algorithms Date: Sun, 7 Feb 2021 09:39:39 -0500 Message-Id: <20210207143946.2099859-5-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210207143946.2099859-1-thara.gopinath@linaro.org> References: <20210207143946.2099859-1-thara.gopinath@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Return unsupported if any three keys are same for DES3 algorithms since CE does not support this and the operation causes the engine to hang. Signed-off-by: Thara Gopinath --- drivers/crypto/qce/skcipher.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) -- 2.25.1 diff --git a/drivers/crypto/qce/skcipher.c b/drivers/crypto/qce/skcipher.c index 12955dcd53dd..de1f37ed4ee6 100644 --- a/drivers/crypto/qce/skcipher.c +++ b/drivers/crypto/qce/skcipher.c @@ -221,12 +221,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; From patchwork Sun Feb 7 14:39:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 378114 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp3953876jah; Sun, 7 Feb 2021 06:42:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJzhFSdaY6Rjq5y60JU7bexvIX3cd0ov2B/GCCVa7ImSMLkCEJzTKJrZe/mtEhATZTvDJOZc X-Received: by 2002:a17:906:a099:: with SMTP id q25mr2533644ejy.549.1612708919916; Sun, 07 Feb 2021 06:41:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612708919; cv=none; d=google.com; s=arc-20160816; b=GoZO5wuTeU0FFgQ3PHdKLu1Uq7+0MXZcO7oitPRBPAquUsWikPpN2xmgB85yaqOYUi 3ECG92/wIPFdMNyPFbkQvsE8le98aCgyhhpRyMmw3IkGH93XULUf3nnhLoD0cT/GJbTa vduiiAJ5dDlb9jIQEJmp6rbDZoTpyjheTntYxaDBt9iK5zCcHYe6DfbFR+YO/e3ZCg9F oS+dJHhV83qUO1FOif4kDQ9JJhdiVVMWmjOSdBeOeQBAzkUdKQb7184LhIZbAdmYEx5g ayT75kz7nA6g2QSMsaRtbRLZTl+qVBUY4vE1TDc3Gtt197D0uTw053XPQWXzqFZZmeEe I8ZQ== 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=ImO8jkC+DpvrTwFdTRomeqFeWgN9hrI9w+kY9c6b/Eg=; b=RZVOrILEh9wFmBFKggkCqvTjvTLnZ+s1MlBdin6KMFvPiIhiKJWafwudKbwzu8sFAu UkBNglxGuHCvcxu5JmIIQDlUK8Xyb0+2C7/ulegIglBUam4isyjnDRL/RTRiEk3Y6SrC 8CgM8f3u/2tAVE2BlRzzsvHF6a3dUDHdw8SUiNPJVlGbsGWn+Fa1K9I7FGcRX4bmtCh1 eQAom+3rkDVunWS0oXqaKIkygMKbPvX/dz9+WFzsZ9XIZ777TzgEH/yAmthBpfzuXLDT 1g1fPwpkI4lAKUgkFNn9AO7WtuBaHpfEI0J1MIvs8+GE9FRh8/1DArfnC53EskIeKHI2 VHuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OCLgpZUE; 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 g26si9550734edy.55.2021.02.07.06.41.59; Sun, 07 Feb 2021 06:41:59 -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=OCLgpZUE; 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 S229892AbhBGOlT (ORCPT + 2 others); Sun, 7 Feb 2021 09:41:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229908AbhBGOlM (ORCPT ); Sun, 7 Feb 2021 09:41:12 -0500 Received: from mail-qk1-x732.google.com (mail-qk1-x732.google.com [IPv6:2607:f8b0:4864:20::732]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D71DC0617A9 for ; Sun, 7 Feb 2021 06:39:53 -0800 (PST) Received: by mail-qk1-x732.google.com with SMTP id x81so11978672qkb.0 for ; Sun, 07 Feb 2021 06:39:53 -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=ImO8jkC+DpvrTwFdTRomeqFeWgN9hrI9w+kY9c6b/Eg=; b=OCLgpZUE37foaDocZaEHBNJMw5JQFRlcV/GQrDUXCXyz99cMVjbMSB2FtH6tTfG2cx E40uoln4Rg3HMYsiCXRdjQ0iKjARyTtS7RBiPPm0LW+Hjo39/NnLxCUbYOsCpQplG8A0 jSwNYwfQnLgYzxJp9qkMP/VzDat7T+ILOMsk+sfT+x4fCiE4BqmogoreyTZb8eeIJ6jr tiwjBcMC3loAKNeFr9gudpWumDus6vUZbpx21UM3C/t//pjbauNLsDDn00iE6YDh4wpR cgwC1mh6tEq3/fSAYF0DtOEtS2J/DF0xxfFjtK9b1M7W+okZls1HwwHYzPlzwV6D/5z4 CpLA== 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=ImO8jkC+DpvrTwFdTRomeqFeWgN9hrI9w+kY9c6b/Eg=; b=PW02RMS1/kzBTbnscHTQPsKmINDvfFS+gljbNfF+gP3F7b64pcGXn1qpO78RM64PBd HuFtayrZeeKjwtTiWQlYsku/QtB/mQLulHW6Xw4D8FySXXcjhesl9hfxX2riGqA65Xf/ UGGN9SExRUCz6tVcA4iWzOLKJwfFxb2xMP0fHrsYkZgcwa/OIg3oDOQKT3eN53hL6hb6 hoH83Q9LfNpNKf1KVI5ui/CkwGTOzFlvRo9n0VnOQqheEvP/joNbbrzGsSidpMPXeyPx JlpGyjPhQ9XY8436PnK1D4uRu0cq6aypgIZ3e5eok9xMcu3aGdDFyXsyyOLNeCcU2Zlc 7oiA== X-Gm-Message-State: AOAM532OlPkEu9u0yryyFAGv+EC+NrQK5G3qXsWqmXocSzIKJZF6Fgzv 9plYZc+GgYTSIpUjZpsz2QNKYw== X-Received: by 2002:a05:620a:12d7:: with SMTP id e23mr12618290qkl.58.1612708792517; Sun, 07 Feb 2021 06:39:52 -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 c81sm13941493qkb.88.2021.02.07.06.39.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Feb 2021 06:39:52 -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 v6 05/11] crypto: qce: skcipher: Return error for zero length messages Date: Sun, 7 Feb 2021 09:39:40 -0500 Message-Id: <20210207143946.2099859-6-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210207143946.2099859-1-thara.gopinath@linaro.org> References: <20210207143946.2099859-1-thara.gopinath@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Crypto engine BAM dma does not support 0 length data. Return unsupported if zero length messages are passed for transformation. Signed-off-by: Thara Gopinath --- v5->v6: - Return 0 for zero length messages instead of -EOPNOTSUPP in the cipher algorithms as pointed out by Eric Biggers. drivers/crypto/qce/skcipher.c | 5 +++++ 1 file changed, 5 insertions(+) -- 2.25.1 diff --git a/drivers/crypto/qce/skcipher.c b/drivers/crypto/qce/skcipher.c index de1f37ed4ee6..96af40c2c8f3 100644 --- a/drivers/crypto/qce/skcipher.c +++ b/drivers/crypto/qce/skcipher.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -260,6 +261,10 @@ 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; + /* CE does not handle 0 length messages */ + if (!req->cryptlen) + return 0; + /* qce is hanging when AES-XTS request len > QCE_SECTOR_SIZE and * is not a multiple of it; pass such requests to the fallback */ From patchwork Sun Feb 7 14:39:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 378111 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp3953857jah; Sun, 7 Feb 2021 06:41:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJy4rVXw9d2PABv/f5fK/1/sXHY0mcrBKe6c+L1GXV13x/QOXOddQSw7DJxD8aw6fPIY7DDZ X-Received: by 2002:a05:6402:34c3:: with SMTP id w3mr13209409edc.3.1612708917338; Sun, 07 Feb 2021 06:41:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612708917; cv=none; d=google.com; s=arc-20160816; b=ZTeJkxtQ3K3q83D27UZzJHvAlLxF7WDYxj/LtdCj9+h7xw66fyGIpUoHtfGkbGZhdE s9zGlgl3okpUTW8qtMZLSVkZo/e9LKDOam1foyQnQW2X+ldIG/zfTqs+anI2aYzhHeZI o+MmhMtVH/Y3bNJLLXrbQk3D38SwOrSl1EwTh5emu5dkiZGVa31QI/khiTf+83lHa3el pB2Ij/aura3Tkt5GKxY0Hqyy7kEU0Ke2qEXT55/TGLqSiT31eGG6KZez6kuAv4iMrn6X vBHq5oANvHcXnS8Am6lwBTc1eYfimznkEah0bXhI/cn56SyRJbjKDnCPQc5ZcJpIJuvq Hjyw== 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=DZiqftGjZZeqxnGuzUfAaT6stfdHVGYnoCL8kLsn0Ng=; b=cK+lv5DHaqOd3NzRevoZtzgPWirPR86B7mLmTfn8JFbut3+mY32+e47OOiB9czx4Bj Rsn+71c432OU/cQJX4iFprZtqBCg54z2saVjODvo6WpLG7hzTzZQSk1TFjXXrljm6l3y aFHAX1bZ5KOtr66zhWE0CaX5ufVgD5U/6KXxazvexxoCrt1HP9Z4NDd2tzJhsrhp62l1 ruzpuuPZvMZTF/QgHl1kEoBVbnpvgr9Z0gLUkLYC3VVglZprJ00D2kP/tUCiBLSqYtrP xBHgU22mT2jPn/EDzyMHtou6IpKl2IfNRoA9OWErrQ4DGD0jdt3ie/cjeK8cAHnUFCVx ILGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HV2LKtCS; 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 g26si9550734edy.55.2021.02.07.06.41.57; Sun, 07 Feb 2021 06:41:57 -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=HV2LKtCS; 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 S229975AbhBGOlS (ORCPT + 2 others); Sun, 7 Feb 2021 09:41:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229892AbhBGOlM (ORCPT ); Sun, 7 Feb 2021 09:41:12 -0500 Received: from mail-qk1-x732.google.com (mail-qk1-x732.google.com [IPv6:2607:f8b0:4864:20::732]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 124A9C0617AA for ; Sun, 7 Feb 2021 06:39:54 -0800 (PST) Received: by mail-qk1-x732.google.com with SMTP id v206so277886qkb.3 for ; Sun, 07 Feb 2021 06:39:54 -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=DZiqftGjZZeqxnGuzUfAaT6stfdHVGYnoCL8kLsn0Ng=; b=HV2LKtCSh+i1BvBIs4cdUJkJ7QqIfp3lQD/DvNQHYyBC+hrpMdTYljRJiXIIcUyos5 K4LzMW38DczfHw5ppQpwECuSmoxypC+Tm1blEz3JnUaIkBZgUG3SvSCUcf/ZofzjHPex p7BYKI+7aArG29y6+g/GzRStkTLmuO2ZedWLsTKKvigu5zj2tkOolNiorSmuu7Tx8aF7 MbaMBDUh5R4EBNV2FMHBk1qImlb5ula8JpFnEKog46j9PCQd0lDwXvMUaXlYLeuzYg8r ky7ZzvOyJ56M956kGCf69h8iVMZjaJ61OwJbvKaTB0CFA6weUM5ilBd3dwOek7/6LF4c Jdgg== 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=DZiqftGjZZeqxnGuzUfAaT6stfdHVGYnoCL8kLsn0Ng=; b=Gz/C9qdmv67y6PYoFOUk8I7E5dOHPSkYN13GL4qzwmpXuH8EEkwLu36EDADtKgGLQU b6G7uRvLtvO0Dx8Ocg9qG0tP7RnVmqonJDmo1zSyOOg7dsbE76Pe3sut4gv+FGnE7ADC HfRBzj5vNhWuJrdT1XC8rVxRJmxSB9Z+ktiqpCQJk/BPD8gQ5b4xa9d2Xzcthwr/RdOB G9ZpyblVm/cyXEEGViNxuvDxefQAHeelWZJprjDpMAJHPkOP0NVWRV8W2KsaCWIavKQZ 736oS5znyDTriTziVAdSNVGil6YTiMHHVv55mGeSTdgqlG6nepNSlQzovMtojHIRHVme H3sw== X-Gm-Message-State: AOAM531FYCajEVwIK7P1vNMVGVJn+u1KT6KKTQB+XY3ZFEcTjoSGH9Gf QPj1jsa66omjpkhivgYMYCY3Mg== X-Received: by 2002:a37:6f06:: with SMTP id k6mr12929201qkc.458.1612708793337; Sun, 07 Feb 2021 06:39:53 -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 c81sm13941493qkb.88.2021.02.07.06.39.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Feb 2021 06:39:52 -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 v6 06/11] crypto: qce: skcipher: Return error for non-blocksize data(ECB/CBC algorithms) Date: Sun, 7 Feb 2021 09:39:41 -0500 Message-Id: <20210207143946.2099859-7-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210207143946.2099859-1-thara.gopinath@linaro.org> References: <20210207143946.2099859-1-thara.gopinath@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org ECB/CBC encryption/decryption requires the data to be blocksize aligned. Crypto engine hangs on non-block sized operations for these algorithms. Return invalid data if data size is not blocksize aligned for these algorithms. Signed-off-by: Thara Gopinath --- v5->v6: - Remove the wrong TODO which implied that AES CBC can do partial block sizes when it is actually CTS mode that can as pointed out by Eric Biggers. drivers/crypto/qce/skcipher.c | 9 +++++++++ 1 file changed, 9 insertions(+) -- 2.25.1 diff --git a/drivers/crypto/qce/skcipher.c b/drivers/crypto/qce/skcipher.c index 96af40c2c8f3..d24d96ed5be9 100644 --- a/drivers/crypto/qce/skcipher.c +++ b/drivers/crypto/qce/skcipher.c @@ -254,6 +254,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; @@ -265,6 +266,14 @@ static int qce_skcipher_crypt(struct skcipher_request *req, int encrypt) if (!req->cryptlen) return 0; + /* + * ECB and CBC algorithms require message lengths to be + * multiples of block size. + */ + if (IS_ECB(rctx->flags) || IS_CBC(rctx->flags)) + if (!IS_ALIGNED(req->cryptlen, blocksize)) + return -EINVAL; + /* qce is hanging when AES-XTS request len > QCE_SECTOR_SIZE and * is not a multiple of it; pass such requests to the fallback */ From patchwork Sun Feb 7 14:39:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 378115 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp3953890jah; Sun, 7 Feb 2021 06:42:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJzJzf6x0+skDAxlguP6/Kr1X1WDENZaSG06NIKzg2d9jWjgN3J80/7KdNxG0eSQ9d0NIsrR X-Received: by 2002:a17:906:ae50:: with SMTP id lf16mr13220606ejb.66.1612708921500; Sun, 07 Feb 2021 06:42:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612708921; cv=none; d=google.com; s=arc-20160816; b=KSBaf2aNTObu5SJggUUINX60FMGG0BmBC3NctplEwKgGUR7+x4YMNP6VvrBNJZULPY 00KExwupUMVjSQiGsVrQcYSCcozo5gLxA3/ko38yj0mGzO5ovp7V3cRj42WRJMeFLsxy O70i6UqL6JMSBDfvfIuiPPBW3HpdhMFPaXOM/XJiJI/A/s1APkAp0TRqE8x0Q1McMhZq /s+cFKXoF3Rl8ORZMctxeJOz6bnNrvf/B0WYk+g86mO45lyKTyOVGOEWFzLARmBwEMsC 70g/nzG3+oUzTw2YQ9M2argbmYwtPG60rRIyyldwF/fd/P79uKlsGw2K0Wwzcmx532JP 36HQ== 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=aBCNw2sBGbDAVprr4vYeHsYbO7AgbkLvqbpGnAY2zpA=; b=RdhMgzj3TPfipYSovcfcupRO/PsPF/c2s6WykOnuuv4r1fj9L32b3zKNTJsZj1UBQY 945D56AH1KUk5i5iKRj/N3CQux2lNs4ACav5D887TsGsV/vWbo2W/OgCNuWq7/6duHib Bn7l0mjHjbC83mfMSkqNvEAhVL7xGUfQbIfNFJoFQfR+mEBkURlEoQc7QIIYOEFwFZuQ hsIdFwDhh5DMFvWtC9pIWRxDjDDuQ34ImNpLQWTtVlViQRKV6BbyPZJFymbIBHGBz27O PlpZCYcMKy3USVRS0Wbm1X8V96//5qusN3eYTPIoNQg7aaG29pw2l6ZTKEMbg7Lr47mY NI3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eQIjWXsR; 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 g26si9550734edy.55.2021.02.07.06.42.01; Sun, 07 Feb 2021 06:42:01 -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=eQIjWXsR; 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 S229979AbhBGOlt (ORCPT + 2 others); Sun, 7 Feb 2021 09:41:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229986AbhBGOl2 (ORCPT ); Sun, 7 Feb 2021 09:41:28 -0500 Received: from mail-qv1-xf36.google.com (mail-qv1-xf36.google.com [IPv6:2607:f8b0:4864:20::f36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 238E7C06121C for ; Sun, 7 Feb 2021 06:39:55 -0800 (PST) Received: by mail-qv1-xf36.google.com with SMTP id h21so5824859qvb.8 for ; Sun, 07 Feb 2021 06:39:55 -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=aBCNw2sBGbDAVprr4vYeHsYbO7AgbkLvqbpGnAY2zpA=; b=eQIjWXsRruSo59w86ZyCxMtGc79M6RTNi9zn5ZsDr0mNYjdxPflsIDBEa2OSsTF8LN 4v5IpdnR0tyhszxBPoVX4n1Xw3D9BfJVxqBr9TvkSymIuPkDzuQN/VsS7sMWhrTAvvhX cn5TSLTzx70MNAsq7M3Mj9yiLoWZSGy8jon9TeKsI9LnepNiF2GgKrjK822FsrDEPSMe zTxeZ1x8IYuTTC10Xq2nzr9Yt0OU2m5Rh8Nlvt0a7ioQT/esnmVTV146gQkd9IZCpDpf Y8xRYiBW87z7eqaIWELirH1o7pVQ1lI1Fd0C2FS18nAq7XtFK8XUY6+nqOI4bY1l0ocF X/HA== 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=aBCNw2sBGbDAVprr4vYeHsYbO7AgbkLvqbpGnAY2zpA=; b=jEcPBAd6MSNVh341GZfBMq4Nxyzr/CBdQ3oTeyu+SuqHQlCk3TWBzQ0IuubXjJYFQT hJ+hKsZ6VRBzslptUr7wbP7rqRhR1b9SQhCN6K3BxVC024xFL6nSQTEx8Mwa6XuriOzc fXidWj+geXnn/NqJl5MOijS6NeSPLNNuf9Vi1LDH+19AQgD19sBk0dKxOuP3hxFYgR69 ZKo1hrIceckT0YHqW27ipwszs2Wc4RZxUUO1Z2Ze+KSjUx97xGpUE19AcQ7tVtMkkyGh AETTKI6zzMIFDu12VIbZYxlUMLwLwVqQNu3Om9PeIhhaVjvJwWjgArOLPDecl9mjHxva kdGg== X-Gm-Message-State: AOAM530ase4kXaaX6khTdhhBVO3GuEBeoeuhbIURTnIPv0qfuhCr9z8r IaExlLyq0iVHladbMxjSi1KZAA== X-Received: by 2002:a0c:dd8b:: with SMTP id v11mr12497164qvk.31.1612708794395; Sun, 07 Feb 2021 06:39:54 -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 c81sm13941493qkb.88.2021.02.07.06.39.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Feb 2021 06:39:53 -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 v6 07/11] crypto: qce: skcipher: Set ivsize to 0 for ecb(aes) Date: Sun, 7 Feb 2021 09:39:42 -0500 Message-Id: <20210207143946.2099859-8-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210207143946.2099859-1-thara.gopinath@linaro.org> References: <20210207143946.2099859-1-thara.gopinath@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org ECB transformations do not have an IV and hence set the ivsize to 0 for ecb(aes). Signed-off-by: Thara Gopinath --- drivers/crypto/qce/skcipher.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.25.1 diff --git a/drivers/crypto/qce/skcipher.c b/drivers/crypto/qce/skcipher.c index d24d96ed5be9..64f661d7335f 100644 --- a/drivers/crypto/qce/skcipher.c +++ b/drivers/crypto/qce/skcipher.c @@ -353,7 +353,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 Sun Feb 7 14:39:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 378118 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp3954328jah; Sun, 7 Feb 2021 06:42:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJx9RWNizV/IqXXjebWadAsNE5E2BspdQUY88p2lzn0NDiTuPXx0EcXF+O4+ik4hAV/whfqI X-Received: by 2002:a05:6402:a49:: with SMTP id bt9mr9238142edb.127.1612708964075; Sun, 07 Feb 2021 06:42:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612708964; cv=none; d=google.com; s=arc-20160816; b=j2vUbfX2eMjGFlyjq7vbaYQ6CZxio3rsGQeccVu4hHb/fkCwNWSJWQSQr+c0yihOdD jHQmDiCVLsy1nxK9dng4B6wRTlResfEWVcuW6pkpuDqJkqNybXvchXdkcPny4ajftN6g f4gD7X+OuVb168fXjujW2ICvjiJW8kxF82KVCjiLkwHWhv4vdeDgnzzZDGfPnfqnAjB6 O95pZwHH/jlU8STHah5zCnTm2oBjmSMa4cQSkOCXD5PYsO6wgbu48wTFbMbUwQ/PAUxs +6ONQGR7Q0vRFtehkYgAHLF6s1phdJ5iWhd0EPgmS4Cm0m2OPwZcu4HkDAPm3oKVxP69 f7Zw== 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=tYyfVG373bOpf6eoJSEUDGRo4VSC1owsiW4MHt1XZKU=; b=jaBpGhP58JCeU+Z4kNFclVdnfiU+JANHlGz2WJYLBh39d0/5krlXF2caunXYolHx8x WSDQvp4kO3RNp0fDzzxVAo7DmtD4o1nS1cH9chM3ljyily29wx045c8vIWW0W8g8WOnS 8TUvC+jhl4u1ezcTwnZKNkhVcZ8gIfT9dlj8pPF7qx90owXHLdvuhpXYzzk6Jm2n0yzf ZgARvigRYMAsSSCugPYHiQgyh+wy3c+ajAXdDYXqs8UknWGRCa2VLrZP40twgQguwJtq J08V8/vQ3rX8DubV2OgD0veoYE3W7QyPWpJQxl1/mh1AQS61fli4xIToQAHaKe23/tjz gN0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O3zpXEie; 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 g26si9550734edy.55.2021.02.07.06.42.43; Sun, 07 Feb 2021 06:42:44 -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=O3zpXEie; 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 S230050AbhBGOmd (ORCPT + 2 others); Sun, 7 Feb 2021 09:42:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230063AbhBGOlx (ORCPT ); Sun, 7 Feb 2021 09:41:53 -0500 Received: from mail-qv1-xf29.google.com (mail-qv1-xf29.google.com [IPv6:2607:f8b0:4864:20::f29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17E11C06121D for ; Sun, 7 Feb 2021 06:39:56 -0800 (PST) Received: by mail-qv1-xf29.google.com with SMTP id p12so941221qvv.5 for ; Sun, 07 Feb 2021 06:39:56 -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=tYyfVG373bOpf6eoJSEUDGRo4VSC1owsiW4MHt1XZKU=; b=O3zpXEieJu8dijkZH819LMHZyBYAVRE+NoWQvj51zMmfUVeZXlEv+jr5AMevaUmQeS S+KcJhHtZh3AT78cURRekswY85PKUJqn6JsxPDubcd3I0rR3AB7zIM40FQTGqZ2lMUe3 Y+1DU4arwyLiYDsAcdP1i0Mv9NIns1NefG1RK1qI2jyP2TMxvEpegwzUMqai0t+kSV6u fWgRV05gzK9jMK7wJahDjZQlooHi+A//yi/m0vX0DcO2rXtd05gJdnnirrkqp5Jza6FL iHMxn+S4i2GwdNHh86QuG/Thi2PRGHycm01oLUoz89BrUI+YEyp9qpZ9J/5wW/EHS0g2 GQRQ== 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=tYyfVG373bOpf6eoJSEUDGRo4VSC1owsiW4MHt1XZKU=; b=rYRMSV4zhzr+yVn6MafZ8CbggYTKAvhEKP3GS9HKfyH+jYBDpYD9qC0mV/wpaAoiIA YzFk7xYqMihWim8k8tguLC/RiSr9sYntYNWKBFTpv/srpQKkne+4hjACag7pkUuU0tuk YHw+Q9eE/6LO1CkIaZxi2zwh3F7kLQcMeEG6Wq2WtfFlK1WFodm8dRpZbgpt4VcQ/Cb0 O8PZt4cdFhhQbKu2fjTsdZZkjx/pKDk6w/PA9Ui07U70yI7wodxtK47XDgAg22OQa489 5hoqdxFrc+lhCPbG6B3NUItQYidaJzEUBr21TTzBnmokzb7caoDy1YMbcqcqQhXrRvQh S3jw== X-Gm-Message-State: AOAM532hNY/SZ9zivMk+U8LfQOEfjQST3f2+/yr2MzaAubPswZG0sJ/a uIbwa0VIoInxPmHprDbBropKTg== X-Received: by 2002:a05:6214:522:: with SMTP id x2mr12733825qvw.13.1612708795396; Sun, 07 Feb 2021 06:39:55 -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 c81sm13941493qkb.88.2021.02.07.06.39.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Feb 2021 06:39:54 -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 v6 08/11] crypto: qce: skcipher: Improve the conditions for requesting AES fallback cipher Date: Sun, 7 Feb 2021 09:39:43 -0500 Message-Id: <20210207143946.2099859-9-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210207143946.2099859-1-thara.gopinath@linaro.org> References: <20210207143946.2099859-1-thara.gopinath@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org The following are the conditions for requesting AES fallback cipher. - AES-192 - AES-XTS request with len <= 512 byte (Allow messages of length less than 512 bytes for all other AES encryption algorithms other than AES XTS) - AES-XTS request with len > QCE_SECTOR_SIZE and is not a multiple of it Signed-off-by: Thara Gopinath --- drivers/crypto/qce/skcipher.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) -- 2.25.1 diff --git a/drivers/crypto/qce/skcipher.c b/drivers/crypto/qce/skcipher.c index 64f661d7335f..66a226d1205e 100644 --- a/drivers/crypto/qce/skcipher.c +++ b/drivers/crypto/qce/skcipher.c @@ -274,14 +274,19 @@ static int qce_skcipher_crypt(struct skcipher_request *req, int encrypt) if (!IS_ALIGNED(req->cryptlen, blocksize)) return -EINVAL; - /* qce is hanging when AES-XTS request len > QCE_SECTOR_SIZE and - * is not a multiple of it; pass such requests to the fallback + /* + * 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, From patchwork Sun Feb 7 14:39:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 378116 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp3954090jah; Sun, 7 Feb 2021 06:42:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJzbNnPMm7NtHJoRdnRHuksxdoGRuDDu8jXZ4Ir9NaWoKAw91qErijn7roiKXUWZk/UReHv9 X-Received: by 2002:aa7:c911:: with SMTP id b17mr2693312edt.382.1612708941373; Sun, 07 Feb 2021 06:42:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612708941; cv=none; d=google.com; s=arc-20160816; b=O4GGwfhbq+9bPeQCcRkcPtNpanhUEQoX7H9EN8Uknet869+95Qq1AqKp/TbQpHb2tr e+B8+coqP3TnO73+XvH+R0WXpJAQsOmCTc74YSa1F+byjkSwxrR8DQC6YXWc8EZrTHtF T+Oq74uP9TYyRT4mF6Rj3RWBdDW8nAswemNzKcdiQYJ1xJNcvkolxck+v3rYe36G4FXx CPqL8NmxvqbQ8IcbvD6SmA+krzU9l7tzsWjPuLJNcX3/G9Zz5jNF9evjjFQq0iTez8J2 Cv5ZvJTBXNCO6zVStua2OYnB2UFs+Bp4EOmQMHTKFfb1X3PKdkDTVZA8q7YnTTIpl7gn 51Rw== 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=H4BViZmMHUNQYYu9VpJJKST4ly897JCfdbGhTeJJKpE=; b=WxLJUk61weFC6VcsmUvee81IBog5dNr4naR8utzYPsKzzepycFMthZVSHgK/gtM8QH pU6Zglh5iIO858KnSGsSIie2WYL+REzhsIdMMbiVdwsaIeTJxkBHEjgfSqlrfyiPyQsJ e8hERrMWeQjOklyF3qsGS+MjAbYbuiMWRva1ZwLPXmotiCtN74ySwW3uOhQXEEWylAet 6FHR5FrzzW53ZdDNz490SWxYRNadxuNtuaoTtji/RSC8ZWYt2+KM1b0RhcQiw4diDVXG ep99mj/ddCStaU2vaEPbv2bjozrd6HoZmVg2tqLIk1fVKQ8FrrUTtUza4Ii+WMEGkgnn Yc5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=veORIMbT; 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 g26si9550734edy.55.2021.02.07.06.42.21; Sun, 07 Feb 2021 06:42:21 -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=veORIMbT; 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 S230023AbhBGOmS (ORCPT + 2 others); Sun, 7 Feb 2021 09:42:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229996AbhBGOla (ORCPT ); Sun, 7 Feb 2021 09:41:30 -0500 Received: from mail-qv1-xf2d.google.com (mail-qv1-xf2d.google.com [IPv6:2607:f8b0:4864:20::f2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBA7FC061221 for ; Sun, 7 Feb 2021 06:39:56 -0800 (PST) Received: by mail-qv1-xf2d.google.com with SMTP id u16so5818138qvo.9 for ; Sun, 07 Feb 2021 06:39:56 -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=H4BViZmMHUNQYYu9VpJJKST4ly897JCfdbGhTeJJKpE=; b=veORIMbTEFHdV2ZFA+S4kEqUqMfKyKjfNRJMTAEVlAONkV2h5bwCaHF3o9lCgPjfFb EJIYZZBFcFhsE+mnA4rdIKkppadaNlyCpp4ZoeiueOvoGJ+BBPJPpMCg/oopX/tMdU4k GorzXEKwPixX/LLKL6FbW4GPvfRshWd8T8J/Ak63guKJSWL5O/3Qycm+ti+q9y/vI4MB Km6FCq47E9QImjzb1P3QQlioEPjq5Cxlc+I3cRp61L2J8VI0wY+2UiZkXJ1zzl8R2GNt 8vOXhAksSFd2wew/MXWwXO+9IZZmJMgDEz9+r8OALJUMCFp4p6aU9odGTWTH+6ZlnBKv O9/g== 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=H4BViZmMHUNQYYu9VpJJKST4ly897JCfdbGhTeJJKpE=; b=i4slo6RJ7x3ejd4zivQZ/x7ObBYXMgDlxty2dZtZU8dgGTtKRZ/L2SvajbGOK3OP6t wwdJJ1zikZ3E0qY86Lx4Wq04sq8WrGI5wOc20YHOf3e/uPHLXQMmxz8n9mwVo6W/WqDT d6BlMeowz+tx+A+tUo3JnuHOth8FkKVbz5rhu1LntDPYkFQdQL00UM3ddNqNKAqtsBWk b1PlLUwo2Ik11frV1hRoqWVicZ9xX5QQxci3eEPzl/En1J974vW3fP1ocU6TxbRo+YSf icxNYCCtL0ym8ezzHisxONGg0wUzBCVuIKOLy5zRssVVk0NRpBYfQ0/y7UTrZVea1g5O XGgg== X-Gm-Message-State: AOAM532TAWfvIrlLBCU2LKfbNk29Uh6ixGE7u+v1tpVqgJ/jDqIV5E9s XvBzM7Wca0yMyvDl1RpinkvXnQ== X-Received: by 2002:a05:6214:1341:: with SMTP id b1mr12650305qvw.57.1612708796200; Sun, 07 Feb 2021 06:39:56 -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 c81sm13941493qkb.88.2021.02.07.06.39.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Feb 2021 06:39:55 -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 v6 09/11] crypto: qce: common: Set data unit size to message length for AES XTS transformation Date: Sun, 7 Feb 2021 09:39:44 -0500 Message-Id: <20210207143946.2099859-10-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210207143946.2099859-1-thara.gopinath@linaro.org> References: <20210207143946.2099859-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. Acked-by: Bjorn Andersson 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 a73db2a5637f..f7bc701a4aa2 100644 --- a/drivers/crypto/qce/common.c +++ b/drivers/crypto/qce/common.c @@ -295,15 +295,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 Sun Feb 7 14:39:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 378119 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp3954382jah; Sun, 7 Feb 2021 06:42:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJwdLF2vrbPWw5agd4o/riCdIUv1Cfxeu2d1pEYCE1telVqnua7L3kW5tHjDT427rVIv+xTD X-Received: by 2002:a17:906:6bc5:: with SMTP id t5mr8640579ejs.253.1612708970118; Sun, 07 Feb 2021 06:42:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612708970; cv=none; d=google.com; s=arc-20160816; b=hJA9TTsU18viXFV9O1U+INBTcUiMgWLvVKYFhrelrngBDDb3oi54vghdlwAxjmybnk d+E9wvS9JJ4lFPmycWi655PSaC7I0WBD0saxFaJr3GUqWE5wppekVe00Voa7mV5+n7BC kxaesOsaGfj+gg5oV4kv1RcU8zg3ECRzujZHyhmkpWh5K1e/3zCeaw9Y5iHNnQtslFT2 EFfG8cg1GzcxoCvivQukcMego5RzazEXhKU0qBN62h/z6CdNrjfT/sd1o8UBKZrmLFFC nNskIKyOEwhvWg62PBr3CWw5b1GAdlHm1QLg/ttCeGyFNmNzZUVBHaA+SkwFBrwtG0fZ 5zFw== 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=BPDwYpHNxd0jE4JhwrDAxCdw+Yf1UG7u/C1BPaHolwlOz9AS0z6/xfCD7DU8XEl2rL j+fo8MZoMy3sj9LGmizbkkVonGC8IruodNL55OZP8e7skOoR0HZPnlCSbLRar8zbB+zl WFOMhkcknkUQBgISbEcWBKvQUkjNflBc0fCXqoC8WnPIWdIzI8gMAuMvJjG17UZzYrrP lVhpL8jNVDLO83gjow7LxxT4Z5YDxl79Rh/x6SuKYp819CkOsuj5QQNGCX+GmevOy/rn Po5i0lKibJfRwecl41ZqthYfxtsXw6/9Hnp0l+2hsg8MyaqxBzD3pkn30kG8mjYmrQ9W jF1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vRZA+bp9; 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 g26si9550734edy.55.2021.02.07.06.42.49; Sun, 07 Feb 2021 06:42:50 -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=vRZA+bp9; 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 S230163AbhBGOmn (ORCPT + 2 others); Sun, 7 Feb 2021 09:42:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229986AbhBGOlz (ORCPT ); Sun, 7 Feb 2021 09:41:55 -0500 Received: from mail-qv1-xf35.google.com (mail-qv1-xf35.google.com [IPv6:2607:f8b0:4864:20::f35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDF04C061222 for ; Sun, 7 Feb 2021 06:39:57 -0800 (PST) Received: by mail-qv1-xf35.google.com with SMTP id v19so1073163qvl.7 for ; Sun, 07 Feb 2021 06:39:57 -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=vRZA+bp9CxaDQnbcLIMCP86fsnHA3pAiAQ+Gh6AZO+NavKryjzwTvbla6AvGQpXs4j 5f7+t6DFu5+mT3AEBZcAEUb6Ps+XJNTnUvvvLyUi2ePkBYR0N7AU/wj85+daDcMKY9sS Zde2mF07V+Kq5v6tnXBdFhSYq7jbMteRcxeoD0PG/q2xIKLqkJIFmrmnOwY+L6bOHrqX vaUrmzjoxYuF0adNhC5tq2qSe61XtxpNKegICELeNh0z2ffrPyWm1khd3ZfHNhTOzsOX j2ZGLeuYzb98FIMOqnxFKsTh2MsYG7QWkoKVuQYRzoWZu3QoK290Es05zpzJ2pvspkNN NPWQ== 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=NFSw60TFa4rF/vnmgALmQSXdinThO5TQan6sqYl2kA+c27nDI6/1uqXBlgykxeb5pi V2rVo5VMQQxcCeyT1Sm/2yN92kbF55um/MefZrD+RrZbuahOPD6AJh/mqud9olGz+tW7 F6zROGKhYnhji8dvZbFMr7UHf+jdvSzN6euQeCilstdgFnbZI3S5yfggAlWoYIQXiC/r uH99UtvUM3m/o5E/cQHuBZy7pDF33l+HqosZ/p/BWVA9y2VLMPgrFsETwuVuRJtZfGhM SxPFSQ4Xe8Hg3DlY7P4WEB+BdNHbb46a8LXdYMUWH/ltBk6wG7qwHzv47kDIBk25oPYq zgbA== X-Gm-Message-State: AOAM533CPKQn8iFhk4oS2ulO5BaKQs/OXRUZ9m/tdawP3aGe/Hxe//zS ef3NeRnG/FH+CwZZ/mqefThFWQ== X-Received: by 2002:ad4:4d4c:: with SMTP id m12mr12732537qvm.6.1612708797055; Sun, 07 Feb 2021 06:39:57 -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 c81sm13941493qkb.88.2021.02.07.06.39.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Feb 2021 06:39:56 -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 v6 10/11] crypto: qce: Remover src_tbl from qce_cipher_reqctx Date: Sun, 7 Feb 2021 09:39:45 -0500 Message-Id: <20210207143946.2099859-11-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210207143946.2099859-1-thara.gopinath@linaro.org> References: <20210207143946.2099859-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 Sun Feb 7 14:39:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 378117 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp3954130jah; Sun, 7 Feb 2021 06:42:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJxziPXsVPmoF6wy8fsJ/BMjeNh+uV1zVrDxgISnNDHGOLBAtZ2BP4XFi8OTCAt45tq7faeM X-Received: by 2002:a05:6402:34c3:: with SMTP id w3mr13210850edc.3.1612708945832; Sun, 07 Feb 2021 06:42:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612708945; cv=none; d=google.com; s=arc-20160816; b=G6VrwnIbrTl8NLsGfswRcLQyeO4cCX6a1wWGZ6CsmN2NAjuVspg5kSXrLmDsrLWA/c K7fkpO2D9PP3nSPAWHOIwg5FmBHx7UeMdS3fbtLhIUPKMoGmhYE8HetE8LhVgBl/+CWv qMLoVUUEVroq79l0d1BOW1kPTOnKoUGIQ/KSfQ7nxRMkZU9wzFtRLsfuTAY9iqeR0T3S cfPJhuhPRFAMFeTXQzDXvuOzBBCaTg5xz6QMdnxTSrZDwTdLSH8E4RbPzzghcPwnvdb5 vwte/xt+RNXi6AKViSl8Gdjm/8KVezz51nk/rMpJr4IOVg7AuigmGXrpU6vWm4O3On+M A99w== 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=S634bOI/l2hQTpgSJr3nVqoDwyDnHV1Gw6IbuFUoXuA=; b=mArcAPhJ4aS0LA2R+rbXMoagRGtVR1bnhmAbeuiydZXaO3LmBJf6M8ynyLVHr/KTZj 1c2sY0FlnzRAH76iyiIh/VHfbOz3cwmWGZ1OiO5Yh9QAnBo89gr6jpJKmc2uJc48mMfu UsOF7OHKV1DOCQ2cZefZ0xalInm6EPJRPytw6nCCD1NqwhN2RQH2ofQKuKmQAr/QfjqS WAv407WwK9JLrhKpblK/HaIqXJrl1R/R//uyGMzQVZ51cNG5Wkhp8PBu8SKA0uuKKXxg kG1OBEOn1/yl2OhdWhiZ/+xKyE1AJodruPqznlk8lKjPNC47khDLYOwUIlteWGpGKq4p YqiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EEeoLHA9; 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 g26si9550734edy.55.2021.02.07.06.42.25; Sun, 07 Feb 2021 06:42:25 -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=EEeoLHA9; 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 S229996AbhBGOmU (ORCPT + 2 others); Sun, 7 Feb 2021 09:42:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229999AbhBGOla (ORCPT ); Sun, 7 Feb 2021 09:41:30 -0500 Received: from mail-qk1-x734.google.com (mail-qk1-x734.google.com [IPv6:2607:f8b0:4864:20::734]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C56B7C061225 for ; Sun, 7 Feb 2021 06:39:58 -0800 (PST) Received: by mail-qk1-x734.google.com with SMTP id a19so11981910qka.2 for ; Sun, 07 Feb 2021 06:39:58 -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=S634bOI/l2hQTpgSJr3nVqoDwyDnHV1Gw6IbuFUoXuA=; b=EEeoLHA9p2j7vGSuG5F6ZMbLX6ECOyCXPLqBP18J1BbcKXAQZslEq0a/S0MfRmOJtn UySXexTVD2tdCjiyJztu+2cOw28gOa+eP7OvFqgtkDnDBFAWHyCE4ivLYEzGiKRaPhz9 q9PGLP0fi0jJfU5FtvMRpyNjzoj26Ae/Zau0UwQAmF0F7N7d5+PgJ2ZU3691JQsFk4Xh 8p5tHrRMIfUNvIHZvPtQKu1iaXnfllBTFstFvq7II7BT3/lUNxYnqbObie0vmXMNo5z9 VRYoSFaytaOb5p7fjDbR3rx7Zuq7CFqVhFVPfnXiF82WCRVol68BKF8+RVigODJTeCqq 8zBQ== 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=S634bOI/l2hQTpgSJr3nVqoDwyDnHV1Gw6IbuFUoXuA=; b=UwiuJsZLTV582foPQZwM+EwSuoS1CjXs36eNt2RWmmayXEMS79vJ1sh8AQxPggk5/H 71l6fWlPMYTG1WAQToS41zHziFzPHEK3mcQhq68eZ6ifbTd+c2lcvu2Hfwt7qReHqjED We/nNinLFmrQJ3S6S6ySkE+8WpondJbq+hq5/bgFvgIdy7AXH53k2F8yrpRdMLbOzSrc WpOALb3nsGw7OpwFHNQigr1nBrWgux2ASIJLepNdXABjJx+2+JusXi8+c6b+nNWovp3s iqs7EJw3u3DzKtGw4gXXwLeSSQhna1MO5sZ7ZlHpjcG6oHum6n9PQ5vSchskrfGAAU2V oPqQ== X-Gm-Message-State: AOAM532/Ldpau8a+Tx7kjCjGOlIkYI+iN5C8g+3ZhqhlCvPUzUstBj8w WJUhmSt9awbjAtMgd72/CjpuCQ== X-Received: by 2002:a37:aa4e:: with SMTP id t75mr12500918qke.343.1612708798033; Sun, 07 Feb 2021 06:39:58 -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 c81sm13941493qkb.88.2021.02.07.06.39.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Feb 2021 06:39:57 -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 v6 11/11] crypto: qce: Remove totallen and offset in qce_start Date: Sun, 7 Feb 2021 09:39:46 -0500 Message-Id: <20210207143946.2099859-12-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210207143946.2099859-1-thara.gopinath@linaro.org> References: <20210207143946.2099859-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. Reviewed-by: Bjorn Andersson 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 f7bc701a4aa2..dceb9579d87a 100644 --- a/drivers/crypto/qce/common.c +++ b/drivers/crypto/qce/common.c @@ -140,8 +140,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); @@ -306,8 +305,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); @@ -367,7 +365,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); @@ -376,7 +374,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); @@ -388,17 +386,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 2813c9a27a6e..8e6fcf2c21cc 100644 --- a/drivers/crypto/qce/sha.c +++ b/drivers/crypto/qce/sha.c @@ -113,7 +113,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 66a226d1205e..9fec5bdc29ec 100644 --- a/drivers/crypto/qce/skcipher.c +++ b/drivers/crypto/qce/skcipher.c @@ -144,7 +144,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;