8 # generate header with malformed json but correct checksum in secondary header
12 # $2 full source luks2 image
17 test -d $TMPDIR || mkdir $TMPDIR
18 read_luks2_json1 $TGT_IMG $TMPDIR/json1
19 read_luks2_bin_hdr1 $TGT_IMG $TMPDIR/hdr1
24 read -r json_str < $TMPDIR/json1
26 json_len=$((json_len-1)) # to replace json closing '}'
27 json_new_str="${json_str:0:json_len},\""
29 while [ ${#json_new_str} -le $((LUKS2_JSON_SIZE*512)) ]; do
30 json_new_str=$json_new_str"all_work_and_no_play_makes_Jack_a_dull_boy_"
33 printf "%s" $json_new_str | _dd of=$TMPDIR/json1 bs=512 count=$LUKS2_JSON_SIZE
35 merge_bin_hdr_with_json $TMPDIR/hdr1 $TMPDIR/json1 $TMPDIR/area1
36 erase_checksum $TMPDIR/area1
37 chks1=$(calc_sha256_checksum_file $TMPDIR/area1)
38 write_checksum $chks1 $TMPDIR/area1
39 write_luks2_hdr1 $TMPDIR/area1 $TGT_IMG
44 read_luks2_bin_hdr1 $TGT_IMG $TMPDIR/hdr_res1
45 chks_res1=$(read_sha256_checksum $TMPDIR/hdr_res1)
46 test "$chks1" = "$chks_res1" || exit 2
47 read_luks2_json1 $TGT_IMG $TMPDIR/json_res1
48 read -r json_str_res1 < $TMPDIR/json_res1
49 test ${#json_str_res1} -eq $((LUKS2_JSON_SIZE*512)) || exit 2
58 test $# -eq 2 || exit 1
60 TGT_IMG=$1/$(test_img_name $0)