mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-06 00:10:04 +01:00
integrity: Fix integrity_key_size for algorithms without keys
INTEGRITY_key_size returns -EINVAL for algorithms without a key and because crypt_params_integrity.integrity_key_size is an unsigned integer we get key size 4294967274 instead of more appropriate 0 for these algorithms.
This commit is contained in:
@@ -5245,13 +5245,15 @@ const char *crypt_get_integrity(struct crypt_device *cd)
|
|||||||
/* INTERNAL only */
|
/* INTERNAL only */
|
||||||
int crypt_get_integrity_key_size(struct crypt_device *cd)
|
int crypt_get_integrity_key_size(struct crypt_device *cd)
|
||||||
{
|
{
|
||||||
|
int key_size = 0;
|
||||||
|
|
||||||
if (isINTEGRITY(cd->type))
|
if (isINTEGRITY(cd->type))
|
||||||
return INTEGRITY_key_size(crypt_get_integrity(cd));
|
key_size = INTEGRITY_key_size(crypt_get_integrity(cd));
|
||||||
|
|
||||||
if (isLUKS2(cd->type))
|
if (isLUKS2(cd->type))
|
||||||
return INTEGRITY_key_size(crypt_get_integrity(cd));
|
key_size = INTEGRITY_key_size(crypt_get_integrity(cd));
|
||||||
|
|
||||||
return 0;
|
return key_size > 0 ? key_size : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* INTERNAL only */
|
/* INTERNAL only */
|
||||||
|
|||||||
@@ -2007,6 +2007,7 @@ static void IntegrityTest(void)
|
|||||||
EQ_(ip.interleave_sectors, params.interleave_sectors);
|
EQ_(ip.interleave_sectors, params.interleave_sectors);
|
||||||
EQ_(ip.journal_size, params.journal_size);
|
EQ_(ip.journal_size, params.journal_size);
|
||||||
EQ_(ip.journal_watermark, params.journal_watermark);
|
EQ_(ip.journal_watermark, params.journal_watermark);
|
||||||
|
EQ_(ip.integrity_key_size, 0);
|
||||||
OK_(strcmp(ip.integrity,params.integrity));
|
OK_(strcmp(ip.integrity,params.integrity));
|
||||||
FAIL_(crypt_set_uuid(cd,DEVICE_1_UUID),"can't set uuid to integrity device");
|
FAIL_(crypt_set_uuid(cd,DEVICE_1_UUID),"can't set uuid to integrity device");
|
||||||
CRYPT_FREE(cd);
|
CRYPT_FREE(cd);
|
||||||
|
|||||||
Reference in New Issue
Block a user