bkcrack 1.8.1
Crack legacy zip encryption with Biham and Kocher's known plaintext attack.
Data.hpp
1#ifndef BKCRACK_DATA_HPP
2#define BKCRACK_DATA_HPP
3
4#include <bkcrack/types.hpp>
5
6#include <map>
7#include <optional>
8
10struct Data
11{
13 static constexpr std::size_t encryptionHeaderSize = 12;
14
16 class Error : public BaseError
17 {
18 public:
20 explicit Error(const std::string& description);
21 };
22
32 Data(std::vector<std::uint8_t> ciphertext, std::optional<std::uint8_t> checkByte,
33 std::vector<std::uint8_t> plaintext, int offset, const std::map<int, std::uint8_t>& extraPlaintext);
34
35 std::vector<std::uint8_t> ciphertext;
36 std::vector<std::uint8_t> plaintext;
37 std::vector<std::uint8_t> keystream;
38
40 std::size_t offset;
41
43 std::vector<std::pair<std::size_t, std::uint8_t>> extraPlaintext;
44};
45
46#endif // BKCRACK_DATA_HPP
BaseError(const std::string &type, const std::string &description)
Constructor.
Error(const std::string &description)
Constructor.
std::vector< std::pair< std::size_t, std::uint8_t > > extraPlaintext
additional bytes of plaintext with their offset relative to ciphertext with encryption header
Definition Data.hpp:43
static constexpr std::size_t encryptionHeaderSize
Size of the traditional PKWARE encryption header.
Definition Data.hpp:13
std::vector< std::uint8_t > ciphertext
ciphertext bytes including encryption header
Definition Data.hpp:35
std::vector< std::uint8_t > keystream
keystream bytes
Definition Data.hpp:37
Data(std::vector< std::uint8_t > ciphertext, std::optional< std::uint8_t > checkByte, std::vector< std::uint8_t > plaintext, int offset, const std::map< int, std::uint8_t > &extraPlaintext)
Construct data and check it can be used to carry out an attack.
std::vector< std::uint8_t > plaintext
plaintext bytes
Definition Data.hpp:36
std::size_t offset
plaintext and keystream offset relative to ciphertext with encryption header
Definition Data.hpp:40
Useful types, constants and utility functions.