|
@ -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. |
|
|