{VERSION 5 0 "IBM INTEL NT" "5.0" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 1 }{CSTYLE "2D Math" -1 2 "Times" 0 1 0 0 0 0 0 0 2 0 0 0 0 0 0 1 }{CSTYLE "2D Output" 2 20 "" 0 1 0 0 255 1 0 0 0 0 0 0 0 0 0 1 } {PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "Maple Output" 0 11 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }3 3 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 11 12 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }1 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Title" -1 18 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 0 1 2 1 1 2 2 2 1 1 1 1 }3 1 0 0 12 12 1 0 1 0 2 2 19 1 }{PSTYLE "Author" -1 19 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }3 1 0 0 8 8 1 0 1 0 2 2 0 1 }} {SECT 0 {EXCHG {PARA 18 "" 0 "" {TEXT -1 22 "AES - Bit Distribution" } }{PARA 19 "" 0 "" {TEXT -1 36 "\251Mike May, S.J., 2002, maymk@slu.edu " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 298 "Following the same pattern we used with \+ Baby DES and DES, we would like to look at the distribution of zeroes \+ and ones from a collection of words encrypted with AES. The digits sh ould behave like independent random variables. First we need to load \+ in the procedures created in AES-Encryption.mws." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "read `AES.m`:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 91 "We want a procedure for turning a 32 character hex string into a list of 128 binary digits." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 221 "hex1 := \"66E94BD4EF8A2C3B884CFA59CA342B2E\";\nhexSt ringToBinList := hexString -> [seq(parse(substring(\n convert(conve rt(convert(hexString,decimal,hex)+2^128,binary),string), \n i)),i=2 ..129)]:\nhexStringToBinList(hex1);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6 #>%%hex1GQA66E94BD4EF8A2C3B884CFA59CA342B2E6\"" }}{PARA 12 "" 1 "" {XPPMATH 20 "6#7\\s\"\"!\"\"\"F%F$F$F%F%F$F%F%F%F$F%F$F$F%F$F%F$F$F%F$ F%F%F%F%F$F%F$F%F$F$F%F%F%F$F%F%F%F%F%F$F$F$F%F$F%F$F$F$F%F$F%F%F$F$F$ F$F%F%F%F$F%F%F%F$F$F$F%F$F$F$F$F%F$F$F%F%F$F$F%F%F%F%F%F$F%F$F$F%F$F% F%F$F$F%F%F%F$F$F%F$F%F$F$F$F%F%F$F%F$F$F$F$F%F$F%F$F%F%F$F$F%F$F%F%F% F$" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 330 "We return to our favorite \+ example. For the key we will use the zero word. For our plaintexts, \+ we will use words that are all zeroes except for a single bit that is \+ turned on. In this situation it makes sense to expand the key only on ce.\nThe list bitChangeCounter gives us a place to record the number o f times each bit is used." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 191 "keyHex := intTo128Bits(0);\nexpandedKey := hexKeyExpander(hexkey) :\nbitChangeCounter := [seq(0,i=1..128)]:\ntestLine2 := intVal -> \n \+ encryptAESExpanded(intTo128Bits(2^(intVal-1)),expandedKey):" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%'keyHexGQA00000000000000000000000000000000 6\"" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 91 "We are ready to count the \+ number of times a bit is used in each of the first 30 test words." }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 136 "for i from 1 to 30 do\n bi tChangeCounter := zip(`+`,bitChangeCounter,\n hexStringToBinList( testLine2(i))):\nend do:\nbitChangeCounter;" }}{PARA 12 "" 1 "" {XPPMATH 20 "6#7\\s\"#7\"#?\"#6F%\"#9F'\"#F-F%F(F'F)F)F( F+F.F.F'F&F-F'F*F+F'F&F+F+F&F)F,F'F+F*F%F)F)F$F'F,F&F)\"#@F)F+F$F*F)F% F&F+F+F'F(F)F+F+F'F'" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 150 "st ats[transform,tally](bitChangeCounter);\nevalf(stats[describe, mean](b itChangeCounter));\nevalf(stats[describe, standarddeviation](bitChange Counter));" }}{PARA 12 "" 1 "" {XPPMATH 20 "6#7.-%'WeightG6$\"#5\"\"&- F%6$\"#6\"\")-F%6$\"#7F+-F%6$\"#8F/-F%6$\"#9\"#A-F%6$\"#:\"#?-F%6$\"#; F=-F%6$\"#\"\"$-F%6$F:\"\"*\"#@" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$\"+]7`%\\\"!\")" }}{PARA 11 "" 1 "" {XPPMATH 20 " 6#$\"+%G1!3E!\"*" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 91 "The expected \+ mean is 30*.5 = 15. The expected standard deviation is sqrt(30*.5*.5) =2.7386." }}{PARA 0 "" 0 "" {TEXT -1 75 "The behavior looks like what \+ we expect from a random distribution of bits." }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 " " }}}}{MARK "0 0 0" 0 }{VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 }{PAGENUMBERS 0 1 2 33 1 1 }