summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2014-11-26 02:05:58 +0000
committerschwarze <schwarze@openbsd.org>2014-11-26 02:05:58 +0000
commit5d8dd67ccea4432375e37006d753438c4a89ff41 (patch)
tree8f7ff0a8d10216038ecb8cf649ad94ce47ce37c7
parentMake the code sipler and more robust by always assigning a value (diff)
downloadwireguard-openbsd-5d8dd67ccea4432375e37006d753438c4a89ff41.tar.xz
wireguard-openbsd-5d8dd67ccea4432375e37006d753438c4a89ff41.zip
macro cleanup; from kaspars at bankovskis dot net
-rw-r--r--lib/libc/hash/sha1.338
-rw-r--r--lib/libc/hash/sha2.323
2 files changed, 37 insertions, 24 deletions
diff --git a/lib/libc/hash/sha1.3 b/lib/libc/hash/sha1.3
index 5923cec854e..885b2c99a3c 100644
--- a/lib/libc/hash/sha1.3
+++ b/lib/libc/hash/sha1.3
@@ -1,4 +1,4 @@
-.\" $OpenBSD: sha1.3,v 1.40 2014/03/23 23:27:22 naddy Exp $
+.\" $OpenBSD: sha1.3,v 1.41 2014/11/26 02:05:58 schwarze Exp $
.\"
.\" Copyright (c) 1997, 2004 Todd C. Miller <Todd.Miller@courtesan.com>
.\"
@@ -17,7 +17,7 @@
.\" See http://csrc.nist.gov/publications/fips/fips180-1/fip180-1.txt
.\" for the detailed standard
.\"
-.Dd $Mdocdate: March 23 2014 $
+.Dd $Mdocdate: November 26 2014 $
.Dt SHA1 3
.Os
.Sh NAME
@@ -68,7 +68,7 @@ functions with which they share a similar interface.
The
.Fn SHA1Init
function initializes a SHA1_CTX
-.Ar context
+.Fa context
for use with
.Fn SHA1Update ,
and
@@ -76,16 +76,16 @@ and
The
.Fn SHA1Update
function adds
-.Ar data
+.Fa data
of length
-.Ar len
+.Fa len
to the SHA1_CTX specified by
-.Ar context .
+.Fa context .
.Fn SHA1Final
is called when all data has been added via
.Fn SHA1Update
and stores a message digest in the
-.Ar digest
+.Fa digest
parameter.
.Pp
The
@@ -123,7 +123,9 @@ function calculates the digest for a file and returns the result via
.Fn SHA1End .
If
.Fn SHA1File
-is unable to open the file a NULL pointer is returned.
+is unable to open the file a
+.Dv NULL
+pointer is returned.
.Pp
.Fn SHA1FileChunk
behaves like
@@ -154,17 +156,22 @@ For each of the
and
.Fn SHA1Data
functions the
-.Ar buf
+.Fa buf
parameter should either be a string of at least 41 characters in
-size or a NULL pointer.
+size or a
+.Dv NULL
+pointer.
In the latter case, space will be dynamically allocated via
.Xr malloc 3
and should be freed using
.Xr free 3
when it is no longer needed.
.Sh EXAMPLES
-The follow code fragment will calculate the digest for
-the string "abc" which is ``0xa9993e364706816aba3e25717850c26c9cd0d89d''.
+The following code fragment will calculate the digest for
+the string
+.Qq abc
+which is
+.Dq 0xa9993e364706816aba3e25717850c26c9cd0d89d .
.Bd -literal -offset indent
SHA1_CTX sha;
u_int8_t results[SHA1_DIGEST_LENGTH];
@@ -215,7 +222,9 @@ printf("0x%s\en", SHA1Data(buf, strlen(buf), output));
The SHA-1 functions appeared in
.Ox 2.0 .
.Sh AUTHORS
-This implementation of SHA-1 was written by Steve Reid.
+.An -nosplit
+This implementation of SHA-1 was written by
+.An Steve Reid .
.Pp
The
.Fn SHA1End ,
@@ -223,7 +232,8 @@ The
.Fn SHA1FileChunk ,
and
.Fn SHA1Data
-helper functions are derived from code written by Poul-Henning Kamp.
+helper functions are derived from code written by
+.An Poul-Henning Kamp .
.Sh CAVEATS
This implementation of SHA-1 has not been validated by NIST
and as such is not in official compliance with the standard.
diff --git a/lib/libc/hash/sha2.3 b/lib/libc/hash/sha2.3
index f99429a1c1b..4a9142be563 100644
--- a/lib/libc/hash/sha2.3
+++ b/lib/libc/hash/sha2.3
@@ -1,4 +1,4 @@
-.\" $OpenBSD: sha2.3,v 1.20 2014/03/23 23:27:22 naddy Exp $
+.\" $OpenBSD: sha2.3,v 1.21 2014/11/26 02:05:58 schwarze Exp $
.\"
.\" Copyright (c) 2003, 2004 Todd C. Miller <Todd.Miller@courtesan.com>
.\"
@@ -20,7 +20,7 @@
.\"
.\" See http://www.nist.gov/sha/ for the detailed standard
.\"
-.Dd $Mdocdate: March 23 2014 $
+.Dd $Mdocdate: November 26 2014 $
.Dt SHA2 3
.Os
.Sh NAME
@@ -130,7 +130,7 @@ For brevity, only the 256-bit variants are described below.
The
.Fn SHA256Init
function initializes a SHA2_CTX
-.Ar context
+.Fa context
for use with
.Fn SHA256Update
and
@@ -138,16 +138,16 @@ and
The
.Fn SHA256Update
function adds
-.Ar data
+.Fa data
of length
-.Ar len
+.Fa len
to the SHA2_CTX specified by
-.Ar context .
+.Fa context .
.Fn SHA256Final
is called when all data has been added via
.Fn SHA256Update
and stores a message digest in the
-.Ar digest
+.Fa digest
parameter.
.Pp
The
@@ -219,7 +219,7 @@ For each of the
and
.Fn SHA256Data
functions the
-.Ar buf
+.Fa buf
parameter should either be a string large enough to hold the resulting digest
(e.g.\&
.Ev SHA224_DIGEST_STRING_LENGTH ,
@@ -280,7 +280,9 @@ printf("0x%s\en", SHA256Data(buf, strlen(buf), output));
The SHA2 functions appeared in
.Ox 3.4 .
.Sh AUTHORS
-This implementation of the SHA functions was written by Aaron D. Gifford.
+.An -nosplit
+This implementation of the SHA functions was written by
+.An Aaron D. Gifford .
.Pp
The
.Fn SHA256End ,
@@ -288,7 +290,8 @@ The
.Fn SHA256FileChunk ,
and
.Fn SHA256Data
-helper functions are derived from code written by Poul-Henning Kamp.
+helper functions are derived from code written by
+.An Poul-Henning Kamp .
.Sh CAVEATS
This implementation of the Secure Hash Standard has not been validated by
NIST and as such is not in official compliance with the standard.