check.sh 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #!/bin/bash
  2. file="$1"
  3. ### signatures ###
  4. public=(
  5. "16b0e942929d6592d4a01b66b334427ba4db03b388a876432958d9010bd8d8b5"
  6. "b0197042824a752c2dba717a4b2ded88852111bbe12e6b5f57fdfa3abb9312c0"
  7. "ba2e6ff4de41ade9959702195d4c26c764e7aab85c627363681c29dbc4a8a2c5"
  8. "a4da8601d27c73a22094a98b02501367c451f364aaabfcf5c597784bf272429c"
  9. "fb9d6beba63dcb6175d0248c1e743b5fe4359474eb264d27f389d7a962e24477"
  10. "f70f9ddeb307fff8fca31a76f4fbd0ac676dab8ad143625f0a4160d434d72876"
  11. "9841dde0b9f6485d5fcdc858fb15c1db1c3bc77fb81aef3f0d4b835f76a3d73b"
  12. "39ef16b1853e54249dae2d06948329a93e3e13f354aaab792552aacd1d0b45ba"
  13. "5126eda4161bca3fcae134fa0e1824e55dffb986cc4e7fe37842857a118e2820"
  14. )
  15. name=(
  16. "HeJ"
  17. "thardes2"
  18. "oscar-"
  19. "THiSCO"
  20. "northalpha"
  21. "Barbarossa"
  22. "kb-light"
  23. "phimeas"
  24. "leeps"
  25. )
  26. ### programm comes here ###
  27. function progress {
  28. echo -en "\033[1;34m➔ "
  29. echo -en $*
  30. echo -en "\033[0m\n"
  31. }
  32. function info {
  33. echo -en "\033[1;36m"
  34. echo -en $*
  35. echo -en "\033[0m\n"
  36. }
  37. function success {
  38. echo -en "\033[1;32m ✔ "
  39. echo -en $*
  40. echo -en "\033[0m\n"
  41. }
  42. function fail {
  43. echo -en "\033[1;31m ✘ "
  44. echo -en $*
  45. echo -en "\033[0m\n"
  46. }
  47. if [ $# != 1 ]; then
  48. fail "Usage: `basename ${0}` manifest_file" >&2
  49. exit 1
  50. fi
  51. if [ ! -r "${file}" ]; then
  52. fail "Manifest \"${file}\" does not exist or is not readable!" >&2
  53. exit 1
  54. fi
  55. manifest="$(mktemp)"
  56. n=0
  57. m=0
  58. count=$((${#public[@]}))
  59. sed -e '/\-\-\-/,$d' $file > $manifest
  60. signatures=$( sed -e '1,/\-\-\-/d' ${file} )
  61. progress "checking signatures of ${file}"
  62. for sign in ${signatures[@]}; do
  63. n=$(($n+1))
  64. right=0
  65. for i in `seq 0 $(($count-1))`; do
  66. if type "ecdsautil" > /dev/null 2>&1; then
  67. ecdsautil verify -s $sign -p ${public[i]} ${manifest}
  68. elif type "ecdsaverify" > /dev/null 2>&1; then
  69. ecdsaverify -s $sign -p ${public[i]} ${manifest}
  70. else
  71. fail "ecdsautil not found"
  72. exit 1
  73. fi
  74. if [ $? -eq 0 ]; then
  75. m=$(($m+1))
  76. right=1
  77. success "valid signature of ${name[i]}"
  78. fi
  79. done
  80. if [ $right == 0 ]; then
  81. fail "can't verify signature No $n"
  82. fi
  83. done
  84. rm -f -- "${manifest}"
  85. progress "finsh"
  86. info "$n signatures checked, $m signatures valid."