"Fossies" - the Fresh Open Source Software Archive

Member "cryptsetup-2.4.3/tests/generators/generate-luks2-invalid-checksum-hdr0.img.sh" (24 Jul 2021, 570 Bytes) of package /linux/misc/cryptsetup-2.4.3.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    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