
#use wml::openssl-macros area=docs page=sha

<title>Documents, sha(3)</title>

<h1>sha(3)</h1>

#use wml::imp::generic

{:
## What's this? [[s|(<STRONG>[^<].+?)</A>(</STRONG><DD>)|$1$2|sg]]
[[s|<P>\s+<P>|<P>|sg]]
[[s|<P>\s+</|</|sg]]
[[s|<DD>\s*<DT>|<DD>&nbsp;<DT>|sg]]
[[s|<DD>\s*</DL>|<DD>&nbsp;</DL>|sg]]
[[s|\[|&#91;|sg]]
[[s|\]|&#93;|sg]]

<!-- INDEX BEGIN -->

<UL>

	<LI><A HREF="#NAME">NAME</A>
	<LI><A HREF="#SYNOPSIS">SYNOPSIS</A>
	<LI><A HREF="#DESCRIPTION">DESCRIPTION</A>
	<LI><A HREF="#RETURN_VALUES">RETURN VALUES</A>
	<LI><A HREF="#CONFORMING_TO">CONFORMING TO</A>
	<LI><A HREF="#SEE_ALSO">SEE ALSO</A>
	<LI><A HREF="#HISTORY">HISTORY</A>
</UL>
<!-- INDEX END -->

<HR>
<P>
<HR>
<H1><A NAME="NAME">NAME</A></H1>
<P>
SHA1, SHA1_Init, SHA1_Update, SHA1_Final - Secure Hash Algorithm

</P>
<P>
<HR>
<H1><A NAME="SYNOPSIS">SYNOPSIS</A></H1>
<PRE> #include &lt;openssl/sha.h&gt;
</PRE>
<PRE> unsigned char *SHA1(const unsigned char *d, unsigned long n,
                  unsigned char *md);
</PRE>
<PRE> int SHA1_Init(SHA_CTX *c);
 int SHA1_Update(SHA_CTX *c, const void *data,
                  unsigned long len);
 int SHA1_Final(unsigned char *md, SHA_CTX *c);
</PRE>
<P>
<HR>
<H1><A NAME="DESCRIPTION">DESCRIPTION</A></H1>
<P>
SHA-1 (Secure Hash Algorithm) is a cryptographic hash function with a 160
bit output.

</P>
<P>
<CODE>SHA1()</CODE> computes the SHA-1 message digest of the <STRONG>n</STRONG>
bytes at <STRONG>d</STRONG> and places it in <STRONG>md</STRONG> (which must have space for SHA_DIGEST_LENGTH == 20 bytes of output). If <STRONG>md</STRONG> is NULL, the digest is placed in a static array.

</P>
<P>
The following functions may be used if the message is not completely stored
in memory:

</P>
<P>
<CODE>SHA1_Init()</CODE> initializes a <STRONG>SHA_CTX</STRONG> structure.

</P>
<P>
<CODE>SHA1_Update()</CODE> can be called repeatedly with chunks of the
message to be hashed (<STRONG>len</STRONG> bytes at <STRONG>data</STRONG>).

</P>
<P>
<CODE>SHA1_Final()</CODE> places the message digest in <STRONG>md</STRONG>, which must have space for SHA_DIGEST_LENGTH == 20 bytes of output, and
erases the <STRONG>SHA_CTX</STRONG>.

</P>
<P>
Applications should use the higher level functions
<A HREF="../crypto/EVP_DigestInit.html#">EVP_DigestInit(3)</A>
etc. instead of calling the hash functions directly.

</P>
<P>
The predecessor of SHA-1, SHA, is also implemented, but it should be used
only when backward compatibility is required.

</P>
<P>
<HR>
<H1><A NAME="RETURN_VALUES">RETURN VALUES</A></H1>
<P>
<CODE>SHA1()</CODE> returns a pointer to the hash value. 

</P>
<P>
<CODE>SHA1_Init(),</CODE> <CODE>SHA1_Update()</CODE> and
<CODE>SHA1_Final()</CODE> return 1 for success, 0 otherwise.

</P>
<P>
<HR>
<H1><A NAME="CONFORMING_TO">CONFORMING TO</A></H1>
<P>
SHA: US Federal Information Processing Standard FIPS PUB 180 (Secure Hash
Standard), SHA-1: US Federal Information Processing Standard FIPS PUB 180-1
(Secure Hash Standard), ANSI X9.30

</P>
<P>
<HR>
<H1><A NAME="SEE_ALSO">SEE ALSO</A></H1>
<P>
<A HREF="../crypto/ripemd.html#">ripemd(3)</A>, <A HREF="../crypto/hmac.html#">hmac(3)</A>, <A HREF="../crypto/EVP_DigestInit.html#">EVP_DigestInit(3)</A>



</P>
<P>
<HR>
<H1><A NAME="HISTORY">HISTORY</A></H1>
<P>
<CODE>SHA1(),</CODE> <CODE>SHA1_Init(),</CODE> <CODE>SHA1_Update()</CODE>
and <CODE>SHA1_Final()</CODE> are available in all versions of SSLeay and
OpenSSL.

</P>
:}

