2 * cryptsetup LUKS2 custom mutator fuzz target
4 * Copyright (C) 2022-2023 Daniel Zatovic <daniel.zatovic@gmail.com>
5 * Copyright (C) 2022-2023 Red Hat, Inc. All rights reserved.
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #ifndef LUKS2_PROTO_CONVERTER_H_
23 #define LUKS2_PROTO_CONVERTER_H_
27 #include <json-c/json.h>
29 #include "LUKS2_plain_JSON.pb.h"
31 #include "crypto_backend/crypto_backend.h"
34 namespace json_proto {
36 class LUKS2ProtoConverter {
38 ~LUKS2ProtoConverter();
39 void create_jobj(const LUKS2_both_headers &headers, uint64_t hdr_size);
40 void convert(const LUKS2_both_headers &headers, int fd);
41 void create_jobj(const LUKS2_both_headers &headers);
42 void emit_luks2_binary_header(const LUKS2_header &header_proto, int fd, uint64_t offset, uint64_t seqid, const std::string &json_text);
44 void set_write_headers_only(bool headers_only);
46 const uint8_t *get_out_buffer();
47 size_t get_out_size();
49 static const uint64_t KEYSLOTS_SIZE = 3 * 1024 * 1024;
50 static const uint64_t DATA_SIZE = 16 * 1024 * 1024;
52 bool write_headers_only = false;
53 struct crypt_hash *hd = NULL;
56 } // namespace LUKS2_proto
58 #endif // LUKS2_PROTO_CONVERTER_H_