test_abd_bi_and.sh 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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) <- H.h
  40. # (7) H.h <- (F) priv
  41. # BIDIRECTIONAL
  42. gnunet-abd --createIssuerSide --ego=a --attribute="a" --subject="$BKEY b" --ttl=5m -c test_abd_lookup.conf
  43. gnunet-namestore -D -z a
  44. gnunet-abd --createIssuerSide --ego=b --attribute="b" --subject="$CKEY c, $GKEY g" --ttl=5m -c test_abd_lookup.conf
  45. gnunet-namestore -D -z b
  46. gnunet-abd --createIssuerSide --ego=g --attribute="g" --subject="$HKEY h" --ttl=5m -c test_abd_lookup.conf
  47. gnunet-namestore -D -z b
  48. SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=c --attribute="c" --subject="$DKEY d" --ttl="2019-12-12 10:00:00"`
  49. gnunet-abd --createSubjectSide --ego=d --import="$SIGNED"
  50. gnunet-namestore -D -z d
  51. SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=d --attribute="d" --subject="$EKEY e" --ttl="2019-12-12 10:00:00"`
  52. gnunet-abd --createSubjectSide --ego=e --import="$SIGNED"
  53. gnunet-namestore -D -z e
  54. SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=e --attribute="e" --subject="$FKEY" --ttl="2019-12-12 10:00:00"`
  55. gnunet-abd --createSubjectSide --ego=f --import="$SIGNED" --private
  56. gnunet-namestore -D -z f
  57. SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=h --attribute="h" --subject="$FKEY" --ttl="2019-12-12 10:00:00"`
  58. gnunet-abd --createSubjectSide --ego=f --import="$SIGNED" --private
  59. gnunet-namestore -D -z h
  60. # Starting to resolve
  61. echo "+++ Starting to Resolve +++"
  62. DELS=`$DO_TIMEOUT gnunet-abd --collect --issuer=$AKEY --attribute="a" --ego=f --forward --backward -c test_abd_lookup.conf | paste -d, -s - -`
  63. echo $DELS
  64. echo gnunet-abd --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate=\'$DELS\' --forward --backward -c test_abd_lookup.conf
  65. gnunet-abd --verify --issuer=$AKEY --attribute="a" --subject=$FKEY --delegate="$DELS" --forward --backward -c test_abd_lookup.conf
  66. RES=$?
  67. # Cleanup properly
  68. gnunet-namestore -z a -d -n "a" -t ATTR -c test_abd_lookup.conf
  69. gnunet-namestore -z b -d -n "b" -t ATTR -c test_abd_lookup.conf
  70. gnunet-namestore -z g -d -n "g" -t ATTR -c test_abd_lookup.conf
  71. gnunet-namestore -z d -d -n "@" -t DEL -c test_abd_lookup.conf
  72. gnunet-namestore -z e -d -n "@" -t DEL -c test_abd_lookup.conf
  73. gnunet-namestore -z f -d -n "@" -t DEL -c test_abd_lookup.conf
  74. gnunet-arm -e -c test_abd_lookup.conf
  75. if [ "$RES" == 0 ]
  76. then
  77. exit 0
  78. else
  79. echo "FAIL: Failed to verify credential."
  80. exit 1
  81. fi