c++ - Generation and storage of all DES keys -


i'm writing data encryption standard "cracker" using c++ , cuda. going simple brute-force - trying possible keys decrypt encrypted data , check if result equal initial plain-text message.

the problem generation of 2^56 keys takes time (and memory). first approach generate keys recursively , save them file.

do have suggestions how improve this?

you don' need recursion, neither need storing keys.

all space of des keys (if don't count 12 or weak keys, won't change purposes) space of 56-bit-long numbers (which btw fit standard uint64_t), , can iterate through numbers 0 2^56-1, feeding next number 56-bit number cuda core whenever core reports done previous key.

if not cores, code such as:

for(uint64_t i=0;i<0xffffffffffffffull /* double-check number of f's number 2^56-1 */;++i) {     uint8_t key[7];   //below endianness-agnostic conversion   key[0] = (uint8_t)i;   key[1] = (uint8_t)(i>>8);   key[2] = (uint8_t)(i>>16);   key[3] = (uint8_t)(i>>24);   key[4] = (uint8_t)(i>>32);   key[5] = (uint8_t)(i>>40);   key[6] = (uint8_t)(i>>48);   bool found = try_your_des_code(key,data_to_decrypt);   if(found) printf("eureka!\n"); } 

to allow restarting program in case if goes wrong, need store (in persistent storage, such file) number (with cores, strictly speaking - number should written persistent storage after numbers before has been processed cuda cores, difference of 2000 or keys won't make difference performance-wise).


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -