Skip to content

Instantly share code, notes, and snippets.

@FauxFaux
Created July 31, 2017 19:28
Show Gist options
  • Save FauxFaux/55c96cefe170a42bc134dff71516b13d to your computer and use it in GitHub Desktop.
Save FauxFaux/55c96cefe170a42bc134dff71516b13d to your computer and use it in GitHub Desktop.
// gcc -Wall -Wextra -O2 guess.c -lcrypto -o guess
#include <openssl/des.h>
#include <stdint.h>
#include <string.h>
int main() {
DES_cblock key_data;
if (!DES_random_key(&key_data)) {
printf("couldn't generate random key");
return 1;
}
for (uint64_t t = 0; t < 100 * 1000 * 1000; ++t) {
memcpy(key_data, &t, 8);
DES_key_schedule ks;
DES_set_key(&key_data, &ks);
const_DES_cblock in = {};
DES_cblock out;
DES_ecb_encrypt(&in, &out, &ks, DES_ENCRYPT);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment