bkcrack: include/bkcrack/Data.hpp Source File

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
9 struct 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::BaseError
BaseError(const std::string &type, const std::string &description)
Constructor.
Data::Error::Error
Error(const std::string &description)
Constructor.
Data::extraPlaintext
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
Data::encryptionHeaderSize
static constexpr std::size_t encryptionHeaderSize
Size of the traditional PKWARE encryption header.
Definition Data.hpp:12
Data::ciphertext
std::vector< std::uint8_t > ciphertext
ciphertext bytes including encryption header
Definition Data.hpp:32
Data::keystream
std::vector< std::uint8_t > keystream
keystream bytes
Definition Data.hpp:34
Data::Data
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.
Data::plaintext
std::vector< std::uint8_t > plaintext
plaintext bytes
Definition Data.hpp:33
Data::offset
std::size_t offset
plaintext and keystream offset relative to ciphertext with encryption header
Definition Data.hpp:37
types.hpp
Useful types, constants and utility functions.