a very compact s-box for aes
TRANSCRIPT
-
7/28/2019 A Very Compact S-Box for AES
1/51
A Very Compact S-box for AES(Advanced Encryption Standard)
D. Canright
Applied Mathematics Dept.
Naval Postgraduate School
Monterey CA 93943, USA
A Very Compact S-box for AES CHES2005 p. 1/26
-
7/28/2019 A Very Compact S-Box for AES
2/51
Advanced Encryption Standard(AES)
A Very Compact S-box for AES CHES2005 p. 2/26
-
7/28/2019 A Very Compact S-Box for AES
3/51
Algorithm
AES is symmetric block cipher
from 128-bit key, a different round key generated for
each of 10 roundseach 128-bit block processed by roundsround 0 :
Add Round Key.rounds 1-9 :
S-Box; Shift Rows; Mix Columns; Add Round Key.round 10 :
S-Box; Shift Rows; Add Round Key.
A Very Compact S-box for AES CHES2005 p. 3/26
-
7/28/2019 A Very Compact S-Box for AES
4/51
step1: Add Round Key
for whole 128-bit block:
inkey out
where is bitwise exclusive-or (XOR)(For decryption, inverse operation is identical.)
A Very Compact S-box for AES CHES2005 p. 4/26
-
7/28/2019 A Very Compact S-Box for AES
5/51
step2: S-Box (Byte Substitution)
for each 8-bit byte a :
1. Inverse : Let c = a 1 , the inverse in GF (28 )
2. Afne : The output s is M c b :s7s6s5s4
s3s2s1
s0
=
1 1 1 1 1 0 0 00 1 1 1 1 1 0 00 0 1 1 1 1 1 00 0 0 1 1 1 1 1
1 0 0 0 1 1 1 11 1 0 0 0 1 1 11 1 1 0 0 0 1 1
1 1 1 1 0 0 0 1
c7c6c5c4
c3c2c1
c0
0110
001
1A Very Compact S-box for AES CHES2005 p. 5/26
-
7/28/2019 A Very Compact S-Box for AES
6/51
step3: Shift Rows
for 4 4 byte matrix, rotate rows 03 accordingly:
a b c de f g hi j k l
m n o p
a b c df g h ek l i j
p m n o
A Very Compact S-box for AES CHES2005 p. 6/26
-
7/28/2019 A Very Compact S-Box for AES
7/51
step4: Mix Columns
for each 4-byte column C of 4 4 byte matrix:
2 3 1 11 2 3 11 1 2 3
3 1 1 2
C 0C 1C 2
C 3
D 0D 1D 2
D 3
where byte multiplication and addition is in GF (28 )
A Very Compact S-box for AES CHES2005 p. 7/26
-
7/28/2019 A Very Compact S-Box for AES
8/51
nonlinearity
the steps Shift Rows, Mix Columns, & Add Round Keyare linear operations (and easy)
A Very Compact S-box for AES CHES2005 p. 8/26
-
7/28/2019 A Very Compact S-Box for AES
9/51
nonlinearity
the steps Shift Rows, Mix Columns, & Add Round Keyare linear operations (and easy)
the S-box function is nonlinear due to the inverse operation in GF (28 ) (not easy to compute)
A Very Compact S-box for AES CHES2005 p. 8/26
-
7/28/2019 A Very Compact S-Box for AES
10/51
Galois Fields
A Very Compact S-box for AES CHES2005 p. 9/26
-
7/28/2019 A Very Compact S-Box for AES
11/51
denition
A eld is a set with two operations, addition andmultiplication :
both satisfy closureboth associative
both commutative
each has identity (0 and 1)
any element a has additive inverse a
any nonzero element a = 0 has multiplicative inverse a 1
multiplication distributive over addition
A Very Compact S-box for AES CHES2005 p. 10/26
-
7/28/2019 A Very Compact S-Box for AES
12/51
-
7/28/2019 A Very Compact S-Box for AES
13/51
GF (28 ) Representation
standard for GF (28 )/ GF (2): A = a7 x7 + + a1 x + a0 ,
where a i {0, 1} and x8
+ x4
+ x3
+ x + 1 = 0 .subeld
for GF (28 )/ GF (24 ): A = a1 x + a0 or a1 x1 + a0 x0 ,where a i , T, N GF (24 ) and x2 + T x + N = 0 ;then for GF (24 )/ GF (22 ): A = a1 x + a0 or a1 x1 + a0 x0 ,where a i , T, N GF (22 ) and x2 + T x + N = 0 ;then for GF (22 )/ GF (2): A = a1 x + a0 or a1 x1 + a0 x0 ,where a i {0, 1} and x2 + x + 1 = 0 .
(note: T is trace and N is norm, over subeld)A Very Compact S-box for AES CHES2005 p. 12/26
-
7/28/2019 A Very Compact S-Box for AES
14/51
Implementation
A Very Compact S-box for AES CHES2005 p. 13/26
-
7/28/2019 A Very Compact S-Box for AES
15/51
Implementation Goals
Different applications have different constraints & goals.speed : throughput and/or latency (by parallelism, pipelining)
Morioka & Satoh, Intl Conf. Computer Design (2002), IEEE
Weaver & Wawrzynek, (2002)Jarvinen et al., FPGA 03 (2003) ACM
low power : e.g., for smart cardsMorioka & Satoh, CHES2002 (2003), LNCS 2523
small size : for limited ciruitry, e.g., also smart cardsRudra et al., CHES2001 (2001), LNCS 2162
Satoh et al., ASIACRYPT (2001), LNCS 2248Wolkerstorfer et al., CT-RSA (2002), LNCS 2271
Chodowiec & Gaj, CHES2003 (2003), LNCS 2779
Mentens et al., CT-RSA (2005), LNCS 3376
A Very Compact S-box for AES CHES2005 p. 14/26
-
7/28/2019 A Very Compact S-Box for AES
16/51
small size
prior smallest: Satoh et al., used nested elds for S-box
A Very Compact S-box for AES CHES2005 p. 15/26
-
7/28/2019 A Very Compact S-Box for AES
17/51
small size
prior smallest: Satoh et al., used nested elds for S-box
recent improvement: Mentens et al., considered other
isomorphisms (64)
A Very Compact S-box for AES CHES2005 p. 15/26
-
7/28/2019 A Very Compact S-Box for AES
18/51
small size
prior smallest: Satoh et al., used nested elds for S-box
recent improvement: Mentens et al., considered other
isomorphisms (64)current work: more improvement
A Very Compact S-box for AES CHES2005 p. 15/26
-
7/28/2019 A Very Compact S-Box for AES
19/51
small size
prior smallest: Satoh et al., used nested elds for S-box
recent improvement: Mentens et al., considered other
isomorphisms (64)current work: more improvement
considered more isomorphisms (432), incl. normalbases
A Very Compact S-box for AES CHES2005 p. 15/26
-
7/28/2019 A Very Compact S-Box for AES
20/51
small size
prior smallest: Satoh et al., used nested elds for S-box
recent improvement: Mentens et al., considered other
isomorphisms (64)current work: more improvement
considered more isomorphisms (432), incl. normalbasesfully optimized basis-change matrices
A Very Compact S-box for AES CHES2005 p. 15/26
-
7/28/2019 A Very Compact S-Box for AES
21/51
small size
prior smallest: Satoh et al., used nested elds for S-box
recent improvement: Mentens et al., considered other
isomorphisms (64)current work: more improvement
considered more isomorphisms (432), incl. normalbasesfully optimized basis-change matriceslogic-gate substitution (NOR for NAND and XORs)
A Very Compact S-box for AES CHES2005 p. 15/26
-
7/28/2019 A Very Compact S-Box for AES
22/51
merged S-box, S-box 1
basis
2:1 mux
GF(2 8)inverter
affine -1 ,basis
basis -1 ,affine basis
-1
2:1 mux
in
out
Satoh architectureshares inverter
between S-box and S-box 1
(left pathways for encryptionright pathways for decryption)
A Very Compact S-box for AES CHES2005 p. 16/26
-
7/28/2019 A Very Compact S-Box for AES
23/51
merged S-box, S-box 1
basis
2:1 mux
GF(2 8)inverter
affine -1 ,basis
basis -1 ,affine basis
-1
2:1 mux
in
out
Satoh architectureshares inverter
between S-box and S-box 1
(left pathways for encryptionright pathways for decryption)
This also allows pairs of transfor-mations (input and output) to beoptimized together
A Very Compact S-box for AES CHES2005 p. 16/26
-
7/28/2019 A Very Compact S-Box for AES
24/51
Main Operations - formulas
using roots of x2 + T x + N , where T is trace, N is normpolynomial basis [x, 1] inverse & multiplication:
[1 , 0 ] 1 = ( 21 N + 1 0 T + 20 ) 1 [ 1 , 0 + 1 T ][1 , 0 ] [ 1 , 0 ] = [ 1 0 + 0 1 + 1 1 T , 0 0 + 1 1 N ]
normal basis [x1 , x2 ] inverse & multiplication:[1 , 0 ] 1 = ( 1 0 T 2 + ( 21 +
20 )N )
1 [ 0 , 1 ]
[1 , 0 ] [ 1 , 0 ] = [ 1 1 T + ( 1 + 0 )( 1 + 0 )NT 1
,0 0 T + ( 1 + 0 )( 1 + 0 )NT 1 ]
May choose T = 1 or N = 1 or NT 1 = 1 ; best is T = 1 .
A Very Compact S-box for AES CHES2005 p. 17/26
-
7/28/2019 A Very Compact S-Box for AES
25/51
Main Operations - diagrams
polynomial inverter normal inverter
2
12
2 1
0
1
0
2
12
2 1
0
1
0
polynomial multiplier normal multiplier
2
2
1
0
1
0
1
0
2
2
1
0
1
0
1
0
Both polynomial and normal bases require same numberand type of subeld operations.
A Very Compact S-box for AES CHES2005 p. 18/26
-
7/28/2019 A Very Compact S-Box for AES
26/51
Main Operations - diagrams
polynomial inverter normal inverter
2
12
2 1
0
1
0
2
12
2 1
0
1
0
polynomial multiplier normal multiplier
2
2
1
0
1
0
1
0
2
2
1
0
1
0
1
0
Both polynomial and normal bases require same numberand type of subeld operations.Note that in normal inverter, each factor to multiplier isshared with another multiplier.
A Very Compact S-box for AES CHES2005 p. 18/26
-
7/28/2019 A Very Compact S-Box for AES
27/51
Optimizations
factoring transformation matrices
A Very Compact S-box for AES CHES2005 p. 19/26
-
7/28/2019 A Very Compact S-Box for AES
28/51
Optimizations
factoring transformation matricesprior work: greedy algorithm
A Very Compact S-box for AES CHES2005 p. 19/26
-
7/28/2019 A Very Compact S-Box for AES
29/51
Optimizations
factoring transformation matricesprior work: greedy algorithm
current: full optimization by tree search
A Very Compact S-box for AES CHES2005 p. 19/26
-
7/28/2019 A Very Compact S-Box for AES
30/51
Optimizations
factoring transformation matricesprior work: greedy algorithm
current: full optimization by tree searchcommon subexpressions
A Very Compact S-box for AES CHES2005 p. 19/26
-
7/28/2019 A Very Compact S-Box for AES
31/51
Optimizations
factoring transformation matricesprior work: greedy algorithm
current: full optimization by tree searchcommon subexpressions
shared factors in inverters
A Very Compact S-box for AES CHES2005 p. 19/26
-
7/28/2019 A Very Compact S-Box for AES
32/51
Optimizations
factoring transformation matricesprior work: greedy algorithm
current: full optimization by tree searchcommon subexpressions
shared factors in invertersbit sums for square&scale
A Very Compact S-box for AES CHES2005 p. 19/26
-
7/28/2019 A Very Compact S-Box for AES
33/51
Optimizations
factoring transformation matricesprior work: greedy algorithm
current: full optimization by tree searchcommon subexpressions
shared factors in invertersbit sums for square&scale
logic gate substitution
A Very Compact S-box for AES CHES2005 p. 19/26
-
7/28/2019 A Very Compact S-Box for AES
34/51
Optimizations
factoring transformation matricesprior work: greedy algorithm
current: full optimization by tree searchcommon subexpressions
shared factors in invertersbit sums for square&scale
logic gate substitution
XNOR for NOT XOR
A Very Compact S-box for AES CHES2005 p. 19/26
-
7/28/2019 A Very Compact S-Box for AES
35/51
Optimizations
factoring transformation matricesprior work: greedy algorithm
current: full optimization by tree searchcommon subexpressions
shared factors in invertersbit sums for square&scale
logic gate substitution
XNOR for NOT XORNAND for AND
A Very Compact S-box for AES CHES2005 p. 19/26
-
7/28/2019 A Very Compact S-Box for AES
36/51
Optimizations
factoring transformation matricesprior work: greedy algorithm
current: full optimization by tree searchcommon subexpressions
shared factors in invertersbit sums for square&scale
logic gate substitution
XNOR for NOT XORNAND for ANDa NOR b for a XOR b XOR a NAND b
A Very Compact S-box for AES CHES2005 p. 19/26
-
7/28/2019 A Very Compact S-Box for AES
37/51
Results
A Very Compact S-box for AES CHES2005 p. 20/26
B C R l
-
7/28/2019 A Very Compact S-Box for AES
38/51
Best Case Results
our smallest implementation of: merged S-box & inverse(Satoh architecture, with shared inverter); S-box alone; andinverse S-box alone.
best XOR NAND NOR NOT MUX total gatesmerged 94 34 6 2 16 234
S-box 80 34 6 0 0 180(S-box) 1 81 34 6 0 0 182
A Very Compact S-box for AES CHES2005 p. 21/26
B C R l
-
7/28/2019 A Very Compact S-Box for AES
39/51
Best Case Results
our smallest implementation of: merged S-box & inverse(Satoh architecture, with shared inverter); S-box alone; andinverse S-box alone.
best XOR NAND NOR NOT MUX total gatesmerged 94 34 6 2 16 234
S-box 80 34 6 0 0 180(S-box) 1 81 34 6 0 0 182
20% smaller than previous smallest merged S-box ofSatoh, at 294 gates.
A Very Compact S-box for AES CHES2005 p. 21/26
B C R l
-
7/28/2019 A Very Compact S-Box for AES
40/51
Best Case Results
our smallest implementation of: merged S-box & inverse(Satoh architecture, with shared inverter); S-box alone; andinverse S-box alone.
best XOR NAND NOR NOT MUX total gatesmerged 94 34 6 2 16 234
S-box 80 34 6 0 0 180(S-box) 1 81 34 6 0 0 182
20% smaller than previous smallest merged S-box ofSatoh, at 294 gates.
same basis that gives smallest merged S-box also givessmallest separate S-box.
A Very Compact S-box for AES CHES2005 p. 21/26
L l f O i i i
-
7/28/2019 A Very Compact S-Box for AES
41/51
Levels of Optimization
Size of GF (28 ) inverter with increasing levels of optimization:
inverter XOR NAND NOR total gates
hierarchical 88 36 0 190w/ shared oper. 66 36 0 152w/ NOR subst. 56 34 6 138
A Very Compact S-box for AES CHES2005 p. 22/26
L l f O ti i ti
-
7/28/2019 A Very Compact S-Box for AES
42/51
Levels of Optimization
Size of GF (28 ) inverter with increasing levels of optimization:
inverter XOR NAND NOR total gates
hierarchical 88 36 0 190w/ shared oper. 66 36 0 152w/ NOR subst. 56 34 6 138
sharing operations saves 20%.
the NOR substitution saves an additional 9%.
A Very Compact S-box for AES CHES2005 p. 22/26
Ch i f B i
-
7/28/2019 A Very Compact S-Box for AES
43/51
Choice of Basis
Comparison of four choices of basis: our best case; bestcase of Mentens et al.; basis of Satoh et al.; and our worstcase.
basis merged S-box S-box 1
ours 253 195 195
Mentens 271 204 206Satoh 275 211 209worst 293 223 222
worst-basis merged S-box bigger than best by 16%.
A Very Compact S-box for AES CHES2005 p. 23/26
M t i O ti i ti
-
7/28/2019 A Very Compact S-Box for AES
44/51
Matrix Optimization
Full optimization of matrices often improves upon the greedyalgorithm, but may require much computation.
matrix matrices # improved by matricessize optimized 1 XOR 2 XORs 3 XORs improved
8 8 1728 613 138 11 44%16 8 55 24 10 6 73%
A Very Compact S-box for AES CHES2005 p. 24/26
M t i Si P di t
-
7/28/2019 A Very Compact S-Box for AES
45/51
Matrix Size Predictors
criteria for comparing matrices before optimization:number of ones vs. opt. greedy algorithm vs. opt.
10 15
15
20
25
30
35
10 15
10
15
20
comparisons of matrices based on:number of ones incorrect for 37% of 8 8 and 44% of 16 8greedy algorithm incorrect for 20% of 8 8 and 31% of 16 8
A Very Compact S-box for AES CHES2005 p. 25/26
C l i
-
7/28/2019 A Very Compact S-Box for AES
46/51
Conclusions
Several improvements allow the merged S-box architectureof Satoh to be reduced in circuitry:
A Very Compact S-box for AES CHES2005 p. 26/26
Conclusions
-
7/28/2019 A Very Compact S-Box for AES
47/51
Conclusions
Several improvements allow the merged S-box architectureof Satoh to be reduced in circuitry:
considering other bases for subelds; of 432 cases, bestuses all normal bases
A Very Compact S-box for AES CHES2005 p. 26/26
Conclusions
-
7/28/2019 A Very Compact S-Box for AES
48/51
Conclusions
Several improvements allow the merged S-box architectureof Satoh to be reduced in circuitry:
considering other bases for subelds; of 432 cases, bestuses all normal bases
full matrix optimization improves on the greedy algorithm
A Very Compact S-box for AES CHES2005 p. 26/26
Conclusions
-
7/28/2019 A Very Compact S-Box for AES
49/51
Conclusions
Several improvements allow the merged S-box architectureof Satoh to be reduced in circuitry:
considering other bases for subelds; of 432 cases, bestuses all normal bases
full matrix optimization improves on the greedy algorithm
the NOR substitution gives further improvement
A Very Compact S-box for AES CHES2005 p. 26/26
Conclusions
-
7/28/2019 A Very Compact S-Box for AES
50/51
Conclusions
Several improvements allow the merged S-box architectureof Satoh to be reduced in circuitry:
considering other bases for subelds; of 432 cases, bestuses all normal bases
full matrix optimization improves on the greedy algorithm
the NOR substitution gives further improvementthe resulting merged S-box is 20% smaller than that ofSatoh
A Very Compact S-box for AES CHES2005 p. 26/26
Conclusions
-
7/28/2019 A Very Compact S-Box for AES
51/51
Conclusions
Several improvements allow the merged S-box architectureof Satoh to be reduced in circuitry:
considering other bases for subelds; of 432 cases, bestuses all normal bases
full matrix optimization improves on the greedy algorithm
the NOR substitution gives further improvementthe resulting merged S-box is 20% smaller than that ofSatoh
this smaller size could save chip area in ASICs, or allowmore copies for parallelism and pipelining