"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/luks2/luks2_luks1_convert.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_luks1_convert.c  (cryptsetup-2.3.6.tar.xz):luks2_luks1_convert.c  (cryptsetup-2.4.0.tar.xz)
skipping to change at line 576 skipping to change at line 576
strncpy(hdr2->checksum_alg, "sha256", LUKS2_CHECKSUM_ALG_L); strncpy(hdr2->checksum_alg, "sha256", LUKS2_CHECKSUM_ALG_L);
crypt_random_get(cd, (char*)hdr2->salt1, sizeof(hdr2->salt1), CRYPT_RND_S ALT); crypt_random_get(cd, (char*)hdr2->salt1, sizeof(hdr2->salt1), CRYPT_RND_S ALT);
crypt_random_get(cd, (char*)hdr2->salt2, sizeof(hdr2->salt2), CRYPT_RND_S ALT); crypt_random_get(cd, (char*)hdr2->salt2, sizeof(hdr2->salt2), CRYPT_RND_S ALT);
strncpy(hdr2->uuid, crypt_get_uuid(cd), LUKS2_UUID_L-1); /* UUID should b e max 36 chars */ strncpy(hdr2->uuid, crypt_get_uuid(cd), LUKS2_UUID_L-1); /* UUID should b e max 36 chars */
hdr2->jobj = jobj; hdr2->jobj = jobj;
/* /*
* It duplicates check in LUKS2_hdr_write() but we don't want to move * It duplicates check in LUKS2_hdr_write() but we don't want to move
* keyslot areas in case it would fail later * keyslot areas in case it would fail later
*/ */
if (max_size < LUKS2_hdr_and_areas_size(hdr2->jobj)) { if (max_size < LUKS2_hdr_and_areas_size(hdr2)) {
r = -EINVAL; r = -EINVAL;
goto out; goto out;
} }
/* check future LUKS2 metadata before moving keyslots area */ /* check future LUKS2 metadata before moving keyslots area */
if (LUKS2_hdr_validate(cd, hdr2->jobj, hdr2->hdr_size - LUKS2_HDR_BIN_LEN )) { if (LUKS2_hdr_validate(cd, hdr2->jobj, hdr2->hdr_size - LUKS2_HDR_BIN_LEN )) {
r = -EINVAL; r = -EINVAL;
goto out; goto out;
} }
skipping to change at line 598 skipping to change at line 598
if (r > 0) if (r > 0)
r = -EBUSY; r = -EBUSY;
goto out; goto out;
} }
// move keyslots 4k -> 32k offset // move keyslots 4k -> 32k offset
buf_offset = 2 * LUKS2_HDR_16K_LEN; buf_offset = 2 * LUKS2_HDR_16K_LEN;
buf_size = luks1_size - LUKS_ALIGN_KEYSLOTS; buf_size = luks1_size - LUKS_ALIGN_KEYSLOTS;
/* check future LUKS2 keyslots area is at least as large as LUKS1 keyslot s area */ /* check future LUKS2 keyslots area is at least as large as LUKS1 keyslot s area */
if (buf_size > LUKS2_keyslots_size(hdr2->jobj)) { if (buf_size > LUKS2_keyslots_size(hdr2)) {
log_err(cd, _("Unable to move keyslot area. LUKS2 keyslots area t oo small.")); log_err(cd, _("Unable to move keyslot area. LUKS2 keyslots area t oo small."));
r = -EINVAL; r = -EINVAL;
goto out; goto out;
} }
if ((r = move_keyslot_areas(cd, 8 * SECTOR_SIZE, buf_offset, buf_size)) < 0) { if ((r = move_keyslot_areas(cd, 8 * SECTOR_SIZE, buf_offset, buf_size)) < 0) {
log_err(cd, _("Unable to move keyslot area.")); log_err(cd, _("Unable to move keyslot area."));
goto out; goto out;
} }
skipping to change at line 886 skipping to change at line 886
memcpy(hdr1->magic, luksMagic, LUKS_MAGIC_L); memcpy(hdr1->magic, luksMagic, LUKS_MAGIC_L);
hdr1->version = 1; hdr1->version = 1;
r = luks_header_in_use(cd); r = luks_header_in_use(cd);
if (r) if (r)
return r > 0 ? -EBUSY : r; return r > 0 ? -EBUSY : r;
// move keyslots 32k -> 4k offset // move keyslots 32k -> 4k offset
buf_offset = 2 * LUKS2_HDR_16K_LEN; buf_offset = 2 * LUKS2_HDR_16K_LEN;
buf_size = LUKS2_keyslots_size(hdr2->jobj); buf_size = LUKS2_keyslots_size(hdr2);
r = move_keyslot_areas(cd, buf_offset, 8 * SECTOR_SIZE, buf_size); r = move_keyslot_areas(cd, buf_offset, 8 * SECTOR_SIZE, buf_size);
if (r < 0) { if (r < 0) {
log_err(cd, _("Unable to move keyslot area.")); log_err(cd, _("Unable to move keyslot area."));
return r; return r;
} }
crypt_wipe_device(cd, crypt_metadata_device(cd), CRYPT_WIPE_ZERO, 0, crypt_wipe_device(cd, crypt_metadata_device(cd), CRYPT_WIPE_ZERO, 0,
8 * SECTOR_SIZE, 8 * SECTOR_SIZE, NULL, NULL); 8 * SECTOR_SIZE, 8 * SECTOR_SIZE, NULL, NULL);
// Write LUKS1 hdr // Write LUKS1 hdr
 End of changes. 3 change blocks. 
3 lines changed or deleted 3 lines changed or added

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