1
0
Fork 0
forked from fun/fun

Added OpenSSL RIPEMD-160 fun. (0.38.14)

This commit is contained in:
Johannes Findeisen 2026-02-19 14:19:17 +01:00
commit 6fa95f0d47
15 changed files with 144 additions and 9 deletions

View file

@ -45,6 +45,7 @@ FUN_LIB_DIR="$(pwd)/lib" fun examples/crypto/openssl_md5.fun
Browse the `examples/` tree for areas of interest:
- crypto — crypto demonstrations (e.g., OpenSSL MD5/SHA-256/SHA-512 helpers; requires build with `-DFUN_WITH_OPENSSL=ON`)
- crypto — crypto demonstrations (e.g., OpenSSL MD5/SHA-256/SHA-512/RIPEMD160 helpers; requires build with `-DFUN_WITH_OPENSSL=ON`)
- blocking / interactive — I/O or user-interactive patterns
- error / broken — negative tests and error showcases
- math — numeric operations

View file

@ -18,7 +18,7 @@ Extensions:
- [PC/SC (Smart cards)](./pcsc.md)
- [Notcurses (TUI)](./notcurses.md)
- [Tcl/Tk (GUI)](./tcltk.md)
- [OpenSSL (MD5 helper)](./openssl.md)
- [OpenSSL](./openssl.md)
Notes:
- These integrations are optional; the VM compiles without them.

View file

@ -1,7 +1,7 @@
# OpenSSL extension (optional)
- CMake option: FUN_WITH_OPENSSL=ON
- Purpose: provide small crypto helpers backed by OpenSSL. Includes md5, sha256, sha512 helpers.
- Purpose: provide small crypto helpers backed by OpenSSL. Includes md5, sha256, sha512, ripemd160 helpers.
- Homepage: https://www.openssl.org/
Build notes:
@ -12,7 +12,8 @@ Provided helper/opcodes:
- Function: openssl_md5(data:string) -> string (lowercase hex). Falls back to empty string when the extension is disabled, mirroring other optional modules.
- Function: openssl_sha256(data:string) -> string (lowercase hex).
- Function: openssl_sha512(data:string) -> string (lowercase hex).
- Opcodes: OP_OPENSSL_MD5, OP_OPENSSL_SHA256, OP_OPENSSL_SHA512 (internal mappings for the functions above).
- Function: openssl_ripemd160(data:string) -> string (lowercase hex). Note: On OpenSSL 3.x this may require the legacy provider; if the digest is unavailable, the helper returns an empty string.
- Opcodes: OP_OPENSSL_MD5, OP_OPENSSL_SHA256, OP_OPENSSL_SHA512, OP_OPENSSL_RIPEMD160 (internal mappings for the functions above).
Quickstart:
- Configure: cmake -S . -B build -DFUN_WITH_OPENSSL=ON
@ -21,6 +22,7 @@ Quickstart:
- ./build/fun examples/crypto/openssl_md5.fun
- ./build/fun examples/crypto/openssl_sha256.fun
- ./build/fun examples/crypto/openssl_sha512.fun
- ./build/fun examples/crypto/openssl_ripemd160.fun
Example output:
- md5(abc) = 900150983cd24fb0d6963f7d28e17f72
@ -29,3 +31,8 @@ Example output:
- sha256("") = e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
- sha512(abc) = ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f
- sha512("") = cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e
- ripemd160(abc) = 8eb208f7e05d987a9b044a8e98c6b087f15a0bfc
- ripemd160("") = 9c1185a5c5e9fc54612808977ee8f548b2258d31
Notes:
- The OpenSSL 3.x provider configuration on your system determines availability of RIPEMD160. If the legacy provider is not enabled, openssl_ripemd160() will return an empty string.

View file

@ -207,6 +207,7 @@ This document provides an overview of the available VM opcodes implemented under
- OP_OPENSSL_MD5: Compute MD5 digest and return lowercase hex string; pops data:string; pushes md5:string.
- OP_OPENSSL_SHA256: Compute SHA256 digest and return lowercase hex string; pops data:string; pushes sha256:string.
- OP_OPENSSL_SHA512: Compute SHA512 digest and return lowercase hex string; pops data:string; pushes sha512:string.
- OP_OPENSSL_RIPEMD160: Compute RIPEMD160 digest and return lowercase hex string; pops data:string; pushes ripemd160:string. On OpenSSL 3.x this may require the legacy provider; if unavailable, the helper returns an empty string.
- Requires building with `-DFUN_WITH_OPENSSL=ON`. When disabled, these opcodes still exist but return an empty string to match other optional extensions fallback behavior.
## PCRE2 (Regex)