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: 123340 Delivered-To: patch@linaro.org Received: by 10.80.135.92 with SMTP id 28csp5928138edv; Wed, 3 Jan 2018 12:27:16 -0800 (PST) X-Google-Smtp-Source: ACJfBosJmWcPbRimiHUuwfCMCte/xPju+KsX0ZgOggkK+gXw4E+xRaxoLygL4tt3GbQ1Xukw1Evh X-Received: by 10.99.97.197 with SMTP id v188mr2078595pgb.291.1515011236047; Wed, 03 Jan 2018 12:27:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515011236; cv=none; d=google.com; s=arc-20160816; b=Jj2xvxTFEwYs10hEUJMXp7jYPn8N+4EOoF2ohAhLbZaDv6CRz7mtrvm4NlWCfw/LYX 9j5TDkk5e2qnpIKGM8Xgyjy4CWyl8opGEODe0U331Ll2EH54myaQAxcXQZLRZS95nOrp eikXAOcqUzJ2Ts959pTF2RDyLoasC5h66XRp0Q+Q8Z8KVV3bg3NFQNszfTY2zouLTj+5 HqwP0gSLkmgyQ3M6gbBrtTtVRM3B8xK7CKCIeMCq1m0IVlmtUvnbX3VRNo2/Ibc7zehr Bs6kyWUaF662rVDzVbv3i+HfpGMD4b60i+IvN7ifjdEB3ejkHIv0Qam+1qP441ntkpzm noJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=LCg/Yvaj9+q1xWy/a3OeqgitkFC3vFLTMKm+P0lDexo=; b=zKzqmPv+IWWuRUJbhQyCHKVm2eh0lW7g/xIZy3CutBMmvzw17HJEaDiaoMaywmEC8W QvYhOVIb+9W5Jc6B9MLlAoyG8K1jCFmjvWHy2fcPST+LoH2sIXCemmyDf0DSO+Ja64Mx oYGfjPsSsi60yT5S2lOY8/BaLuUqERp0t6YjcKEnxBy4uy3sKVadXYR5xSfUz6uqbFtp pGVxeOYN6X1zsQpqnRXwwkIwoU5ZFpIUy9x/HXSK4YY82dkIPeo4L7nxLSqcIeNNKDXk tskB0keVABZyU5d6M7lRbca8xV1SAPjHBAmV5vXK8XTl1mNW9dfTaC/2gYQ5f3PPgtb6 rHmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=l4++G9KQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 17si1045746pgh.538.2018.01.03.12.27.15; Wed, 03 Jan 2018 12:27:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=l4++G9KQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752299AbeACU1M (ORCPT + 28 others); Wed, 3 Jan 2018 15:27:12 -0500 Received: from mail-wr0-f195.google.com ([209.85.128.195]:46749 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752163AbeACUNW (ORCPT ); Wed, 3 Jan 2018 15:13:22 -0500 Received: by mail-wr0-f195.google.com with SMTP id g17so2832848wrd.13; 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=rvEUC2LMydRUS7LB/KoLgJFncTXayf6Xp5BFE7KsWZ6/V85y1Bk28qJXTaNo9QQLXF pNZo56fUtBIoHXqjfb2m9ZaZ4ekr9cnUrxkeiRN1IKbz41+1vHIzLxK7Tc9FdYSVkP5U oYCyiLn3Vyl6IiK6bvdcDvpPoeQ8l1/em8gkE2plNxRD0I9YaTjRseaKPRgr+kiR9DeC JzY8HzjfGMb4vgdwZw5+1UNfneMT7qXmmWlZgVwShud2o7VgNnAFQ3OxuwHztgRi/ntE i59sImLh3uAShbm6X7dNQaVpl5OnoFYpFgNTuEZ48JX5cM/Yw8FInMHdcvpPnSPa+Flw xe8A== X-Gm-Message-State: AKGB3mJe47b1v/1Yi4VgE98AJLX3b9+MwZDfFOLR9WiBH5tBFTRmeEx+ TFA6LbKTV2OWvWci3ldygXXcUkX3 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 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, fabien.dessenne@st.com, Corentin Labbe 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Signed-off-by: Corentin Labbe --- Documentation/crypto/crypto_engine.rst | 46 ++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 Documentation/crypto/crypto_engine.rst -- 2.13.6 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