1 set PATH and ARTIFACTS for convenience: 2 3 $ [ -n "$FWTOOL" ] && export PATH="$(dirname "$FWTOOL"):$PATH" 4 $ export ARTIFACTS="$TESTDIR/../artifacts" 5 $ alias fwtool='valgrind --quiet --leak-check=full fwtool' 6 7 check usage: 8 9 $ fwtool 10 Usage: fwtool <options> <firmware> 11 12 Options: 13 -S <file>:\t\tAppend signature file to firmware image (esc) 14 -I <file>:\t\tAppend metadata file to firmware image (esc) 15 -s <file>:\t\tExtract signature file from firmware image (esc) 16 -i <file>:\t\tExtract metadata file from firmware image (esc) 17 -t:\t\t\tRemove extracted chunks from firmare image (using -s, -i) (esc) 18 -T:\t\t\tOutput firmware image without extracted chunks to stdout (using -s, -i) (esc) 19 -q:\t\t\tQuiet (suppress error messages) (esc) 20 21 [1] 22 23 check that -T don't truncate ouput by 16 bytes and produces desired error output: 24 25 $ dd if=/dev/urandom of=image.bin bs=512k count=1 2> /dev/null 26 $ cp image.bin image.bin.stripped 27 $ md5sum image.bin* > md5sums 28 29 $ fwtool -T -i /dev/null image.bin > image.bin.stripped 30 Data not found 31 [1] 32 33 $ md5sum --check md5sums 34 image.bin: OK 35 image.bin.stripped: OK 36 37 check metadata insertion and extraction: 38 39 $ cp "$ARTIFACTS/metadata.json" . 40 $ dd if=/dev/urandom of=image.bin bs=512k count=1 2> /dev/null 41 $ md5sum image.bin metadata.json > md5sums 42 43 $ fwtool -I metadata.json image.bin 44 $ strings image.bin | grep metadata_version > metadata.json.extracted 45 $ diff --unified "$ARTIFACTS/metadata.json" metadata.json.extracted 46 $ rm metadata.json 47 48 $ fwtool -t -i metadata.json image.bin 49 $ md5sum --check md5sums 50 image.bin: OK 51 metadata.json: OK 52 53 check signature insertion and extraction: 54 55 $ cp "$ARTIFACTS/key-build.ucert" . 56 $ dd if=/dev/urandom of=image.bin bs=512k count=1 2> /dev/null 57 $ md5sum image.bin key-build.ucert > md5sums 58 59 $ fwtool -S key-build.ucert image.bin 60 $ tail --bytes 532 image.bin | head --bytes 516 > key-build.ucert.extracted 61 $ cmp --print-bytes "$ARTIFACTS/key-build.ucert" key-build.ucert.extracted 62 $ rm key-build.ucert 63 64 $ fwtool -t -s key-build.ucert image.bin 65 $ md5sum --check md5sums 66 image.bin: OK 67 key-build.ucert: OK 68 69 check both signature and metadata insertion and extraction: 70 71 $ cp "$ARTIFACTS/metadata.json" "$ARTIFACTS/key-build.ucert" . 72 $ dd if=/dev/urandom of=image.bin bs=512k count=1 2> /dev/null 73 $ md5sum image.bin metadata.json key-build.ucert > md5sums 74 75 $ fwtool -I metadata.json image.bin 76 $ fwtool -S key-build.ucert image.bin 77 78 $ strings image.bin | grep metadata_version > metadata.json.extracted 79 $ diff -u "$ARTIFACTS/metadata.json" metadata.json.extracted 80 $ rm metadata.json 81 82 $ tail --bytes 532 image.bin | head --bytes 516 > key-build.ucert.extracted 83 $ cmp -b "$ARTIFACTS/key-build.ucert" key-build.ucert.extracted 84 $ rm key-build.ucert 85 86 $ fwtool -t -s key-build.ucert image.bin 87 $ fwtool -t -i metadata.json image.bin 88 $ md5sum --check md5sums 89 image.bin: OK 90 metadata.json: OK 91 key-build.ucert: OK
This page was automatically generated by LXR 0.3.1. • OpenWrt