DES Key Expansion \302\2512007 by Mike May, S.J., Saint Louis University - maymk@slu.edu This expands the key for the example from class. restart; This worksheet does a step by step walk through of a single key expansion for DES. This worksheet assumes that you have already executed the DES-ConstantsFunctions.mws and produced the DES.m file, and that this file is stored in the current directory. If Maple cannot read the DES.m file, either find it and move it to the current directory, or rerun the DES-ConstantsFunctions.mws worksheet again to create the file. read `DES.m`: currentdir(); We want to start with a key in hex and expand it out to the string of 16 keys used for DES. We first convert the hex string to a 64 bit binary string. To avoid the problem of leading zeroes getting left off, we add 2^64 to get a leading 1 followed by the number we want, then take the substring of the last 64 bits. keytest := "133457799BBCDFF1"; keybin64:= substring(convert(convert( 2^64 + convert(keytest, decimal, hex), binary), string), 2..65); It is of interest to see the "real" key obtained by removing the parity checkbits. keybin56 :=cat(seq(substring(keybin64,i*8-7..i*8-1),i=1..8)); However, our functions are set up to apply permutation PC1 to the original key. PC1key := PC1onKey(keybin64); This gets broken into 2 halves. c0 := substring(PC1key,1..28); d0:=substring(PC1key,29..56); The halves are permuted by leftshifts according to the formula. c := linalg[vector](16): d := linalg[vector](16): key := linalg[vector](16): c[1] := cat(substring(c0,2..28),substring(c0,1)): d[1] := cat(substring(d0,2..28),substring(d0,1)): for i from 2 to 16 do c[i] := cat(substring(c[i-1],keyshifts[i]+1..28), substring(c[i-1],1..keyshifts[i])): d[i] := cat(substring(d[i-1],keyshifts[i]+1..28), substring(d[i-1],1..keyshifts[i])): end do; The keys are then produced by acting PC2 on the halves put back together. for i from 1 to 16 do key[i] := convert(PC2onKey(cat(c[i],d[i])),string); end do;
<Text-field style="Heading 1" layout="Heading 1">Exercise</Text-field> Start with the key "0123456789ABCDEF". Produce three round keys by hand. Verify your work.
You are now ready to go to worksheets with DES properly done, either DES-Example.mws or DES-Modes.mws. Legal Notice: The copyright for this application is owned by the author(s). Neither Maplesoft nor the author are responsible for any errors contained within and are not liable for any damages resulting from the use of this material. This application is intended for non-commercial, non-profit use only. Contact the author for permission if you wish to use this application in for-profit activities.