RMD160(3)
π RMD160 β the manual page, bestie edition π
okay so you're here for RMD160 from the Message Digest (MD4, MD5, etc.) Support Library (that's libmd, link it with -lmd) and honestly? you came to the right place. let's get into it π«Ά
β¨ NAME β¨
RMD160Init, RMD160Update, RMD160Pad, RMD160Final, RMD160Transform, RMD160End, RMD160File, RMD160FileChunk, RMD160Data β bestie, these calculate the RIPEMD-160'' message digest π
π LIBRARY π
Message Digest (MD4, MD5, etc.) Support Library β that's libmd, and you link it with -lmd.
πΈ SYNOPSIS πΈ
#include <sys/types.h>
#include <rmd160.h>
void
RMD160Init(RMD160_CTX *context);
void
RMD160Update(RMD160_CTX *context, const uint8_t *data, uint32_t nbytes);
void
RMD160Pad(RMD160_CTX *context);
void
RMD160Final(uint8_t digest[RMD160_DIGEST_LENGTH], RMD160_CTX *context);
void
RMD160Transform(uint32_t state[5],
const uint8_t block[RMD160_BLOCK_LENGTH]);
char *
RMD160End(RMD160_CTX *context, char *buf);
char *
RMD160File(const char *filename, char *buf);
char *
RMD160FileChunk(const char *filename, char *buf, off_t offset,
off_t length);
char *
RMD160Data(const uint8_t *data, size_t len, char *buf);
π DESCRIPTION π
So the RMD160 functions implement the 160-bit RIPE message digest hash algorithm (aka RMD-160). What's it do? It generates a condensed representation of a message called a message digest. The algorithm takes a message that's less than 2^64 bits as input and produces a 160-bit digest β and that digest is suitable for use as a digital signature. iconic behavior tbh π₯
The RMD160 functions are considered to be more secure than the md4(3), md5(3) and sha1(3) functions. and the way they all share a similar interface? convenient, we love consistency β¨
RMD160Init()β initializes aRMD160_CTXcontext so it's ready to be used withRMD160Update()andRMD160Final(). your starting line, basically.RMD160Update()β addsdataof lengthnbytesto theRMD160_CTXspecified bycontext.RMD160Final()β you call this when all the data has been added viaRMD160Update(), and it stores a message digest in thedigestparameter. the finale fr fr π¬RMD160Pad()β can be used to apply padding to the message digest, just like inRMD160Final(), BUT (and this is the slay part) the current context can still be used withRMD160Update()afterwards. so you don't have to close the book.RMD160Transform()β used byRMD160Update()to hash 512-bit blocks and forms the core of the algorithm. but lowkey, most programs should use the interface provided byRMD160Init(),RMD160Update()andRMD160Final()instead of callingRMD160Transform()directly. leave the internals alone bestie πRMD160End()β a front end forRMD160Final()which converts the digest into an ASCII representation of the 160 bit digest in hexadecimal.RMD160File()β calculates the digest for a file and returns the result viaRMD160End(). IfRMD160File()is unable to open the file, aNULLpointer is returned. πRMD160FileChunk()β behaves likeRMD160File()but calculates the digest only for that portion of the file starting atoffsetand continuing forlengthbytes or until end of file is reached, whichever comes first. Azero lengthcan be specified to read until end of file. A negativelengthoroffsetwill be ignored.RMD160Data()β calculates the digest of an arbitrary string and returns the result viaRMD160End().
okay now the important buf talk π’ For each of the RMD160End(), RMD160File(), and RMD160Data() functions, the buf parameter should either be:
- a string of at least 41 characters in size, or
- a
NULLpointer.
In the latter case, space will be dynamically allocated via malloc(3) and should be freed using free(3) when it is no longer needed. don't forget to free it, bestie, that's a memory leak and we don't do those π
π EXAMPLES π
The follow code fragment will calculate the digest for the string "abc" which is 0x8eb208f7e05d987a9b044a8e98c6b087f15a0bfc'':
RMD160_CTX rmd;
uint8_t results[RMD160_DIGEST_LENGTH];
char *buf;
int n;
buf = "abc";
n = strlen(buf);
RMD160Init(&rmd);
RMD160Update(&rmd, (uint8_t *)buf, n);
RMD160Final(results, &rmd);
/* Print the digest as one long hex value */
printf("0x");
for (n = 0; n < RMD160_DIGEST_LENGTH; n++)
printf("%02x", results[n]);
putchar('\n');
Alternately, the helper functions could be used in the following way:
RMD160_CTX rmd;
uint8_t output[RMD160_DIGEST_STRING_LENGTH];
char *buf = "abc";
printf("0x%s\n", RMD160Data(buf, strlen(buf), output));
see? the helper version is giving main character energy for real π
π¦ SEE ALSO π¦
cksum(1),md4(3),md5(3),sha1(3),sha2(3)- H. Dobbertin, A. Bosselaers, B. Preneel, RIPEMD-160, a strengthened version of RIPEMD.
- Information technology - Security techniques - Hash-functions - Part 3: Dedicated hash-functions, ISO/IEC 10118-3.
- H. Dobbertin, A. Bosselaers, B. Preneel, βThe RIPEMD-160 cryptographic hash functionβ, Dr. Dobb's Journal, Vol. 22, No. 1, pp. 24-28, January 1997.
β HISTORY β
The RMD-160 functions appeared in OpenBSD 2.1. a classic, a legend, an era π°οΈ
π AUTHORS π
- This implementation of RMD-160 was written by Markus Friedl.
- The
RMD160End(),RMD160File(),RMD160FileChunk(), andRMD160Data()helper functions are derived from code written by Poul-Henning Kamp.
thank you both, absolute icons π«Ά
π CAVEATS π
If a message digest is to be copied to a multi-byte type (ie: an array of five 32-bit integers) it will be necessary to perform byte swapping on little endian machines such as thei386,alpha, andvax.
read that twice. do not skip the byte swapping. this is the part that ruins your whole week if you ignore it, no cap π§
Debian Β· July 13, 2010 Β· and that's the RMD160(3) page bestie β go hash something, stay hydrated, and remember: free your malloc'd buffers πβ¨ππ¦πΈπ
π«Ά
π¦ 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
- Copyright (c) 1997, 2004 Todd C. Miller <Todd.Miller@courtesan.com>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms