Browse Source

macro cleanup; from kaspars at bankovskis dot net

OPENBSD_5_7
schwarze 10 years ago
parent
commit
c009471d0a
2 changed files with 37 additions and 24 deletions
  1. +24
    -14
      src/lib/libc/hash/sha1.3
  2. +13
    -10
      src/lib/libc/hash/sha2.3

+ 24
- 14
src/lib/libc/hash/sha1.3 View File

@ -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> .\" 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 .\" See http://csrc.nist.gov/publications/fips/fips180-1/fip180-1.txt
.\" for the detailed standard .\" for the detailed standard
.\" .\"
.Dd $Mdocdate: March 23 2014 $
.Dd $Mdocdate: November 26 2014 $
.Dt SHA1 3 .Dt SHA1 3
.Os .Os
.Sh NAME .Sh NAME
@ -68,7 +68,7 @@ functions with which they share a similar interface.
The The
.Fn SHA1Init .Fn SHA1Init
function initializes a SHA1_CTX function initializes a SHA1_CTX
.Ar context
.Fa context
for use with for use with
.Fn SHA1Update , .Fn SHA1Update ,
and and
@ -76,16 +76,16 @@ and
The The
.Fn SHA1Update .Fn SHA1Update
function adds function adds
.Ar data
.Fa data
of length of length
.Ar len
.Fa len
to the SHA1_CTX specified by to the SHA1_CTX specified by
.Ar context .
.Fa context .
.Fn SHA1Final .Fn SHA1Final
is called when all data has been added via is called when all data has been added via
.Fn SHA1Update .Fn SHA1Update
and stores a message digest in the and stores a message digest in the
.Ar digest
.Fa digest
parameter. parameter.
.Pp .Pp
The The
@ -123,7 +123,9 @@ function calculates the digest for a file and returns the result via
.Fn SHA1End . .Fn SHA1End .
If If
.Fn SHA1File .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 .Pp
.Fn SHA1FileChunk .Fn SHA1FileChunk
behaves like behaves like
@ -154,17 +156,22 @@ For each of the
and and
.Fn SHA1Data .Fn SHA1Data
functions the functions the
.Ar buf
.Fa buf
parameter should either be a string of at least 41 characters in 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 In the latter case, space will be dynamically allocated via
.Xr malloc 3 .Xr malloc 3
and should be freed using and should be freed using
.Xr free 3 .Xr free 3
when it is no longer needed. when it is no longer needed.
.Sh EXAMPLES .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 .Bd -literal -offset indent
SHA1_CTX sha; SHA1_CTX sha;
u_int8_t results[SHA1_DIGEST_LENGTH]; 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 The SHA-1 functions appeared in
.Ox 2.0 . .Ox 2.0 .
.Sh AUTHORS .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 .Pp
The The
.Fn SHA1End , .Fn SHA1End ,
@ -223,7 +232,8 @@ The
.Fn SHA1FileChunk , .Fn SHA1FileChunk ,
and and
.Fn SHA1Data .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 .Sh CAVEATS
This implementation of SHA-1 has not been validated by NIST This implementation of SHA-1 has not been validated by NIST
and as such is not in official compliance with the standard. and as such is not in official compliance with the standard.


+ 13
- 10
src/lib/libc/hash/sha2.3 View File

@ -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> .\" 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 .\" See http://www.nist.gov/sha/ for the detailed standard
.\" .\"
.Dd $Mdocdate: March 23 2014 $
.Dd $Mdocdate: November 26 2014 $
.Dt SHA2 3 .Dt SHA2 3
.Os .Os
.Sh NAME .Sh NAME
@ -130,7 +130,7 @@ For brevity, only the 256-bit variants are described below.
The The
.Fn SHA256Init .Fn SHA256Init
function initializes a SHA2_CTX function initializes a SHA2_CTX
.Ar context
.Fa context
for use with for use with
.Fn SHA256Update .Fn SHA256Update
and and
@ -138,16 +138,16 @@ and
The The
.Fn SHA256Update .Fn SHA256Update
function adds function adds
.Ar data
.Fa data
of length of length
.Ar len
.Fa len
to the SHA2_CTX specified by to the SHA2_CTX specified by
.Ar context .
.Fa context .
.Fn SHA256Final .Fn SHA256Final
is called when all data has been added via is called when all data has been added via
.Fn SHA256Update .Fn SHA256Update
and stores a message digest in the and stores a message digest in the
.Ar digest
.Fa digest
parameter. parameter.
.Pp .Pp
The The
@ -219,7 +219,7 @@ For each of the
and and
.Fn SHA256Data .Fn SHA256Data
functions the functions the
.Ar buf
.Fa buf
parameter should either be a string large enough to hold the resulting digest parameter should either be a string large enough to hold the resulting digest
(e.g.\& (e.g.\&
.Ev SHA224_DIGEST_STRING_LENGTH , .Ev SHA224_DIGEST_STRING_LENGTH ,
@ -280,7 +280,9 @@ printf("0x%s\en", SHA256Data(buf, strlen(buf), output));
The SHA2 functions appeared in The SHA2 functions appeared in
.Ox 3.4 . .Ox 3.4 .
.Sh AUTHORS .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 .Pp
The The
.Fn SHA256End , .Fn SHA256End ,
@ -288,7 +290,8 @@ The
.Fn SHA256FileChunk , .Fn SHA256FileChunk ,
and and
.Fn SHA256Data .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 .Sh CAVEATS
This implementation of the Secure Hash Standard has not been validated by This implementation of the Secure Hash Standard has not been validated by
NIST and as such is not in official compliance with the standard. NIST and as such is not in official compliance with the standard.


Loading…
Cancel
Save