main.c 1011 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #include <stdio.h>
  2. #include <stdint.h>
  3. #include <string.h>
  4. #include "bits-set/bits.h"
  5. #include "idea.h"
  6. #include "io.h"
  7. static void encrypt(bit_array *initial_keys, uint16_t *data)
  8. {
  9. uint16_t subkeys[IDEA_SUBKEYS] = {0};
  10. generate_subkeys(initial_keys, subkeys);
  11. rounds(subkeys, data);
  12. }
  13. /*
  14. static void decrypt(uint16_t *subkeys, bit *data)
  15. {
  16. // TODO
  17. }
  18. */
  19. static void startup_messages(void)
  20. {
  21. printf("Complied: %s %s\n", __DATE__, __TIME__);
  22. }
  23. int main(void)
  24. {
  25. startup_messages();
  26. bit_array initial_keys[IDEA_INITIAL_KEYS * 16] = {0};
  27. input_hex_to_bits(initial_keys, IDEA_INITIAL_KEYS);
  28. uint16_t data[IDEA_DATA_BLOCK] = {0};
  29. input_hex_to_int16(data, IDEA_DATA_BLOCK);
  30. putchar('\n');
  31. printf("Input Data:\n");
  32. print_uint16_array(data, 4, " ");
  33. encrypt(initial_keys, data);
  34. printf("Output Data:\n");
  35. print_uint16_array(data, 4, " ");
  36. memset(initial_keys, 0, IDEA_INITIAL_KEYS);
  37. memset(data, 0, IDEA_DATA_BLOCK);
  38. return 0;
  39. }