git: fd3ced150708 - main - libmd: export and document *Fd/*FdChunk interfaces

From: Kyle Evans <kevans_at_FreeBSD.org>
Date: Mon, 30 Sep 2024 03:36:10 UTC
The branch main has been updated by kevans:

URL: https://cgit.FreeBSD.org/src/commit/?id=fd3ced15070885c818b74a44a0fbe45ed8687f44

commit fd3ced15070885c818b74a44a0fbe45ed8687f44
Author:     Kyle Evans <kevans@FreeBSD.org>
AuthorDate: 2022-03-08 17:42:52 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2024-09-30 03:34:20 +0000

    libmd: export and document *Fd/*FdChunk interfaces
    
    PR:             280784 (exp-run)
    Fixes: de13c2427d6c ("libmd: introduce functions that operate on an fd")
    Reviewed by:    manpages (bcr), fuz
    Differential Revision:  https://reviews.freebsd.org/D34502
---
 lib/libmd/mdX.3    | 21 ++++++++++++++++++++-
 lib/libmd/mdXhl.c  |  4 ++++
 lib/libmd/ripemd.3 | 21 ++++++++++++++++++++-
 lib/libmd/sha.3    | 27 ++++++++++++++++++++++++++-
 lib/libmd/sha256.3 | 27 ++++++++++++++++++++++++++-
 lib/libmd/sha512.3 | 33 ++++++++++++++++++++++++++++++++-
 lib/libmd/skein.3  | 33 ++++++++++++++++++++++++++++++++-
 7 files changed, 160 insertions(+), 6 deletions(-)

diff --git a/lib/libmd/mdX.3 b/lib/libmd/mdX.3
index 26c8b2b43c81..7c86f28ad628 100644
--- a/lib/libmd/mdX.3
+++ b/lib/libmd/mdX.3
@@ -6,7 +6,7 @@
 .\" this stuff is worth it, you can buy me a beer in return.   Poul-Henning Kamp
 .\" ----------------------------------------------------------------------------
 .\"
-.Dd May 21, 2019
+.Dd March 8, 2022
 .Dt MDX 3
 .Os
 .Sh NAME
@@ -15,6 +15,8 @@
 .Nm MDXPad ,
 .Nm MDXFinal ,
 .Nm MDXEnd ,
+.Nm MDXFd ,
+.Nm MDXFdChunk ,
 .Nm MDXFile ,
 .Nm MDXFileChunk ,
 .Nm MDXData
@@ -35,6 +37,10 @@
 .Ft "char *"
 .Fn MDXEnd "MDX_CTX *context" "char *buf"
 .Ft "char *"
+.Fn MDXFd "int fd" "char *buf"
+.Ft "char *"
+.Fn MDXFdChunk "int fd" "char *buf" "off_t offset" "off_t length"
+.Ft "char *"
 .Fn MDXFile "const char *filename" "char *buf"
 .Ft "char *"
 .Fn MDXFileChunk "const char *filename" "char *buf" "off_t offset" "off_t length"
@@ -125,6 +131,19 @@ function calculates the digest of a chunk of data in memory, and uses
 .Fn MDXEnd
 to return the result.
 .Pp
+The
+.Fn MDXFd
+and
+.Fn MDXFdChunk
+functions are identical to their
+.Fn MDXFile
+and
+.Fn MDXFileChunk
+counterparts, with the exception that the first argument is an
+.Fa fd
+instead of a
+.Fa filename .
+.Pp
 When using
 .Fn MDXEnd ,
 .Fn MDXFile ,
diff --git a/lib/libmd/mdXhl.c b/lib/libmd/mdXhl.c
index 171b97b38794..68598f192056 100644
--- a/lib/libmd/mdXhl.c
+++ b/lib/libmd/mdXhl.c
@@ -130,6 +130,10 @@ __weak_reference(_libmd_MDXEnd, MDXEnd);
 __weak_reference(_libmd_MDXFile, MDXFile);
 #undef MDXFileChunk
 __weak_reference(_libmd_MDXFileChunk, MDXFileChunk);
+#undef MDXFd
+__weak_reference(_libmd_MDXFd, MDXFd);
+#undef MDXFdChunk
+__weak_reference(_libmd_MDXFdChunk, MDXFdChunk);
 #undef MDXData
 __weak_reference(_libmd_MDXData, MDXData);
 #endif
diff --git a/lib/libmd/ripemd.3 b/lib/libmd/ripemd.3
index fcd2ea308791..cad07aac8007 100644
--- a/lib/libmd/ripemd.3
+++ b/lib/libmd/ripemd.3
@@ -8,7 +8,7 @@
 .\"
 .\" 	From: Id: mdX.3,v 1.14 1999/02/11 20:31:49 wollman Exp
 .\"
-.Dd July 20, 2018
+.Dd March 8, 2022
 .Dt RIPEMD 3
 .Os
 .Sh NAME
@@ -16,6 +16,8 @@
 .Nm RIPEMD160_Update ,
 .Nm RIPEMD160_Final ,
 .Nm RIPEMD160_End ,
+.Nm RIPEMD160_Fd ,
+.Nm RIPEMD160_FdChunk ,
 .Nm RIPEMD160_File ,
 .Nm RIPEMD160_FileChunk ,
 .Nm RIPEMD160_Data
@@ -34,6 +36,10 @@
 .Ft "char *"
 .Fn RIPEMD160_End "RIPEMD160_CTX *context" "char *buf"
 .Ft "char *"
+.Fn RIPEMD160_Fd "int fd" "char *buf"
+.Ft "char *"
+.Fn RIPEMD160_FdChunk "int fd" "char *buf" "off_t offset" "off_t length"
+.Ft "char *"
 .Fn RIPEMD160_File "const char *filename" "char *buf"
 .Ft "char *"
 .Fn RIPEMD160_FileChunk "const char *filename" "char *buf" "off_t offset" "off_t length"
@@ -106,6 +112,19 @@ function calculates the digest of a chunk of data in memory, and uses
 .Fn RIPEMD160_End
 to return the result.
 .Pp
+The
+.Fn RIPEMD160_Fd
+and
+.Fn RIPEMD160_FdChunk
+functions are identical to their
+.Fn RIPEMD160_File
+and
+.Fn RIPEMD160_FileChunk
+counterparts, with the exception that the first argument is an
+.Fa fd
+instead of a
+.Fa filename .
+.Pp
 When using
 .Fn RIPEMD160_End ,
 .Fn RIPEMD160_File ,
diff --git a/lib/libmd/sha.3 b/lib/libmd/sha.3
index 49ee322eacab..e2475f981738 100644
--- a/lib/libmd/sha.3
+++ b/lib/libmd/sha.3
@@ -8,7 +8,7 @@
 .\"
 .\" 	From: Id: mdX.3,v 1.14 1999/02/11 20:31:49 wollman Exp
 .\"
-.Dd February 6, 2023
+.Dd February 12, 2023
 .Dt SHA 3
 .Os
 .Sh NAME
@@ -16,6 +16,8 @@
 .Nm SHA_Update ,
 .Nm SHA_Final ,
 .Nm SHA_End ,
+.Nm SHA_Fd ,
+.Nm SHA_FdChunk ,
 .Nm SHA_File ,
 .Nm SHA_FileChunk ,
 .Nm SHA_Data ,
@@ -23,6 +25,8 @@
 .Nm SHA1_Update ,
 .Nm SHA1_Final ,
 .Nm SHA1_End ,
+.Nm SHA1_Fd ,
+.Nm SHA1_FdChunk ,
 .Nm SHA1_File ,
 .Nm SHA1_FileChunk ,
 .Nm SHA1_Data
@@ -41,6 +45,10 @@
 .Ft "char *"
 .Fn SHA_End "SHA_CTX *context" "char *buf"
 .Ft "char *"
+.Fn SHA_Fd "int fd" "char *buf"
+.Ft "char *"
+.Fn SHA_FdChunk "int fd" "char *buf" "off_t offset" "off_t length"
+.Ft "char *"
 .Fn SHA_File "const char *filename" "char *buf"
 .Ft "char *"
 .Fn SHA_FileChunk "const char *filename" "char *buf" "off_t offset" "off_t length"
@@ -55,6 +63,10 @@
 .Ft "char *"
 .Fn SHA1_End "SHA_CTX *context" "char *buf"
 .Ft "char *"
+.Fn SHA1_Fd "int fd" "char *buf"
+.Ft "char *"
+.Fn SHA1_FdChunk "int fd" "char *buf" "off_t offset" "off_t length"
+.Ft "char *"
 .Fn SHA1_File "const char *filename" "char *buf"
 .Ft "char *"
 .Fn SHA1_FileChunk "const char *filename" "char *buf" "off_t offset" "off_t length"
@@ -130,6 +142,19 @@ calculates the digest of a chunk of data in memory, and uses
 .Fn SHA1_End
 to return the result.
 .Pp
+The
+.Fn SHA1_Fd
+and
+.Fn SHA1_FdChunk
+functions are identical to their
+.Fn SHA1_File
+and
+.Fn SHA1_FileChunk
+counterparts, with the exception that the first argument is an
+.Fa fd
+instead of a
+.Fa filename .
+.Pp
 When using
 .Fn SHA1_End ,
 .Fn SHA1_File ,
diff --git a/lib/libmd/sha256.3 b/lib/libmd/sha256.3
index e22258f40140..406dfd1b357d 100644
--- a/lib/libmd/sha256.3
+++ b/lib/libmd/sha256.3
@@ -8,7 +8,7 @@
 .\"
 .\" 	From: Id: mdX.3,v 1.14 1999/02/11 20:31:49 wollman Exp
 .\"
-.Dd July 20, 2018
+.Dd March 8, 2022
 .Dt SHA256 3
 .Os
 .Sh NAME
@@ -16,6 +16,8 @@
 .Nm SHA224_Update ,
 .Nm SHA224_Final ,
 .Nm SHA224_End ,
+.Nm SHA224_Fd ,
+.Nm SHA224_FdChunk ,
 .Nm SHA224_File ,
 .Nm SHA224_FileChunk ,
 .Nm SHA224_Data ,
@@ -23,6 +25,8 @@
 .Nm SHA256_Update ,
 .Nm SHA256_Final ,
 .Nm SHA256_End ,
+.Nm SHA256_Fd ,
+.Nm SHA256_FdChunk ,
 .Nm SHA256_File ,
 .Nm SHA256_FileChunk ,
 .Nm SHA256_Data
@@ -41,6 +45,10 @@
 .Ft "char *"
 .Fn SHA224_End "SHA224_CTX *context" "char *buf"
 .Ft "char *"
+.Fn SHA224_Fd "int fd" "char *buf"
+.Ft "char *"
+.Fn SHA224_FdChunk "int fd" "char *buf" "off_t offset" "off_t length"
+.Ft "char *"
 .Fn SHA224_File "const char *filename" "char *buf"
 .Ft "char *"
 .Fn SHA224_FileChunk "const char *filename" "char *buf" "off_t offset" "off_t length"
@@ -56,6 +64,10 @@
 .Ft "char *"
 .Fn SHA256_End "SHA256_CTX *context" "char *buf"
 .Ft "char *"
+.Fn SHA256_Fd "int fd" "char *buf"
+.Ft "char *"
+.Fn SHA256_FdChunk "int fd" "char *buf" "off_t offset" "off_t length"
+.Ft "char *"
 .Fn SHA256_File "const char *filename" "char *buf"
 .Ft "char *"
 .Fn SHA256_FileChunk "const char *filename" "char *buf" "off_t offset" "off_t length"
@@ -125,6 +137,19 @@ calculates the digest of a chunk of data in memory, and uses
 .Fn SHA256_End
 to return the result.
 .Pp
+The
+.Fn SHA256_Fd
+and
+.Fn SHA256_FdChunk
+functions are identical to their
+.Fn SHA256_File
+and
+.Fn SHA256_FileChunk
+counterparts, with the exception that the first argument is an
+.Fa fd
+instead of a
+.Fa filename .
+.Pp
 When using
 .Fn SHA256_End ,
 .Fn SHA256_File ,
diff --git a/lib/libmd/sha512.3 b/lib/libmd/sha512.3
index a5c478efa9ae..17d0d0988350 100644
--- a/lib/libmd/sha512.3
+++ b/lib/libmd/sha512.3
@@ -8,7 +8,7 @@
 .\"
 .\" 	From: Id: mdX.3,v 1.14 1999/02/11 20:31:49 wollman Exp
 .\"
-.Dd February 3, 2023
+.Dd February 12, 2023
 .Dt SHA512 3
 .Os
 .Sh NAME
@@ -16,6 +16,8 @@
 .Nm SHA512_Update ,
 .Nm SHA512_Final ,
 .Nm SHA512_End ,
+.Nm SHA512_Fd ,
+.Nm SHA512_FdChunk ,
 .Nm SHA512_File ,
 .Nm SHA512_FileChunk ,
 .Nm SHA512_Data ,
@@ -23,6 +25,8 @@
 .Nm SHA384_Update ,
 .Nm SHA384_Final ,
 .Nm SHA384_End ,
+.Nm SHA384_Fd ,
+.Nm SHA384_FdChunk ,
 .Nm SHA384_File ,
 .Nm SHA384_FileChunk ,
 .Nm SHA384_Data ,
@@ -37,6 +41,8 @@
 .Nm SHA512_256_Update ,
 .Nm SHA512_256_Final ,
 .Nm SHA512_256_End ,
+.Nm SHA512_256_Fd ,
+.Nm SHA512_256_FdChunk ,
 .Nm SHA512_256_File ,
 .Nm SHA512_256_FileChunk ,
 .Nm SHA512_256_Data
@@ -55,6 +61,10 @@
 .Ft "char *"
 .Fn SHA512_End "SHA512_CTX *context" "char *buf"
 .Ft "char *"
+.Fn SHA512_Fd "int fd" "char *buf"
+.Ft "char *"
+.Fn SHA512_FdChunk "int fd" "char *buf" "off_t offset" "off_t length"
+.Ft "char *"
 .Fn SHA512_File "const char *filename" "char *buf"
 .Ft "char *"
 .Fn SHA512_FileChunk "const char *filename" "char *buf" "off_t offset" "off_t length"
@@ -70,6 +80,10 @@
 .Ft "char *"
 .Fn SHA384_End "SHA384_CTX *context" "char *buf"
 .Ft "char *"
+.Fn SHA384_Fd "int fd" "char *buf"
+.Ft "char *"
+.Fn SHA384_FdChunk "int fd" "char *buf" "off_t offset" "off_t length"
+.Ft "char *"
 .Fn SHA384_File "const char *filename" "char *buf"
 .Ft "char *"
 .Fn SHA384_FileChunk "const char *filename" "char *buf" "off_t offset" "off_t length"
@@ -99,6 +113,10 @@
 .Ft "char *"
 .Fn SHA512_256_End "SHA512_CTX *context" "char *buf"
 .Ft "char *"
+.Fn SHA512_256_Fd "int fd" "char *buf"
+.Ft "char *"
+.Fn SHA512_256_FdChunk "int fd" "char *buf" "off_t offset" "off_t length"
+.Ft "char *"
 .Fn SHA512_256_File "const char *filename" "char *buf"
 .Ft "char *"
 .Fn SHA512_256_FileChunk "const char *filename" "char *buf" "off_t offset" "off_t length"
@@ -168,6 +186,19 @@ calculates the digest of a chunk of data in memory, and uses
 .Fn SHA512_End
 to return the result.
 .Pp
+The
+.Fn SHA512_Fd
+and
+.Fn SHA512_FdChunk
+functions are identical to their
+.Fn SHA512_File
+and
+.Fn SHA512_FileChunk
+counterparts, with the exception that the first argument is an
+.Fa fd
+instead of a
+.Fa filename .
+.Pp
 When using
 .Fn SHA512_End ,
 .Fn SHA512_File ,
diff --git a/lib/libmd/skein.3 b/lib/libmd/skein.3
index 1dff9e2c92dc..8fe79a4ad0bf 100644
--- a/lib/libmd/skein.3
+++ b/lib/libmd/skein.3
@@ -23,7 +23,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd May 21, 2019
+.Dd March 8, 2022
 .Dt SKEIN 3
 .Os
 .Sh NAME
@@ -31,6 +31,8 @@
 .Nm SKEIN256_Update ,
 .Nm SKEIN256_Final ,
 .Nm SKEIN256_End ,
+.Nm SKEIN256_Fd ,
+.Nm SKEIN256_FdChunk ,
 .Nm SKEIN256_File ,
 .Nm SKEIN256_FileChunk ,
 .Nm SKEIN256_Data ,
@@ -38,6 +40,8 @@
 .Nm SKEIN512_Update ,
 .Nm SKEIN512_Final ,
 .Nm SKEIN512_End ,
+.Nm SKEIN512_Fd ,
+.Nm SKEIN512_FdChunk ,
 .Nm SKEIN512_File ,
 .Nm SKEIN512_FileChunk ,
 .Nm SKEIN512_Data ,
@@ -45,6 +49,8 @@
 .Nm SKEIN1024_Update ,
 .Nm SKEIN1024_Final ,
 .Nm SKEIN1024_End ,
+.Nm SKEIN1024_Fd ,
+.Nm SKEIN1024_FdChunk ,
 .Nm SKEIN1024_File ,
 .Nm SKEIN1024_FileChunk ,
 .Nm SKEIN1024_Data
@@ -63,6 +69,10 @@
 .Ft "char *"
 .Fn SKEIN256_End "SKEIN256_CTX *context" "char *buf"
 .Ft "char *"
+.Fn SKEIN256_Fd "int fd" "char *buf"
+.Ft "char *"
+.Fn SKEIN256_FdChunk "int fd" "char *buf" "off_t offset" "off_t length"
+.Ft "char *"
 .Fn SKEIN256_File "const char *filename" "char *buf"
 .Ft "char *"
 .Fn SKEIN256_FileChunk "const char *filename" "char *buf" "off_t offset" "off_t length"
@@ -77,6 +87,10 @@
 .Ft "char *"
 .Fn SKEIN512_End "SKEIN512_CTX *context" "char *buf"
 .Ft "char *"
+.Fn SKEIN512_Fd "int fd" "char *buf"
+.Ft "char *"
+.Fn SKEIN512_FdChunk "int fd" "char *buf" "off_t offset" "off_t length"
+.Ft "char *"
 .Fn SKEIN512_File "const char *filename" "char *buf"
 .Ft "char *"
 .Fn SKEIN512_FileChunk "const char *filename" "char *buf" "off_t offset" "off_t length"
@@ -91,6 +105,10 @@
 .Ft "char *"
 .Fn SKEIN1024_End "SKEIN1024_CTX *context" "char *buf"
 .Ft "char *"
+.Fn SKEIN1024_Fd "int fd" "char *buf"
+.Ft "char *"
+.Fn SKEIN1024_FdChunk "int fd" "char *buf" "off_t offset" "off_t length"
+.Ft "char *"
 .Fn SKEIN1024_File "const char *filename" "char *buf"
 .Ft "char *"
 .Fn SKEIN1024_FileChunk "const char *filename" "char *buf" "off_t offset" "off_t length"
@@ -160,6 +178,19 @@ calculates the digest of a chunk of data in memory, and uses
 .Fn SKEIN256_End
 to return the result.
 .Pp
+The
+.Fn SKEIN256_Fd
+and
+.Fn SKEIN256_FdChunk
+functions are identical to their
+.Fn SKEIN256_File
+and
+.Fn SKEIN256_FileChunk
+counterparts, with the exception that the first argument is an
+.Fa fd
+instead of a
+.Fa filename .
+.Pp
 When using
 .Fn SKEIN256_End ,
 .Fn SKEIN256_File ,