General Purpose library for Freestanding C++ and POSIX systems
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.3 KiB

  1. #include "rc6_generic.hpp"
  2. #include "test_scaffold.h"
  3. #include <iostream>
  4. #include <ios>
  5. struct RC6test : public test_scaffold {
  6. RC6test() {
  7. name = __FILE__ ":1";
  8. }
  9. virtual int run() {
  10. using rc = RC6<>;
  11. auto res = 0;
  12. {
  13. rc::key_type key = {0x00000000, 0x00000000, 0x00000000, 0x00000000};
  14. rc::block_type plaintext = {0,0,0,0};
  15. rc::block_type expected = {0x8fc3a536,0x56b1f778,0xc129df4e,0x9848a41e};
  16. auto cipher = rc{key};
  17. plaintext = cipher.encrypt(plaintext);
  18. res += plaintext != expected;
  19. }
  20. {
  21. rc::key_type key = {0x80000000, 0x00000000, 0x00000000, 0x00000000};
  22. rc::block_type plaintext = {0,0,0,0};
  23. rc::block_type expected = {0x1AD578A0, 0x2A081628, 0x50A15A15, 0x52A17AD4};
  24. auto cipher = rc{key};
  25. plaintext = cipher.encrypt(plaintext);
  26. res += plaintext != expected;
  27. }
  28. return res;
  29. }
  30. };
  31. append_test dummy_szfhu5463(new RC6test{});
  32. struct RC6test2 : public test_scaffold {
  33. RC6test2() {
  34. name = __FILE__ ":2";
  35. }
  36. virtual int run() {
  37. using rc = RC6<>;
  38. rc::key_type key{0,0,0,0};
  39. rc::block_type plaintext{0,0,0,0};
  40. rc::block_type expected{0,0,0,0};
  41. auto cipher = rc{key};
  42. auto plaintext2 = cipher.encrypt(plaintext);
  43. auto plaintext3 = cipher.decrypt(plaintext2);
  44. return plaintext3 != expected;
  45. }
  46. };
  47. append_test dummy_szmltz63(new RC6test2{});