~/bend-docscommunity

check.bend checks

raw source on the hub · import bend-osdev-cipher-core@0.1.0.0/check.bend as Check

cipher-core on its own: a block's hex and byte forms, XOR, tables, the word helpers on bits against their native forms, Feistel rounds over a toy round function, and the 64-bit modes over a toy cipher (XOR with the key block: not a cipher, but enough to show the modes chain and undo themselves), with their refusals. The ciphers' own packages test the modes over real ciphers (des: against Python's cryptography).

4 imports
import Base
import bend-osdev-bytes@0.1.1.0/bytes.bend as B
import ./cipher_core.bend as L
import ./modes64.bend as X

Definitions

def err source · line 12 · raw

@e:0x5c26418ab13c9e565c5b1309d2f085a0/cipher_core.LcError -> String

def show source · line 21 · raw

@r:Result<&2, &2, 0x5c26418ab13c9e565c5b1309d2f085a0/cipher_core.LcError, 0xe0217e1ab38629fddf738452c1f2a82e/bytes.Octets> -> String

def show_blocks source · line 28 · raw

@r:Result<&2, &2, 0x5c26418ab13c9e565c5b1309d2f085a0/cipher_core.LcError, List<&2, 0x5c26418ab13c9e565c5b1309d2f085a0/cipher_core.LcBlock64>> -> String

def show_some source · line 35 · raw

@m:Maybe<&2, 0x5c26418ab13c9e565c5b1309d2f085a0/cipher_core.LcBlock64> -> String

def word source · line 43 · raw

@x:U32 -> String

a word as hex, through the block's hex form

def toy source · line 47 · raw

@k:0x5c26418ab13c9e565c5b1309d2f085a0/cipher_core.LcBlock64 -> @b:0x5c26418ab13c9e565c5b1309d2f085a0/cipher_core.LcBlock64 -> 0x5c26418ab13c9e565c5b1309d2f085a0/cipher_core.LcBlock64

the toy cipher: XOR with the key block, its own inverse

def toy_key source · line 50 · raw

0x5c26418ab13c9e565c5b1309d2f085a0/cipher_core.LcBlock64

def toy_f source · line 54 · raw

@k:U32 -> @x:U32 -> U32

a toy round function for the Feistel rounds: x + k, then rotated by 7

def msg source · line 57 · raw

0xe0217e1ab38629fddf738452c1f2a82e/bytes.Octets

def iv source · line 60 · raw

0xe0217e1ab38629fddf738452c1f2a82e/bytes.Octets

def ecb source · line 63 · raw

@m:0xe0217e1ab38629fddf738452c1f2a82e/bytes.Octets -> String

def cbc source · line 67 · raw

@+v:0xe0217e1ab38629fddf738452c1f2a82e/bytes.Octets -> @m:0xe0217e1ab38629fddf738452c1f2a82e/bytes.Octets -> String

def feistel source · line 71 · raw

@+b:0x5c26418ab13c9e565c5b1309d2f085a0/cipher_core.LcBlock64 -> String

def tab source · line 76 · raw

String

def main source · line 80 · raw

IO(Unit)