Add crypt_get_old_volume_key_size API.

It allows to get former (old) volume key size
from LUKS2 device in reencryption state when
there's at least one keyslot containing encrypted
volume key.
This commit is contained in:
Ondrej Kozina
2025-05-16 13:49:37 +02:00
committed by Milan Broz
parent 3dcb532bd3
commit 4e94c8d809
6 changed files with 73 additions and 0 deletions

View File

@@ -6413,6 +6413,19 @@ int crypt_get_volume_key_size(struct crypt_device *cd)
return 0;
}
int crypt_get_old_volume_key_size(struct crypt_device *cd)
{
int r = _onlyLUKS2(cd, CRYPT_CD_QUIET,
CRYPT_REQUIREMENT_ONLINE_REENCRYPT | CRYPT_REQUIREMENT_OPAL);
if (r < 0)
return 0;
r = LUKS2_get_old_volume_key_size(&cd->u.luks2.hdr);
return r < 0 ? 0 : r;
}
int crypt_get_hw_encryption_key_size(struct crypt_device *cd)
{
if (!cd || !isLUKS2(cd->type))