git: 2d7f27a4fb4c - stable/13 - opencrypto: Add a routine to copy a crypto buffer cursor
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 18 Mar 2022 15:41:54 UTC
The branch stable/13 has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=2d7f27a4fb4c1c67c48fad9c73b1f3eec60195d5
commit 2d7f27a4fb4c1c67c48fad9c73b1f3eec60195d5
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2022-02-16 02:45:32 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
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)
{