#include "blowfish.hpp" #include "vectors.h" #include template constexpr void printKey() { for (int i = 0; i < sz; ++i) { printf("%02x ", set_key[i]); } printf("\n"); } template struct set_key_wrapper { constexpr void operator()() const { if constexpr (i < 3) { printf("skip - minimal key length is 32bits (4bytes): current key " "length: %i bytes\n", i + 1); } else { constexpr auto s = std::span(set_key, i + 1); constexpr Blowfish::Context b(s); constexpr Blowfish::Block x(set_key_ptext); constexpr auto y = b.encrypt(x); static_assert(static_cast(y) == set_key_ctext[i]); printf("0x%016lx\t", static_cast(y)); constexpr auto z = b.decrypt(y); static_assert(static_cast(z) == set_key_ptext); printf("0x%016lx\t", static_cast(z)); printKey(); } } }; void run_set_key_wrapper() { printf("%-18s\t%-18s\t%-18s\n", "/ encrypt", "/ decrypt", "/ key"); call_times(); printf("%-18s\t0x%016lx\n", "cleartext", set_key_ptext); }