From b557ddde70c1f7b203f89b9cd32089ecd9d8b509 Mon Sep 17 00:00:00 2001
From: Marc Beninca <git@marc.beninca.link>
Date: Tue, 12 Nov 2024 23:36:20 +0100
Subject: [PATCH] formats

---
 bash/rescue-hetzner.sh | 28 ++--------------------------
 bash/rescue-ovh.sh     | 28 ++--------------------------
 2 files changed, 4 insertions(+), 52 deletions(-)

diff --git a/bash/rescue-hetzner.sh b/bash/rescue-hetzner.sh
index 9637910..81930b4 100644
--- a/bash/rescue-hetzner.sh
+++ b/bash/rescue-hetzner.sh
@@ -105,19 +105,7 @@ rescue_wipe_0_init_hetzner_8_8() {
 		--uuid "00000000:00000000:00000000:00000001" \
 		"${members[@]}"
 	# encrypt
-	echo "${passphrase}" |
-		cryptsetup \
-			--verbose \
-			--batch-mode \
-			--type "luks2" \
-			--pbkdf "argon2id" \
-			--cipher "aes-xts-plain64" \
-			--iter-time 8192 \
-			--key-size 512 \
-			--hash "sha512" \
-			--use-random \
-			luksFormat \
-			"/dev/md/crypt"
+	luks_format "${passphrase}" "/dev/md/crypt"
 	# open
 	echo "${passphrase}" |
 		cryptsetup luksOpen "/dev/md/crypt" "crypt"
@@ -132,19 +120,7 @@ rescue_wipe_2_make_hetzner_8_8() {
 	# read passphrase
 	passphrase="$(read_passphrase)"
 	# encrypt
-	echo "${passphrase}" |
-		cryptsetup \
-			--verbose \
-			--batch-mode \
-			--type "luks2" \
-			--pbkdf "argon2id" \
-			--cipher "aes-xts-plain64" \
-			--iter-time 8192 \
-			--key-size 512 \
-			--hash "sha512" \
-			--use-random \
-			luksFormat \
-			"/dev/md/crypt"
+	luks_format "${passphrase}" "/dev/md/crypt"
 	# open
 	echo "${passphrase}" |
 		cryptsetup luksOpen "/dev/md/crypt" "crypt"
diff --git a/bash/rescue-ovh.sh b/bash/rescue-ovh.sh
index e15c9d9..ed225d1 100644
--- a/bash/rescue-ovh.sh
+++ b/bash/rescue-ovh.sh
@@ -38,19 +38,7 @@ rescue_wipe_0_init_ovh_vle2() {
 	# crypt / wipe
 	fs_wipe "${device}1" "1G" 1
 	# crypt / encrypt
-	echo "${passphrase}" |
-		cryptsetup \
-			--verbose \
-			--batch-mode \
-			--type "luks2" \
-			--pbkdf "argon2id" \
-			--cipher "aes-xts-plain64" \
-			--iter-time 4096 \
-			--key-size 512 \
-			--hash "sha512" \
-			--use-random \
-			luksFormat \
-			"${device}1"
+	luks_format "${passphrase}" "${device}1"
 	# crypt / open
 	echo "${passphrase}" |
 		cryptsetup luksOpen "${device}1" "crypt"
@@ -66,19 +54,7 @@ rescue_wipe_2_make_ovh_vle2() {
 	# read passphrase
 	passphrase="$(read_passphrase)"
 	# crypt / encrypt
-	echo "${passphrase}" |
-		cryptsetup \
-			--verbose \
-			--batch-mode \
-			--type "luks2" \
-			--pbkdf "argon2id" \
-			--cipher "aes-xts-plain64" \
-			--iter-time 4096 \
-			--key-size 512 \
-			--hash "sha512" \
-			--use-random \
-			luksFormat \
-			"${device}1"
+	luks_format "${passphrase}" "${device}1"
 	# crypt / open
 	echo "${passphrase}" |
 		cryptsetup luksOpen "${device}1" "crypt"