From nobody Fri Mar 18 15:41:54 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4CB7F1A312D3; Fri, 18 Mar 2022 15:41:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KKpCl1FbYz3vVT; Fri, 18 Mar 2022 15:41:55 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1647618115; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=sbAIGrIMtTFxBjao/Gx4rCAgrtMmjNjdaBP5fDzX6yE=; b=Vc46xuP1AIxV7EuTtJznvbK0y6jDdsry/ucHCLorFURCm0sOJvlZnioZLREhIuXnILz0vK 3/+2sIGkIGD4dkMDQTCAYSfojvU666da3FqACkYz+zA/LpofjRx+bML8tjIcvnWOhMYhrs liNyRupLoDb+aWspQHek7Relvc47g7Jxfs/OHEJYnQC7qFabYiImzcs1qdi8DnE+UB+b2/ 1glv37ceQzJw5j+NzOAyZoAqKKlg7Dz6dcVEZzVwfVR5hn6zi7QesQpY+eFB+0vty4fOkz /JBq77Y7kTz2oB2cO/JIvldzN/kMS41IkU9XbHg3QXpXU8HfQmN6/fxnSnqmww== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0973F21937; Fri, 18 Mar 2022 15:41:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 22IFfsQ3089215; Fri, 18 Mar 2022 15:41:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 22IFfsnF089214; Fri, 18 Mar 2022 15:41:54 GMT (envelope-from git) Date: Fri, 18 Mar 2022 15:41:54 GMT Message-Id: <202203181541.22IFfsnF089214@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 2d7f27a4fb4c - stable/13 - opencrypto: Add a routine to copy a crypto buffer cursor List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 2d7f27a4fb4c1c67c48fad9c73b1f3eec60195d5 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1647618115; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=sbAIGrIMtTFxBjao/Gx4rCAgrtMmjNjdaBP5fDzX6yE=; b=WUL7y8tq/xZhcDfdWjZWN7l8c4XerIon1fpDe/DGL5geJ0mKk1agnDPVfnSOcB6ILPR4WZ /8QPL9fOwUjCciPP+He0t4FHoDCk9JalmSru2sCanuaB9lz0mahFeWFvRbcTyEmt2zMPiK jnaY7BeF4JmqS3yheHMp3/fysy4L92TCYSF5RzJpIVxFgAcQS3cxjZs9SMmFGVYvOSfdQZ bj+RTbvRIQ8lYa21xwYQ+jgbyGTfcPZ88Kl0McLObOAb6/wUeR/VqSRgf1tg9E+3BAsi8g +6+gKeks7VPCxVxptFmdcp3B5QUPbGfkphHykK9BWTwVcDzM9QnteILZV/PH8g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1647618115; a=rsa-sha256; cv=none; b=MaLzHxqCeChCKtT4OGtgQ+jMPPN1KQtEOnWvVMJBKPeauPrQ8mKSbV50LxhxRH4l20FfzX bqWdnJP+5IhonZ43Xe70abXWxN8nzlB+Ua4j5XDdVKniTAcF41RFuTkHKxeMfyRv/K7nRV 7IxaIqlbR6JHoUnje3D5sdX623Jv4w8rkDf8m43tfpQ9zrhn3MKCs3G3r2Jero8r1TtDCD TGKgjeaJuCdRpv5xga+z4GyPPcPALtaMLfFE1j58Q5ymH56MWnbP2SnZiiHDEsMXxO0uSs mWg2I1Sfcyn95dtA1/VFTzx+1rR93OFBCwukx5hi/+tnKQUp55jQtlm5TV95qA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=2d7f27a4fb4c1c67c48fad9c73b1f3eec60195d5 commit 2d7f27a4fb4c1c67c48fad9c73b1f3eec60195d5 Author: Mark Johnston AuthorDate: 2022-02-16 02:45:32 +0000 Commit: Mark Johnston CommitDate: 2022-03-18 15:31:33 +0000 opencrypto: Add a routine to copy a crypto buffer cursor This was useful in converting armv8crypto to use buffer cursors. There are some cases where one wants to make two passes over data, and this provides a way to "reset" a cursor. Reviewed by: jhb (cherry picked from commit 09bfa5cf16a37509a136367431472f9169a173ad) --- share/man/man9/crypto_buffer.9 | 13 ++++++++++++- sys/opencrypto/cryptodev.h | 7 +++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/share/man/man9/crypto_buffer.9 b/share/man/man9/crypto_buffer.9 index a16206e8e607..064c6fbc12e3 100644 --- a/share/man/man9/crypto_buffer.9 +++ b/share/man/man9/crypto_buffer.9 @@ -30,7 +30,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 25, 2021 +.Dd Feburary 11, 2022 .Dt CRYPTO_BUFFER 9 .Os .Sh NAME @@ -99,6 +99,11 @@ .Fn crypto_cursor_segbase "struct crypto_buffer_cursor *cc" .Ft size_t .Fn crypto_cursor_seglen "struct crypto_buffer_cursor *cc" +.Ft void +.Fo crypto_cursor_copy +.Fa "const struct crypto_buffer_cursor *fromc" +.Fa "struct crypto_buffer_cursor *toc" +.Fc .Ft bool .Fn CRYPTO_HAS_OUTPUT_BUFFER "struct cryptop *crp" .Sh DESCRIPTION @@ -327,6 +332,12 @@ returns the length of a buffer in bytes. .Fn crypto_cursor_seglen returns the length in bytes of a contiguous segment. .Pp +.Fn crypto_cursor_copy +makes a deep copy of the cursor +.Fa fromc . +The two copies do not share any state and can thus be used +independently. +.Pp .Fn CRYPTO_HAS_OUTPUT_BUFFER returns true if the request uses a separate output buffer. .Sh SEE ALSO diff --git a/sys/opencrypto/cryptodev.h b/sys/opencrypto/cryptodev.h index 1aa11c34d8ba..b127f4ee6b38 100644 --- a/sys/opencrypto/cryptodev.h +++ b/sys/opencrypto/cryptodev.h @@ -741,6 +741,13 @@ void crypto_cursor_copydata(struct crypto_buffer_cursor *cc, int size, void crypto_cursor_copydata_noadv(struct crypto_buffer_cursor *cc, int size, void *vdst); +static __inline void +crypto_cursor_copy(const struct crypto_buffer_cursor *fromc, + struct crypto_buffer_cursor *toc) +{ + memcpy(toc, fromc, sizeof(*toc)); +} + static __inline void crypto_read_iv(struct cryptop *crp, void *iv) {