{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 } {CSTYLE "" -1 256 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{PSTYLE "Normal " -1 0 1 {CSTYLE "" -1 -1 "Geneva" 1 12 0 0 0 0 0 0 0 0 0 0 0 0 0 1 } 0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{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 "Title" 0 18 1 {CSTYLE "" -1 -1 "" 1 18 0 0 0 0 0 1 1 0 0 0 0 0 0 1 }3 0 0 -1 12 12 0 0 0 0 0 0 19 0 }{PSTYLE "Autho r" 0 19 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 }3 0 0 -1 8 8 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 256 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 }3 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }} {SECT 0 {EXCHG {PARA 18 "" 0 "" {TEXT -1 17 "DES Key expansion" }} {PARA 19 "" 0 "" {TEXT -1 23 "\251 Mike May, S. J., 2002" }}{PARA 19 " " 0 "" {TEXT -1 13 "maymk@slu.edu" }}{PARA 256 "" 0 "" {TEXT 256 48 "T his expands the key for the example from class." }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 225 "This \+ worksheet assumes that you have already executed the DES constants and DES functions worksheets in this Maple session. At the end of the DE S functions worksheet, the variables and functions are stored in the D ES.m file." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "read `DES.m`: " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 91 "We want to start with a key i n hex and expand it out to the string of 16 keys used for DES." }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 114 "keytest := \"133457799BBCDF F1\";\nkeybin:= convert(convert(keytest,decimal,hex),binary);\nbinleng th := length(keybin);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%(keytestGQ1 133457799BBCDFF16\"" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%'keybinG\"hn, +6666,6+66565,5,56,6,,,+,6+6+\"" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%* binlengthG\"#h" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 61 "We convert the \+ key to binary and add leading zeroes as needed" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 53 "keybin64 := cat(seq(\"0\",i=1..(64-binlength)) ,keybin);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%)keybin64GQ[o0001001100 1101000101011101111001100110111011110011011111111100016\"" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 53 "We can see what we have if we remove pari ty checkbits" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 61 "keybin56 := cat(seq(substring(keybin64,i*8-7..i*8-1),i=1..8));" }}{PARA 11 "" 1 " " {XPPMATH 20 "6#>%)keybin56GQY000100100110100101011011110010011011011 110110111111110006\"" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 39 "But we ap ply permutation PC1 to the key" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "PC1key := PC1onKey(keybin64);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%'PC1keyGQY1111000011001100101010101111010101010110011001111000111 16\"" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 30 "This gets broken into 2 h alves" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 60 "c0 := substring(PC 1key,1..28): d0:=substring(PC1key,29..56):" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 62 "The halves are permuted by leftshifts according to the fo rmula" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 410 "c := linalg[vecto r](16): d := linalg[vector](16):\nkey := linalg[vector](16):\nc[1] := \+ cat(substring(c0,2..28),substring(c0,1)):\nd[1] := cat(substring(d0,2. .28),substring(d0,1)):\nfor i from 2 to 16 do\n c[i] := cat(substrin g(c[i-1],keyshifts[i]+1..28),\n substring(c[i-1],1..keys hifts[i])):\n d[i] := cat(substring(d[i-1],keyshifts[i]+1..28),\n \+ substring(d[i-1],1..keyshifts[i])):\nod:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 72 "The keys are then produced by acting PC2 on the halves put back together" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 79 "for i from 1 to 16 do\n key[i] := convert(PC2onKey(cat(c[i],d[i]) ),string);\nod;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%$keyG6#\"\"\"QQ0 001101100000010111011111111110001110000011100106\"" }}{PARA 11 "" 1 " " {XPPMATH 20 "6#>&%$keyG6#\"\"#QQ011110011010111011011001110110111100 1001111001016\"" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%$keyG6#\"\"$QQ01 01010111111100100010100100001011001111100110016\"" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%$keyG6#\"\"%QQ01110010101011011101011011011011001101 01000111016\"" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%$keyG6#\"\"&QQ0111 110011101100000001111110101101010011101010006\"" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%$keyG6#\"\"'QQ01100011101001010011111001010000011110 11001011116\"" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%$keyG6#\"\"(QQ1110 110010000100101101111111011000011000101111006\"" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%$keyG6#\"\")QQ11110111100010100011101011000001001110 11111110116\"" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%$keyG6#\"\"*QQ1110 000011011011111010111110110111100111100000016\"" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%$keyG6#\"#5QQ101100011111001101000111101110100100011 0010011116\"" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%$keyG6#\"#6QQ001000 0101011111110100111101111011010011100001106\"" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%$keyG6#\"#7QQ011101010111000111110101100101000110011 1111010016\"" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%$keyG6#\"#8QQ100101 1111000101110100011111101010111010010000016\"" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%$keyG6#\"#9QQ010111110100001110110111111100101110011 1001110106\"" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%$keyG6#\"#:QQ101111 1110010001100011010011110100111111000010106\"" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%$keyG6#\"#;QQ110010110011110110001011000011100001011 1111101016\"" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 94 "You are now ready to go to worksheets wit h DES properly done, either DES example or DES modes." }}}{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 }