St epsi nt heAESEncr ypt i onPr ocess Theenc r y pt i o npr o ces sus esas etofs pec i al l yde r i v edke y sc al l edr o undk e ys .The sear eappl i e d,al ongwi t h ot hero per at i ons ,o nana r r a yofd at at hathol d se x ac t l yonebl oc kofd at a?t hedat at obee nc r y pt ed.Thi sa r r a y wec al l t hes t at ear r a y . Yout ak et hef ol l owi ngaesst epsofenc r y p t i onf ora128bi tbl oc k: 1. De r i v et hes etofr oundke ysf r om t hec i pherk e y . 2. I ni t i al i z et hes t at ear r aywi t ht hebl oc kdat a( pl ai nt ex t ) . 3. Addt hei ni t i alr oundk eyt ot hes t ar t i ngs t at ear r ay . 4. Per f or m ni ner ound sofs t at ema ma ni pul at i on. 5. Per f or mt het ent handfinal r oundofs t at emani pul at i on. 6. Cop yt hefi nal s t at ear r a youta st heenc r y pt eddat a( c i ph er t e xt ) . Ther ea sont hatt her o undsha v eb eenl i s t edas" ni nef ol l o wedbyafinal t ent hr o und "i sbec au set het ent hr ound i nv ol v esas l i ght l ydi ff er entmani pul at i onf r om t heot her s . Thebl oc kt obeenc r y pt edi sj us tasequen ceof128bi t s .AESwor k swi t hby t equ ant i t i ess owefir s tc on v er tt he 128bi t si nt o16by t es .Wes ay" c onv er t , "but ,i nr eal i t y ,i ti sal mos tc er t ai nl yst or edt hi swayal r eady .Oper at i ons i nRSN/ AESa r ep er f o r me do nat wo d i me ns i o na lb y t ea r r a yoff o urr o wsan df o urc o l u mn mn s.Att h es t a r t o ft h e e nc r y pt i o n,t h e1 6b yt e so fd at a ,n umb er e dD0?D1 5,a r el o ad edi n t ot h ea r r a yass ho wni nTa bl eA. 5 . Eac hr oundoft heenc r y pt i onpr oc es sr e qui r esas er i esofs t epst oal t ert hes t at ear r a y .Thes es t epsi nv ol v ef our t y pesofoper at i onscal l ed: •
SubByt es
•
Sh i f t Ro ws
Table A.5. Initial Value of the State Array D0
D4
D8
D12
D1
D5
D9
D13
D2
D6
D10
D14
D3
D7
D11
D15
•
Mi xCol umn mns
•
Xor RoundKey
Thedet ai l soft hes eoper at i onsar edes cr i bedshor t l y ,butfi r s tweneedt ol ooki nmor edet ai l att hegener at i on o ft h eRo un dKe y s ,s oc al l e db ec au set h er ei sad i ff er e nto nef o re a chr o un di nt h ep r o ce ss . RoundKeys
Thec i phe rk e yus edf ore nc r y pt i oni s128bi t sl ong.Wher et hi sk eyc ome sf r om i snoti mpor t anther e;r ef ert o Ch ap t e r1 0o nk e yhi e r a r c h ya ndho wt h et emp or a le nc r y pt i o nk e y sar epr o du ce d.Th ec i p he rk e yi sa l r e ad yt h e r e sul tofman yh as hi nga ndc r y pt ogr aphi ct r ans f or mat i onsand,b yt het i mei ta r r i v esatt heAESbl oc k enc r y pt i on,i ti sf arr emov edf r om t hes ec r etmas t erk eyhel dbyt heaut hent i c at i ons er v er .Now,fi nal l y ,i ti sus ed t oge ner at eas etofe l e ven128bi tr oundk e yst hatwi l lbec ombi nedwi t ht hedat adur i ngen cr y pt i on.Al t hough t her ea r et enr o unds ,el e v enk e ysar ene ededb ec aus eon ee xt r ak e yi sadd edt ot hei ni t i als t at ea r r a ybef or e t h er o un dss t a r t .Th eb es twa yt ov i e wt h es ek e y si sana r r a yofe l e v en1 6b y t ev a l u es ,e ac hma deu po ff o ur 3 2b i two r d s,a ss ho wni nT ab l eA. 6 . T os t ar twi t h,t hefi r s tr oundk eyRk ey 0i ssi mpl yi ni t i al i z edt ot hev al ueoft hec i pherk ey( t hati st hes ec r e tk ey del i v er edt hr ought hek eyhi er ar c hy ) . Eac hoft her e mai ni ngt enk ey si sder i v edf r om t hi sasf ol l ows .
Table A.6. oun! "ey Array 32 bits
32 bits
32 bits
32 bi
#ey0
$0
$1
$2
$3
#ey1
$0
$1
$2
$3
#ey2
$0
$1
$2
$3
#ey3
$0
$1
$2
$3
#ey4
$0
$1
$2
$3
#ey5
$0
$1
$2
$3
#ey6
$0
$1
$2
$3
#ey7
$0
$1
$2
$3
#ey8
$0
$1
$2
$3
#ey9
$0
$1
$2
$3
#ey10
$0
$1
$2
$3
F ore ac ho ft h er o un dk e y sRk e y 1t oRk e y 1 0 ,wo r d sW1 ,W2 ,W3a r ec o mp ut e da st h es um[ 1 ]o ft h e c o r r e s po nd i n gwo r di nt h ep r e v i o usr o un dk e ya ndt h ep r e ce di n gwo r di nt h ec ur r e ntr o un dk e y .Fo re x a mp l e , u si n gXORf o ra dd i t i o n:
[ 1]Us i ngfi ni t efi el dar i t hmet i c .
Rk ey 5:W1=Rk ey 4: W1XORRk ey 5: W0,
Rk ey 8:W3=Rk ey 7: W3XORRk ey 8: W2an ds oon .
Ther ul ef ort hev al ueofW0i sal i t t l emor ec ompl i c at edt odes cr i be,al t houghs t i l ls i mpl et oc omput e.Foreac h r o un dk e yRk e y 1t oRk e y 10 ,t h ev a l u eo fW0i st h es um o ft h r e e3 2b i tv a l u es : •
Th ev a l u eo fW0f r o mt h ep r e v i o usr o un dk e y
•
Thev al ueofW3f r om t hepr e vi ou sr o undk e y ,r o t at edr i g htb y8bi t s
•
As pec i al v al uef r om at abl ecal l edRc on
Th us ,wewr i t e :
Rk e y i : W0=Rk e y ( i 1 ) : W0XOR( Rk e y ( i 1 ) : W3> >>8 )XORRc o n [ i ]
wh er eW > >>8me an sr o t a t er i g ht8 ?f o re x a mp l e( i nhe x a de c i ma l )1 23 4b ec o me s41 23an dRc o n[ i ]i sa ne nt r y i nT abl eA. 7.
Table A.7. Value% in &on i
Rcon(i)
1
2
2
4
3
8
4
16
5
32
6
64
7
128
8
27
9
54
10
108
Th er ei sag oo dr e as onwh yt h es eq ue nc eo ft h i st a bl es ud de nl ybr e ak sofff r o m1 28t o2 7.I ti sbe ca us eo ft h e wa yfi ni t efi el d so ve r fl o w,asde sc r i bedi nt hep r e v i ouss ec t i on. Al t hought heal gor i t hm f order i v i ngt her o undke yss eemsr at herc ompl i c at ed,y ouwi l l not i c et hatnodi ffic ul t c omput at i onsha vebeenper f or medandi ti snotatal l c omput at i onal l yi nt ens i v e.Al s onot et hat ,af t ert hefi r s t , ea chk eyi sgener at edsequent i al l yandbas edont hepr e vi ou sone.Thi smean st hati ti spo ss i bl et ogener at e eac hr oundk eyj us ti nt i mebef or ei ti sneededi nt heenc r y pt i onc omput at i on.Al t er nat i v el y ,i ft her ei spl ent yof me mo r y , t h eyc a nb ed er i v e do nc ea tt h es t a r t a nds t o r e df o ru s ewi t he ac hsu bs e qu en tAESb l o c k . Comput i ngt heRounds
Ha v i n gd es c r i b edh owt h er o un dk e y sar ed er i v e d,wec a nn owr e t u r nt ot h eo pe r a t i o nsus e di nc o mp ut i n ge ac h r ound.Ear l i erwement i onedt hatf ouroper at i onsar er e qui r edcal l ed: •
SubByt es
•
Sh i f t Ro ws
•
Mi xCol umns
•
Xor RoundKey
Eac honeoft hes eoper at i on si sappl i edt ot hecu r r ents t at ea r r a yan dpr oduc esane wv er s i onoft hes t at e ar r a y .I nal l butt her ar es tc as es ,t hes t at ear r a yi schangedb yt heoper at i on.Thedet ai l sofeac hoper at i onar e gi v ens hor t l y . I nt hefi r s tni ner oundsoft hepr oc es s,t hef ouroper at i onsar eper f or medi nt heor derl i s t ed.I nt hel as t( t ent h) r o un d,t h eMi x Co l u mn sop er a t i o ni sn otp er f o r me da ndon l yt h eSu bBy t e s ,Sh i f t Ro ws ,a ndXo r Ro un dKe y o pe r a t i o nsa r edo ne . SubByt es Thi soper at i oni sas i mpl es ubs t i t ut i ont hatc on v er t sev er yby t ei nt oadi ff er entv al ue.AESdefi nesat abl eof256 v al u esf ort hes ubs t i t ut i on.Youwor kt hr ought he16b yt esoft hes t at ear r a y ,us eea chb yt easani nde xi nt ot he 256b yt es ubs t i t ut i ont abl e,andr epl ac et heby t ewi t ht hev al uef r om t hes ubs t i t ut i ont abl e.Bec aus eal l pos si bl e 256b yt ev al u esar epr es enti nt het abl e,y ouendupwi t hat ot al l yne wr e sul ti nt hes t at ea r r a y ,whi c hc anbe r es t or edt oi t sor i gi nal c ont ent sus i ngani nv er s es ubs t i t ut i ont abl e.Thec ont ent soft hes ubs t i t ut i ont abl ear enot ar bi t r ar y ;t heent r i esar ec omput edus i ngamat hemat i c al f or mul abutmos ti mpl ement at i onswi l l s i mpl yha vet he s ubs t i t ut i ont abl es t or edi nmemor yaspar toft hede si gn. Sh i f t Ro ws Ast h en ames ug ge s t s ,Sh i f t Ro wsop er a t e so ne ac hr o wo ft h es t at ea r r a y .Ea chr o wi sr o t at e dt ot h er i g htb ya c er t ai nn umberofb yt esasf ol l o ws :
•
1%t o'(
rotate! by 0 byte% )i.e.* i% not &han+e!,
•
2n! o'(
rotate! by 1 byte
•
3r! o'(
rotate! by 2 byte%
•
4th o'(
rotate! by 3 byte%
Asane xampl e,i ft heShi f t Rowsoper at i oni sappl i edt ot hes t at i ngs t at ear r a ys ho wni nT abl eA. 8,t her es ul ti s s h owni nT ab l eA. 9 . Mi xCol umns Thi soper at i oni st hemos tdi ffic ul t ,b ot ht oe xpl ai nandper f or m.Ea chc ol umnoft hes t at ear r a yi spr oc es s ed s e pa r a t e l yt op r o du c ean ewc o l u mn .Th en ewc o l u mnr e pl a c est h eo l do ne .Th ep r o c es s i n gi n v o l v e sama t r i x mul t i pl i c at i on.I fy ouar enotf ami l i arwi t hmat r i xar i t hmet i c ,don' tgett oc oncer ned?i ti sr e al l yj us tac onv eni ent no t at i onf ors howi ngoper at i on so nt abl e sa nda r r a y s. Th eMi x Co l u mn sop er a t i o nt a k ese ac hc ol u mnoft h es t a t ear r a yC0t oC3an dr e pl a c esi twi t han ewc o l u mn c omput edbyt hemat r i xmul t i pl i c at i onsho wni nFi gur eA. 2.
Fi g ur eA. 2 .Mi x Co l u mn sOp er a t i o n
Table A.8. -ffe&t of Shifto'% /erationStart State D0
D4
D8
D12
D1
D5
D9
D13
D2
D6
D10
D14
D3
D7
D11
D15
Table A.9. -ffe&t of Shifto'% /eration-n! State D0
D4
D8
D12
D13
D1
D5
D9
D10
D14
D2
D6
D7
D11
D15
D3
Th en e wc o l u mni sc o mp ut e da sf o l l o ws :
C' 0=02*C0+01*C1+01*C2+03*C3
C' 1=03*C0+02*C1+01*C2+01*C3
C' 2=01*C0+03*C1+02*C2+01*C3
C' 3=01*C0+01*C1+03*C2+02*C3
Re me mb ert h atwea r en otu si n gn or ma la r i t h me t i c ?wea r eu si n gfi n i t efi el da r i t h me t i c ,wh i c hh ass pe ci a lr u l e s a ndbo t ht h emu l t i p l i c at i o nsa ndad di t i o nsc anbei mp l e me nt e du s i n gXOR.
Xor RoundKey Af t e rt h eMi x Co l u mn so pe r a t i o n,t h eXo r Ro un dKe yi sv e r ys i mp l ei n de eda ndh ar d l yne ed si t so wnn ame .Th i s oper at i ons i mpl yt ak est hee xi s t i ngs t at ear r a y ,XORst hev al ueoft heappr opr i at er oun dk e y ,andr epl ac est he s t at ea r r a ywi t ht her es ul t .I ti sdoneonc ebef or et her oun dsst ar tan dt henonc epe rr ound,us i nge ac hoft he r oundk e ysi nt ur n. De cr y pt i on Asy oumi ghte xpec t ,dec r y p t i oni nv ol v esr e ver s i ngal l t hes t epst ak eni nenc r y pt i onus i ngi nv er s ef unc t i ons : •
I n v Su bBy t e s
•
I n v Sh i f t Ro ws
•
I nvMi xCol umns
Xo r Ro un dKe ydo es n' tn ee da ni n v er s ef u nc t i o nb ec a us eXORi n gt wi c et a k esy o ub ac kt ot h eo r i g i n al v a l u e. I n v Su bBy t e swo r k st h es amewa ya sSu bBy t e sb utu se sad i ff er e ntt a bl et h atr e t u r n st h eo r i g i n al v a l u e. I n vShi f t Rowsi n vol v esr ot at i ngl ef ti ns t eadofr i ghtandI nv Mi x Col umnsus esadi ff er entc ons t antmat r i xt o mul t i pl yt hec ol umns . Theor derofoper at i oni ndec r y pt i oni s : 1. Pe r f or mi ni t i a lde cr y pt i onr ound: Xor RoundKey I n v Sh i f t Ro ws I n v Su bBy t e s 2. Per f or m ni nef ul l dec r y pt i onr ounds : Xor RoundKey I nvMi xCol umns I n v Sh i f t Ro ws I n v Su bBy t e s 3. Per f or m finalXor RoundKey Th es amer o un dk e y sa r eus e di nt h es ameor d e r . Summar yofAES No w weha vese enal l t hest epsneededt ot a kea12 8bi tbl o ckofdat aandt r ans f or mi ti nt oci pher t e xt .Weal s o l o ok e da tt h er e v er s ep r o ce s sf o rd e cr y pt i o n.Th ep r o c es sofe nc r y p t i o nc anbesu mma r i z edass ho wni nFi g ur e A. 3 .Th emat h ema t i c sb eh i n dt h ea l g or i t h mi sr at h erh ar dt oun de r s t a ndf o rn on ma t h ema t i c i a nsa ndweha v e f oc us edonhowr at hert hanwhyi nt hi sbook .I fy ouar ei nt er es t edi nsuc hmat t er s ,i ti spr obabl ywor t hr eadi ng t het heor et i c al paper sofl ook i ngatt hebookt hats pec i al i z ei nc r y p t ogr aphy .Whati si nt er es t i ng,howev er ,i st he wa yi nwhi c hal l t heo per at i onsar eba sedonb yt ev al ue sandoper at i onst hatar es i mpl et oi mpl ementi nd i gi t al l ogi cgat e s.AESac hi e ve st hegoal ofbei ngbo t hs ec ur eandpr ac t i c al f orr eal s y st ems . Fi gur eA. 3.Summar yofAES/ RSNEncr ypt i on