~/bend-docscommunity

inst_cm.bend checks

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

The adapter for cipher-modes: its error type mapped onto CrError, and the block format of its 128-bit block CmBlock (an open type: four big-endian 32-bit words), for every 128-bit cipher that uses it (cipher-modes' AES, legacy-ciphers' SM4, Camellia, Serpent and Twofish).

The format's conversions are written here, on the open type, so that its law (format: blk_of(blk_to(b)) == Some{b}) is proved in this package: cipher-modes proves the same of its own CmBlock.of_octets and CmBlock.to_octets, but its PROOF.bend cannot be imported by a proof that passes --verdict (README.md, "Laws").

5 imports
import Base
import bend-osdev-bytes@0.1.0.0/bytes.bend as B
import bend-osdev-word64@0.1.0.0/word64.bend as W
import bend-osdev-cipher-modes@0.1.0.0/cipher_modes.bend as M
import ./crypto.bend as Cr

Definitions

def CrCm.err source · line 19 · raw

@e:0xf4b936e0e6b2608080d2f02bb3ce9abe/cipher_modes.CmError -> 0x01313a4f070f7ffd2bd276fcd2143eda/crypto.CrError

def cr.f128.bits8 source · line 54 · raw

@b:U32 -> Word(8n)

def cr.f128.word source · line 60 · raw

@a:U32 -> @b:U32 -> @c:U32 -> @d:U32 -> U32

the word with bytes a, b, c, d, most significant first

def cr.f128.bytes source · line 64 · raw

@b:0xf4b936e0e6b2608080d2f02bb3ce9abe/cipher_modes.CmBlock -> List<&2, U32>

the 16 bytes of a block, most significant byte of w0 first

def cr.f128.block source · line 70 · raw

@xs:List<&2, U32> -> Maybe<&2, 0xf4b936e0e6b2608080d2f02bb3ce9abe/cipher_modes.CmBlock>

exactly 16 bytes as a block

def CrBlk128.to_octets source · line 78 · raw

@b:0xf4b936e0e6b2608080d2f02bb3ce9abe/cipher_modes.CmBlock -> 0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets

a block's 16 bytes

def CrBlk128.of_octets source · line 82 · raw

@o:0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets -> Maybe<&2, 0xf4b936e0e6b2608080d2f02bb3ce9abe/cipher_modes.CmBlock>

16 bytes as a block; None for any other length

def CrBlk128.xor source · line 85 · raw

@a:0xf4b936e0e6b2608080d2f02bb3ce9abe/cipher_modes.CmBlock -> @b:0xf4b936e0e6b2608080d2f02bb3ce9abe/cipher_modes.CmBlock -> 0xf4b936e0e6b2608080d2f02bb3ce9abe/cipher_modes.CmBlock

Templates

template CrCm.lift source · line 45 · raw

@-A:Data -> @r:Result<&2, &2, 0xf4b936e0e6b2608080d2f02bb3ce9abe/cipher_modes.CmError, A> -> Result<&2, &2, 0x01313a4f070f7ffd2bd276fcd2143eda/crypto.CrError, A>

a cipher-modes result as an interface result

template CrCm.key source · line 49 · raw

@-K:Data -> @-key:(@_:0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets -> Result<&2, &2, 0xf4b936e0e6b2608080d2f02bb3ce9abe/cipher_modes.CmError, K>) -> @o:0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets -> Result<&2, &2, 0x01313a4f070f7ffd2bd276fcd2143eda/crypto.CrError, K>

a cipher-modes key schedule as the interface's ~key