common

package
v0.0.0-...-b7fcb3c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2016 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package common contains code common to many constructions.

Index

Constants

View Source
const (
	SliceSize  = 4096  // = 256*16
	SlicesSize = 65536 // = 16*SliceSize
)

Variables

This section is empty.

Functions

func GenerateMasks

func GenerateMasks(rs *random.Source, opts KeyGenerationOpts, inputMask, outputMask *matrix.Matrix)

GenerateMasks generates input and output encodings for a white-box AES construction.

func MixingBijection

func MixingBijection(rs *random.Source, size, round, position int) matrix.Matrix

Generate byte/word mixing bijections. TODO: Ensure that blocks are full-rank.

func NoShift

func NoShift(i int) int

func ParseBlockSlices

func ParseBlockSlices(in []byte) (outM [16]table.Block, rest []byte)

func SerializeBlockMatrix

func SerializeBlockMatrix(dst []byte, m [16]table.Block, xor BlockXORTables) int

func ShiftRows

func ShiftRows(i int) int

ShiftRows is the block permutation in AES. Index in, index out.

Example: ShiftRows(5) = 1 because ShiftRows(block) returns [16]byte{block[0], block[5], ...

func UnShiftRows

func UnShiftRows(i int) int

UnShiftRows is the inverse of ShiftRows.

Types

type BlockMatrix

type BlockMatrix struct {
	Linear   matrix.Matrix
	Constant [16]byte
	Position int
}

func (BlockMatrix) Get

func (bm BlockMatrix) Get(i byte) (out [16]byte)

type BlockXORTables

type BlockXORTables interface {
	SquashBlocks(blocks [16][16]byte, dst []byte)
	Serialize() []byte
}

type ByteXORTable

type ByteXORTable struct{}

Computes the XOR of two bytes.

func (ByteXORTable) Get

func (bxt ByteXORTable) Get(i [2]byte) (out byte)

type ByteXORTables

type ByteXORTables [16][15]table.DoubleToByte // [byte-wise position][gate number]

func BlockByteXORTables

func BlockByteXORTables(SliceEncoding, XOREncoding func(int, int) encoding.Byte, RoundEncoding func(int) encoding.Byte) (out ByteXORTables)

Generate the XOR Tables for squashing the result of a BlockMatrix.

func ParseBlockByteMatrix

func ParseBlockByteMatrix(in []byte) (outM [16]table.Block, outXOR ByteXORTables, rest []byte)

func ParseByteXORTables

func ParseByteXORTables(in []byte) (bxts ByteXORTables, rest []byte)

func (ByteXORTables) Serialize

func (bxts ByteXORTables) Serialize() []byte

func (ByteXORTables) SquashBlocks

func (bxts ByteXORTables) SquashBlocks(blocks [16][16]byte, dst []byte)

type IndependentMasks

type IndependentMasks struct {
	Input, Output MaskType
}

IndependentMasks generates the input and output masks independently of each other.

type InvTBox

type InvTBox struct {
	Constr   saes.Construction
	KeyByte1 byte
	KeyByte2 byte
}

func (InvTBox) Get

func (tbox InvTBox) Get(i byte) byte

type InvTyiTable

type InvTyiTable uint

func (InvTyiTable) Get

func (tyi InvTyiTable) Get(i byte) (out [4]byte)

type KeyGenerationOpts

type KeyGenerationOpts interface{}

type MaskType

type MaskType int
const (
	RandomMask MaskType = iota
	IdentityMask
)

type MatchingMasks

type MatchingMasks struct{}

MatchingMasks implies a randomly generated input mask and the inverse mask on the output.

type NibbleXORTable

type NibbleXORTable struct{}

Computes the XOR of two nibbles.

func (NibbleXORTable) Get

func (nxt NibbleXORTable) Get(i byte) (out byte)

type NibbleXORTables

type NibbleXORTables [32][15]table.Nibble // [nibble-wise position][gate number]

func BlockNibbleXORTables

func BlockNibbleXORTables(SliceEncoding, XOREncoding func(int, int) encoding.Nibble, RoundEncoding func(int) encoding.Nibble) (out NibbleXORTables)

Generate the XOR Tables for squashing the result of a BlockMatrix.

func ParseBlockNibbleMatrix

func ParseBlockNibbleMatrix(in []byte) (outM [16]table.Block, outXOR NibbleXORTables, rest []byte)

func ParseNibbleXORTables

func ParseNibbleXORTables(in []byte) (nxts NibbleXORTables, rest []byte)

func (NibbleXORTables) Serialize

func (nxts NibbleXORTables) Serialize() []byte

func (NibbleXORTables) SquashBlocks

func (nxts NibbleXORTables) SquashBlocks(blocks [16][16]byte, dst []byte)

type SameMasks

type SameMasks MaskType

SameMasks puts the exact same mask on the input and output of the white-box.

type Surface

type Surface int
const (
	Inside Surface = iota
	Outside
)

type TBox

type TBox struct {
	Constr   saes.Construction
	KeyByte1 byte
	KeyByte2 byte
}

A T-Box computes the SubBytes and AddRoundKey steps.

func (TBox) Get

func (tbox TBox) Get(i byte) byte

type TyiTable

type TyiTable uint

A Tyi Table computes the MixColumns step.

func (TyiTable) Get

func (tyi TyiTable) Get(i byte) (out [4]byte)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL