"Fossies" - the Fresh Open Source Software Archive

Member "cryptsetup-2.4.3/tests/compat-test-args" (13 Jan 2022, 10049 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 PS4='$LINENO:'
    4 [ -z "$CRYPTSETUP_PATH" ] && CRYPTSETUP_PATH=".."
    5 CRYPTSETUP=$CRYPTSETUP_PATH/cryptsetup
    6 
    7 CRYPTSETUP_VALGRIND=../.libs/cryptsetup
    8 CRYPTSETUP_LIB_VALGRIND=../.libs
    9 
   10 TEST_UUID="12345678-1234-1234-1234-123456789abc"
   11 
   12 TFILE=test-args.out
   13 
   14 function cleanup()
   15 {
   16     rm -f $TFILE 2> /dev/null
   17 }
   18 
   19 function fail()
   20 {
   21     [ -n "$1" ] && echo "$1"
   22     echo "FAILED backtrace:"
   23     while caller $frame; do ((frame++)); done
   24     cleanup
   25     exit 2
   26 }
   27 
   28 function valgrind_setup()
   29 {
   30     which valgrind >/dev/null 2>&1 || fail "Cannot find valgrind."
   31     [ ! -f $CRYPTSETUP_VALGRIND ] && fail "Unable to get location of cryptsetup executable."
   32     export LD_LIBRARY_PATH="$CRYPTSETUP_LIB_VALGRIND:$LD_LIBRARY_PATH"
   33 }
   34 
   35 function valgrind_run()
   36 {
   37     INFOSTRING="$(basename ${BASH_SOURCE[1]})-line-${BASH_LINENO[0]}" ./valg.sh ${CRYPTSETUP_VALGRIND} "$@"
   38 }
   39 
   40 function xxx()
   41 {
   42     $CRYPTSETUP --test-args $@ > $TFILE 2>&1
   43     local ret=$?
   44 
   45     grep -q -e ": unknown option\|Argument <action> missing" $TFILE && {
   46         echo "'$CRYPTSETUP --test-args $@' command:"
   47         cat $TFILE
   48         fail "Probably typo in test"
   49     }
   50     test $ret -ne 0 || fail
   51 }
   52 
   53 function exp_fail()
   54 {
   55     # xxx $@
   56     $CRYPTSETUP --test-args $@ 2>/dev/null && fail
   57 }
   58 
   59 function exp_pass()
   60 {
   61     $CRYPTSETUP --test-args $@ >/dev/null || fail
   62 }
   63 
   64 export LANG=C
   65 
   66 [ -n "$VALG" ] && valgrind_setup && CRYPTSETUP=valgrind_run
   67 
   68 # initial test constructed acccording to current cryptsetup content
   69 echo "[1] Current state"
   70 exp_fail resize NAME --test-passphrase
   71 exp_fail close NAME --test-passphrase
   72 exp_pass open DEV NAME --test-passphrase --type bitlk
   73 exp_pass open DEV NAME --test-passphrase --type luks
   74 exp_pass open DEV NAME --test-passphrase --type luks1
   75 exp_pass open DEV NAME --test-passphrase --type luks2
   76 exp_fail open DEV NAME --test-passphrase --type plain
   77 
   78 exp_fail open DEV NAME --deferred
   79 exp_pass close NAME --deferred
   80 
   81 exp_pass open DEV NAME --type plain --shared
   82 exp_fail open DEV NAME --type luks1 --shared
   83 exp_fail close NAME --shared
   84 
   85 exp_pass open DEV NAME --allow-discards
   86 exp_fail close NAME --allow-discards
   87 
   88 exp_fail close NAME --persistent
   89 exp_pass open DEV NAME --persistent
   90 exp_fail open DEV NAME --persistent --test-passphrase
   91 
   92 exp_fail luksFormat DEV --serialize-memory-hard-pbkdf
   93 exp_pass open DEV NAME --serialize-memory-hard-pbkdf
   94 
   95 exp_pass reencrypt DEV --key-size 32
   96 exp_fail reencrypt DEV --key-size 31
   97 exp_fail reencrypt DEV --key-size -32
   98 exp_pass luksFormat DEV --key-size 32
   99 exp_fail luksFormat DEV --key-size 31
  100 exp_fail luksFormat DEV --key-size -32
  101 exp_pass open DEV NAME --key-size 32 # --type plain -c aes-xts-plain64
  102 exp_fail open DEV NAME --key-size 31 # --type plain -c aes-xts-plain64
  103 exp_pass benchmark --key-size 32
  104 exp_fail benchmark --key-size 31
  105 exp_pass luksAddKey DEV --key-size 32 # --unbound
  106 exp_fail luksAddKey DEV --key-size 31 # --unbound
  107 
  108 exp_fail close NAME --key-size 32
  109 exp_fail luksUUID DEV --key-size 32
  110 
  111 # bug
  112 # exp_fail luksFormat DEV --type luks1 --integrity hmac-sha256
  113 exp_pass luksFormat DEV --type luks2 --integrity hmac-sha256
  114 exp_fail open DEV NAME --integrity hmac-sha256
  115 
  116 exp_pass luksFormat DEV --type luks2 --integrity hmac-sha256 --integrity-no-wipe
  117 exp_fail luksFormat DEV --type luks2 --integrity-no-wipe
  118 # bug
  119 # exp_fail luksFormat DEV --type luks1 --integrity hmac-sha256 --integrity-no-wipe
  120 exp_fail open DEV NAME --integrity-no-wipe
  121 exp_fail open DEV NAME --integrity-no-wipe --integrity hmac-sha256
  122 
  123 exp_pass luksFormat --label L --subsystem S DEV # --type luks2
  124 exp_pass luksFormat --label L DEV # --type luks2
  125 exp_pass luksFormat --subsystem S DEV # --type luks2
  126 exp_pass config --label L --subsystem S DEV
  127 exp_pass config --label L DEV
  128 exp_pass config --subsystem S DEV
  129 # bug
  130 #exp_fail luksFormat --label L --subsystem S DEV --type luks1
  131 #exp_fail luksFormat --label L DEV --type luks1
  132 #exp_fail luksFormat --subsystem S DEV --type luks1
  133 exp_fail open DEV NAME --label L --subsystem S
  134 exp_fail open DEV NAME --label L
  135 exp_fail open DEV NAME --subsystem S
  136 
  137 exp_fail luksFormat DEV -S-2
  138 # bug
  139 # exp_fail luksFormat DEV -S-1
  140 
  141 # prob. many bug: accepts --[new-]keyfile-size w/o --[new-]key-file
  142 exp_pass luksFormat DEV --keyfile-size 42 --key-file F
  143 exp_fail luksFormat DEV --keyfile-size -1 --key-file F
  144 # bug (is it? e.g. empty passphrase)
  145 # exp_fail luksFormat DEV --keyfile-size 0
  146 exp_pass luksAddKey DEV --keyfile-size 42 --key-file F --new-keyfile-size 42 NF
  147 exp_fail luksAddKey DEV --new-keyfile-size -42 NF
  148 exp_fail luksAddKey DEV --keyfile-size 42 --key-file F --new-keyfile-size -42 NF
  149 exp_fail luksFormat DEV --keyfile-size -1 --key-file F
  150 # bug (is it? e.g. empty passphrase)
  151 # exp_fail luksFormat DEV --keyfile-size 0
  152 
  153 exp_fail open DEV NAME --key-file F0 --key-file F1
  154 exp_pass open DEV NAME --key-file F0 --key-file F1 --type tcrypt
  155 
  156 # why? (luksAddKey fail)
  157 exp_fail luksAddKey DEV --use-random
  158 exp_fail luksAddKey DEV --use-urandom
  159 exp_fail luksAddKey DEV --use-urandom --use-random
  160 exp_fail luksFormat DEV --use-urandom --use-random
  161 exp_pass luksFormat DEV --use-random
  162 exp_pass luksFormat DEV --use-urandom
  163 
  164 exp_fail open DEV NAME --uuid $TEST_UUID
  165 exp_pass luksFormat DEV --uuid $TEST_UUID
  166 exp_pass luksUUID DEV --uuid $TEST_UUID
  167 
  168 exp_fail open DEV NAME --align-payload 8192
  169 exp_fail open DEV NAME --align-payload 8292 --type plain
  170 exp_pass luksFormat DEV --align-payload 8192
  171 exp_fail luksFormat DEV --align-payload 8192 --offset 16384
  172 exp_fail luksFormat DEV --align-payload 8192 --offset 8192
  173 
  174 exp_fail resize NAME --luks2-metadata-size 16k
  175 exp_fail resize NAME --luks2-keyslots-size 16m
  176 exp_pass luksFormat DEV --luks2-keyslots-size 16m
  177 exp_pass luksFormat DEV --luks2-metadata-size 16k
  178 exp_pass reencrypt DEV --luks2-keyslots-size 16m
  179 exp_pass reencrypt DEV --luks2-metadata-size 16k
  180 
  181 exp_fail luksFormat DEV --skip 8192
  182 exp_fail open DEV NAME --skip 8192
  183 exp_pass open DEV NAME --skip 8192 --type plain
  184 exp_pass open DEV NAME --skip 8192 --type loopaes
  185 
  186 exp_fail resize NAME --offset 8292
  187 exp_pass luksFormat DEV --offset 16384
  188 exp_fail open DEV NAME --offset 16384
  189 exp_pass open DEV NAME --offset 16384 --type plain
  190 exp_pass open DEV NAME --offset 16384 --type loopaes
  191 
  192 exp_fail open DEV NAME --tcrypt-hidden
  193 exp_fail open DEV NAME --tcrypt-system
  194 exp_fail open DEV NAME --tcrypt-backup
  195 # bug
  196 # exp_fail open DEV NAME --tcrypt-hidden --tcrypt-system --tcrypt-backup --type tcrypt
  197 exp_pass open DEV NAME --tcrypt-hidden --type tcrypt
  198 exp_pass open DEV NAME --tcrypt-backup --type tcrypt
  199 exp_pass open DEV NAME --tcrypt-system --type tcrypt
  200 exp_pass tcryptDump DEV NAME --tcrypt-hidden --type tcrypt
  201 exp_pass tcryptDump DEV NAME --tcrypt-backup --type tcrypt
  202 exp_pass tcryptDump DEV NAME --tcrypt-system --type tcrypt
  203 exp_fail tcryptDump DEV NAME --allow-discards --tcrypt-hidden --type tcrypt
  204 
  205 # bug
  206 # exp_fail close NAME --type tcrypt --veracrypt
  207 exp_fail open DEV NAME --veracrypt
  208 exp_pass open DEV NAME --type tcrypt --veracrypt
  209 exp_pass open DEV NAME --type tcrypt --veracrypt --veracrypt-pim 1
  210 exp_fail open DEV NAME --type tcrypt --veracrypt --veracrypt-pim -2
  211 exp_fail open DEV NAME --type tcrypt --disable-veracrypt --veracrypt-pim 1
  212 exp_fail open DEV NAME --type tcrypt --veracrypt --veracrypt-pim -1
  213 exp_fail open DEV NAME --type tcrypt --disable-veracrypt --veracrypt-query-pim
  214 exp_fail open DEV NAME --type tcrypt --disable-veracrypt --veracrypt-query-pim --veracrypt-pim 1
  215 exp_fail open DEV NAME --disable-veracrypt --veracrypt-query-pim
  216 
  217 # bug
  218 # exp_fail open DEV NAME --priority normal
  219 exp_fail config DEV --priority normal
  220 exp_fail config DEV -S1 --priority norma
  221 exp_pass config DEV -S1 --priority normal
  222 exp_pass config DEV -S1 --priority ignore
  223 exp_pass config DEV -S1 --priority prefer
  224 
  225 # bug
  226 # exp_fail open DEV NAME --pbkdf argon2i
  227 exp_fail luksFormat DEV --pbkdf blah
  228 exp_pass luksFormat DEV --pbkdf argon2i
  229 exp_pass luksFormat DEV --pbkdf pbkdf2
  230 exp_pass luksFormat DEV --pbkdf argon2id
  231 exp_fail luksFormat DEV --type luks2 --pbkdf-force-iterations 4 -i1
  232 exp_fail luksFormat DEV --type luks1 --pbkdf-force-iterations 1001 -i1
  233 
  234 exp_fail open DEV NAME --sector-size 1024
  235 exp_pass open DEV NAME --type plain --sector-size 1024
  236 # bug
  237 # exp_fail luksFormat DEV --sector-size 0
  238 exp_fail luksFormat DEV --sector-size 511
  239 exp_fail luksFormat DEV --sector-size 8192
  240 exp_pass reencrypt DEV --sector-size 1024
  241 exp_pass luksFormat DEV --sector-size 1024
  242 
  243 exp_fail luksFormat DEV --iv-large-sectors
  244 exp_fail open DEV --type tcrypt --iv-large-sectors
  245 exp_fail open DEV --type plain --iv-large-sectors --sector-size 512
  246 exp_pass open DEV --type plain --iv-large-sectors --sector-size 1024
  247 
  248 exp_fail luksAddKey DEV --unbound
  249 exp_fail luksAddKey DEV --unbound --key-size 0
  250 exp_pass luksAddKey DEV --unbound --key-size 8
  251 exp_pass luksDump DEV --unbound -S5
  252 exp_fail luksDump DEV --unbound
  253 
  254 exp_fail resize NAME --refresh
  255 exp_fail open DEV NAME --test-passphrase --refresh
  256 exp_pass open DEV NAME --refresh
  257 exp_pass refresh DEV NAME
  258 exp_fail refresh DEV NAME --test-passphrase
  259 
  260 # bug
  261 # exp_fail luksFormat DEV --reduce-device-size 64m
  262 exp_fail reencrypt DEV --reduce-device-size 2G # max 1g
  263 exp_fail reencrypt DEV --reduce-device-size $((64*1024*1024+1))
  264 exp_fail reencrypt DEV --reduce-device-size -64m
  265 exp_pass reencrypt DEV --reduce-device-size 64m
  266 exp_fail reencrypt DEV --reduce-device-size 64m --device-size 100g
  267 exp_fail reencrypt DEV --decrypt
  268 # bugs
  269 # exp_fail open DEV --decrypt --header H
  270 # exp_fail open DEV --encrypt
  271 # exp_fail open DEV NAME --device-size 32m
  272 # exp_fail open DEV NAME --size 100
  273 exp_pass open DEV NAME --device-size 32m --type plain
  274 exp_pass open DEV NAME --size 100 --type plain
  275 exp_fail open DEV NAME --size 100 --device-size $((512*100)) --type plain
  276 exp_fail reencrypt DEV --device-size $((32*1024*1024+1))
  277 exp_pass reencrypt DEV --device-size 32m
  278 
  279 exp_fail luksFormat DEV NAME --keyslot-cipher ks
  280 exp_fail luksFormat DEV NAME --keyslot-key-size 32
  281 exp_pass luksFormat DEV NAME --keyslot-cipher ks --keyslot-key-size 32
  282 # bugs
  283 # exp_fail open DEV NAME --keyslot-cipher ks --keyslot-key-size 32
  284 # exp_fail luksFormat --type luks1 DEV NAME --keyslot-cipher ks --keyslot-key-size 32
  285 
  286 cleanup
  287 exit 0