MDC2_INIT(3ossl)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 15.1

πŸ’– MDC2_INIT β€” the MDC2 hash function, explained by your fav Unix bestie πŸ’–

Okay so real talk: this is the MDC2_INIT(3ossl) page from the OpenSSL manual, and it's lowkey a ✨vintage✨ situation β€” every single function on this page is deprecated. But you're here, bestie, so let's learn what it does anyway, because knowing legacy crypto is giving main character energy. πŸŽ€


🌸 NAME 🌸

MDC2, MDC2_Init, MDC2_Update, MDC2_Final β€” the MDC2 hash function. That's the whole squad right there. 🫢


✨ SYNOPSIS ✨

First, you gotta pull in the header, obviously:

#include <openssl/mdc2.h>

Now, real talk β€” these functions have been deprecated since OpenSSL 3.0, and you can hide them entirely by defining OPENSSL_API_COMPAT with a suitable version value. Wanna know what counts as "suitable"? Check openssl_user_macros(7), iykyk. πŸ’…

Here's the full lineup:

unsigned char *MDC2(const unsigned char *d, unsigned long n,
                    unsigned char *md);

int MDC2_Init(MDC2_CTX *c);
int MDC2_Update(MDC2_CTX *c, const unsigned char *data,
                unsigned long len);
int MDC2_Final(unsigned char *md, MDC2_CTX *c);

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay, so, the elephant in the room: all of the functions described on this page are deprecated. No cap. If you're writing new code, do not be using these. Applications should instead use EVP_DigestInit_ex(3), EVP_DigestUpdate(3) and EVP_DigestFinal_ex(3). That's the moment. πŸ‘‘

So what even is MDC2? It's a method to construct hash functions with 128 bit output from block ciphers β€” and these particular functions are an implementation of MDC2 with DES. Cute history lesson, honestly. 🧚

Here's the one-shot version:

  • MDC2() β€” computes the MDC2 message digest of the n bytes at d and places it in md. Now, md must have space for MDC2_DIGEST_LENGTH == 16 bytes of output β€” don't skimp on the buffer, bestie. And if md is NULL, the digest gets placed in a static array instead. πŸ™ˆ

But what if your message isn't completely stored in memory? Say less β€” these next three are for you:

  • MDC2_Init() β€” initializes an MDC2_CTX structure. Setting the stage, giving setup energy.
  • MDC2_Update() β€” can be called repeatedly with chunks of the message to be hashed (len bytes at data). Feed it piece by piece, it eats it all up. πŸ“
  • MDC2_Final() β€” places the message digest in md, which must have space for MDC2_DIGEST_LENGTH == 16 bytes of output, and erases the MDC2_CTX. Cleanup queen behavior β€” the context gets wiped.

And to say it one more time in case it didn't land: applications should use the higher level functions EVP_DigestInit(3) etc. instead of calling the hash functions directly. Please. For me. πŸ’œ


πŸ’€ RETURN VALUES πŸ’€

  • MDC2() returns a pointer to the hash value. Slay.
  • MDC2_Init(), MDC2_Update() and MDC2_Final() return 1 for success, 0 otherwise. Simple as that, no plot twists.

🌈 CONFORMING TO 🌈

ISO/IEC 10118-2:2000 Hash-Function 2, with DES as the underlying block cipher. Look at it being all standards-compliant and official. πŸŽ€


πŸ‘‘ SEE ALSO πŸ‘‘


⭐ HISTORY ⭐

All of these functions were deprecated in OpenSSL 3.0. That's the timeline, bestie. Not me mourning the old days. 😭


Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.


⚠️ Friendly reminder from your girl: this is deprecated crypto. If you're out here newly implementing 128-bit DES-based hashing in the year of our lord, I need you to take a vibe check first. The EVP_* functions are right there and they're iconic. 🌸

okay that's the whole page, mwah πŸ’… β€” this was brought to you by OpenSSL version 3.5.6, dated 2026-04-07, and the MDC2_INIT(3ossl) manual. Go forth and hash responsibly, bestie πŸ«ΆπŸŽ€

πŸ“¦ where this page comes from