RIPEMD(3)

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

πŸ’… RIPEMD(3) β€” the ripemd girlies are here

okay so bestie, welcome to the RIPEMD160 page, from the Library Functions Manual, and honestly it's a whole moment. no cap, it's giving "cryptographic fingerprint" energy and i'm obsessed. let me walk you through it πŸŽ€

✨ NAME ✨

RIPEMD160_Init, RIPEMD160_Update, RIPEMD160_Final, RIPEMD160_End, RIPEMD160_Fd, RIPEMD160_FdChunk, RIPEMD160_File, RIPEMD160_FileChunk, RIPEMD160_Data β€” literally all of them, bestie, and their whole entire job is calculating the RIPEMD160 message digest πŸ¦‹


πŸ“š LIBRARY πŸ“š

Message Digest (MD4, MD5, etc.) Support Library β€” that's libmd, and you link it with -lmd πŸ’–


🌸 SYNOPSIS 🌸

here's the part where you copy-paste, bestie. no shame.

#include <sys/types.h>
#include <ripemd.h>

void
RIPEMD160_Init(RIPEMD160_CTX *context);

void
RIPEMD160_Update(RIPEMD160_CTX *context, const unsigned char *data,
    unsigned int len);

void
RIPEMD160_Final(unsigned char digest[20], RIPEMD160_CTX *context);

char *
RIPEMD160_End(RIPEMD160_CTX *context, char *buf);

char *
RIPEMD160_Fd(int fd, char *buf);

char *
RIPEMD160_FdChunk(int fd, char *buf, off_t offset, off_t length);

char *
RIPEMD160_File(const char *filename, char *buf);

char *
RIPEMD160_FileChunk(const char *filename, char *buf, off_t offset,
    off_t length);

char *
RIPEMD160_Data(const unsigned char *data, unsigned int len, char *buf);

πŸ’œ DESCRIPTION πŸ’œ

so the RIPEMD160_ functions (all of them, collectively, they're a team πŸ’…) calculate a 160-bit cryptographic checksum β€” a digest β€” for any number of input bytes. any. number. slay.

a cryptographic checksum is a one-way hash function, meaning it's computationally impractical to find the input that corresponds to a particular output. it just doesn't happen, bestie. the net result is basically a "fingerprint" of the input-data β€” and here's the iconic part β€” it does not disclose the actual input. the math ate and left no crumbs πŸ”₯

🌈 the core trio 🌈

RIPEMD160_Init(), RIPEMD160_Update(), and RIPEMD160_Final() are the core functions. the whole ritual is:

  1. Allocate an RIPEMD160_CTX
  2. Initialize it with RIPEMD160_Init()
  3. Run over the data with RIPEMD160_Update()
  4. Finally extract the result using RIPEMD160_Final()

and plot twist β€” RIPEMD160_Final() will also erase the RIPEMD160_CTX. it cleans up after itself. main character energy honestly πŸ’…

✨ the wrapper squad ✨

  • RIPEMD160_End() β€” a wrapper for RIPEMD160_Final() which converts the return value to a 41-character (including the terminating '\0') ASCII string, representing the 160 bits in hexadecimal 🐝
  • RIPEMD160_File() β€” calculates the digest of a file, and uses RIPEMD160_End() to return the result. if the file cannot be opened, a null pointer is returned 😭
  • RIPEMD160_FileChunk() β€” similar to RIPEMD160_File(), but it only calculates the digest over a byte-range of the file specified, starting at offset and spanning length bytes. and get this: if the length parameter is specified as 0, or more than the length of the remaining part of the file, RIPEMD160_FileChunk() calculates the digest from offset to the end of file. it just keeps going. iconic πŸŽ€
  • RIPEMD160_Data() β€” calculates the digest of a chunk of data in memory, and uses RIPEMD160_End() to return the result πŸ’–
  • RIPEMD160_Fd() and RIPEMD160_FdChunk() β€” identical to their RIPEMD160_File() and RIPEMD160_FileChunk() counterparts, with the exception that the first argument is an fd instead of a filename. same vibe, different door πŸšͺ
🫢 buf tea, listen up bestie: when you're using RIPEMD160_End(), RIPEMD160_File(), or RIPEMD160_Data(), the buf argument can be a null pointer, in which case the returned string is allocated with malloc(3) and subsequently must be explicitly deallocated using free(3) after use. don't forget, or that's a leak, and leaks are not the vibe. if the buf argument is non-null it must point to at least 41 characters of buffer space. 41. not 40. πŸ”₯

😭 ERRORS 😭

the RIPEMD160_End() function called with a null buf argument may fail and return NULL if:

  • [ENOMEM] β€” insufficient storage space is available πŸ’€

and RIPEMD160_File() and RIPEMD160_FileChunk() may return NULL when underlying open(2), fstat(2), lseek(2), or RIPEMD160_End(3) fail. rough out here fr fr πŸ™ˆ


πŸ¦‹ SEE ALSO πŸ¦‹

the whole hash family, we love a supportive friend group 🌸


⭐ HISTORY ⭐

these functions appeared in FreeBSD 4.0. vintage. retro. lowkey a legacy queen πŸ‘‘


πŸ‘‘ AUTHORS πŸ‘‘

the core hash routines were implemented by Eric Young, based on the published RIPEMD160 specification. periodt. we stan πŸ’œ


πŸ’€ BUGS πŸ’€

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. however β€” and this is the part where you sit down β€” there is on the other hand no guarantee that such a method does not exist. 😭 the math is mathing but we stay humble 🧚


and that's the page, bestie ✨ this one's from the Debian edition, dated March 8, 2022 β€” go forth and hash responsibly, ily, mwah πŸ’–πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from