bkcrack: include/bkcrack/Attack.hpp Source File

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

Attack.hpp
Go to the documentation of this file.
1#ifndef BKCRACK_ATTACK_HPP
2#define BKCRACK_ATTACK_HPP
3
4#include <bkcrack/Data.hpp>
5#include <bkcrack/Keys.hpp>
6#include <bkcrack/Progress.hpp>
7#include <bkcrack/types.hpp>
8
9#include <mutex>
10
12
14 class Attack
15{
16public:
25 Attack(const Data& data, std::size_t index, std::vector<Keys>& solutions, std::mutex& solutionsMutex,
26 bool exhaustive, Progress& progress);
27
29 void carryout(std::uint32_t z7_2_32);
30
32 static constexpr std::size_t contiguousSize = 8;
33
35 static constexpr std::size_t attackSize = 12;
36
37private:
38 // iterate recursively over Z-lists
39 void exploreZlists(int i);
40
41 // iterate recursively over Y-lists
42 void exploreYlists(int i);
43
44 // check whether the X-list is valid or not
45 void testXlist();
46
47 const Data& data;
48
49 const std::size_t index; // starting index of the used plaintext and keystream
50
51 std::vector<Keys>& solutions; // shared output vector of valid keys
52 std::mutex& solutionsMutex;
53 const bool exhaustive;
54 Progress& progress;
55
56 std::array<std::uint32_t, contiguousSize> zlist;
57 std::array<std::uint32_t, contiguousSize> ylist; // the first two elements are not used
58 std::array<std::uint32_t, contiguousSize> xlist; // the first four elements are not used
59};
60
71 auto attack(const Data& data, const std::vector<std::uint32_t>& zi_2_32_vector, int& start, std::size_t index, int jobs,
72 bool exhaustive, Progress& progress) -> std::vector<Keys>;
73
74#endif // BKCRACK_ATTACK_HPP
attack
auto attack(const Data &data, const std::vector< std::uint32_t > &zi_2_32_vector, int &start, std::size_t index, int jobs, bool exhaustive, Progress &progress) -> std::vector< Keys >
Iterate on Zi[2,32) candidates to try and find complete internal keys.
Attack::carryout
void carryout(std::uint32_t z7_2_32)
Carry out the attack for the given Z[2,32) value.
Attack::Attack
Attack(const Data &data, std::size_t index, std::vector< Keys > &solutions, std::mutex &solutionsMutex, bool exhaustive, Progress &progress)
Constructor.
Attack::contiguousSize
static constexpr std::size_t contiguousSize
Number of contiguous known plaintext bytes required by the attack.
Definition Attack.hpp:32
Attack::attackSize
static constexpr std::size_t attackSize
Total number of known plaintext bytes required by the attack.
Definition Attack.hpp:35
Progress
Structure to report the progress of a long operation or to cancel it.
Definition Progress.hpp:11
Data
Structure to hold the data needed for an attack.
Definition Data.hpp:10
types.hpp
Useful types, constants and utility functions.