Documentation ¶
Overview ¶
Package saes implements a reference copy of AES-128. It's useful for stealing AES' internals or seeing the ways you can garble them without affecting its output.
Example (Encrypt) ¶
constr := Construction{ Key: []byte{100, 17, 10, 146, 79, 7, 67, 213, 0, 204, 173, 174, 114, 193, 52, 39}, } src := []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} dst := make([]byte, 16) constr.Encrypt(dst, src) fmt.Println(dst)
Output: [53 135 12 106 87 233 233 35 20 188 184 8 124 222 114 206]
Index ¶
- type Construction
- func (constr *Construction) AddRoundKey(roundKey, block []byte)
- func (constr Construction) BlockSize() int
- func (constr Construction) Decrypt(dst, src []byte)
- func (constr Construction) Encrypt(dst, src []byte)
- func (constr *Construction) MixColumn(slice []byte)
- func (constr *Construction) MixColumns(block []byte)
- func (constr *Construction) ShiftRows(block []byte)
- func (constr *Construction) StretchedKey() [11][]byte
- func (constr *Construction) SubByte(e byte) byte
- func (constr *Construction) SubBytes(block []byte)
- func (constr *Construction) SubWord(w uint32) uint32
- func (constr *Construction) UnMixColumn(slice []byte)
- func (constr *Construction) UnMixColumns(block []byte)
- func (constr *Construction) UnShiftRows(block []byte)
- func (constr *Construction) UnSubByte(e byte) byte
- func (constr *Construction) UnSubBytes(block []byte)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Construction ¶
type Construction struct { // A 16-byte AES key. Key []byte }
func (*Construction) AddRoundKey ¶
func (constr *Construction) AddRoundKey(roundKey, block []byte)
AddRoundKey XORs roundKey into block.
func (Construction) BlockSize ¶
func (constr Construction) BlockSize() int
BlockSize returns the block size of AES. (Necessary to implement cipher.Block.)
func (Construction) Decrypt ¶
func (constr Construction) Decrypt(dst, src []byte)
Decrypt decrypts the first block in src into dst. Dst and src may point at the same memory.
func (Construction) Encrypt ¶
func (constr Construction) Encrypt(dst, src []byte)
Encrypt encrypts the first block in src into dst. Dst and src may point at the same memory.
func (*Construction) MixColumn ¶
func (constr *Construction) MixColumn(slice []byte)
MixColumn multiplies the first four bytes of slice by a fixed element of GF(2^32).
func (*Construction) MixColumns ¶
func (constr *Construction) MixColumns(block []byte)
MixColumns multiplies each word of block by a fixed elment of GF(2^32).
func (*Construction) ShiftRows ¶
func (constr *Construction) ShiftRows(block []byte)
ShiftRows permutes the first sixteen bytes of block with a fixed permutation.
func (*Construction) StretchedKey ¶
func (constr *Construction) StretchedKey() [11][]byte
StretchedKey implements AES' key schedule. It returns the 11 round keys derived from the master key.
func (*Construction) SubByte ¶
func (constr *Construction) SubByte(e byte) byte
SubByte is AES' S-box. It is a bijection.
func (*Construction) SubBytes ¶
func (constr *Construction) SubBytes(block []byte)
SubBytes rewrites each byte of block with its image under SubByte.
func (*Construction) SubWord ¶
func (constr *Construction) SubWord(w uint32) uint32
SubWord applies SubByte to each byte of an unsigned integer word and returns the result.
func (*Construction) UnMixColumn ¶
func (constr *Construction) UnMixColumn(slice []byte)
UnMixColumn is the inverse of MixColumn.
func (*Construction) UnMixColumns ¶
func (constr *Construction) UnMixColumns(block []byte)
UnMixColumns is the inverse of MixColumns.
func (*Construction) UnShiftRows ¶
func (constr *Construction) UnShiftRows(block []byte)
UnShiftRows permutes the first sixteen bytes of block. It is the inverse of ShiftRows.
func (*Construction) UnSubByte ¶
func (constr *Construction) UnSubByte(e byte) byte
UnSubByte is the inverse of SubByte. It is a bijection.
func (*Construction) UnSubBytes ¶
func (constr *Construction) UnSubBytes(block []byte)
UnSubBytes rewrites each byte of block with its image under UnSubByte.