"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/luks2/luks2_json_format.c" between
cryptsetup-2.3.6.tar.xz and cryptsetup-2.4.0.tar.xz

About: cryptsetup is a utility used to conveniently setup disk encryption based on the dm-crypt kernel module. These include plain dm-crypt volumes, LUKS volumes, loop-AES and TrueCrypt compatible format.

luks2_json_format.c  (cryptsetup-2.3.6.tar.xz):luks2_json_format.c  (cryptsetup-2.4.0.tar.xz)
skipping to change at line 33 skipping to change at line 33
#include <uuid/uuid.h> #include <uuid/uuid.h>
#include <assert.h> #include <assert.h>
struct area { struct area {
uint64_t offset; uint64_t offset;
uint64_t length; uint64_t length;
}; };
static size_t get_area_size(size_t keylength) static size_t get_area_size(size_t keylength)
{ {
//FIXME: calculate this properly, for now it is AF_split_sectors /* for now it is AF_split_sectors */
return size_round_up(keylength * 4000, 4096); return size_round_up(keylength * 4000, 4096);
} }
static size_t get_min_offset(struct luks2_hdr *hdr) static size_t get_min_offset(struct luks2_hdr *hdr)
{ {
return 2 * hdr->hdr_size; return 2 * hdr->hdr_size;
} }
static size_t get_max_offset(struct luks2_hdr *hdr) static size_t get_max_offset(struct luks2_hdr *hdr)
{ {
return LUKS2_hdr_and_areas_size(hdr->jobj); return LUKS2_hdr_and_areas_size(hdr);
} }
int LUKS2_find_area_max_gap(struct crypt_device *cd, struct luks2_hdr *hdr, int LUKS2_find_area_max_gap(struct crypt_device *cd, struct luks2_hdr *hdr,
uint64_t *area_offset, uint64_t *area_length) uint64_t *area_offset, uint64_t *area_length)
{ {
struct area areas[LUKS2_KEYSLOTS_MAX], sorted_areas[LUKS2_KEYSLOTS_MAX+1] = {}; struct area areas[LUKS2_KEYSLOTS_MAX], sorted_areas[LUKS2_KEYSLOTS_MAX+1] = {};
int i, j, k, area_i; int i, j, k, area_i;
size_t valid_offset, offset, length; size_t valid_offset, offset, length;
/* fill area offset + length table */ /* fill area offset + length table */
skipping to change at line 180 skipping to change at line 180
offset = sorted_areas[i].offset + sorted_areas[i].length; offset = sorted_areas[i].offset + sorted_areas[i].length;
} }
if ((offset + length) > get_max_offset(hdr)) { if ((offset + length) > get_max_offset(hdr)) {
log_dbg(cd, "Not enough space in header keyslot area."); log_dbg(cd, "Not enough space in header keyslot area.");
return -EINVAL; return -EINVAL;
} }
log_dbg(cd, "Found area %zu -> %zu", offset, length + offset); log_dbg(cd, "Found area %zu -> %zu", offset, length + offset);
*area_offset = offset; if (area_offset)
*area_length = length; *area_offset = offset;
if (area_length)
*area_length = length;
return 0; return 0;
} }
int LUKS2_check_metadata_area_size(uint64_t metadata_size) int LUKS2_check_metadata_area_size(uint64_t metadata_size)
{ {
/* see LUKS2_HDR2_OFFSETS */ /* see LUKS2_HDR2_OFFSETS */
return (metadata_size != 0x004000 && return (metadata_size != 0x004000 &&
metadata_size != 0x008000 && metadata_size != 0x010000 && metadata_size != 0x008000 && metadata_size != 0x010000 &&
metadata_size != 0x020000 && metadata_size != 0x040000 && metadata_size != 0x020000 && metadata_size != 0x040000 &&
metadata_size != 0x080000 && metadata_size != 0x100000 && metadata_size != 0x080000 && metadata_size != 0x100000 &&
skipping to change at line 374 skipping to change at line 377
offset, length + offset); offset, length + offset);
r = crypt_wipe_device(cd, crypt_metadata_device(cd), CRYPT_WIPE_ZERO, r = crypt_wipe_device(cd, crypt_metadata_device(cd), CRYPT_WIPE_ZERO,
offset, length, wipe_block, NULL, NULL); offset, length, wipe_block, NULL, NULL);
if (r < 0) if (r < 0)
return r; return r;
/* Wipe keyslot area */ /* Wipe keyslot area */
wipe_block = 1024 * 1024; wipe_block = 1024 * 1024;
offset = get_min_offset(hdr); offset = get_min_offset(hdr);
length = LUKS2_keyslots_size(hdr->jobj); length = LUKS2_keyslots_size(hdr);
log_dbg(cd, "Wiping keyslots area (0x%06" PRIx64 " - 0x%06" PRIx64") with random data.", log_dbg(cd, "Wiping keyslots area (0x%06" PRIx64 " - 0x%06" PRIx64") with random data.",
offset, length + offset); offset, length + offset);
return crypt_wipe_device(cd, crypt_metadata_device(cd), CRYPT_WIPE_RANDOM , return crypt_wipe_device(cd, crypt_metadata_device(cd), CRYPT_WIPE_RANDOM ,
offset, length, wipe_block, NULL, NULL); offset, length, wipe_block, NULL, NULL);
} }
/* FIXME: what if user wanted to keep original keyslots size? */ int LUKS2_set_keyslots_size(struct crypt_device *cd __attribute__((unused)),
int LUKS2_set_keyslots_size(struct crypt_device *cd,
struct luks2_hdr *hdr, struct luks2_hdr *hdr,
uint64_t data_offset) uint64_t data_offset)
{ {
json_object *jobj_config; json_object *jobj_config;
uint64_t keyslots_size; uint64_t keyslots_size;
if (data_offset < get_min_offset(hdr)) if (data_offset < get_min_offset(hdr))
return 1; return 1;
keyslots_size = data_offset - get_min_offset(hdr); keyslots_size = data_offset - get_min_offset(hdr);
 End of changes. 5 change blocks. 
7 lines changed or deleted 9 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)