test_abd_bi_and2.sh 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #!/usr/bin/env bash
  2. trap "gnunet-arm -e -c test_abd_lookup.conf" SIGINT
  3. LOCATION=$(which gnunet-config)
  4. if [ -z $LOCATION ]
  5. then
  6. LOCATION="gnunet-config"
  7. fi
  8. $LOCATION --version 1> /dev/null
  9. if test $? != 0
  10. then
  11. echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX"
  12. exit 77
  13. fi
  14. rm -rf `gnunet-config -c test_abd_lookup.conf -s PATHS -o GNUNET_HOME -f`
  15. which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 10"
  16. gnunet-arm -s -c test_abd_lookup.conf
  17. gnunet-identity -C a -c test_abd_lookup.conf
  18. gnunet-identity -C b -c test_abd_lookup.conf
  19. gnunet-identity -C c -c test_abd_lookup.conf
  20. gnunet-identity -C d -c test_abd_lookup.conf
  21. gnunet-identity -C e -c test_abd_lookup.conf
  22. gnunet-identity -C f -c test_abd_lookup.conf
  23. gnunet-identity -C g -c test_abd_lookup.conf
  24. gnunet-identity -C h -c test_abd_lookup.conf
  25. AKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep a | awk '{print $3}')
  26. BKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep b | awk '{print $3}')
  27. CKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep c | awk '{print $3}')
  28. DKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep d | awk '{print $3}')
  29. EKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep e | awk '{print $3}')
  30. FKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep f | awk '{print $3}')
  31. GKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep g | awk '{print $3}')
  32. HKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep h | awk '{print $3}')
  33. gnunet-identity -d
  34. # (1) (A.a) <- B.b
  35. # (2) (B.b) <- C.c AND G.g
  36. # (3) C.c <- (D.D)
  37. # (4) D.d <- (E.e)
  38. # (5) E.e <- (F) priv
  39. # (6) G.g <- (F) priv
  40. # BIDIRECTIONAL
  41. gnunet-abd --createIssuerSide --ego=a --attribute="a" --subject="$BKEY b" --ttl=5m -c test_abd_lookup.conf
  42. gnunet-namestore -D -z a
  43. gnunet-abd --createIssuerSide --ego=b --attribute="b" --subject="$CKEY c, $GKEY g" --ttl=5m -c test_abd_lookup.conf
  44. gnunet-namestore -D -z b
  45. SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=c --attribute="c" --subject="$DKEY d" --ttl="2019-12-12 10:00:00"`
  46. gnunet-abd --createSubjectSide --ego=d --import="$SIGNED"
  47. gnunet-namestore -D -z d
  48. SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=d --attribute="d" --subject="$EKEY e" --ttl="2019-12-12 10:00:00"`
  49. gnunet-abd --createSubjectSide --ego=e --import="$SIGNED"
  50. gnunet-namestore -D -z e
  51. SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=e --attribute="e" --subject="$FKEY" --ttl="2019-12-12 10:00:00"`
  52. gnunet-abd --createSubjectSide --ego=f --import="$SIGNED" --private
  53. gnunet-namestore -D -z f
  54. SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=g --attribute="g" --subject="$FKEY" --ttl="2019-12-12 10:00:00"`
  55. gnunet-abd --createSubjectSide --ego=f --import="$SIGNED" --private
  56. gnunet-namestore -D -z h
  57. # Starting to resolve
  58. echo "+++ Starting to Resolve +++"
  59. DELS=`$DO_TIMEOUT gnunet-abd --collect --issuer=$AKEY --attribute="a" --ego=f -c test_abd_lookup.conf | paste -d, -s - -`
  60. echo $DELS
  61. echo gnunet-abd --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate=\'$DELS\' -c test_abd_lookup.conf
  62. gnunet-abd --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate="$DELS" -c test_abd_lookup.conf
  63. RES=$?
  64. # Cleanup properly
  65. gnunet-namestore -z a -d -n "a" -t ATTR -c test_abd_lookup.conf
  66. gnunet-namestore -z b -d -n "b" -t ATTR -c test_abd_lookup.conf
  67. gnunet-namestore -z d -d -n "@" -t DEL -c test_abd_lookup.conf
  68. gnunet-namestore -z e -d -n "@" -t DEL -c test_abd_lookup.conf
  69. gnunet-namestore -z f -d -n "@" -t DEL -c test_abd_lookup.conf
  70. gnunet-arm -e -c test_abd_lookup.conf
  71. if [ "$RES" == 0 ]
  72. then
  73. exit 0
  74. else
  75. echo "FAIL: Failed to verify credential."
  76. exit 1
  77. fi