Example #1
0
func (constr *Construction) decrypt(in gfmatrix.Row) gfmatrix.Row {
	roundKeys := constr.StretchedKey()

	state := in.Add(roundConst).Add(roundKeys[10])
	state = firstRound.Mul(state)
	state = constr.subBytes(state)

	for i := 9; i >= 1; i-- {
		state = state.Add(roundConst).Add(roundKeys[i])
		state = unRound.Mul(state)
		state = constr.subBytes(state)
	}

	state = state.Add(roundKeys[0])

	return state
}
Example #2
0
func (constr *Construction) encrypt(in gfmatrix.Row) gfmatrix.Row {
	roundKeys := constr.StretchedKey()

	state := in.Add(roundKeys[0])

	for i := 1; i <= 9; i++ {
		state = constr.subBytes(state)
		state = round.Mul(state)
		state = state.Add(roundConst).Add(roundKeys[i])
	}

	state = constr.subBytes(state)
	state = lastRound.Mul(state)
	state = state.Add(roundConst).Add(roundKeys[10])

	return state
}