1.\" $OpenBSD: MD5.3,v 1.8 2018/03/27 17:35:50 schwarze Exp $ 2.\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 3.\" 4.\" This file was written by Ulf Moeller <ulf@openssl.org> and 5.\" Richard Levitte <levitte@openssl.org>. 6.\" Copyright (c) 2000, 2006 The OpenSSL Project. All rights reserved. 7.\" 8.\" Redistribution and use in source and binary forms, with or without 9.\" modification, are permitted provided that the following conditions 10.\" are met: 11.\" 12.\" 1. Redistributions of source code must retain the above copyright 13.\" notice, this list of conditions and the following disclaimer. 14.\" 15.\" 2. Redistributions in binary form must reproduce the above copyright 16.\" notice, this list of conditions and the following disclaimer in 17.\" the documentation and/or other materials provided with the 18.\" distribution. 19.\" 20.\" 3. All advertising materials mentioning features or use of this 21.\" software must display the following acknowledgment: 22.\" "This product includes software developed by the OpenSSL Project 23.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)" 24.\" 25.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 26.\" endorse or promote products derived from this software without 27.\" prior written permission. For written permission, please contact 28.\" openssl-core@openssl.org. 29.\" 30.\" 5. Products derived from this software may not be called "OpenSSL" 31.\" nor may "OpenSSL" appear in their names without prior written 32.\" permission of the OpenSSL Project. 33.\" 34.\" 6. Redistributions of any form whatsoever must retain the following 35.\" acknowledgment: 36.\" "This product includes software developed by the OpenSSL Project 37.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)" 38.\" 39.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 40.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 41.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 42.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 43.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 44.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 46.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 47.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 48.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 51.\" 52.Dd $Mdocdate: March 27 2018 $ 53.Dt MD5 3 54.Os 55.Sh NAME 56.Nm MD4 , 57.Nm MD5 , 58.Nm MD4_Init , 59.Nm MD4_Update , 60.Nm MD4_Final , 61.Nm MD5_Init , 62.Nm MD5_Update , 63.Nm MD5_Final 64.Nd MD4 and MD5 hash functions 65.Sh SYNOPSIS 66.In openssl/md4.h 67.Ft unsigned char * 68.Fo MD4 69.Fa "const unsigned char *d" 70.Fa "unsigned long n" 71.Fa "unsigned char *md" 72.Fc 73.Ft int 74.Fo MD4_Init 75.Fa "MD4_CTX *c" 76.Fc 77.Ft int 78.Fo MD4_Update 79.Fa "MD4_CTX *c" 80.Fa "const void *data" 81.Fa "unsigned long len" 82.Fc 83.Ft int 84.Fo MD4_Final 85.Fa "unsigned char *md" 86.Fa "MD4_CTX *c" 87.Fc 88.In openssl/md5.h 89.Ft unsigned char * 90.Fo MD5 91.Fa "const unsigned char *d" 92.Fa "unsigned long n" 93.Fa "unsigned char *md" 94.Fc 95.Ft int 96.Fo MD5_Init 97.Fa "MD5_CTX *c" 98.Fc 99.Ft int 100.Fo MD5_Update 101.Fa "MD5_CTX *c" 102.Fa "const void *data" 103.Fa "unsigned long len" 104.Fc 105.Ft int 106.Fo MD5_Final 107.Fa "unsigned char *md" 108.Fa "MD5_CTX *c" 109.Fc 110.Sh DESCRIPTION 111MD4 and MD5 are cryptographic hash functions with a 128-bit 112output. 113.Pp 114.Fn MD4 115and 116.Fn MD5 117compute the MD4 and MD5 message digest of the 118.Fa n 119bytes at 120.Fa d 121and place it in 122.Fa md , 123which must have space for 124.Dv MD4_DIGEST_LENGTH No == Dv MD5_DIGEST_LENGTH No == 16 125bytes of output. 126If 127.Fa md 128is 129.Dv NULL , 130the digest is placed in a static array. 131.Pp 132The following functions may be used if the message is not completely 133stored in memory: 134.Pp 135.Fn MD5_Init 136initializes a 137.Vt MD5_CTX 138structure. 139.Pp 140.Fn MD5_Update 141can be called repeatedly with chunks of the message to be hashed 142.Pq Fa len No bytes at Fa data . 143.Pp 144.Fn MD5_Final 145places the message digest in 146.Fa md , 147which must have space for 148.Dv MD5_DIGEST_LENGTH No == 16 149bytes of output, and erases the 150.Vt MD5_CTX . 151.Pp 152.Fn MD4_Init , 153.Fn MD4_Update , 154and 155.Fn MD4_Final 156are analogous using an 157.Vt MD4_CTX 158structure. 159.Pp 160Applications should use the higher level functions 161.Xr EVP_DigestInit 3 162etc. instead of calling these hash functions directly. 163.Sh RETURN VALUES 164.Fn MD4 165and 166.Fn MD5 167return pointers to the hash value. 168.Pp 169.Fn MD4_Init , 170.Fn MD4_Update , 171.Fn MD4_Final , 172.Fn MD5_Init , 173.Fn MD5_Update , 174and 175.Fn MD5_Final 176return 1 for success or 0 otherwise. 177.Sh SEE ALSO 178.Xr EVP_DigestInit 3 179.Sh STANDARDS 180RFC 1320, RFC 1321 181.Sh HISTORY 182.Fn MD5 , 183.Fn MD5_Init , 184.Fn MD5_Update , 185and 186.Fn MD5_Final 187appeared in SSLeay 0.4 or earlier and have been available since 188.Ox 2.4 . 189.Pp 190.Fn MD4 , 191.Fn MD4_Init , 192.Fn MD4_Update , 193and 194.Fn MD4_Final 195first appeared in OpenSSL 0.9.6 and have been available since 196.Ox 2.9 . 197