ripemd128(n)

πŸ“¦
version 2.0 Β· 2 versions
, in fedora 43, fedora 44, nixos 26.05, nixpkgs unstable

πŸ’– ripemd128 β€” RIPEMD-128 Message-Digest Algorithm πŸ’–

hiii bestie, welcome to ripemd128(n) β€” the page all about the RIPEMD-128 Message-Digest Algorithm. sit down, grab a lil snack, we're gonna get into it πŸ“


🌸 NAME 🌸

ripemd128 β€” RIPEMD-128 Message-Digest Algorithm. yes that's literally it, short and iconic πŸ’…


✨ SYNOPSIS ✨

package require Tcl 8.5 9

package require ripemd128 ?1.0.6?

::ripemd::ripemd128  ?-hex? [ -channel channel | -file filename | string
]

::ripemd::hmac128 ?-hex? -key key [ -channel channel | -file filename  |
string ]

::ripemd::RIPEMD128Init

::ripemd::RIPEMD128Update token data

::ripemd::RIPEMD128Final token

::ripemd::RIPEHMAC128Init key

::ripemd::RIPEHMAC128Update token data

::ripemd::RIPEHMAC128Final token

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so. this package is a Tcl implementation of the RIPEMD-128 message-digest algorithm (1). it takes an arbitrary quantity of data and spits out a 128-bit message digest from that input. like, any amount of data. no cap.

RIPEMD-128 is based on the MD4 algorithm (2, 4), but β€” and this is the glow-up β€” it's been cryptographically strengthened against the weaknesses that people found in MD4 (4). RIPEMD-128 was designed to be a drop-in replacement for MD4 and MD5 (5). and listen, if security is your major consideration? then RIPEMD-160 or SHA1 should be considered instead. be smart about it bestie 🫢

this package will use Trf to accelerate the digest computation if it's available. in the absence of an accelerator package, the pure-Tcl implementation will be used. either way she works πŸ’…

BEWARE ⚠️ the commands in this package expect binary data as their input. when a -file is provided, that's ensured by the commands themselves, because they open the referenced file in binary mode. but when literal data, or a -channel, are provided instead β€” then it's the command's caller who is responsible for ensuring this fact. the necessary conversion command is encoding convertto utf-8 $string.
ATTENTION, there is a Tcl 9 COMPATIBILITY ISSUE here. 😭

Tcl 8.x silently mishandles non-binary input by cutting it internally to size. i.e. by only using the low byte of a higher unicode point. no error is thrown β€” the result is simply wrong. πŸ’€

Tcl 9 throws an error instead, i.e.

expected byte sequence but character <location> was ...

πŸŽ€ COMMANDS πŸŽ€

  • ::ripemd::ripemd128 ?-hex? [ -channel channel | -file filename | string ] β€” calculates the RIPEMD-128 digest of the data given in string. it's returned as a binary string</> by default. give it the -hex option and you get a hexadecimal encoded version of the digest back instead. ✨

the data to be hashed can be specified either as a string argument to the ripemd128 command, or as a filename, or as a pre-opened channel. if the -filename argument is given, then the file is opened, the data is read and hashed, and the file is closed. if the -channel argument is given, then data is read from the channel until the end of file. the channel is not closed. πŸ™ˆ

only one of -file, -channel or string should be given. pick a lane bestie.

  • ::ripemd::hmac128 ?-hex? -key key [ -channel channel | -file filename | string ] β€” calculates a Hashed Message Authentication digest (HMAC) using the RIPEMD-128 digest algorithm. HMACs are described in RFC 2104 (6) and they give you a RIPEMD-128 digest that includes a key. all options other than -key are exactly as for the ::ripemd::ripemd128 command. πŸ”‘

🌈 PROGRAMMING INTERFACE 🌈

