aesround.bend checks
raw source on the hub · import bend-osdev-aead@0.1.0.0/aesround.bend as Aesround
The AES encryption round function, AESRound(A, B) = MixColumns(ShiftRows( SubBytes(A))) xor B (FIPS 197, sections 5.1.1 to 5.1.4; not the last round), on 16-byte blocks: the building block of AEGIS (aegis128.bend). It is the x86 instruction AESENC; RFC 10032 (the AEGIS family), Appendix A.1, gives its test vector.
A block is four big-endian 32-bit words, each one column of the AES state: byte r of word c is the state's row r, column c (FIPS 197, 3.4: byte i of the input is row i mod 4, column i / 4). The S-box is a table built once (AdAes.sbox) and passed in, so a caller that runs many rounds (AEGIS keeps it in its key) builds it once.
2 imports
import Base import bend-osdev-bytes@0.1.0.0/bytes.bend as B
Types
type AdBlk source · line 16 · raw
Data
A 16-byte block (open type)
AdBlk@w0:U32 -> @w1:U32 -> @w2:U32 -> @w3:U32 -> AdBlk
type AdTab source · line 88 · raw
Data
a table of 2^d words, read by the bits of an index (internal)
AdLeaf@v:U32 -> AdTab
AdNode@l:AdTab -> @r:AdTab -> AdTab
type AdSbox source · line 143 · raw
Data
The S-box as a table (opaque)
AdSbox@t:AdTab -> AdSbox
Definitions
def AdBlk.zero source · line 19 · raw
AdBlk
def AdBlk.xor source · line 22 · raw
@a:AdBlk -> @b:AdBlk -> AdBlk
def AdBlk.and source · line 27 · raw
@a:AdBlk -> @b:AdBlk -> AdBlk
def ad.blk.at source · line 32 · raw
@xs:List<&2, U32> -> @i:Nat -> U32
def ad.blk.word source · line 43 · raw
@+xs:List<&2, U32> -> @+i:Nat -> U32
def AdBlk.of_list source · line 47 · raw
@+xs:List<&2, U32> -> AdBlk
the block of the first 16 bytes of xs (zeros past the end)
def AdBlk.to_list source · line 51 · raw
@b:AdBlk -> List<&2, U32>
a block's 16 bytes
def AdBlk.of_octets source · line 56 · raw
@+o:0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets -> AdBlk
def AdBlk.to_octets source · line 59 · raw
@b:AdBlk -> 0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets
def AdBlk.hex source · line 62 · raw
@b:AdBlk -> String
def ad.aes.sbox.list source · line 68 · raw
List<&2, U32>
BEGIN GENERATED by gen/tables.py: sbox
def ad.tab.leaves source · line 92 · raw
@xs:List<&2, U32> -> List<&2, AdTab>
def ad.tab.pairs source · line 99 · raw
@ts:List<&2, AdTab> -> List<&2, AdTab>
def ad.tab.up source · line 106 · raw
@n:Nat -> @ts:List<&2, AdTab> -> List<&2, AdTab>
def ad.tab.root source · line 113 · raw
@ts:List<&2, AdTab> -> AdTab
def ad.tab.pick source · line 120 · raw
@one:Bool -> @l:AdTab -> @r:AdTab -> AdTab
def ad.tab.get source · line 127 · raw
@d:Nat -> @t:AdTab -> @+i:U32 -> U32
def AdAes.sbox source · line 146 · raw
AdSbox
def ad.aes.s source · line 149 · raw
@+t:AdTab -> @+w:U32 -> @n:Nat -> U32
def ad.aes.x2 source · line 153 · raw
@+a:U32 -> U32
x times 2 in GF(2^8) (xtime, FIPS 197 4.2.1)
def ad.aes.mix source · line 157 · raw
@+a0:U32 -> @+a1:U32 -> @+a2:U32 -> @+a3:U32 -> U32
MixColumns of one column a0 .. a3 (row 0 first), as a word
def ad.aes.col source · line 166 · raw
@+t:AdTab -> @+x0:U32 -> @+x1:U32 -> @+x2:U32 -> @+x3:U32 -> U32
one column of the round: rows 0 .. 3 from columns c, c + 1, c + 2, c + 3 (ShiftRows), each through the S-box (SubBytes), then MixColumns
def AdAes.round source · line 170 · raw
@s:AdSbox -> @a:AdBlk -> @k:AdBlk -> AdBlk
AESRound(a, k)