Received: by 10.223.176.46 with SMTP id f43csp1070092wra; Fri, 26 Jan 2018 11:20:29 -0800 (PST) X-Google-Smtp-Source: AH8x226JMBbWVXnU7eij56aOwsouKnF8jIw+r8BSoY3EDmM8bk71JvXb1bVSEp6Zbu5kTAsNbGWX X-Received: by 2002:a17:902:bc85:: with SMTP id bb5-v6mr15447069plb.425.1516994429531; Fri, 26 Jan 2018 11:20:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516994429; cv=none; d=google.com; s=arc-20160816; b=hOhaXZ+p2n24fAZza+U7CuFS91nP8ecb79WJX63c72ff4JhKH5P6h/r9UeTvFS5dJQ yuaE95f29R4uYqs2V37GWcfxlEUJIIOV/ddqRSbjxV0zrEWlLWWq8G0RpUYKl8PqbP1f gePzxzxq6DSN1KyHjyWTgQ3PDyFlKSMTl/vS/KzIdy1mWCvEjaLfxi2VRYfQdyrAIPxB d678Dhw5uKOVhuXWKARpRbk0otur3L7pKS98U4KuIi3hw196FktiOLsb23xy+Spc21QS WdWE1dtv/XKBvSGvtWULALCqXuxW95NV0KmYuJYpDtCBVv5sO/NPhbl1dYpRRCfFplKf RDhw== 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 k132si3368288pgc.18.2018.01.26.11.20.15; Fri, 26 Jan 2018 11:20:29 -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 S1753134AbeAZTT3 (ORCPT + 99 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 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 -- 2.13.6