From 1d6a445e43f71f6442d851b2f66193ab4d424be6 Mon Sep 17 00:00:00 2001 From: Milan Broz Date: Sun, 17 Apr 2022 19:48:26 +0200 Subject: [PATCH] Fix integrity api-test. The journal crypt is in wrong format (this never worked! :), here it takes kernel syntax. Also use CBC a CTR mode could be missing here. Fox typo in key length caclulation. Clear temporary dm devices after test, loop devices are reused. If the first device format is ok, all subsequent cals should be treated as an error. --- tests/api-test.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/tests/api-test.c b/tests/api-test.c index 25e2cc0e..122ccb53 100644 --- a/tests/api-test.c +++ b/tests/api-test.c @@ -1881,12 +1881,7 @@ static void ResizeIntegrity(void) OK_(crypt_init(&cd, DEVICE_2)); OK_(create_dmdevice_over_loop(H_DEVICE, 1024 * 1024 / 512)); OK_(crypt_init_data_device(&cd, DMDIR H_DEVICE, DEVICE_2)); - ret = crypt_format(cd,CRYPT_INTEGRITY,NULL,NULL,NULL,NULL,0,¶ms); - if (ret < 0) { - printf("WARNING: cannot format integrity device, skipping test.\n"); - CRYPT_FREE(cd); - return; - } + OK_(crypt_format(cd,CRYPT_INTEGRITY,NULL,NULL,NULL,NULL,0,¶ms)); OK_(crypt_activate_by_volume_key(cd, CDEVICE_1, NULL, 0, 0)); if (!t_device_size(DMDIR CDEVICE_1, &whole_device_size)) EQ_(10 * 1024 * 1024 / 512, whole_device_size >> TST_SECTOR_SHIFT); @@ -1903,6 +1898,7 @@ static void ResizeIntegrity(void) OK_(crypt_deactivate(cd, CDEVICE_1)); CRYPT_FREE(cd); + _cleanup_dmdevices(); } static void ResizeIntegrityWithKey(void) @@ -1911,7 +1907,7 @@ static void ResizeIntegrityWithKey(void) .tag_size = 4, .integrity = "hmac(sha256)", .journal_integrity = "hmac(sha256)", - .journal_crypt = "ctr-aes", + .journal_crypt = "cbc(aes)", .sector_size = 4096, }; int ret; @@ -1924,7 +1920,7 @@ static void ResizeIntegrityWithKey(void) char integrity_key[128], journal_integrity_key[128], journal_crypt_key[128]; size_t integrity_key_size = strlen(key_integrity_hex) / 2; - size_t journal_integrity_key_size = strlen(key_journal_crypt_hex) / 2; + size_t journal_integrity_key_size = strlen(key_journal_integrity_hex) / 2; size_t journal_crypt_key_size = strlen(key_journal_crypt_hex) / 2; crypt_decode_key(integrity_key, key_integrity_hex, integrity_key_size); @@ -1964,12 +1960,7 @@ static void ResizeIntegrityWithKey(void) OK_(crypt_init(&cd, DEVICE_2)); OK_(create_dmdevice_over_loop(H_DEVICE, 1024 * 1024 / 512)); OK_(crypt_init_data_device(&cd, DMDIR H_DEVICE, DEVICE_2)); - ret = crypt_format(cd,CRYPT_INTEGRITY,NULL,NULL,NULL,NULL,0,¶ms); - if (ret < 0) { - printf("WARNING: cannot format integrity device, skipping test.\n"); - CRYPT_FREE(cd); - return; - } + OK_(crypt_format(cd,CRYPT_INTEGRITY,NULL,NULL,NULL,NULL,0,¶ms)); OK_(crypt_activate_by_volume_key(cd, CDEVICE_1, integrity_key, integrity_key_size, 0)); if (!t_device_size(DMDIR CDEVICE_1, &whole_device_size)) EQ_(10*1024*1024/512, whole_device_size >> TST_SECTOR_SHIFT); @@ -1986,6 +1977,7 @@ static void ResizeIntegrityWithKey(void) OK_(crypt_deactivate(cd, CDEVICE_1)); CRYPT_FREE(cd); + _cleanup_dmdevices(); } static void IntegrityTest(void)