No matching definitions.

secret/hygiene

src/secret/hygiene.tur

free-standing crypto hygiene primitives.

Since: 0.1.0

defn

secure-wipe-ptr!

(secure-wipe-ptr! [p ptr<void> n : int] :)

zero `n` bytes at `p` in a way the optimizer may not

pstart of the region to zero; NULL is a no-op
nbyte count; values <= 0 are a no-op

Nothing.

(secure-wipe-ptr! key 32)

Since: 0.1.0

defn

crypto-random-bytes!

(crypto-random-bytes! [p ptr<void> n : int])

fill `n` bytes at `p` from the OS CSPRNG.

pdestination buffer, at least `n` bytes
nbyte count; 0 succeeds trivially, negative is an error

(Result int cstr) -- ok carries the byte count written; err carries a static description. On error the destination is left wiped, never partially filled with low-entropy bytes.

(let [r (crypto-random-bytes! buf 32)]
    (if (ok? r) (use-key buf) (die (err-val r))))

Since: 0.1.0

defn

crypto-random-source

(crypto-random-source :)

name the CSPRNG backend this build selected.

A static cstr: "BCryptGenRandom", "arc4random_buf", "getrandom", or "/dev/urandom".

(println (crypto-random-source))  ; => "arc4random_buf" on macOS

Since: 0.1.0

defn

ct-eq-ptr?

(ct-eq-ptr? [a ptr<void> b ptr<void> n : int] :)

compare two `n`-byte buffers in time independent of content.

afirst buffer
bsecond buffer
nbyte count to compare; <= 0 compares equal

true when all `n` bytes match.

(if (ct-eq-ptr? computed-mac supplied-mac 32) (accept) (reject))

Since: 0.1.0