diff options
author | Mark Johnston <markj@FreeBSD.org> | 2022-02-16 02:45:32 +0000 |
---|---|---|
committer | Mark Johnston <markj@FreeBSD.org> | 2022-02-16 02:47:10 +0000 |
commit | 09bfa5cf16a37509a136367431472f9169a173ad (patch) | |
tree | 8c307f013043c62901692e691cc1c21489b01a85 | |
parent | 6baea3312d92cd7eb25f5b9e0e474132636f62d9 (diff) | |
download | src-09bfa5cf16a37509a136367431472f9169a173ad.tar.gz src-09bfa5cf16a37509a136367431472f9169a173ad.zip |
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
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D28949
-rw-r--r-- | share/man/man9/crypto_buffer.9 | 13 | ||||
-rw-r--r-- | sys/opencrypto/cryptodev.h | 7 |
2 files changed, 19 insertions, 1 deletions
diff --git a/share/man/man9/crypto_buffer.9 b/share/man/man9/crypto_buffer.9 index c6911d3bb1c9..87cdf53b1abd 100644 --- a/share/man/man9/crypto_buffer.9 +++ b/share/man/man9/crypto_buffer.9 @@ -30,7 +30,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 16, 2021 +.Dd Feburary 11, 2022 .Dt CRYPTO_BUFFER 9 .Os .Sh NAME @@ -95,6 +95,11 @@ .Fc .Ft void * .Fn crypto_cursor_segment "struct crypto_buffer_cursor *cc" "size_t *len" +.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 @@ -315,6 +320,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 3eef1aada2a7..3a0022996a3c 100644 --- a/sys/opencrypto/cryptodev.h +++ b/sys/opencrypto/cryptodev.h @@ -686,6 +686,13 @@ 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) { const struct crypto_session_params *csp; |