8 # generate header with malformed json but correct checksum in primary header
12 # $2 full source luks2 image
17 test -d $TMPDIR || mkdir $TMPDIR
18 read_luks2_json0 $TGT_IMG $TMPDIR/json0
19 read_luks2_bin_hdr0 $TGT_IMG $TMPDIR/hdr0
24 read -r json_str < $TMPDIR/json0
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/json0 bs=512 count=$LUKS2_JSON_SIZE
35 merge_bin_hdr_with_json $TMPDIR/hdr0 $TMPDIR/json0 $TMPDIR/area0
36 erase_checksum $TMPDIR/area0
37 chks0=$(calc_sha256_checksum_file $TMPDIR/area0)
38 write_checksum $chks0 $TMPDIR/area0
39 write_luks2_hdr0 $TMPDIR/area0 $TGT_IMG
44 chks_res0=$(read_sha256_checksum $TGT_IMG)
45 test "$chks0" = "$chks_res0" || exit 2
46 read_luks2_json0 $TGT_IMG $TMPDIR/json_res0
47 read -r json_str_res0 < $TMPDIR/json_res0
48 test ${#json_str_res0} -eq $((LUKS2_JSON_SIZE*512)) || exit 2
57 test $# -eq 2 || exit 1
59 TGT_IMG=$1/$(test_img_name $0)