MD4(3)
π MD4 β the one where we calculate the RSA Data Security, Inc., "MD4" message digest β¨
okay bestie, pull up a chair, this is the MD4 page from the Library Functions Manual and we're gonna go through it together, every last crumb, no skipping π«Ά
π LIBRARY π
Message Digest (MD4, MD5, etc.) Support Library (libmd, -lmd)
link against it with -lmd and you're in π
β¨ SYNOPSIS β¨
#include <sys/types.h>
#include <md4.h>
void
MD4Init(MD4_CTX *context);
void
MD4Update(MD4_CTX *context, const uint8_t *data, size_t len);
void
MD4Pad(MD4_CTX *context);
void
MD4Final(uint8_t digest[MD4_DIGEST_LENGTH], MD4_CTX *context);
void
MD4Transform(uint32_t state[4], uint8_t block[MD4_BLOCK_LENGTH]);
char *
MD4End(MD4_CTX *context, char *buf);
char *
MD4File(const char *filename, char *buf);
char *
MD4FileChunk(const char *filename, char *buf, off_t offset,
off_t length);
char *
MD4Data(const uint8_t *data, size_t len, char *buf);
like, look at that list. nine functions. all of them yours π
πΈ DESCRIPTION πΈ
so the MD4 functions calculate a 128-bit cryptographic checksum (a digest) for literally any number of input bytes. a cryptographic checksum is a one-way hash-function, which means: you cannot find the input that corresponds to a particular output β unless you do an exhaustive search, and bestie, good luck with that π. the net result is a "fingerprint" of the input-data, and it doesn't disclose the actual input. iconic behaviour, honestly.
now, the lore π: MD2 is the slowest, MD4 is the fastest, and MD5 is somewhere in the middle. MD2 can only be used for Privacy-Enhanced Mail. MD4 has been criticized for being too weak, so MD5 was developed in response as "MD4 with safety-belts". and, um, MD4 and MD5 have been broken; they should only be used where necessary for backward compatibility. the attacks on both MD4 and MD5 are both in the nature of finding "collisions" β that is, multiple inputs which hash to the same value. it is still unlikely for an attacker to be able to determine the exact original input given a hash value. okay so that last bit is the good news, the collision thing is the bad news, we contain multitudes π
the core trio is MD4Init(), MD4Update(), and MD4Final(). the routine is: allocate an MD4_CTX, initialize it with MD4Init(), run over the data with MD4Update(), and finally extract the result using MD4Final(). that's it, that's the whole dance π§
MD4Pad() can be used to apply padding to the message digest as in MD4Final(), but β plot twist β the current context can still be used with MD4Update(). so you're not locked out. slay.
MD4Transform() is used by MD4Update() to hash 512-bit blocks and forms the core of the algorithm. most programs should use the interface provided by MD4Init(), MD4Update() and MD4Final() instead of calling MD4Transform() directly. like, you can touch it, but it's giving low-level, iykyk.
MD4End() is a wrapper for MD4Final() which converts the return value to an MD4_DIGEST_STRING_LENGTH-character (including the terminating '\0') ASCII string which represents the 128 bits in hexadecimal. cute little glow-up from raw bytes to readable string β¨
MD4File() calculates the digest of a file, and uses MD4End() to return the result. if the file cannot be opened, a null pointer is returned. no drama, just NULL.
MD4FileChunk() behaves like MD4File() but calculates the digest only for that portion of the file starting at offset and continuing for length bytes or until end of file is reached, whichever comes first. a zero length can be specified to read until end of file. a negative length or offset will be ignored. and MD4Data() calculates the digest of a chunk of data in memory, and uses MD4End() to return the result. so like, file, file-but-just-a-slice, or vibes-in-RAM, pick your fighter π
β οΈ okay this part matters so listen up: when usingMD4End(),MD4File(),MD4FileChunk(), orMD4Data(), the buf argument can be a null pointer, in which case the returned string is allocated withmalloc(3)and subsequently must be explicitly deallocated usingfree(3)after use. if the buf argument is non-null it must point to at leastMD4_DIGEST_STRING_LENGTHcharacters of buffer space. free your mallocs bestie, the memory isn't gonna free itself π
π SEE ALSO π
md2(3),md4(3),md5(3),rmd160(3),sha1(3),sha2(3)- B. Kaliski, The MD2 Message-Digest Algorithm, RFC 1319.
- R. Rivest, The MD4 Message-Digest Algorithm, RFC 1186.
- R. Rivest, The MD5 Message-Digest Algorithm, RFC 1321.
- RSA Laboratories, Frequently Asked Questions About today's Cryptography,
<http://www.rsa.com/rsalabs/faq/>. - H. Dobbertin, "Alf Swindles Ann", CryptoBytes, 1(3):5, 1995.
- MJ. B. Robshaw, "On Recent Results for MD4 and MD5", RSA Laboratories Bulletin, 4, November 12, 1996.
- Hans Dobbertin, Cryptanalysis of MD5 Compress.
the reading list is long but bestie the reading list is important π
π HISTORY π
these functions appeared in OpenBSD 2.0 and NetBSD 1.3. ancient. vintage. still here. periodt.
π¦ AUTHORS π¦
the original MD4 routines were developed by RSA Data Security, Inc., and published in the above references. this code is derived from a public domain implementation written by Colin Plumb.
the MD4End(), MD4File(), MD4FileChunk(), and MD4Data() helper functions are derived from code written by Poul-Henning Kamp.
thank you kings for your service π«Ά
π BUGS π
collisions have been found for the full versions of both MD4 and MD5. the use of sha2(3) is recommended instead.
yeah. that's the whole section. no notes, just, use sha2(3) instead fr fr π
and that's the page, bestie!! this one came from Debian, dated July 13, 2010, and it lives in the Library Functions Manual as MD4(3). go forth, hash responsibly, use sha2(3), and don't forget to free(3) πβ¨π
π¦ where this page comes from
- alpine 3.22: libmd-doc 1.1.0-r0 Β· BSD-3-Clause AND BSD-2-Clause AND ISC AND Beerware AND Public Domain
- alpine 3.23: libmd-doc 1.1.0-r0 Β· BSD-3-Clause AND BSD-2-Clause AND ISC AND Beerware AND Public Domain
- alpine 3.24: libmd-doc 1.2.0-r0 Β· BSD-3-Clause AND BSD-2-Clause AND ISC AND Beerware AND Public Domain
- arch rolling: libmd 1.3.0-1 Β· BSD-3-Clause AND BSD-2-Clause AND ISC AND Beerware AND CC-PDM-1.0
- debian bookworm: libmd-dev 1.0.4-2
- debian trixie: libmd-dev 1.1.0-2+b1
- epel 10: libmd-devel 1.3.0-1.el10_3 Β· BSD-2-Clause AND BSD-3-Clause AND ISC AND Beerware AND LicenseRef-Fedora-Public-Domain
- epel 9: libmd-devel 1.3.0-1.el9 Β· BSD-2-Clause AND BSD-3-Clause AND ISC AND Beerware AND LicenseRef-Fedora-Public-Domain
- fedora 43: libmd-devel 1.1.0-8.fc43 Β· BSD-2-Clause AND BSD-3-Clause AND ISC AND Beerware AND LicenseRef-Fedora-Public-Domain
- fedora 43: libmd-devel 1.1.0-8.fc43 Β· BSD-2-Clause AND BSD-3-Clause AND ISC AND Beerware AND LicenseRef-Fedora-Public-Domain
- fedora 43: libmd-devel 1.2.0-1.fc43
- fedora 43: libmd-devel 1.2.0-1.fc43
- fedora 43: libmd-devel 1.3.0-1.fc43 Β· BSD-2-Clause AND BSD-3-Clause AND ISC AND Beerware AND LicenseRef-Fedora-Public-Domain
- fedora 43: libmd-devel 1.3.0-1.fc43 Β· BSD-2-Clause AND BSD-3-Clause AND ISC AND Beerware AND LicenseRef-Fedora-Public-Domain
- fedora 44: libmd-devel 1.1.0-9.fc44 Β· BSD-2-Clause AND BSD-3-Clause AND ISC AND Beerware AND LicenseRef-Fedora-Public-Domain
- fedora 44: libmd-devel 1.1.0-9.fc44 Β· BSD-2-Clause AND BSD-3-Clause AND ISC AND Beerware AND LicenseRef-Fedora-Public-Domain
- fedora 44: libmd-devel 1.3.0-1.fc44 Β· BSD-2-Clause AND BSD-3-Clause AND ISC AND Beerware AND LicenseRef-Fedora-Public-Domain
- fedora 44: libmd-devel 1.3.0-1.fc44 Β· BSD-2-Clause AND BSD-3-Clause AND ISC AND Beerware AND LicenseRef-Fedora-Public-Domain
- nixos 26.05: libmd 1.1.0
- nixpkgs unstable: libmd 1.3.0
- opensuse-leap 16.0: libmd-devel 1.1.0-160000.3.2 Β· BSD-2-Clause OR BSD-3-Clause OR ISC OR SUSE-Public-Domain
- opensuse-leap 16.0: libmd-devel 1.1.0-160000.3.2 Β· BSD-2-Clause OR BSD-3-Clause OR ISC OR SUSE-Public-Domain
- opensuse-leap 16.0: libmd-devel 1.1.0-160000.3.2 Β· BSD-2-Clause OR BSD-3-Clause OR ISC OR SUSE-Public-Domain
- opensuse-leap 16.0: libmd-devel 1.1.0-160000.3.2 Β· BSD-2-Clause OR BSD-3-Clause OR ISC OR SUSE-Public-Domain
- ubuntu jammy: libmd-dev 1.0.4-1build1
- ubuntu noble: libmd-dev 1.1.0-2build1
- ubuntu noble: libmd-dev 1.1.0-2build1.1
- ubuntu questing: libmd-dev 1.1.0-2build3
- ubuntu resolute: libmd-dev 1.1.0-2build4
- ubuntu stonking: libmd-dev 1.2.0-2
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms