From patchwork Wed Jan 3 20:11:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 10143309 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 849F360594 for ; Wed, 3 Jan 2018 20:32:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 792042933D for ; Wed, 3 Jan 2018 20:32:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6C55E2935C; Wed, 3 Jan 2018 20:32:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EE48129311 for ; Wed, 3 Jan 2018 20:32:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=tS9gwPg+TZ7bKz4krBAts4/12qPCJuOMmxN191AeAKw=; b=iYcc1Auzt94NZXZHQZeOdQSzSw zTDMIn9XykOCy8kMQ87oogu4kmXg/JDpxJF0gUCITa5/+9KYGO/+jGE903lbbPdQvOoaA5/horSb5 DqLVZnuWkUNFuz5YkAI+r6n9FMdWy56te4YpWFQcoUaeHIMg45ywhb4h61/Uzo9s7clntHu1FncV+ 6V+6CPLs0Sd6cr9CBv417kfEjPCQnnupruxoGdky3ViAGatBrVW+GmvNrJ+ay9ZXSYx3y6Sb4TMLD YpFwf7/NpUrTgR4Hr3/1m7QNPZWeAizKiiG+ki3zmVfUadJ08hx2szvYbkPBqY+7O+IO27/vcjn/J TkLjzklg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eWpiU-0004fr-La; Wed, 03 Jan 2018 20:32:50 +0000 Received: from casper.infradead.org ([85.118.1.10]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eWphQ-0002t4-OG for linux-arm-kernel@bombadil.infradead.org; Wed, 03 Jan 2018 20:31:44 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=LCg/Yvaj9+q1xWy/a3OeqgitkFC3vFLTMKm+P0lDexo=; b=aTpc6gI02Yw1xST2IFVwXejbH Iaf6Af2iqJR+3tVdcMUAdlAaH0i0PuTncQyH4fHmXiXY2gREqb6N5yuIHR2Oukbg5jOF+27J6expe cg86YHF49zh69C7MJod9UgTPvveFCVgKai3VtOuRMF9je8ngo7jqiB26i970E/XjiemW71uSxpOYh myv1gnZzPvkGXTJgv6lYVTMG5AWAY/YAsHjq7hOylPDK5QJIJsmvQZLlrne1gCt/4v9BVgqv4phlN OZvdATFGBbyF9Kg1ZsmYiMCUsMg1dkNkgobk/ep1urrq3sP0ZwzVsKp4qWVxJXYW2F5o22trInTms 36stbqqLw==; Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]) by casper.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eWpPo-0004Z1-0I for linux-arm-kernel@lists.infradead.org; Wed, 03 Jan 2018 20:13:36 +0000 Received: by mail-wr0-x244.google.com with SMTP id 36so2850331wrh.1 for ; Wed, 03 Jan 2018 12:13:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=LCg/Yvaj9+q1xWy/a3OeqgitkFC3vFLTMKm+P0lDexo=; b=l4++G9KQ+5bnsgUFy3bCes4ypUNcgyCVfYWqQWU97Rl8X+QjZT0J5IE21/JphAxXXM U2M9d9vRsv0VkH0EZe4HGGsYIA9QQB5uoDH9tD+RG3DE4IILbY2R0LCAu7j35x5DOGD/ AieIfihmGEu7ZJBMSbpJhS+Wrwk6prIVtP/725RhUfuRmcYhg40rWPlTol1hIDgaly7C jPyRCMG/pbz8rbo1bRHkm9DZFdainIb743i/NQx0I+F5Ars727kOoizQFR3wY7w9Rvj/ c9bHFKWlXssk0IAsSeoFoxpwzvC5L1mkeimb3ZkPtuW4bc4UJM+aD9yqTNtbhH9wUK00 RsqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=LCg/Yvaj9+q1xWy/a3OeqgitkFC3vFLTMKm+P0lDexo=; b=kLzIbbkiFjQq7t8hDoLNFCHCAuPVY+Qef0Qx/2SA8R3g6J9/iYqKywWMLPg175PEyq XwHolvdoNX1GL28USFFhQLO7akhBpTT1hMfS/pcB+IDV14HwlnaLrcFOZ7SZ1IwthqnD qlmpNSnJgTE63obeoofJtR5npYI4sC4HkiKsM6i11IoPH2KD33S8pZ8ZTgqpkEsj9KP7 XJ9jkBUVsD8/O//IbMr5QR0YY8+/etRURrsvPBmok3um5ur8NQhbhuuRjWu6wzy9tIxT b2W6XLEZsVnVZe5b//SuT8uJvdUrQuy1A+CcjldnFu5XFqsGsOtzzT9UHgRAHIqzvxmK piAA== X-Gm-Message-State: AKGB3mKyVjv1rt8MXFgqDJ5m1ceeZW2caOq7cEoF16Y5u9VgbKYwlWYG PidpaMZAuOKieP/igG8qi70= X-Google-Smtp-Source: ACJfBovJKFacvKarfX0HuwMNeZKHkhOY12n7hi7V4tGfxZzK7vcAuCTQiWSYvWl56iQqtDSyoWxtPA== X-Received: by 10.223.150.178 with SMTP id u47mr2713030wrb.115.1515010400723; Wed, 03 Jan 2018 12:13:20 -0800 (PST) Received: from Red.local (LFbn-1-6953-20.w90-116.abo.wanadoo.fr. [90.116.134.20]) by smtp.googlemail.com with ESMTPSA id p90sm1800627wmf.3.2018.01.03.12.13.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Jan 2018 12:13:20 -0800 (PST) From: Corentin Labbe To: alexandre.torgue@st.com, arei.gonglei@huawei.com, corbet@lwn.net, davem@davemloft.net, herbert@gondor.apana.org.au, jasowang@redhat.com, mcoquelin.stm32@gmail.com, mst@redhat.com Subject: [PATCH 1/6] Documentation: crypto: document crypto engine API Date: Wed, 3 Jan 2018 21:11:04 +0100 Message-Id: <20180103201109.16077-2-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180103201109.16077-1-clabbe.montjoie@gmail.com> References: <20180103201109.16077-1-clabbe.montjoie@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180103_201333_858975_D28E4E04 X-CRM114-Status: GOOD ( 15.06 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, fabien.dessenne@st.com, virtualization@lists.linux-foundation.org, Corentin Labbe , linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Corentin Labbe --- Documentation/crypto/crypto_engine.rst | 46 ++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 Documentation/crypto/crypto_engine.rst diff --git a/Documentation/crypto/crypto_engine.rst b/Documentation/crypto/crypto_engine.rst new file mode 100644 index 000000000000..b0ed37f9fb0c --- /dev/null +++ b/Documentation/crypto/crypto_engine.rst @@ -0,0 +1,46 @@ +============= +CRYPTO ENGINE +============= + +Overview +-------- +The crypto engine API (CE), is a crypto queue manager. + +Requirement +----------- +You have to put at start of your tfm_ctx the struct crypto_engine_reqctx +struct your_tfm_ctx { + struct crypto_engine_reqctx enginectx; + ... +}; +Why: Since CE manage only crypto_async_request, it cannot know the underlying +request_type and so have access only on the TFM. +So using container_of for accessing __ctx is impossible. +Furthermore, the crypto engine cannot know the "struct your_tfm_ctx", +so it must assume that crypto_engine_reqctx is at start of it. + +Order of operations +------------------- +You have to obtain a struct crypto_engine via crypto_engine_alloc_init(). +And start it via crypto_engine_start(). + +Before transferring any request, you have to fill the enginectx. +- prepare_request: (taking a function pointer) If you need to do some processing before doing the request +- unprepare_request: (taking a function pointer) Undoing what's done in prepare_request +- do_one_request: (taking a function pointer) Do encryption for current request + +Note: that those three functions get the crypto_async_request associated with the received request. +So your need to get the original request via container_of(areq, struct yourrequesttype_request, base); + +When your driver receive a crypto_request, you have to transfer it to +the cryptoengine via one of: +- crypto_transfer_cipher_request_to_engine() +- crypto_transfer_skcipher_request_to_engine() +- crypto_transfer_akcipher_request_to_engine() +- crypto_transfer_hash_request_to_engine() + +At the end of the request process, a call to one of the following function is needed: +- crypto_finalize_cipher_request +- crypto_finalize_skcipher_request +- crypto_finalize_akcipher_request +- crypto_finalize_hash_request