Blame SOURCES/cryptsetup-2.5.0-Get-rid-of-SHA1-in-tests.patch

0f7e16
diff -rupN cryptsetup-2.4.3.old/tests/api-test.c cryptsetup-2.4.3/tests/api-test.c
0f7e16
--- cryptsetup-2.4.3.old/tests/api-test.c	2022-02-17 16:37:09.535345938 +0100
0f7e16
+++ cryptsetup-2.4.3/tests/api-test.c	2022-02-17 16:37:29.156459763 +0100
0f7e16
@@ -312,7 +312,7 @@ static int _setup(void)
0f7e16
 static void AddDevicePlain(void)
0f7e16
 {
0f7e16
 	struct crypt_params_plain params = {
0f7e16
-		.hash = "sha1",
0f7e16
+		.hash = "sha256",
0f7e16
 		.skip = 0,
0f7e16
 		.offset = 0,
0f7e16
 		.size = 0
0f7e16
@@ -322,7 +322,7 @@ static void AddDevicePlain(void)
0f7e16
 
0f7e16
 	const char *passphrase = PASSPHRASE;
0f7e16
 	// hashed hex version of PASSPHRASE
0f7e16
-	const char *mk_hex = "bb21158c733229347bd4e681891e213d94c685be6a5b84818afe7a78a6de7a1a";
0f7e16
+	const char *mk_hex = "ccadd99b16cd3d200c22d6db45d8b6630ef3d936767127347ec8a76ab992c2ea";
0f7e16
 	size_t key_size = strlen(mk_hex) / 2;
0f7e16
 	const char *cipher = "aes";
0f7e16
 	const char *cipher_mode = "cbc-essiv:sha256";
0f7e16
@@ -438,7 +438,7 @@ static void AddDevicePlain(void)
0f7e16
 	OK_(crypt_deactivate(cd,CDEVICE_1));
0f7e16
 
0f7e16
 	CRYPT_FREE(cd);
0f7e16
-	params.hash = "sha1";
0f7e16
+	params.hash = "sha256";
0f7e16
 	params.offset = 0;
0f7e16
 	params.size = 0;
0f7e16
 	params.skip = 0;
0f7e16
@@ -620,7 +620,7 @@ static void new_log(int level, const cha
0f7e16
 static void CallbacksTest(void)
0f7e16
 {
0f7e16
 	struct crypt_params_plain params = {
0f7e16
-		.hash = "sha1",
0f7e16
+		.hash = "sha256",
0f7e16
 		.skip = 0,
0f7e16
 		.offset = 0,
0f7e16
 	};
0f7e16
@@ -1116,7 +1116,7 @@ static void LuksHeaderRestore(void)
0f7e16
 		.data_alignment = 2048, // 4M, data offset will be 4096
0f7e16
 	};
0f7e16
 	struct crypt_params_plain pl_params = {
0f7e16
-		.hash = "sha1",
0f7e16
+		.hash = "sha256",
0f7e16
 		.skip = 0,
0f7e16
 		.offset = 0,
0f7e16
 		.size = 0
0f7e16
@@ -1203,7 +1203,7 @@ static void LuksHeaderLoad(void)
0f7e16
 		.data_alignment = 2048,
0f7e16
 	};
0f7e16
 	struct crypt_params_plain pl_params = {
0f7e16
-		.hash = "sha1",
0f7e16
+		.hash = "sha256",
0f7e16
 		.skip = 0,
0f7e16
 		.offset = 0,
0f7e16
 		.size = 0
0f7e16
diff -rupN cryptsetup-2.4.3.old/tests/api-test-2.c cryptsetup-2.4.3/tests/api-test-2.c
0f7e16
--- cryptsetup-2.4.3.old/tests/api-test-2.c	2022-02-17 16:37:09.535345938 +0100
0f7e16
+++ cryptsetup-2.4.3/tests/api-test-2.c	2022-02-17 16:37:29.155459758 +0100
0f7e16
@@ -1232,7 +1232,7 @@ static void Luks2HeaderRestore(void)
0f7e16
 		.sector_size = 512
0f7e16
 	};
0f7e16
 	struct crypt_params_plain pl_params = {
0f7e16
-		.hash = "sha1",
0f7e16
+		.hash = "sha256",
0f7e16
 		.skip = 0,
0f7e16
 		.offset = 0,
0f7e16
 		.size = 0
0f7e16
@@ -1242,7 +1242,7 @@ static void Luks2HeaderRestore(void)
0f7e16
 	};
0f7e16
 	uint32_t flags = 0;
0f7e16
 
0f7e16
-	const char *mk_hex = "bb21158c733229347bd4e681891e213d94c685be6a5b84818afe7a78a6de7a1a";
0f7e16
+	const char *mk_hex = "ccadd99b16cd3d200c22d6db45d8b6630ef3d936767127347ec8a76ab992c2ea";
0f7e16
 	size_t key_size = strlen(mk_hex) / 2;
0f7e16
 	const char *cipher = "aes";
0f7e16
 	const char *cipher_mode = "cbc-essiv:sha256";
0f7e16
@@ -1337,7 +1337,7 @@ static void Luks2HeaderLoad(void)
0f7e16
 		.sector_size = 512
0f7e16
 	};
0f7e16
 	struct crypt_params_plain pl_params = {
0f7e16
-		.hash = "sha1",
0f7e16
+		.hash = "sha256",
0f7e16
 		.skip = 0,
0f7e16
 		.offset = 0,
0f7e16
 		.size = 0
0f7e16
@@ -2142,7 +2142,7 @@ static void LuksConvert(void)
0f7e16
 		.parallel_threads = 1
0f7e16
 	}, pbkdf2 = {
0f7e16
 		.type = CRYPT_KDF_PBKDF2,
0f7e16
-		.hash = "sha1",
0f7e16
+		.hash = "sha256",
0f7e16
 		.time_ms = 1
0f7e16
 	};
0f7e16
 
0f7e16
@@ -2675,7 +2675,7 @@ static void Pbkdf(void)
0f7e16
 		.hash = default_luks1_hash
0f7e16
 	};
0f7e16
 	struct crypt_params_plain params = {
0f7e16
-		.hash = "sha1",
0f7e16
+		.hash = "sha256",
0f7e16
 		.skip = 0,
0f7e16
 		.offset = 0,
0f7e16
 		.size = 0
0f7e16
@@ -2874,11 +2874,11 @@ static void Pbkdf(void)
0f7e16
 	pbkdf2.time_ms = 9;
0f7e16
 	pbkdf2.hash = NULL;
0f7e16
 	FAIL_(crypt_set_pbkdf_type(cd, &pbkdf2), "Hash is mandatory for pbkdf2");
0f7e16
-	pbkdf2.hash = "sha1";
0f7e16
+	pbkdf2.hash = "sha256";
0f7e16
 	OK_(crypt_set_pbkdf_type(cd, &pbkdf2));
0f7e16
 
0f7e16
 	argon2.time_ms = 9;
0f7e16
-	argon2.hash = "sha1"; // will be ignored
0f7e16
+	argon2.hash = "sha256"; // will be ignored
0f7e16
 	OK_(crypt_set_pbkdf_type(cd, &argon2));
0f7e16
 	argon2.hash = NULL;
0f7e16
 	OK_(crypt_set_pbkdf_type(cd, &argon2));
0f7e16
@@ -3839,7 +3839,7 @@ static void Luks2Reencryption(void)
0f7e16
 	struct crypt_params_reencrypt retparams = {}, rparams = {
0f7e16
 		.direction = CRYPT_REENCRYPT_FORWARD,
0f7e16
 		.resilience = "checksum",
0f7e16
-		.hash = "sha1",
0f7e16
+		.hash = "sha256",
0f7e16
 		.luks2 = &params2,
0f7e16
 	};
0f7e16
 	dev_t devno;
0f7e16
@@ -3983,7 +3983,7 @@ static void Luks2Reencryption(void)
0f7e16
 	rparams.hash = "hamSter";
0f7e16
 	FAIL_(crypt_reencrypt_init_by_passphrase(cd, NULL, PASSPHRASE, strlen(PASSPHRASE), 21, 9, "aes", "xts-plain64", &rparams), "Invalid resilience hash.");
0f7e16
 
0f7e16
-	rparams.hash = "sha1";
0f7e16
+	rparams.hash = "sha256";
0f7e16
 	OK_(crypt_reencrypt_init_by_passphrase(cd, NULL, PASSPHRASE, strlen(PASSPHRASE), 21, 9, "aes", "xts-plain64", &rparams));
0f7e16
 	OK_(crypt_reencrypt_run(cd, NULL, NULL));
0f7e16
 
0f7e16
diff -rupN cryptsetup-2.4.3.old/tests/compat-test cryptsetup-2.4.3/tests/compat-test
0f7e16
--- cryptsetup-2.4.3.old/tests/compat-test	2022-02-17 16:37:09.541345973 +0100
0f7e16
+++ cryptsetup-2.4.3/tests/compat-test	2022-02-17 16:37:29.157459769 +0100
0f7e16
@@ -302,8 +302,8 @@ $CRYPTSETUP -q luksUUID $IMG | grep -q $
0f7e16
 prepare	"[1] open - compat image - acceptance check" new
0f7e16
 echo $PWD0 | $CRYPTSETUP luksOpen $LOOPDEV $DEV_NAME || fail
0f7e16
 check_exists
0f7e16
-ORG_SHA1=$(sha1sum -b /dev/mapper/$DEV_NAME | cut -f 1 -d' ')
0f7e16
-[ "$ORG_SHA1" = 676062b66ebf36669dab705442ea0762dfc091b0 ] || fail
0f7e16
+ORG_SHA256=$(sha256sum -b /dev/mapper/$DEV_NAME | cut -f 1 -d' ')
0f7e16
+[ "$ORG_SHA256" = 7428e8f2436882a07eb32765086f5c899474c08b5576f556b573d2aabdf923e8 ] || fail
0f7e16
 $CRYPTSETUP -q luksClose  $DEV_NAME || fail
0f7e16
 
0f7e16
 # Check it can be opened from header backup as well
0f7e16
@@ -315,6 +315,7 @@ $CRYPTSETUP -q luksClose  $DEV_NAME || f
0f7e16
 $CRYPTSETUP luksHeaderRestore -q $IMG --header-backup-file $HEADER_IMG || fail
0f7e16
 
0f7e16
 # Repeat for V1.0 header - not aligned first keyslot
0f7e16
+if [ ! fips_mode ] ; then
0f7e16
 echo $PWD0 | $CRYPTSETUP luksOpen $IMG10 $DEV_NAME || fail
0f7e16
 check_exists
0f7e16
 ORG_SHA1=$(sha1sum -b /dev/mapper/$DEV_NAME | cut -f 1 -d' ')
0f7e16
@@ -326,6 +327,7 @@ $CRYPTSETUP luksHeaderBackup $IMG10 --he
0f7e16
 echo $PWD0 | $CRYPTSETUP luksOpen $IMG10 $DEV_NAME --header $HEADER_IMG || fail
0f7e16
 check_exists
0f7e16
 $CRYPTSETUP -q luksClose  $DEV_NAME || fail
0f7e16
+fi
0f7e16
 
0f7e16
 prepare "[2] open - compat image - denial check" new
0f7e16
 echo $PWDW | $CRYPTSETUP luksOpen $LOOPDEV $DEV_NAME 2>/dev/null && fail
0f7e16
@@ -526,7 +528,7 @@ $CRYPTSETUP luksDump $LOOPDEV | grep -q
0f7e16
 
0f7e16
 prepare "[19] create & status & resize" wipe
0f7e16
 echo $PWD1 | $CRYPTSETUP create $DEV_NAME $LOOPDEV --hash xxx 2>/dev/null && fail
0f7e16
-echo $PWD1 | $CRYPTSETUP create $DEV_NAME $LOOPDEV --hash sha1 --cipher aes-cbc-essiv:sha256 --offset 3 --skip 4 --readonly || fail
0f7e16
+echo $PWD1 | $CRYPTSETUP create $DEV_NAME $LOOPDEV --hash sha256 --cipher aes-cbc-essiv:sha256 --offset 3 --skip 4 --readonly || fail
0f7e16
 $CRYPTSETUP -q status  $DEV_NAME | grep "offset:" | grep -q "3 sectors" || fail
0f7e16
 $CRYPTSETUP -q status  $DEV_NAME | grep "skipped:" | grep -q "4 sectors" || fail
0f7e16
 $CRYPTSETUP -q status  $DEV_NAME | grep "mode:" | grep -q "readonly" || fail
0f7e16
@@ -546,15 +548,15 @@ $CRYPTSETUP -q resize  $DEV_NAME || fail
0f7e16
 $CRYPTSETUP -q status  $DEV_NAME | grep "size:" | grep -q "32765 sectors" || fail
0f7e16
 $CRYPTSETUP -q remove  $DEV_NAME || fail
0f7e16
 $CRYPTSETUP -q status  $DEV_NAME >/dev/null && fail
0f7e16
-echo $PWD1 | $CRYPTSETUP create $DEV_NAME --hash sha1 $LOOPDEV || fail
0f7e16
+echo $PWD1 | $CRYPTSETUP create $DEV_NAME --hash sha256 $LOOPDEV || fail
0f7e16
 $CRYPTSETUP -q remove  $DEV_NAME || fail
0f7e16
-echo $PWD1 | $CRYPTSETUP -q create $DEV_NAME --hash sha1 $LOOPDEV || fail
0f7e16
+echo $PWD1 | $CRYPTSETUP -q create $DEV_NAME --hash sha256 $LOOPDEV || fail
0f7e16
 $CRYPTSETUP -q remove  $DEV_NAME || fail
0f7e16
-echo $PWD1 | $CRYPTSETUP -q create $DEV_NAME --hash sha1 --size 100 $LOOPDEV || fail
0f7e16
+echo $PWD1 | $CRYPTSETUP -q create $DEV_NAME --hash sha256 --size 100 $LOOPDEV || fail
0f7e16
 $CRYPTSETUP -q status  $DEV_NAME | grep "size:" | grep -q "100 sectors" || fail
0f7e16
 $CRYPTSETUP -q remove  $DEV_NAME || fail
0f7e16
 # 4k sector resize (if kernel supports it)
0f7e16
-echo $PWD1 | $CRYPTSETUP -q open --type plain $LOOPDEV $DEV_NAME --sector-size 4096 --size 8  >/dev/null 2>&1
0f7e16
+echo $PWD1 | $CRYPTSETUP -q open --type plain --hash sha256 $LOOPDEV $DEV_NAME --sector-size 4096 --size 8  >/dev/null 2>&1
0f7e16
 if [ $? -eq 0 ] ; then
0f7e16
 	$CRYPTSETUP -q status  $DEV_NAME | grep "size:" | grep -q "8 sectors" || fail
0f7e16
 	$CRYPTSETUP -q resize  $DEV_NAME --size 16 || fail
0f7e16
@@ -567,7 +569,7 @@ if [ $? -eq 0 ] ; then
0f7e16
 fi
0f7e16
 # Resize not aligned to logical block size
0f7e16
 add_scsi_device dev_size_mb=32 sector_size=4096
0f7e16
-echo $PWD1 | $CRYPTSETUP create $DEV_NAME --hash sha1 $DEV || fail
0f7e16
+echo $PWD1 | $CRYPTSETUP create $DEV_NAME --hash sha256 $DEV || fail
0f7e16
 OLD_SIZE=$($CRYPTSETUP status $DEV_NAME | grep "^ \+size:" | sed 's/.* \([0-9]\+\) .*/\1/')
0f7e16
 $CRYPTSETUP resize $DEV_NAME -b 7 2> /dev/null && fail
0f7e16
 dmsetup info $DEV_NAME | grep -q SUSPENDED && fail
0f7e16
@@ -575,10 +577,10 @@ NEW_SIZE=$($CRYPTSETUP status $DEV_NAME
0f7e16
 test $OLD_SIZE -eq $NEW_SIZE || fail
0f7e16
 $CRYPTSETUP close $DEV_NAME || fail
0f7e16
 # Add check for unaligned plain crypt activation
0f7e16
-echo $PWD1 | $CRYPTSETUP create $DEV_NAME --hash sha1 $DEV -b 7 2>/dev/null && fail
0f7e16
+echo $PWD1 | $CRYPTSETUP create $DEV_NAME --hash sha256 $DEV -b 7 2>/dev/null && fail
0f7e16
 $CRYPTSETUP status $DEV_NAME >/dev/null 2>&1 && fail
0f7e16
 # verify is ignored on non-tty input
0f7e16
-echo $PWD1 | $CRYPTSETUP create $DEV_NAME $LOOPDEV --hash sha1 --verify-passphrase 2>/dev/null || fail
0f7e16
+echo $PWD1 | $CRYPTSETUP create $DEV_NAME $LOOPDEV --hash sha256 --verify-passphrase 2>/dev/null || fail
0f7e16
 $CRYPTSETUP -q remove  $DEV_NAME || fail
0f7e16
 $CRYPTSETUP create $DEV_NAME $LOOPDEV -d $KEY1 --key-size 255 2>/dev/null && fail
0f7e16
 $CRYPTSETUP create $DEV_NAME $LOOPDEV -d $KEY1 --key-size -1 2>/dev/null && fail
0f7e16
@@ -695,15 +697,15 @@ $CRYPTSETUP luksChangeKey $LOOPDEV $FAST
0f7e16
 dmsetup remove --retry $DEV_NAME2
0f7e16
 
0f7e16
 prepare "[25] Create shared segments" wipe
0f7e16
-echo $PWD1 | $CRYPTSETUP create $DEV_NAME $LOOPDEV  --hash sha1 --offset   0 --size 256 || fail
0f7e16
-echo $PWD1 | $CRYPTSETUP create $DEV_NAME2 $LOOPDEV --hash sha1 --offset 512 --size 256 2>/dev/null && fail
0f7e16
-echo $PWD1 | $CRYPTSETUP create $DEV_NAME2 $LOOPDEV --hash sha1 --offset 512 --size 256 --shared || fail
0f7e16
+echo $PWD1 | $CRYPTSETUP create $DEV_NAME $LOOPDEV  --hash sha256 --offset   0 --size 256 || fail
0f7e16
+echo $PWD1 | $CRYPTSETUP create $DEV_NAME2 $LOOPDEV --hash sha256 --offset 512 --size 256 2>/dev/null && fail
0f7e16
+echo $PWD1 | $CRYPTSETUP create $DEV_NAME2 $LOOPDEV --hash sha256 --offset 512 --size 256 --shared || fail
0f7e16
 $CRYPTSETUP -q remove  $DEV_NAME2 || fail
0f7e16
 $CRYPTSETUP -q remove  $DEV_NAME || fail
0f7e16
 
0f7e16
 prepare "[26] Suspend/Resume" wipe
0f7e16
 # only LUKS is supported
0f7e16
-echo $PWD1 | $CRYPTSETUP create $DEV_NAME --hash sha1 $LOOPDEV || fail
0f7e16
+echo $PWD1 | $CRYPTSETUP create $DEV_NAME --hash sha256 $LOOPDEV || fail
0f7e16
 $CRYPTSETUP luksSuspend $DEV_NAME 2>/dev/null && fail
0f7e16
 $CRYPTSETUP luksResume $DEV_NAME 2>/dev/null && fail
0f7e16
 $CRYPTSETUP -q remove  $DEV_NAME || fail
0f7e16
diff -rupN cryptsetup-2.4.3.old/tests/compat-test2 cryptsetup-2.4.3/tests/compat-test2
0f7e16
--- cryptsetup-2.4.3.old/tests/compat-test2	2022-02-17 16:37:09.541345973 +0100
0f7e16
+++ cryptsetup-2.4.3/tests/compat-test2	2022-02-17 16:37:29.158459775 +0100
0f7e16
@@ -774,7 +774,7 @@ $CRYPTSETUP luksDump $LOOPDEV | grep -q
0f7e16
 $CRYPTSETUP luksDump $LOOPDEV | grep -q "5: luks2" || fail
0f7e16
 $CRYPTSETUP -q convert --type luks1 $LOOPDEV || fail
0f7e16
 # hash test
0f7e16
-$CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 --sector-size 512 $LOOPDEV $KEY5 -S 0 --hash sha1 || fail
0f7e16
+$CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 --sector-size 512 $LOOPDEV $KEY5 -S 0 --hash sha512 || fail
0f7e16
 $CRYPTSETUP luksAddKey $FAST_PBKDF_OPT -S 1 -d $KEY5 $LOOPDEV $KEY1 --hash sha256 || fail
0f7e16
 $CRYPTSETUP -q convert --type luks1 $LOOPDEV >/dev/null 2>&1 && fail
0f7e16
 $CRYPTSETUP -q luksKillSlot $LOOPDEV 1 || fail
0f7e16
diff -rupN cryptsetup-2.4.3.old/tests/discards-test cryptsetup-2.4.3/tests/discards-test
0f7e16
--- cryptsetup-2.4.3.old/tests/discards-test	2022-02-17 16:37:09.541345973 +0100
0f7e16
+++ cryptsetup-2.4.3/tests/discards-test	2022-02-17 16:37:29.158459775 +0100
0f7e16
@@ -80,7 +80,7 @@ dmsetup table $DEV_NAME | grep allow_dis
0f7e16
 $CRYPTSETUP luksClose $DEV_NAME || fail
0f7e16
 
0f7e16
 echo "[2] Allowing discards for plain device"
0f7e16
-echo $PWD1 | $CRYPTSETUP create -q $DEV_NAME $DEV --hash sha1 --allow-discards || fail
0f7e16
+echo $PWD1 | $CRYPTSETUP create -q $DEV_NAME $DEV --hash sha256 --allow-discards || fail
0f7e16
 $CRYPTSETUP status $DEV_NAME | grep flags | grep discards >/dev/null || fail
0f7e16
 $CRYPTSETUP resize $DEV_NAME --size 100 || fail
0f7e16
 $CRYPTSETUP status $DEV_NAME | grep flags | grep discards >/dev/null || fail
0f7e16
diff -rupN cryptsetup-2.4.3.old/tests/integrity-compat-test cryptsetup-2.4.3/tests/integrity-compat-test
0f7e16
--- cryptsetup-2.4.3.old/tests/integrity-compat-test	2022-02-17 16:37:09.542345979 +0100
0f7e16
+++ cryptsetup-2.4.3/tests/integrity-compat-test	2022-02-17 16:37:29.159459781 +0100
0f7e16
@@ -168,7 +168,7 @@ intformat() # alg alg_out tagsize outtag
0f7e16
 	echo -n "[FORMAT]"
0f7e16
 	$INTSETUP format --integrity-legacy-padding -q --integrity $1 $TAG_PARAMS --sector-size $5 $KEY_PARAMS $DEV >/dev/null 2>&1
0f7e16
 	if [ $? -ne 0 ] ; then
0f7e16
-		if [[ $1 =~ "sha" || $1 =~ "crc" ]] ; then
0f7e16
+		if [[ $1 =~ "sha2" || $1 =~ "crc" ]] ; then
0f7e16
 			fail "Cannot format device."
0f7e16
 		fi
0f7e16
 		echo "[N/A]"
0f7e16
@@ -214,7 +214,14 @@ int_error_detection() # mode alg tagsize
0f7e16
 
0f7e16
 	echo -n "[INTEGRITY:$1:$2:$4:$5]"
0f7e16
 	echo -n "[FORMAT]"
0f7e16
-	$INTSETUP format -q --integrity $2 $TAG_PARAMS --sector-size $5 $KEY_PARAMS $DEV $INT_MODE >/dev/null || fail "Cannot format device."
0f7e16
+	$INTSETUP format -q --integrity $2 $TAG_PARAMS --sector-size $5 $KEY_PARAMS $DEV $INT_MODE >/dev/null 2>&1
0f7e16
+	if [ $? -ne 0 ] ; then
0f7e16
+		if [[ $2 =~ "sha2" || $2 =~ "crc" ]] ; then
0f7e16
+			fail "Cannot format device."
0f7e16
+		fi
0f7e16
+		echo "[N/A]"
0f7e16
+		return
0f7e16
+	fi
0f7e16
 	echo -n "[ACTIVATE]"
0f7e16
 	$INTSETUP open $DEV $DEV_NAME --integrity $2 --integrity-no-journal $KEY_PARAMS $INT_MODE || fail "Cannot activate device."
0f7e16
 
0f7e16
diff -rupN cryptsetup-2.4.3.old/tests/keyring-compat-test cryptsetup-2.4.3/tests/keyring-compat-test
0f7e16
--- cryptsetup-2.4.3.old/tests/keyring-compat-test	2022-02-17 16:37:09.542345979 +0100
0f7e16
+++ cryptsetup-2.4.3/tests/keyring-compat-test	2022-02-17 16:39:07.132028140 +0100
0f7e16
@@ -119,7 +119,7 @@ add_device() {
0f7e16
 which dmsetup >/dev/null 2>&1 || skip "Cannot find dmsetup, test skipped"
0f7e16
 which keyctl >/dev/null 2>&1 || skip "Cannot find keyctl, test skipped"
0f7e16
 which xxd >/dev/null 2>&1 || skip "Cannot find xxd, test skipped"
0f7e16
-which sha1sum > /dev/null 2>&1 || skip "Cannot find sha1sum, test skipped"
0f7e16
+which sha256sum >/dev/null 2>&1 || skip "Cannot find sha256sum, test skipped"
0f7e16
 modprobe dm-crypt >/dev/null 2>&1 || fail "dm-crypt failed to load"
0f7e16
 dm_crypt_keyring_support || skip "dm-crypt doesn't support kernel keyring, test skipped."
0f7e16
 
0f7e16
@@ -132,23 +132,23 @@ dd if=/dev/urandom of=$DEV bs=1M count=$
0f7e16
 #test aes cipher with xts mode, plain IV
0f7e16
 echo -n "Testing $CIPHER_XTS_PLAIN..."
0f7e16
 dmsetup create $NAME --table "0 $DEVSECTORS crypt $CIPHER_XTS_PLAIN $HEXKEY_32 0 $DEV 0" || fail
0f7e16
-sha1sum /dev/mapper/$NAME > $CHKS_DMCRYPT || fail
0f7e16
+sha256sum /dev/mapper/$NAME > $CHKS_DMCRYPT || fail
0f7e16
 dmsetup remove --retry $NAME || fail
0f7e16
 load_key "$HEXKEY_32" logon  $LOGON_KEY_32_OK "$TEST_KEYRING" || fail "Cannot load 32 byte logon key type"
0f7e16
 dmsetup create $NAME --table "0 $DEVSECTORS crypt $CIPHER_XTS_PLAIN :32:logon:$LOGON_KEY_32_OK 0 $DEV 0" || fail
0f7e16
-sha1sum /dev/mapper/$NAME > $CHKS_KEYRING || fail
0f7e16
+sha256sum /dev/mapper/$NAME > $CHKS_KEYRING || fail
0f7e16
 dmsetup remove --retry $NAME || fail
0f7e16
 diff $CHKS_DMCRYPT $CHKS_KEYRING || fail "Plaintext checksums mismatch (corruption)"
0f7e16
 # same test using message
0f7e16
 dmsetup create $NAME --table "0 $DEVSECTORS crypt $CIPHER_XTS_PLAIN $HEXKEY_32 0 $DEV 0" || fail
0f7e16
-sha1sum /dev/mapper/$NAME > $CHKS_DMCRYPT || fail
0f7e16
+sha256sum /dev/mapper/$NAME > $CHKS_DMCRYPT || fail
0f7e16
 dmsetup remove --retry $NAME || fail
0f7e16
 dmsetup create $NAME --table "0 $DEVSECTORS crypt $CIPHER_XTS_PLAIN $HEXKEY_32 0 $DEV 0" || fail
0f7e16
 dmsetup suspend $NAME || fail
0f7e16
 dmsetup message $NAME 0 key wipe || fail
0f7e16
 dmsetup message $NAME 0 "key set :32:logon:$LOGON_KEY_32_OK" || fail
0f7e16
 dmsetup resume $NAME || fail
0f7e16
-sha1sum /dev/mapper/$NAME > $CHKS_KEYRING || fail
0f7e16
+sha256sum /dev/mapper/$NAME > $CHKS_KEYRING || fail
0f7e16
 dmsetup remove --retry $NAME || fail
0f7e16
 diff $CHKS_DMCRYPT $CHKS_KEYRING || fail "Plaintext checksums mismatch (corruption)"
0f7e16
 echo "OK"
0f7e16
@@ -156,23 +156,23 @@ echo "OK"
0f7e16
 #test aes cipher, xts mode, essiv IV
0f7e16
 echo -n "Testing $CIPHER_CBC_ESSIV..."
0f7e16
 dmsetup create $NAME --table "0 $DEVSECTORS crypt $CIPHER_CBC_ESSIV $HEXKEY_16 0 $DEV 0" || fail
0f7e16
-sha1sum /dev/mapper/$NAME > $CHKS_DMCRYPT || fail
0f7e16
+sha256sum /dev/mapper/$NAME > $CHKS_DMCRYPT || fail
0f7e16
 dmsetup remove --retry $NAME || fail
0f7e16
 load_key "$HEXKEY_16" logon  $LOGON_KEY_16_OK "$TEST_KEYRING" || fail "Cannot load 16 byte logon key type"
0f7e16
 dmsetup create $NAME --table "0 $DEVSECTORS crypt $CIPHER_CBC_ESSIV :16:logon:$LOGON_KEY_16_OK 0 $DEV 0" || fail
0f7e16
-sha1sum /dev/mapper/$NAME > $CHKS_KEYRING || fail
0f7e16
+sha256sum /dev/mapper/$NAME > $CHKS_KEYRING || fail
0f7e16
 dmsetup remove --retry $NAME || fail
0f7e16
 diff $CHKS_DMCRYPT $CHKS_KEYRING || fail "Plaintext checksums mismatch (corruption)"
0f7e16
 # same test using message
0f7e16
 dmsetup create $NAME --table "0 $DEVSECTORS crypt $CIPHER_CBC_ESSIV $HEXKEY_16 0 $DEV 0" || fail
0f7e16
-sha1sum /dev/mapper/$NAME > $CHKS_DMCRYPT || fail
0f7e16
+sha256sum /dev/mapper/$NAME > $CHKS_DMCRYPT || fail
0f7e16
 dmsetup remove --retry $NAME || fail
0f7e16
 dmsetup create $NAME --table "0 $DEVSECTORS crypt $CIPHER_CBC_ESSIV $HEXKEY_16 0 $DEV 0" || fail
0f7e16
 dmsetup suspend $NAME || fail
0f7e16
 dmsetup message $NAME 0 key wipe || fail
0f7e16
 dmsetup message $NAME 0 "key set :16:logon:$LOGON_KEY_16_OK" || fail
0f7e16
 dmsetup resume $NAME || fail
0f7e16
-sha1sum /dev/mapper/$NAME > $CHKS_KEYRING || fail
0f7e16
+sha256sum /dev/mapper/$NAME > $CHKS_KEYRING || fail
0f7e16
 dmsetup remove --retry $NAME || fail
0f7e16
 diff $CHKS_DMCRYPT $CHKS_KEYRING || fail "Plaintext checksums mismatch (corruption)"
0f7e16
 echo "OK"
0f7e16
@@ -181,23 +181,23 @@ echo "OK"
0f7e16
 fips_mode || {
0f7e16
 echo -n "Testing $CIPHER_CBC_TCW..."
0f7e16
 dmsetup create $NAME --table "0 $DEVSECTORS crypt $CIPHER_CBC_TCW $HEXKEY_64 0 $DEV 0" || fail
0f7e16
-sha1sum /dev/mapper/$NAME > $CHKS_DMCRYPT || fail
0f7e16
+sha256sum /dev/mapper/$NAME > $CHKS_DMCRYPT || fail
0f7e16
 dmsetup remove --retry $NAME || fail
0f7e16
 load_key "$HEXKEY_64" logon  $LOGON_KEY_64_OK "$TEST_KEYRING" || fail "Cannot load 16 byte logon key type"
0f7e16
 dmsetup create $NAME --table "0 $DEVSECTORS crypt $CIPHER_CBC_TCW :64:logon:$LOGON_KEY_64_OK 0 $DEV 0" || fail
0f7e16
-sha1sum /dev/mapper/$NAME > $CHKS_KEYRING || fail
0f7e16
+sha256sum /dev/mapper/$NAME > $CHKS_KEYRING || fail
0f7e16
 dmsetup remove --retry $NAME || fail
0f7e16
 diff $CHKS_DMCRYPT $CHKS_KEYRING || fail "Plaintext checksum mismatch (corruption)"
0f7e16
 # same test using message
0f7e16
 dmsetup create $NAME --table "0 $DEVSECTORS crypt $CIPHER_CBC_TCW $HEXKEY_64 0 $DEV 0" || fail
0f7e16
-sha1sum /dev/mapper/$NAME > $CHKS_DMCRYPT || fail
0f7e16
+sha256sum /dev/mapper/$NAME > $CHKS_DMCRYPT || fail
0f7e16
 dmsetup remove --retry $NAME || fail
0f7e16
 dmsetup create $NAME --table "0 $DEVSECTORS crypt $CIPHER_CBC_TCW $HEXKEY_64 0 $DEV 0" || fail
0f7e16
 dmsetup suspend $NAME || fail
0f7e16
 dmsetup message $NAME 0 key wipe || fail
0f7e16
 dmsetup message $NAME 0 "key set :64:logon:$LOGON_KEY_64_OK" || fail
0f7e16
 dmsetup resume $NAME || fail
0f7e16
-sha1sum /dev/mapper/$NAME > $CHKS_KEYRING || fail
0f7e16
+sha256sum /dev/mapper/$NAME > $CHKS_KEYRING || fail
0f7e16
 dmsetup remove --retry $NAME || fail
0f7e16
 diff $CHKS_DMCRYPT $CHKS_KEYRING || fail "Plaintext checksums mismatch (corruption)"
0f7e16
 echo "OK"
0f7e16
@@ -207,10 +207,10 @@ echo -n "Test LUKS2 key refresh..."
0f7e16
 echo $PWD | $CRYPTSETUP luksFormat --type luks2 --luks2-metadata-size 16k --luks2-keyslots-size 4064k --pbkdf pbkdf2 --pbkdf-force-iterations 1000 --force-password $DEV || fail
0f7e16
 echo $PWD | $CRYPTSETUP open $DEV $NAME || fail
0f7e16
 $CRYPTSETUP status $NAME | grep -q -i "location:.*keyring" || skip "LUKS2 can't use keyring. Test skipped."
0f7e16
-dd if=/dev/mapper/$NAME bs=1M iflag=direct status=none | sha1sum > $CHKS_KEYRING || fail
0f7e16
+dd if=/dev/mapper/$NAME bs=1M iflag=direct status=none | sha256sum > $CHKS_KEYRING || fail
0f7e16
 echo $PWD | $CRYPTSETUP refresh $NAME --disable-keyring || fail
0f7e16
 $CRYPTSETUP status $NAME | grep -q -i "location:.*keyring" && fail "Key is still in keyring"
0f7e16
-dd if=/dev/mapper/$NAME bs=1M iflag=direct status=none | sha1sum > $CHKS_DMCRYPT || fail
0f7e16
+dd if=/dev/mapper/$NAME bs=1M iflag=direct status=none | sha256sum > $CHKS_DMCRYPT || fail
0f7e16
 diff $CHKS_DMCRYPT $CHKS_KEYRING || fail "Plaintext checksum mismatch (corruption)"
0f7e16
 echo "OK"
0f7e16
 
0f7e16
diff -rupN cryptsetup-2.4.3.old/tests/password-hash-test cryptsetup-2.4.3/tests/password-hash-test
0f7e16
--- cryptsetup-2.4.3.old/tests/password-hash-test	2022-02-17 16:37:09.541345973 +0100
0f7e16
+++ cryptsetup-2.4.3/tests/password-hash-test	2022-02-17 16:37:29.160459787 +0100
0f7e16
@@ -75,7 +75,7 @@ crypt_key() # hash keysize pwd/file name
0f7e16
 	esac
0f7e16
 
0f7e16
 	# ignore these cases, not all libs/kernel supports it
0f7e16
-	if [ "$1" != "sha1" -a "$1" != "sha256" ] || [ $2 -gt 256 ] ; then
0f7e16
+	if [ "$1" != "sha256" ] || [ $2 -gt 256 ] ; then
0f7e16
 		if [ $ret -ne 0 ] ; then
0f7e16
 			echo " [N/A] ($ret, SKIPPED)"
0f7e16
 			return
0f7e16
diff -rupN cryptsetup-2.4.3.old/tests/reencryption-compat-test cryptsetup-2.4.3/tests/reencryption-compat-test
0f7e16
--- cryptsetup-2.4.3.old/tests/reencryption-compat-test	2022-02-17 16:37:09.541345973 +0100
0f7e16
+++ cryptsetup-2.4.3/tests/reencryption-compat-test	2022-02-17 16:37:29.160459787 +0100
0f7e16
@@ -338,7 +338,7 @@ simple_scsi_reenc "[4096/512 sector]"
0f7e16
 echo "[OK]"
0f7e16
 
0f7e16
 echo "[8] Header only reencryption (hash and iteration time)"
0f7e16
-echo $PWD1 | $CRYPTSETUP -q luksFormat --type luks1 --hash sha1 $FAST_PBKDF $LOOPDEV1 || fail
0f7e16
+echo $PWD1 | $CRYPTSETUP -q luksFormat --type luks1 --hash sha512 $FAST_PBKDF $LOOPDEV1 || fail
0f7e16
 wipe $PWD1
0f7e16
 check_hash $PWD1 $HASH1
0f7e16
 echo $PWD1 | $REENC $LOOPDEV1 -q --keep-key || fail
0f7e16
diff -rupN cryptsetup-2.4.3.old/tests/verity-compat-test cryptsetup-2.4.3/tests/verity-compat-test
0f7e16
--- cryptsetup-2.4.3.old/tests/verity-compat-test	2022-02-17 16:37:09.541345973 +0100
0f7e16
+++ cryptsetup-2.4.3/tests/verity-compat-test	2022-02-17 16:37:29.161459793 +0100
0f7e16
@@ -148,7 +148,13 @@ function check_root_hash() # $1 size, $2
0f7e16
 	for fail in data hash; do
0f7e16
 	wipe
0f7e16
 	echo -n "V$4(sb=$sb root_hash_as_file=$root_hash_as_file) $5 block size $1: "
0f7e16
-	$VERITYSETUP format $DEV_PARAMS $FORMAT_PARAMS >$DEV_OUT || fail
0f7e16
+	$VERITYSETUP format $DEV_PARAMS $FORMAT_PARAMS >$DEV_OUT
0f7e16
+	if [ $? -ne 0 ] ; then
0f7e16
+		if [[ $1 =~ "sha2" ]] ; then
0f7e16
+			fail "Cannot format device."
0f7e16
+		fi
0f7e16
+		return
0f7e16
+	fi
0f7e16
 
0f7e16
 	echo -n "[root hash]"
0f7e16
 	compare_out "root hash" $2