aboutsummaryrefslogtreecommitdiff
path: root/lib/libmd/sha512.3
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libmd/sha512.3')
-rw-r--r--lib/libmd/sha512.388
1 files changed, 75 insertions, 13 deletions
diff --git a/lib/libmd/sha512.3 b/lib/libmd/sha512.3
index 6a5ed6f887d9..17d0d0988350 100644
--- a/lib/libmd/sha512.3
+++ b/lib/libmd/sha512.3
@@ -7,9 +7,8 @@
.\" ----------------------------------------------------------------------------
.\"
.\" From: Id: mdX.3,v 1.14 1999/02/11 20:31:49 wollman Exp
-.\" $FreeBSD$
.\"
-.Dd May 21, 2019
+.Dd February 12, 2023
.Dt SHA512 3
.Os
.Sh NAME
@@ -17,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 ,
@@ -24,13 +25,24 @@
.Nm SHA384_Update ,
.Nm SHA384_Final ,
.Nm SHA384_End ,
+.Nm SHA384_Fd ,
+.Nm SHA384_FdChunk ,
.Nm SHA384_File ,
.Nm SHA384_FileChunk ,
.Nm SHA384_Data ,
+.Nm SHA512_224_Init ,
+.Nm SHA512_224_Update ,
+.Nm SHA512_224_Final ,
+.Nm SHA512_224_End ,
+.Nm SHA512_224_File ,
+.Nm SHA512_224_FileChunk ,
+.Nm SHA512_224_Data
.Nm SHA512_256_Init ,
.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
@@ -49,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"
@@ -64,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"
@@ -71,6 +91,20 @@
.Fn SHA384_Data "const unsigned char *data" "unsigned int len" "char *buf"
.In sha512t.h
.Ft void
+.Fn SHA512_224_Init "SHA512_CTX *context"
+.Ft void
+.Fn SHA512_224_Update "SHA512_CTX *context" "const unsigned char *data" "size_t len"
+.Ft void
+.Fn SHA512_224_Final "unsigned char digest[32]" "SHA512_CTX *context"
+.Ft "char *"
+.Fn SHA512_224_End "SHA512_CTX *context" "char *buf"
+.Ft "char *"
+.Fn SHA512_224_File "const char *filename" "char *buf"
+.Ft "char *"
+.Fn SHA512_224_FileChunk "const char *filename" "char *buf" "off_t offset" "off_t length"
+.Ft "char *"
+.Fn SHA512_224_Data "const unsigned char *data" "unsigned int len" "char *buf"
+.Ft void
.Fn SHA512_256_Init "SHA512_CTX *context"
.Ft void
.Fn SHA512_256_Update "SHA512_CTX *context" "const unsigned char *data" "size_t len"
@@ -79,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"
@@ -119,8 +157,7 @@ is a wrapper for
.Fn SHA512_Final
which converts the return value to a 129-character
(including the terminating '\e0')
-.Tn ASCII
-string which represents the 512 bits in hexadecimal.
+ASCII string which represents the 512 bits in hexadecimal.
.Pp
.Fn SHA512_File
calculates the digest of a file, and uses
@@ -149,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 ,
@@ -167,29 +217,43 @@ If the
argument is non-null it must point to at least 129 characters of buffer space.
.Pp
The
-.Li SHA384_
+.Li SHA384_ ,
+.Li SHA512_224 ,
and
.Li SHA512_256_
functions are identical to the
.Li SHA512_
functions except they use a different initial hash value and the output is
-truncated to 384 bits and 256 bits respectively.
+truncated to 384, 224, and 256 bits respectively.
.Pp
.Fn SHA384_End
is a wrapper for
.Fn SHA384_Final
which converts the return value to a 97-character
(including the terminating '\e0')
+ASCII string which represents the 384 bits in hexadecimal.
+.Pp
+.Fn SHA512_224_End
+is a wrapper for
+.Fn SHA512_Final
+which converts the return value to a 57-character
+(including the terminating '\e0')
+ASCII string which represents the 224 bits in hexadecimal.
+.Pp
+.Fn SHA512_224_End
+is a wrapper for
+.Fn SHA512_Final
+which converts the return value to a 57-character
+(including the terminating '\e0')
.Tn ASCII
-string which represents the 384 bits in hexadecimal.
+string which represents the 224 bits in hexadecimal.
.Pp
.Fn SHA512_256_End
is a wrapper for
.Fn SHA512_Final
which converts the return value to a 65-character
(including the terminating '\e0')
-.Tn ASCII
-string which represents the 256 bits in hexadecimal.
+ASCII string which represents the 256 bits in hexadecimal.
.Sh ERRORS
The
.Fn SHA512_End
@@ -208,7 +272,7 @@ may return NULL when underlying
.Xr fstat 2 ,
.Xr lseek 2 ,
or
-.Xr SHA512_End 2
+.Xr SHA512_End 3
fail.
.Sh SEE ALSO
.Xr md4 3 ,
@@ -223,9 +287,7 @@ These functions appeared in
.Fx 9.0 .
.Sh AUTHORS
The core hash routines were implemented by Colin Percival based on
-the published
-.Tn FIPS 180-2
-standard.
+the published FIPS 180-2 standard.
.Sh BUGS
No method is known to exist which finds two files having the same hash value,
nor to find a file with a specific hash value.