des.cpp
// preprocess sbox and p into one
preprocess sbox and p into one
preprocess sbox and p into one
void preprocess() {
  for (int box = 0; box < 8; box++) {
    for (uint64_t window = 0; window < (1 << 6); window++) {
      uint64_t row = ((window & 1) << 1) | (window >> 5);
      uint64_t col = ((window & 0x2) << 2) | ((window & 0x4)) |
                     ((window & 0x8) >> 2) | ((window & 0x10) >> 4);
      uint64_t index = (row << 4) | col;
      uint64_t sbox = s[box][index];
      sbox = ((sbox & 0x1) << 3) | ((sbox & 0x2) << 1) | ((sbox & 0x4) >> 1) |
             ((sbox & 0x8) >> 3);
      sbox = sbox << (box * 4);
      s_preprocessed[box][window] = apply_permutation<32>(sbox, p);
    }
  }
}
void preprocess ( ) { for ( int box = 0 ; box < 8 ; box ++ ) { for ( uint64_t window = 0 ; window < ( 1 << 6 ) ; window ++ ) { uint64_t row = ( ( window & 1 ) << 1 ) | ( window >> 5 ) ; uint64_t col = ( ( window & 0x2 ) << 2 ) | ( ( window & 0x4 ) ) | ( ( window & 0x8 ) >> 2 ) | ( ( window & 0x10 ) >> 4 ) ; uint64_t index = ( row << 4 ) | col ; uint64_t sbox = s [ box ] [ index ] ; sbox = ( ( sbox & 0x1 ) << 3 ) | ( ( sbox & 0x2 ) << 1 ) | ( ( sbox & 0x4 ) >> 1 ) | ( ( sbox & 0x8 ) >> 3 ) ; sbox = sbox << ( box * 4 ) ; s_preprocessed [ box ] [ window ] = apply_permutation < 32 > ( sbox , p ) ; } } }
preprocess sbox and p into one
preprocess sbox and p into one
// row: bit 0 | bit 5 // col: bit 1 | bit 2 | bit 3 | bit 4 // index = row << 4 | col // reverse bit order in sbox