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

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

<h1>md5(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="#NOTE">NOTE</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>
MD2, MD4, MD5, MD2_Init, MD2_Update, MD2_Final, MD4_Init, MD4_Update,
MD4_Final, MD5_Init, MD5_Update, MD5_Final - MD2, MD4, and MD5 hash
functions

</P>
<P>
<HR>
<H1><A NAME="SYNOPSIS">SYNOPSIS</A></H1>
<PRE> #include &lt;openssl/md2.h&gt;
</PRE>
<PRE> unsigned char *MD2(const unsigned char *d, unsigned long n,
                  unsigned char *md);
</PRE>
<PRE> int MD2_Init(MD2_CTX *c);
 int MD2_Update(MD2_CTX *c, const unsigned char *data,
                  unsigned long len);
 int MD2_Final(unsigned char *md, MD2_CTX *c);
</PRE>
<PRE> #include &lt;openssl/md4.h&gt;
</PRE>
<PRE> unsigned char *MD4(const unsigned char *d, unsigned long n,
                  unsigned char *md);
</PRE>
<PRE> int MD4_Init(MD4_CTX *c);
 int MD4_Update(MD4_CTX *c, const void *data,
                  unsigned long len);
 int MD4_Final(unsigned char *md, MD4_CTX *c);
</PRE>
<PRE> #include &lt;openssl/md5.h&gt;
</PRE>
<PRE> unsigned char *MD5(const unsigned char *d, unsigned long n,
                  unsigned char *md);
</PRE>
<PRE> int MD5_Init(MD5_CTX *c);
 int MD5_Update(MD5_CTX *c, const void *data,
                  unsigned long len);
 int MD5_Final(unsigned char *md, MD5_CTX *c);
</PRE>
<P>
<HR>
<H1><A NAME="DESCRIPTION">DESCRIPTION</A></H1>
<P>
MD2, MD4, and MD5 are cryptographic hash functions with a 128 bit output.

</P>
<P>
<CODE>MD2(),</CODE> <CODE>MD4(),</CODE> and <CODE>MD5()</CODE> compute the
MD2, MD4, and MD5 message digest of the <STRONG>n</STRONG> bytes at <STRONG>d</STRONG> and place it in <STRONG>md</STRONG> (which must have space for MD2_DIGEST_LENGTH == MD4_DIGEST_LENGTH ==
MD5_DIGEST_LENGTH == 16 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>MD2_Init()</CODE> initializes a <STRONG>MD2_CTX</STRONG> structure.

</P>
<P>
<CODE>MD2_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>MD2_Final()</CODE> places the message digest in <STRONG>md</STRONG>, which must have space for MD2_DIGEST_LENGTH == 16 bytes of output, and
erases the <STRONG>MD2_CTX</STRONG>.

</P>
<P>
<CODE>MD4_Init(),</CODE> <CODE>MD4_Update(),</CODE>
<CODE>MD4_Final(),</CODE> <CODE>MD5_Init(),</CODE>
<CODE>MD5_Update(),</CODE> and <CODE>MD5_Final()</CODE> are analogous using
an <STRONG>MD4_CTX</STRONG> and <STRONG>MD5_CTX</STRONG> structure.

</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>
<HR>
<H1><A NAME="NOTE">NOTE</A></H1>
<P>
MD2, MD4, and MD5 are recommended only for compatibility with existing
applications. In new applications, SHA-1 or RIPEMD-160 should be preferred.

</P>
<P>
<HR>
<H1><A NAME="RETURN_VALUES">RETURN VALUES</A></H1>
<P>
<CODE>MD2(),</CODE> <CODE>MD4(),</CODE> and <CODE>MD5()</CODE> return
pointers to the hash value. 

</P>
<P>
<CODE>MD2_Init(),</CODE> <CODE>MD2_Update(),</CODE>
<CODE>MD2_Final(),</CODE> <CODE>MD4_Init(),</CODE>
<CODE>MD4_Update(),</CODE> <CODE>MD4_Final(),</CODE>
<CODE>MD5_Init(),</CODE> <CODE>MD5_Update(),</CODE> and
<CODE>MD5_Final()</CODE> return 1 for success, 0 otherwise.

</P>
<P>
<HR>
<H1><A NAME="CONFORMING_TO">CONFORMING TO</A></H1>
<P>
RFC 1319, RFC 1320, RFC 1321

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



</P>
<P>
<HR>
<H1><A NAME="HISTORY">HISTORY</A></H1>
<P>
<CODE>MD2(),</CODE> <CODE>MD2_Init(),</CODE> <CODE>MD2_Update()</CODE>
<CODE>MD2_Final(),</CODE> <CODE>MD5(),</CODE> <CODE>MD5_Init(),</CODE>
<CODE>MD5_Update()</CODE> and <CODE>MD5_Final()</CODE> are available in all
versions of SSLeay and OpenSSL.

</P>
<P>
<CODE>MD4(),</CODE> <CODE>MD4_Init(),</CODE> and <CODE>MD4_Update()</CODE>
are available in OpenSSL 0.9.6 and above.

</P>
:}


