1 / 14

Programming DES

Programming DES. CPTR 427. Outline. Top Level Design Design Decisions Operations to write Putting it together. Top Level Design. Depending on whether we are encrypting or decrypting we set the input files accordingly.

brice
Télécharger la présentation

Programming DES

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Programming DES CPTR 427

  2. Outline • Top Level Design • Design Decisions • Operations to write • Putting it together

  3. Top Level Design Depending on whether we are encrypting or decrypting we set the input files accordingly. Create a “Keys” object that generates all the round keys used by DES in the order needed to encrypt or decrypt This is the hard part! Let’s delve into the design decisions that have to be made first.

  4. Design Decisions • Representing Data consistently • BitSets (Java) • BitArray (C#) • UInt64 (C#) • Long (Java) • Operations • Permutations • Expansions/Contractions • XOR operations • Odd side consideration: • we work with 4/6/28/32/48/56/64 bit values

  5. BitSets and BitArrays • Advantages: • Easy to perform permutations – bit level access • Can easily expand or contract length… • … can express arbitrary size • Has XOR operation • Bit position easy to understand • Disadvantages • Data is not in this format natively… • Must convert between bytes and BitSets/BitArrays • SLOW!

  6. Long and UInt64 • Advantages • Bytes convert easily to long or unsigned int64 • Easy shift and XOR operations • Unnecessary to convert data to a new object type • THIS IS THE WAY IT SHOULD BE DONE… • Disadvantages • Odd size information location (e.g. where does my 56 bits start?) • Permutations are no longer intuitive

  7. What format? • For better or worse, I chose long in Java to avoid and delt with the permutation issues – in retrospect that was a good choice because it made my work easier because I didn’t have to process data in two very different formats. My Advice: • Chose long/UInt64 and deal with the selection problem instead.

  8. Operations • Permutations • Left Circular Shifts • Swaps

  9. Operations (Single Round) • XOR • S-Box operations

  10. Operations to Write • Simple Ops • Permutations (with expansion or contraction + odd sizes) • Separate left circular shifts within a 64 bit long/UInt64 • Swaps (first 32 bits for second 32 bits) • XOR (Native) • S-Box Operations • Named Ops • Data: IP and IP-1, E, S-Box, P, XOR • Key: PC-1, PC-2, XOR, Left Circular shifts

  11. Permutations • Defined by • Data Input • Size of input data • Data Output • Size of output data • Mapping: input output • That takes care of IP, IP-1, E, P, PC-1, PC-2 • Leaving: S-Box, Left Circular Shifts, swap32 and XOR public UInt64 perm(UInt64 input, intinsize, int outsize, int[] map)

  12. Permutation Logic Move a bit from position x in the input to position y in the output.

  13. The rest of the Ops public UInt64 leftShift(UInt64 input, intshiftAmount) public UInt64 swap32(UInt64 input) public UInt64 sBox(UInt64 input)

  14. Putting it all together… • The entire goal of this project is for you to put this together using the instructions from the Stallings textbook. • Use the notes and the program skeleton provided!

More Related