From patchwork Fri Jan 26 19:15:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 10186887 X-Patchwork-Delegate: herbert@gondor.apana.org.au 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 98D09601D5 for ; Fri, 26 Jan 2018 19:19:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 87A4929679 for ; Fri, 26 Jan 2018 19:19:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7A7C5297ED; Fri, 26 Jan 2018 19:19:44 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1E6C929679 for ; Fri, 26 Jan 2018 19:19:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753112AbeAZTT2 (ORCPT ); Fri, 26 Jan 2018 14:19:28 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:51708 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752498AbeAZTSE (ORCPT ); Fri, 26 Jan 2018 14:18:04 -0500 Received: by mail-wm0-f67.google.com with SMTP id r71so3296107wmd.1; Fri, 26 Jan 2018 11:18:03 -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=ZnAgI50T1OQp461MDiTH2WDx81c5Uz3+RL5E47VXitk=; b=fnMdNNMULQ34daCkEddo9a6WrZ9sSlH7QT2sGCFRE13bhM/3dYE6D0wWMEnGG1xkwj f5m+icjwRlFUrQ1Z7sCiR5i88On2jY9lDbLUI9Jo9f/tmZzEb5ITHr1m0B/nUoTSgMQN MpGVJT692Tw24Ow2OuZEm/WgvMAmQgOGadA+ESRKoWClxQBWXVqk1TcCitxVGU/AcWRG 8tOz/bpTdJje5FSlDShvNoKWXkegXpua6YIx824wtd2lyNO8DJqNw+M7zrJlVzHS9ezA H3/uW9NLV547Rlk92TOdkBjN0aSONxsxfEf35akCgkX1hvFlIWmZuXPsuo1MPLve2G2x iQkA== 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=ZnAgI50T1OQp461MDiTH2WDx81c5Uz3+RL5E47VXitk=; b=jLveGnpWkkKx2+eIzsLTf9MZJsW1nhNNbc6rF+XO+k7Vp/vCmxv46umJ3P0ybbDSnN I4FyAkQJoVFAb09E/34E/2WCHNEABcX6CdPej9CnBwA8O68AnrUr+TIuxHeiKHprUgMT MlziV3LQZGQjsG07YVFKmggPsW1Udoi3ne9EG+wqpl0d3aiJzgMkfD9eRzfUky/B2BN6 4WETcGiyDScj9nxarb3viV2TZmAkUsnkjGm93CLaaNVuIhOenBG8E8ewxMDtCGQWvM6O qvPnTV5pwAUPDIv2ufCAR2pBMRpNgqG7fr7nparQYl7gS+j+7Llq9oXBjIVW/vNFZrTs YNXw== X-Gm-Message-State: AKwxytd6yoMt7xGg+5+1nFH9lDoenZBIcZwl58GmaHpWsWArPHgzcG4V ftaS3gBMrCrbF/469iRkkdEhgwOP X-Google-Smtp-Source: AH8x224BQ0US3aDeoSnfrcz7gUwR98Z0qmpw+0xBjxz9b1Zz6YqoXgjGlD3q7TzAuEmx50aiHlqwvw== X-Received: by 10.28.86.132 with SMTP id k126mr10609545wmb.98.1516994282888; Fri, 26 Jan 2018 11:18:02 -0800 (PST) Received: from Red.local (LFbn-MAR-1-494-174.w2-15.abo.wanadoo.fr. [2.15.82.174]) by smtp.googlemail.com with ESMTPSA id k125sm7587510wmd.48.2018.01.26.11.18.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Jan 2018 11:18:02 -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, fabien.dessenne@st.com Cc: linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, linux-sunxi@googlegroups.com, Corentin Labbe Subject: [PATCH v2 1/6] Documentation: crypto: document crypto engine API Date: Fri, 26 Jan 2018 20:15:29 +0100 Message-Id: <20180126191534.17569-2-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180126191534.17569-1-clabbe.montjoie@gmail.com> References: <20180126191534.17569-1-clabbe.montjoie@gmail.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Corentin Labbe --- Documentation/crypto/crypto_engine.rst | 48 ++++++++++++++++++++++++++++++++++ 1 file changed, 48 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..8272ac92a14f --- /dev/null +++ b/Documentation/crypto/crypto_engine.rst @@ -0,0 +1,48 @@ +============= +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_ctx +struct your_tfm_ctx { + struct crypto_engine_ctx 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_ctx 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_ablkcipher_request_to_engine() +- crypto_transfer_aead_request_to_engine() +- crypto_transfer_akcipher_request_to_engine() +- crypto_transfer_hash_request_to_engine() +- crypto_transfer_skcipher_request_to_engine() + +At the end of the request process, a call to one of the following function is needed: +- crypto_finalize_ablkcipher_request +- crypto_finalize_aead_request +- crypto_finalize_akcipher_request +- crypto_finalize_hash_request +- crypto_finalize_skcipher_request