diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2020-11-08 12:13:01 +0200 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2020-11-08 12:13:01 +0200 |
commit | 6d89ab37754462928b28ad85714af316c83f43cb (patch) | |
tree | 9231ffc8b29f3d6c256ad7a074e524e58fa96b39 /blowfish_init.hpp | |
parent | Replace P and S C-arrays with std::array (diff) | |
download | blowfish-6d89ab37754462928b28ad85714af316c83f43cb.tar.xz |
Add compile-time key length check
Diffstat (limited to 'blowfish_init.hpp')
-rw-r--r-- | blowfish_init.hpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/blowfish_init.hpp b/blowfish_init.hpp index 9d2366d..2d7bf6c 100644 --- a/blowfish_init.hpp +++ b/blowfish_init.hpp @@ -1,12 +1,14 @@ #pragma once #include <array> -#include <cstddef> #include <cstdint> -constexpr size_t ROUNDS = 16; -constexpr size_t SUBKEYS = ROUNDS + 2; -constexpr size_t BOXES = 4; -constexpr size_t ENTRIES = 256; +namespace Blowfish { + +constexpr std::size_t KEYLEN = 448 / sizeof(uint8_t); +constexpr std::size_t ROUNDS = 16; +constexpr std::size_t SUBKEYS = ROUNDS + 2; +constexpr std::size_t BOXES = 4; +constexpr std::size_t ENTRIES = 256; constexpr std::array<uint32_t, SUBKEYS> P_INIT{ 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, 0xa4093822, 0x299f31d0, @@ -191,3 +193,5 @@ constexpr std::array<std::array<uint32_t, ENTRIES>, BOXES> S_INIT{ 0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e, 0x1948c25c, 0x02fb8a8c, 0x01c36ae4, 0xd6ebe1f9, 0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f, 0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6}}; + +} // namespace Blowfish |