Imported Upstream version 2.3.3
[platform/upstream/cryptsetup.git] / tests / generators / generate-luks2-invalid-checksum-hdr0.img.sh
1 #!/bin/bash
2
3 . lib.sh
4
5 #
6 # *** Description ***
7 #
8 # generate header with bad checksum in primary binary header
9 #
10
11 # 1 full target dir
12 # 2 full source luks2 image
13
14 function prepare()
15 {
16         cp $SRC_IMG $TGT_IMG
17 }
18
19 function generate()
20 {
21         chks=$(echo "Arbitrary chosen string: D'oh!" | calc_sha256_checksum_stdin)
22         write_checksum $chks $TGT_IMG
23 }
24
25 function check()
26 {
27         chks_res=$(read_sha256_checksum $TGT_IMG)
28         test "$chks" = "$chks_res" || exit 2
29 }
30
31 #function cleanup()
32 #{
33 #}
34
35 test $# -eq 2 || exit 1
36
37 TGT_IMG=$1/$(test_img_name $0)
38 SRC_IMG=$2
39
40 prepare
41 generate
42 check
43 #cleanup