From 51528ecf3d90d09351322e172d91eed0cb45b2e7 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Sun, 8 Nov 2020 20:34:13 +0200 Subject: Add more test vectors --- main.cpp | 46 ++++------------------------------------------ 1 file changed, 4 insertions(+), 42 deletions(-) (limited to 'main.cpp') diff --git a/main.cpp b/main.cpp index 2a46d8c..d11aba1 100644 --- a/main.cpp +++ b/main.cpp @@ -2,49 +2,11 @@ #include "vectors.h" #include -constexpr uint64_t k(const uint8_t key[8]) { - uint64_t r = 0; - for (int i = 0; i < 8; ++i) { - r += static_cast(key[i]) << (64 - 8 * (i + 1)); - } - return r; -} - -template struct wrapper { - constexpr void operator()() const { - constexpr Blowfish::Context<8> b(std::to_array(variable_key[i])); - constexpr Blowfish::Block x(plaintext_l[i], plaintext_r[i]); - - constexpr auto y = b.encrypt(x); - static_assert(y.L == ciphertext_l[i]); - static_assert(y.R == ciphertext_r[i]); - - constexpr auto z = b.decrypt(y); - static_assert(x.L == z.L); - static_assert(x.R == z.R); - - printf("0x%016lx\t", k(variable_key[i])); - printf("0x%016lx\t", static_cast(x)); - printf("0x%016lx\t", static_cast(y)); - printf("0x%016lx\n", static_cast(z)); - } -}; - -template