1 /* 2 * The LUKS volume header functions 3 * 4 * Copyright (C) 2013-2020, Joachim Metz <joachim.metz@gmail.com> 5 * 6 * Refer to AUTHORS for acknowledgements. 7 * 8 * This program is free software: you can redistribute it and/or modify 9 * it under the terms of the GNU Lesser General Public License as published by 10 * the Free Software Foundation, either version 3 of the License, or 11 * (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public License 19 * along with this program. If not, see <https://www.gnu.org/licenses/>. 20 */ 21 22 #if !defined( _LIBLUKSDE_VOLUME_HEADER_H ) 23 #define _LIBLUKSDE_VOLUME_HEADER_H 24 25 #include <common.h> 26 #include <types.h> 27 28 #include "libluksde_libbfio.h" 29 #include "libluksde_libcdata.h" 30 #include "libluksde_libcerror.h" 31 32 #if defined( __cplusplus ) 33 extern "C" { 34 #endif 35 36 typedef struct libluksde_volume_header libluksde_volume_header_t; 37 38 struct libluksde_volume_header 39 { 40 /* The format version 41 */ 42 uint16_t format_version; 43 44 /* The encrypted volume start sector 45 */ 46 uint64_t encrypted_volume_start_sector; 47 48 /* The master key size 49 */ 50 uint32_t master_key_size; 51 52 /* The master key validation hash 53 */ 54 uint8_t master_key_validation_hash[ 20 ]; 55 56 /* The master key salt 57 */ 58 uint8_t master_key_salt[ 32 ]; 59 60 /* The master key number of iterations 61 */ 62 uint32_t master_key_number_of_iterations; 63 64 /* Encryption method 65 */ 66 int encryption_method; 67 68 /* Encryption chaining mode 69 */ 70 int encryption_chaining_mode; 71 72 /* Initialization vector mode 73 */ 74 int initialization_vector_mode; 75 76 /* The password and diffuser hashing method 77 */ 78 int hashing_method; 79 80 /* The ESSIV hashing method 81 */ 82 int essiv_hashing_method; 83 84 /* The volume identifier 85 */ 86 uint8_t volume_identifier[ 16 ]; 87 88 /* The key slots array 89 */ 90 libcdata_array_t *key_slots_array; 91 }; 92 93 int libluksde_volume_header_initialize( 94 libluksde_volume_header_t **volume_header, 95 libcerror_error_t **error ); 96 97 int libluksde_volume_header_free( 98 libluksde_volume_header_t **volume_header, 99 libcerror_error_t **error ); 100 101 int libluksde_volume_parse_encryption_method( 102 libluksde_volume_header_t *volume_header, 103 const uint8_t *encryption_method, 104 libcerror_error_t **error ); 105 106 int libluksde_volume_parse_encryption_mode( 107 libluksde_volume_header_t *volume_header, 108 const uint8_t *encryption_mode, 109 libcerror_error_t **error ); 110 111 int libluksde_volume_parse_hashing_method( 112 libluksde_volume_header_t *volume_header, 113 const uint8_t *hashing_method, 114 libcerror_error_t **error ); 115 116 int libluksde_volume_header_read_data( 117 libluksde_volume_header_t *volume_header, 118 const uint8_t *data, 119 size_t data_size, 120 libcerror_error_t **error ); 121 122 int libluksde_volume_header_read_file_io_handle( 123 libluksde_volume_header_t *volume_header, 124 libbfio_handle_t *file_io_handle, 125 off64_t file_offset, 126 libcerror_error_t **error ); 127 128 int libluksde_volume_header_get_format_version( 129 libluksde_volume_header_t *volume_header, 130 uint16_t *format_version, 131 libcerror_error_t **error ); 132 133 int libluksde_volume_header_get_volume_identifier( 134 libluksde_volume_header_t *volume_header, 135 uint8_t *uuid_data, 136 size_t uuid_data_size, 137 libcerror_error_t **error ); 138 139 #if defined( __cplusplus ) 140 } 141 #endif 142 143 #endif /* !defined( _LIBLUKSDE_VOLUME_HEADER_H ) */ 144 145