Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Data Encryption Standard (DES) implementation.

Brian Gianforcaro
September 27, 2011
180

Data Encryption Standard (DES) implementation.

Brian Gianforcaro

September 27, 2011
Tweet

Transcript

  1.   64 bit data block   64 bit key of

    which 56 bits are used.   Uses 16 rounds   A round consists of   Reordering bits   XORing with the key   Run the Feistel function   Swapping the data block halves
  2.   Methods   DES::algorithm( .. )   DES::keyschedule( .. )

      DES::mixer( .. )   DES::f(..)   Implemented in C++   --std=c99   Uses OOP Design
  3.   Schedule’s all 16 key’s   Initial Permutation   For

    each round   Choose key for round   Run Feistel function   Cross over halves of key’s   Inverse Initial Permutation
  4.   Permutation Choice #1   For each round   Shift

    bits N times   Permutation Choice #2   Store key for this round
  5.   Rearrange the order of bit’s based on the given

    parameters.   General use function, total of 6 different permutations that are performed on the key or data block in DES. /* IP defined on pg: 14 */ InitialPermutation[]= { 58, 50, 42, 34, 26, 18, 10, 2, 60, 52, 44, 36, 28, 20, 12, 4, 62, 54, 46, 38, 30, 22, 14, 6, 64, 56, 48, 40, 32, 24, 16, 8, 57, 49, 41, 33, 25, 17, 9, 1, 59, 51, 43, 35, 27, 19, 11, 3, 61, 53, 45, 37, 29, 21, 13, 5, 63, 55, 47, 39, 31, 23, 15, 7 };
  6.   Expansion Permutation on data block   XOR Expanded data

    with Subkey   For each S-Box   Run selected bits through   Primitive Permutation on combined S-Box output
  7.   Loop unrolling of all permutations   Manual function in

    lining   Where ever mixer was called we in lined the permutation   While unrolling we discovered that in some places we could combine multiple steps to reduce the amount of times we iterate through the data.
  8.   Before 44 seconds   f() = 22.88%   keyschedule()

    = 20.2%   algorithm() = 8.2%   mixer() = 40.9   get() = 5.6%   After 14.2 seconds   f() = 42.9%   keyschedule() = 24.4%   algorithm() = 24.2%   N/A   N/A
  9.   How easy it is to make a critical mistake

    in cryptography.   There are definitely security flaws in our implementation which would probably make it unusable for actual serious cryptography.  
  10.   A few more loops could be unrolled.   It

    would be really ugly   It would be very complicated.   It would be possible to inline all functions   Not really a clean implementation, not positive how much would be gained   Change from operations on individual array’s of bits to operations on entire bytes (ex. Skein implementation)   Feistel function may be optimizable, not sure how.