These libraries are experimental. APIs may change without notice. Generated from source with koruc 0.1.7 on 8/19/2026.

EVP

@korulang/evp@0.0.1

OpenSSL message digests for Koru — leak-proof SHA-256/512/1 and MD5 with phantom obligations

evp/index.kz · 8 tors

@korulang/openssl — the definitive Koru OpenSSL edition (v0: message digests) · 18 more lines
@korulang/openssl — the definitive Koru OpenSSL edition (v0: message digests) Lifts OpenSSL's EVP message-digest API (SHA-256/512/1, MD5) behind a phantom obligation. The notorious C footguns this compiles away: 1. EVP_MD_CTX_new() returns a context that MUST be freed with EVP_MD_CTX_free() — forget it and you leak on every hash. Here the `hashing` obligation makes forgetting uncompilable. 2. Reading a digest before EVP_DigestFinal_ex, or calling update() after final, is undefined behaviour. Here `final` CONSUMES the handle and never re-grants it, so use-after-final is a build error. 3. Picking a digest by runtime string ("sha266") is a runtime failure. Here the algorithm is a distinct event — an invalid one won't parse. House style follows the phantom-obligation cursor in the Koru suite (tests/regression/900_EXAMPLES_SHOWCASE/910_LANGUAGE_SHOOTOUT/2104_*/db.kz and sqlite3/index.kz): `<state!>` grants an obligation, `<!state>` consumes it, re-granting `<state!>` keeps the resource alive across a loop.

Phantom lifecycles

Derived from the phantom labels in the declarations below — state! issues an obligation the compiler will chase, !state discharges it, a bare state holds it without moving it. Nothing here is hand-drawn.

Digest 1 state hashing!

sha256.init

<hashing!> index.kz:77

sha512.init

<hashing!> index.kz:83

sha1.init

<hashing!> index.kz:89

md5.init

<hashing!> index.kz:95

update

<hashing> index.kz:108

final.hex

<!hashing> index.kz:122

final.bytes

<!hashing> index.kz:135

sha256.hex

index.kz:155