mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-05 16:00:05 +01:00
Fix --disable-luks2-reencryption configuration option.
This commit is contained in:
@@ -846,6 +846,50 @@ void LUKS2_reencrypt_free(struct crypt_device *cd, struct luks2_reencrypt *rh)
|
||||
crypt_unlock_internal(cd, rh->reenc_lock);
|
||||
free(rh);
|
||||
}
|
||||
|
||||
int LUKS2_reencrypt_max_hotzone_size(struct crypt_device *cd,
|
||||
struct luks2_hdr *hdr,
|
||||
const struct reenc_protection *rp,
|
||||
int reencrypt_keyslot,
|
||||
uint64_t *r_length)
|
||||
{
|
||||
#if USE_LUKS2_REENCRYPTION
|
||||
int r;
|
||||
uint64_t dummy, area_length;
|
||||
|
||||
assert(hdr);
|
||||
assert(rp);
|
||||
assert(r_length);
|
||||
|
||||
if (rp->type <= REENC_PROTECTION_NONE) {
|
||||
*r_length = LUKS2_REENCRYPT_MAX_HOTZONE_LENGTH;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (rp->type == REENC_PROTECTION_DATASHIFT) {
|
||||
*r_length = rp->p.ds.data_shift;
|
||||
return 0;
|
||||
}
|
||||
|
||||
r = LUKS2_keyslot_area(hdr, reencrypt_keyslot, &dummy, &area_length);
|
||||
if (r < 0)
|
||||
return -EINVAL;
|
||||
|
||||
if (rp->type == REENC_PROTECTION_JOURNAL) {
|
||||
*r_length = area_length;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (rp->type == REENC_PROTECTION_CHECKSUM) {
|
||||
*r_length = (area_length / rp->p.csum.hash_size) * rp->p.csum.block_size;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -EINVAL;
|
||||
#else
|
||||
return -ENOTSUP;
|
||||
#endif
|
||||
}
|
||||
#if USE_LUKS2_REENCRYPTION
|
||||
static size_t reencrypt_get_alignment(struct crypt_device *cd,
|
||||
struct luks2_hdr *hdr)
|
||||
@@ -2680,46 +2724,6 @@ static int reencrypt_verify_resilience_params(struct crypt_device *cd,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
int LUKS2_reencrypt_max_hotzone_size(struct crypt_device *cd,
|
||||
struct luks2_hdr *hdr,
|
||||
const struct reenc_protection *rp,
|
||||
int reencrypt_keyslot,
|
||||
uint64_t *r_length)
|
||||
{
|
||||
int r;
|
||||
uint64_t dummy, area_length;
|
||||
|
||||
assert(hdr);
|
||||
assert(rp);
|
||||
assert(r_length);
|
||||
|
||||
if (rp->type <= REENC_PROTECTION_NONE) {
|
||||
*r_length = LUKS2_REENCRYPT_MAX_HOTZONE_LENGTH;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (rp->type == REENC_PROTECTION_DATASHIFT) {
|
||||
*r_length = rp->p.ds.data_shift;
|
||||
return 0;
|
||||
}
|
||||
|
||||
r = LUKS2_keyslot_area(hdr, reencrypt_keyslot, &dummy, &area_length);
|
||||
if (r < 0)
|
||||
return -EINVAL;
|
||||
|
||||
if (rp->type == REENC_PROTECTION_JOURNAL) {
|
||||
*r_length = area_length;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (rp->type == REENC_PROTECTION_CHECKSUM) {
|
||||
*r_length = (area_length / rp->p.csum.hash_size) * rp->p.csum.block_size;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static int reencrypt_decrypt_with_datashift_init(struct crypt_device *cd,
|
||||
const char *name,
|
||||
struct luks2_hdr *hdr,
|
||||
|
||||
Reference in New Issue
Block a user