bkcrack: include/bkcrack/KeystreamTab.hpp Source File

bkcrack 1.8.1 Crack legacy zip encryption with Biham and Kocher's known plaintext attack.

KeystreamTab.hpp
1#ifndef BKCRACK_KEYSTREAMTAB_HPP
2#define BKCRACK_KEYSTREAMTAB_HPP
3
4#include <bkcrack/types.hpp>
5
6#include <bitset>
7
9 class KeystreamTab
10{
11public:
14 static auto getByte(std::uint32_t zi) -> std::uint8_t
15 {
16 return instance.keystreamtab[(zi & mask<0, 16>) >> 2];
17 }
18
22 static auto getZi_2_16_vector(std::uint8_t ki, std::uint32_t zi_10_16) -> const std::vector<std::uint32_t>&
23 {
24 return instance.keystreaminvfiltertab[ki][(zi_10_16 & mask<0, 16>) >> 10];
25 }
26
29 static auto hasZi_2_16(std::uint8_t ki, std::uint32_t zi_10_16) -> bool
30 {
31 return instance.keystreaminvexists[ki][(zi_10_16 & mask<0, 16>) >> 10];
32 }
33
34private:
35 // initialize lookup tables
36 KeystreamTab();
37
38 // lookup tables
39 std::array<std::uint8_t, 1 << 14> keystreamtab;
40 std::array<std::array<std::vector<std::uint32_t>, 64>, 256> keystreaminvfiltertab;
41 std::array<std::bitset<64>, 256> keystreaminvexists;
42
43 static const KeystreamTab instance;
44};
45
46#endif // BKCRACK_KEYSTREAMTAB_HPP
KeystreamTab
Lookup tables for keystream related computations.
Definition KeystreamTab.hpp:10
KeystreamTab::hasZi_2_16
static auto hasZi_2_16(std::uint8_t ki, std::uint32_t zi_10_16) -> bool
Definition KeystreamTab.hpp:29
KeystreamTab::getByte
static auto getByte(std::uint32_t zi) -> std::uint8_t
Definition KeystreamTab.hpp:14
KeystreamTab::getZi_2_16_vector
static auto getZi_2_16_vector(std::uint8_t ki, std::uint32_t zi_10_16) -> const std::vector< std::uint32_t > &
Definition KeystreamTab.hpp:22
types.hpp
Useful types, constants and utility functions.
mask
constexpr auto mask
Constant value for bit masking.
Definition types.hpp:39