check.sh 2.3 KB

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