tarequeh / DES

Implementation of Data Encryption Standard (DES) in C
http://www.codexn.com
MIT License
258 stars 140 forks source link

generate_sub_keys depends on initial value of key_sets #7

Open Grazfather opened 6 years ago

Grazfather commented 6 years ago

There's a bug somewhere in generate_sub_keys. I haven't dug into it. I just noticed that if write a value into key sets before generating the sub keys, the output ciphertext changes.

$ xxd outx
00000000: 8ca6 4de9 c1b1 23a7 7e42 2822 7736 66c0  ..M...#.~B("w6f.
$ vim run_des.c # Add a memset before generate_sub_keys
$ gcc -o mydes des.c run_des.c
$ ./mydes -e key inp outy
Encrypting..
Finished processing inp. Time taken: 0.000106 seconds.
$ xxd outy
00000000: 038b 53ff 9828 9c81 1bb7 97cd 35ab 14ad  ..S..(......5...