bkcrack 1.7.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 "types.hpp"
5
6#include <map>
7
9struct Data
10{
12 static constexpr std::size_t encryptionHeaderSize = 12;
13
15 class Error : public BaseError
16 {
17 public:
19 explicit Error(const std::string& description);
20 };
21
29 Data(std::vector<std::uint8_t> ciphertext, std::vector<std::uint8_t> plaintext, int offset,
30 const std::map<int, std::uint8_t>& extraPlaintext);
31
32 std::vector<std::uint8_t> ciphertext;
33 std::vector<std::uint8_t> plaintext;
34 std::vector<std::uint8_t> keystream;
35
37 std::size_t offset;
38
40 std::vector<std::pair<std::size_t, std::uint8_t>> extraPlaintext;
41};
42
43#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:40
static constexpr std::size_t encryptionHeaderSize
Size of the traditional PKWARE encryption header.
Definition Data.hpp:12
std::vector< std::uint8_t > ciphertext
ciphertext bytes including encryption header
Definition Data.hpp:32
std::vector< std::uint8_t > keystream
keystream bytes
Definition Data.hpp:34
Data(std::vector< std::uint8_t > ciphertext, 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:33
std::size_t offset
plaintext and keystream offset relative to ciphertext with encryption header
Definition Data.hpp:37
Useful types, constants and utility functions.