for the programmer, hash functions can be viewed as a bucket into which one pours data. when you're done pouring, you extract a value that's uniquely derived from all the data that went in. the programming interface to the hash operates on a token (which is basically the bucket, okay, it's the bucket). you call RIPEMD128Init to obtain a token, then call RIPEMD128Update as many times as you need to add data to the hash. to release any resources and get the hash value, you then call RIPEMD128Final. an equivalent set of functions gives you a keyed digest (HMAC). πŸͺ£βœ¨

if you have critcl and have built the tcllibc package, then the implementation of the hashing function will be performed by compiled code. alternatively, if both the Trf and Memchan extensions are available, then those will be used. finally the package will revert to a pure-Tcl implementation. the programming interface remains the same, however. no matter which one she picks, you code the same way πŸ’…

  • ::ripemd::RIPEMD128Init β€” begins a brand new RIPEMD-128 hash. returns a token ID that you must use for the remaining functions. main character token honestly πŸ‘‘
  • ::ripemd::RIPEMD128Update token data β€” adds data to the hash identified by token. calling RIPEMD128Update $token "abcd" is equivalent to calling RIPEMD128Update $token "ab" followed by RIPEMD128Update $token "cb". see EXAMPLES. 🧚
  • ::ripemd::RIPEMD128Final token β€” returns the hash value and releases any resources held by this token. once this command completes, the token will be invalid. the result is a binary string of 16 bytes representing the 128 bit RIPEMD-128 digest value. ⭐
  • ::ripemd::RIPEHMAC128Init key β€” this is equivalent to the ::ripemd::RIPEMD128Init command, except that it requires the key that will be included in the HMAC. πŸ”
  • ::ripemd::RIPEHMAC128Update token data
  • ::ripemd::RIPEHMAC128Final token

these commands are identical to the RIPEMD128 equivalent commands. same energy, keyed edition πŸ’œ


🌟 EXAMPLES 🌟

% ripemd::ripemd128 -hex "Tcl does RIPEMD-128"
3cab177bae65205d81e7978f63556c63

% ripemd::hmac128 -hex -key Sekret "Tcl does RIPEMD-128"
b359dc5971a05beea0be7b106b30e389

% set tok [ripemd::RIPEMD128Init]
::ripemd::1
% ripemd::RIPEMD128Update $tok "Tcl "
% ripemd::RIPEMD128Update $tok "does "
% ripemd::RIPEMD128Update $tok "RIPEMD-128"
% ripemd::Hex [ripemd::RIPEMD128Final $tok]
3cab177bae65205d81e7978f63556c63

look at that last one β€” pouring it in three lil sips gives you the exact same digest as pouring it all at once. ate and left no crumbs πŸ’…βœ¨


πŸ“š REFERENCES πŸ“š

  1. [1] H. Dobbertin, A. Bosselaers, B. Preneel, "RIPEMD-160, a strengthened version of RIPEMD" http://www.esat.kuleuven.ac.be/~cosicart/pdf/AB-9601/AB-9601.pdf
  2. [2] Rivest, R., "The MD4 Message Digest Algorithm", RFC 1320, MIT, April 1992. (http://www.rfc-editor.org/rfc/rfc1320.txt)
  3. [3] Rivest, R., "The MD4 message digest algorithm", in A.J. Menezes and S.A. Vanstone, editors, Advances in Cryptology - CRYPTO '90 Proceedings, pages 303-311, Springer-Verlag, 1991.
  4. [4] Dobbertin, H., "Cryptanalysis of MD4", Journal of Cryptology vol 11 (4), pp. 253-271 (1998)
  5. [5] Rivest, R., "The MD5 Message-Digest Algorithm", RFC 1321, MIT and RSA Data Security, Inc, April 1992. (http://www.rfc-editor.org/rfc/rfc1321.txt)
  6. [6] Krawczyk, H., Bellare, M. and Canetti, R. "HMAC: Keyed-Hashing for Message Authentication", RFC 2104, February 1997. (http://www.rfc-editor.org/rfc/rfc2104.txt)

πŸ’Œ BUGS, IDEAS, FEEDBACK πŸ’Œ

ngl bestie, this document β€” and the package it describes β€” will undoubtedly contain bugs and other problems. it's giving "we know". 😭 please report such things in the category ripemd of the Tcllib Trackers [http://core.tcl.tk/tcllib/reportlist]. please also report any ideas for enhancements you may have for either the package and/or the documentation. we wanna hear it 🫢

when proposing code changes, please provide unified diffs, i.e the output of diff -u. periodt.

note further that attachments are strongly preferred over inlined patches. attachments can be made by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar. iykyk πŸ‘‘


πŸ‘€ SEE ALSO πŸ‘€

md4, md5, ripemd160, sha1


πŸ”‘ KEYWORDS πŸ”‘

RIPEMD, hashing, md4, message-digest, rfc 1320, rfc 1321, rfc 2104, security


πŸ—‚οΈ CATEGORY πŸ—‚οΈ

Hashes, checksums, and encryption


Copyright (c) 2004, Pat Thoyts <patthoyts@users.sourceforge.net>


okay that's the whole page bestie, we did it πŸ’– this one's from tcllib, version 1.0.6, and it's the ripemd128(n) page β€” big love to Pat Thoyts for the 2004 copyright, an absolute legend. now go hash something responsibly, and remember: binary input only, fr fr πŸ¦‹βœ¨πŸ’…

πŸ“¦ where this page comes from