test_abd_own.sh 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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 d -c test_abd_lookup.conf
  19. gnunet-identity -C e -c test_abd_lookup.conf
  20. gnunet-identity -C f -c test_abd_lookup.conf
  21. gnunet-identity -C g -c test_abd_lookup.conf
  22. AKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep a | awk '{print $3}')
  23. DKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep d | awk '{print $3}')
  24. EKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep e | awk '{print $3}')
  25. FKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep f | awk '{print $3}')
  26. GKEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep g | awk '{print $3}')
  27. ############################################################################################
  28. # (1) EPub.discount <- EOrg.preferred
  29. # (2) EOrg.preferred <- StateU.student
  30. # (3) StateU.student <- RegistrarB.student
  31. # (4) RegistrarB.student <- Alice
  32. gnunet-identity -C epub -c test_abd_lookup.conf
  33. gnunet-identity -C eorg -c test_abd_lookup.conf
  34. gnunet-identity -C stateu -c test_abd_lookup.conf
  35. gnunet-identity -C registrarb -c test_abd_lookup.conf
  36. gnunet-identity -C alice -c test_abd_lookup.conf
  37. EPUB_KEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep epub | awk '{print $3}')
  38. EORG_KEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep eorg | awk '{print $3}')
  39. STATEU_KEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep stateu | awk '{print $3}')
  40. REGISTRARB_KEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep registrarb | awk '{print $3}')
  41. ALICE_KEY=$(gnunet-identity -d -c test_abd_lookup.conf | grep alice | awk '{print $3}')
  42. DISC_ATTR="discount"
  43. PREF_ATTR="preferred"
  44. STATE_STUD_ATTR="student"
  45. REG_STUD_ATTR="student"
  46. END_ATTR="end"
  47. gnunet-identity -d
  48. # FORWARD, subject side stored (different constellations)
  49. SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=a --attribute="a" --subject="$AKEY b.c" --ttl="2019-12-12 10:00:00"`
  50. gnunet-abd --createSubjectSide --ego=a --import="$SIGNED"
  51. gnunet-namestore -D -z a
  52. SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=a --attribute="b" --subject="$DKEY d" --ttl="2019-12-12 10:00:00"`
  53. gnunet-abd --createSubjectSide --ego=d --import="$SIGNED"
  54. gnunet-namestore -D -z d
  55. SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=d --attribute="d" --subject="$EKEY" --ttl="2019-12-12 10:00:00"`
  56. gnunet-abd --createSubjectSide --ego=e --import="$SIGNED"
  57. gnunet-namestore -D -z e
  58. SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=e --attribute="c" --subject="$FKEY c" --ttl="2019-12-12 10:00:00"`
  59. gnunet-abd --createSubjectSide --ego=f --import="$SIGNED"
  60. SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=e --attribute="k" --subject="$FKEY c.k" --ttl="2019-12-12 10:00:00"`
  61. gnunet-abd --createSubjectSide --ego=f --import="$SIGNED"
  62. gnunet-namestore -D -z f
  63. SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=f --attribute="c" --subject="$GKEY" --ttl="2019-12-12 10:00:00"`
  64. gnunet-abd --createSubjectSide --ego=g --import="$SIGNED" --private
  65. SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=a --attribute="c" --subject="$GKEY" --ttl="2019-12-12 10:00:00"`
  66. gnunet-abd --createSubjectSide --ego=g --import="$SIGNED" --private
  67. SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=d --attribute="h.o" --subject="$GKEY" --ttl="2019-12-12 10:00:00"`
  68. gnunet-abd --createSubjectSide --ego=g --import="$SIGNED"
  69. gnunet-namestore -D -z g
  70. # BACKWARD, issuer side stored
  71. # (1) EPub assigns the attribute "discount" to all entities that have been assigned "preferred" by EOrg
  72. gnunet-abd --createIssuerSide --ego=epub --attribute=$DISC_ATTR --subject="$EORG_KEY $PREF_ATTR" --ttl=5m -c test_abd_lookup.conf
  73. # (2) EOrg assigns the attribute "preferred" to all entities that have been assigned "student" by StateU
  74. gnunet-abd --createIssuerSide --ego=eorg --attribute=$PREF_ATTR --subject="$STATEU_KEY $STATE_STUD_ATTR" --ttl=5m -c test_abd_lookup.conf
  75. # (3) StateU assigns the attribute "student" to all entities that have been asssigned "student" by RegistrarB
  76. gnunet-abd --createIssuerSide --ego=stateu --attribute=$STATE_STUD_ATTR --subject="$REGISTRARB_KEY $REG_STUD_ATTR" --ttl=5m -c test_abd_lookup.conf
  77. # (4) RegistrarB issues Alice the credential "student"
  78. SIGNED=`$DO_TIMEOUT gnunet-abd --signSubjectSide --ego=registrarb --attribute="$REG_STUD_ATTR" --subject="$ALICE_KEY" --ttl="2019-12-12 10:00:00"`
  79. gnunet-abd --createSubjectSide --ego=alice --import="$SIGNED" --private
  80. # Starting to resolve
  81. echo "+++ Starting to Resolve +++"
  82. # FORWARD
  83. #DELS=`$DO_TIMEOUT gnunet-abd --collect --issuer=$AKEY --attribute="a" --ego=g --forward -c test_abd_lookup.conf | paste -d, -s - -`
  84. #echo $DELS
  85. #echo gnunet-abd --verify --issuer=$AKEY --attribute="a" --subject=$GKEY --delegate=\'$DELS\' --forward -c test_abd_lookup.conf
  86. #RES_DELS=`gnunet-abd --verify --issuer=$AKEY --attribute="a" --subject=$GKEY --delegate="$DELS" --forward -c test_abd_lookup.conf`
  87. # BACKWARD
  88. DELS=`$DO_TIMEOUT gnunet-abd --collect --issuer=$EPUB_KEY --attribute=$DISC_ATTR --ego=alice --backward -c test_abd_lookup.conf | paste -d, -s - -`
  89. echo $DELS
  90. echo gnunet-abd --verify --issuer=$EPUB_KEY --attribute=$DISC_ATTR --subject=$ALICE_KEY --delegate=\'$DELS\' --backward -c test_abd_lookup.conf
  91. gnunet-abd --verify --issuer=$EPUB_KEY --attribute=$DISC_ATTR --subject=$ALICE_KEY --delegate="$DELS" --backward -c test_abd_lookup.conf
  92. RES=$?
  93. # Cleanup properly
  94. gnunet-namestore -z epub -d -n $DISC_ATTR -t ATTR -c test_abd_lookup.conf
  95. gnunet-namestore -z eorg -d -n $PREF_ATTR -t ATTR -c test_abd_lookup.conf
  96. gnunet-namestore -z stateu -d -n $STATE_STUD_ATTR -t ATTR -c test_abd_lookup.conf
  97. #gnunet-namestore -z a -d -n "@" -t DEL -c test_abd_lookup.conf
  98. #gnunet-namestore -z d -d -n "@" -t DEL -c test_abd_lookup.conf
  99. #gnunet-namestore -z e -d -n "@" -t DEL -c test_abd_lookup.conf
  100. #gnunet-namestore -z f -d -n "@" -t DEL -c test_abd_lookup.conf
  101. #gnunet-namestore -z g -d -n "@" -t DEL -c test_abd_lookup.conf
  102. gnunet-arm -e -c test_abd_lookup.conf
  103. if [ "$RES" == 0 ]
  104. then
  105. exit 0
  106. else
  107. echo "FAIL: Failed to verify credential."
  108. exit 1
  109. fi