MD4(3) NetBSD Programmer's Manual MD4(3) NNAAMMEE MMDD44IInniitt, MMDD44UUppddaattee, MMDD44FFiinnaall, MMDD44EEnndd, MMDD44FFiillee, MMDD44DDaattaa - calculate the RSA Data Security, Inc., ``MD4'' message digest SSYYNNOOPPSSIISS ##iinncclluuddee <> ##iinncclluuddee <> _v_o_i_d MMDD44IInniitt(_M_D_4___C_T_X _*_c_o_n_t_e_x_t); _v_o_i_d MMDD44UUppddaattee(_M_D_4___C_T_X _*_c_o_n_t_e_x_t, _u_n_s_i_g_n_e_d _c_h_a_r _*_d_a_t_a, _u_n_s_i_g_n_e_d _i_n_t _l_e_n); _v_o_i_d MMDD44FFiinnaall(_u_n_s_i_g_n_e_d _c_h_a_r _d_i_g_e_s_t_[_1_6_], _M_D_4___C_T_X _*_c_o_n_t_e_x_t); _c_h_a_r _* MMDD44EEnndd(_M_D_4___C_T_X _*_c_o_n_t_e_x_t, _c_h_a_r _*_b_u_f); _c_h_a_r _* MMDD44FFiillee(_c_h_a_r _*_f_i_l_e_n_a_m_e, _c_h_a_r _*_b_u_f); _c_h_a_r _* MMDD44DDaattaa(_u_n_s_i_g_n_e_d _c_h_a_r _*_d_a_t_a, _u_n_s_i_g_n_e_d _i_n_t _l_e_n, _c_h_a_r _*_b_u_f); DDEESSCCRRIIPPTTIIOONN The MD4 functions calculate a 128-bit cryptographic checksum (digest) for any number of input bytes. A cryptographic checksum is a one-way hash- function, that is, you cannot find (except by exhaustive search) the in- put corresponding to a particular output. This net result is a ``finger- print'' of the input-data, which doesn't disclose the actual input. MD2 is the slowest, MD4 is the fastest and MD5 is somewhere in the mid- dle. MD2 can only be used for Privacy-Enhanced Mail. MD4 has been crit- icized for being too weak, so MD5 was developed in response as ``MD4 with safety-belts''. When in doubt, use MD5. The MMDD44IInniitt(), MMDD44UUppddaattee(), and MMDD44FFiinnaall() functions are the core func- tions. Allocate an MD4_CTX, initialize it with MMDD44IInniitt(), run over the data with MMDD44UUppddaattee(), and finally extract the result using MMDD44FFiinnaall(). MMDD44EEnndd() is a wrapper for MMDD44FFiinnaall() which converts the return value to a 33-character (including the terminating '\0') ASCII string which repre- sents the 128 bits in hexadecimal. MMDD44FFiillee() calculates the digest of a file, and uses MMDD44EEnndd() to return the result. If the file cannot be opened, a null pointer is returned. MMDD44DDaattaa() calculates the digest of a chunk of data in memory, and uses MMDD44EEnndd() to return the result. When using MMDD44EEnndd(), MMDD44FFiillee(), or MMDD44DDaattaa(), the _b_u_f argument can be a null pointer, in which case the returned string is allocated with mal- loc(3) and subsequently must be explicitly deallocated using free(3) af- ter use. If the _b_u_f argument is non-null it must point to at least 33 characters of buffer space. SSEEEE AALLSSOO md2(3), md4(3), md5(3) B. Kaliski, _T_h_e _M_D_2 _M_e_s_s_a_g_e_-_D_i_g_e_s_t _A_l_g_o_r_i_t_h_m, RFC 1319. R. Rivest, _T_h_e _M_D_4 _M_e_s_s_a_g_e_-_D_i_g_e_s_t _A_l_g_o_r_i_t_h_m, RFC 1186. R. Rivest, _T_h_e _M_D_5 _M_e_s_s_a_g_e_-_D_i_g_e_s_t _A_l_g_o_r_i_t_h_m, RFC 1321. RSA Laboratories, _F_r_e_q_u_e_n_t_l_y _A_s_k_e_d _Q_u_e_s_t_i_o_n_s _A_b_o_u_t _t_o_d_a_y_'_s _C_r_y_p_t_o_g_r_a_p_h_y. AAUUTTHHOORR The original MD4 routines were developed by RSA Data Security, Inc., and published in the above references. This code is derived directly from these implementations by Poul-Henning Kamp Phk ristede runen. HHIISSTTOORRYY These functions appeared in NetBSD 1.3. BBUUGGSS No method is known to exist which finds two files having the same hash value, nor to find a file with a specific hash value. There is on the other hand no guarantee that such a method doesn't exist. CCOOPPYYRRIIGGHHTT Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All rights reserved. License to copy and use this software is granted provided that it is identified as the "RSA Data Security, Inc. MD4 Message-Digest Algorithm" in all material mentioning or referencing this software or this function. License is also granted to make and use derivative works provided that such works are identified as "derived from the RSA Data Security, Inc. MD4 Message-Digest Algorithm" in all material mentioning or referencing the derived work. RSA Data Security, Inc. makes no representations concerning either the merchantability of this software or the suitability of this software for any particular purpose. It is provided "as is" without express or implied warranty of any kind. These notices must be retained in any copies of any part of this documen- tation and/or software. NetBSD October 9, 1996 2