~/bend-docscommunity

crypto.bend checks

raw source on the hub · import bend-osdev-crypto@0.1.0.0/crypto.bend as Crypto

bend-osdev-crypto: one set of typed interfaces for the cryptographic algorithms of bend-osdev, the Bend counterpart of Linux's crypto API.

An interface is a signature of template arguments: an algorithm satisfies it by supplying a def of each type, and a generic algorithm (HMAC over a hash, a mode over a block cipher) takes the signature as its own template arguments, so it is specialised at compile time for each algorithm it runs over. The interfaces, one file each:

block.bend block cipher: key schedule, encrypt and decrypt a block stream.bend stream cipher: a state that encrypts the next piece of data hash.bend hash: streaming init / update / final, and one-shot mac.bend message authentication code: compute and verify aead.bend authenticated encryption with associated data: seal, open kdf.bend key derivation sign.bend signature: sign and verify kex.bend key agreement

Each interface has laws that every instance must satisfy; README.md states them and gen/instances.py writes one law per instance into LAWS.bend. This file holds what every interface shares: the error type.

2 imports
import Base
import bend-osdev-bytes@0.1.0.0/bytes.bend as B

Types

type CrError source · line 27 · raw

Data

Every failure an interface reports. An instance whose algorithm has its own error type maps it onto these (inst_lc.bend, inst_cm.bend).

Definitions

def CrError.check source · line 43 · raw

@ok:Bool -> @e:CrError -> Result<&2, &2, CrError, Unit>

A check, as a step of a Result block

Templates

template CrError.lift source · line 51 · raw

@-E:Data -> @-A:Data -> @-f:(@_:E -> CrError) -> @r:Result<&2, &2, E, A> -> Result<&2, &2, CrError, A>

A result with an algorithm's own error type, its error mapped onto CrError