~/bend-docscommunity

aes.bend checks

raw source on the hub · import element-crypto@0.1.0.0/aes.bend as Aes

2 imports
import Base
import ./aes_sbox.bend as Sbox

Types

type B16 source · line 9 · raw

Data

type C4 source · line 52 · raw

Data

Definitions

def or0 source · line 12 · raw

@m:Maybe<&2, U32> -> U32

def nth source · line 19 · raw

@xs:List<&2, U32> -> @n:Nat -> U32

def of_bytes source · line 22 · raw

@+bs:List<&2, U32> -> B16

def to_bytes source · line 26 · raw

@s:B16 -> List<&2, U32>

def xor16 source · line 31 · raw

@x:B16 -> @y:B16 -> B16

def s source · line 37 · raw

@+x:U32 -> U32

def sub_shift source · line 41 · raw

@st:B16 -> B16

SubBytes and ShiftRows together (5.1.1, 5.1.2): row r turns left by r.

def xt source · line 49 · raw

@+b:U32 -> U32

multiplication by x in GF(2^8), without a branch: the reduction is 0x1b times the bit that falls off

def mix source · line 56 · raw

@+a0:U32 -> @+a1:U32 -> @+a2:U32 -> @+a3:U32 -> C4

MixColumns on one column (5.1.3): {02}a0+{03}a1+a2+a3 and its rotations.

def cols source · line 61 · raw

@m0:C4 -> @m1:C4 -> @m2:C4 -> @m3:C4 -> B16

def mix_cols source · line 66 · raw

@st:B16 -> B16

def next_key source · line 72 · raw

@k:B16 -> @+rcon:U32 -> B16

Key expansion (5.2): the next round key from the last and its Rcon.

def expand_go source · line 89 · raw

@n:Nat -> @+k:B16 -> @+rcon:U32 -> List<&2, B16>

def expand source · line 97 · raw

@+key:List<&2, U32> -> List<&2, B16>

The 11 round keys of a 16-byte key.

def rounds source · line 101 · raw

@ks:List<&2, B16> -> @+st:B16 -> B16

Rounds 1-9 mix the columns; the last round (no key after it) does not.

def encrypt_with source · line 112 · raw

@ks:List<&2, B16> -> @+block:B16 -> B16

def encrypt source · line 120 · raw

@+key:List<&2, U32> -> @+block:List<&2, U32> -> List<&2, U32>

One 16-byte block under a 16-byte key.