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: 126018 Delivered-To: patch@linaro.org Received: by 10.46.84.92 with SMTP id y28csp555523ljd; Fri, 26 Jan 2018 11:19:31 -0800 (PST) X-Google-Smtp-Source: AH8x226nSyQOdDjzcqWfLbN+aKSYhMXqAU88eovfH2Aga1PxM/p0tFMorOb6VBgeucMa63uuE7yL X-Received: by 10.99.152.84 with SMTP id l20mr16330442pgo.382.1516994371033; Fri, 26 Jan 2018 11:19:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516994371; cv=none; d=google.com; s=arc-20160816; b=SLMgxv0n1cfUe3qetekL1jUMVaqmwzzorpHDPk5UL65jnkc7dPnmzckjPnRGo8fOJL If5FpiFs/0ThcN3BZc3DH2ENfZX16sM1je03kN0/xyHjqcnLy3ogMDZvyhjQ8KZ9zUbM lr852zAhiJ9vYM+QqhV41p9BEujYPhpEPJjKsaouuTX1X4vVSBowsz86KOMJnsT43Kts o7V0DaP5LBkI1eLuSTYJLD2z/qM9T+Zm45DYXnEWW9zbnbchrRUUjeQJIiK5gWFmqhHo u1Jm4jOU5WTyP2W/tiKOHVPn7xnZgzWanH0Kqmhs5tF9wd7rgd/zs3Kr4M0sHIArUS7f hZ+w== 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=ZnAgI50T1OQp461MDiTH2WDx81c5Uz3+RL5E47VXitk=; b=rtyzgBm6eUtE59VItmLxzI8VtwKQAPsvcfqyb8ZWgyqP1eWvK5hx2+lkKaNBY4+skG 40JKLEb9zcgZ830Uo9BxEPbmjZUFkdrTn9KoyQyhLkUi1BBgeiRim0JX37A7SD+otybr LWuh7v5jcSbZjoxaCp+IxpLaE9vwToJn1gMKeIIx1SSgn67SDDo5O85IBRgF8FbczSS4 MYEwGkYG3RJj7KUfhCFT6rTz4odyFa4ZOtvRHPF9Eh1YDEcSAQzeZclME8jRbhYRgmyw Yy3nnUOe9g/f2NdE3Rn6E90m1oN6qjIKxfqc1qnjariu5k0JRaYY5dE1B6cc2YzWO1Ox TsVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fnMdNNMU; 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 l24si3351745pgo.128.2018.01.26.11.19.30; Fri, 26 Jan 2018 11:19:31 -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=fnMdNNMU; 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 S1753139AbeAZTT3 (ORCPT + 26 others); Fri, 26 Jan 2018 14:19:29 -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-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-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 | 48 ++++++++++++++++++++++++++++++++++ 1 file changed, 48 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..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