aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSchanzenbach, Martin <mschanzenbach@posteo.de>2016-12-07 16:43:35 +0100
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2016-12-07 16:43:35 +0100
commitd0f60b23e15edfd27a0885a3cd0bd6daa765cde3 (patch)
tree00b1a3c43df5cebd5e5d06e9e68a5723ba05f633 /src
parent472380f62852feed2cacff57c70f1c888bc3b9e6 (diff)
downloadgnunet-d0f60b23e15edfd27a0885a3cd0bd6daa765cde3.tar.gz
gnunet-d0f60b23e15edfd27a0885a3cd0bd6daa765cde3.zip
- fix; more recognizable case in test
Diffstat (limited to 'src')
-rw-r--r--src/credential/gnunet-service-credential.c11
-rwxr-xr-xsrc/credential/test_credential_verify.sh59
2 files changed, 46 insertions, 24 deletions
diff --git a/src/credential/gnunet-service-credential.c b/src/credential/gnunet-service-credential.c
index 9f7b60f1f..f07c777d6 100644
--- a/src/credential/gnunet-service-credential.c
+++ b/src/credential/gnunet-service-credential.c
@@ -476,11 +476,16 @@ start_backward_resolution (void* cls,
476 strcpy (issuer_attribute_name, 476 strcpy (issuer_attribute_name,
477 (char*)&vrh->current_attribute->data[1]); 477 (char*)&vrh->current_attribute->data[1]);
478 char *next_attr = strtok (issuer_attribute_name, "."); 478 char *next_attr = strtok (issuer_attribute_name, ".");
479 GNUNET_asprintf (&lookup_attr, 479 GNUNET_asprintf (&lookup_attr,
480 "%s.gnu", 480 "%s.gnu",
481 next_attr); 481 next_attr);
482 next_attr += strlen (next_attr) + 1; 482 if (strlen (next_attr) == strlen ((char*)&vrh->current_attribute->data[1]))
483 vrh->current_attribute->attr_trailer = GNUNET_strdup (next_attr); 483 {
484 vrh->current_attribute->attr_trailer = NULL;
485 } else {
486 next_attr += strlen (next_attr) + 1;
487 vrh->current_attribute->attr_trailer = GNUNET_strdup (next_attr);
488 }
484 489
485 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 490 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
486 "Looking up %s\n", lookup_attr); 491 "Looking up %s\n", lookup_attr);
diff --git a/src/credential/test_credential_verify.sh b/src/credential/test_credential_verify.sh
index ab3c78f41..3b76d20e5 100755
--- a/src/credential/test_credential_verify.sh
+++ b/src/credential/test_credential_verify.sh
@@ -15,39 +15,56 @@ fi
15 15
16rm -rf `gnunet-config -c test_credential_lookup.conf -s PATHS -o GNUNET_HOME -f` 16rm -rf `gnunet-config -c test_credential_lookup.conf -s PATHS -o GNUNET_HOME -f`
17 17
18# (1) Authority.test -> Intermediate.org.user 18# (1) Service.user -> GNU.project.member
19# (2) Intermediate.org -> Issuer 19# (2) GNU.project -> GNUnet
20# (3) Issuer.user -> Subject 20# (3) GNUnet.member -> GNUnet.developer
21# (4) GNUnet.member -> GNUnet.user
22# (5) GNUnet.developer -> Alice
21 23
22 24
23which timeout &> /dev/null && DO_TIMEOUT="timeout 30" 25which timeout &> /dev/null && DO_TIMEOUT="timeout 30"
24gnunet-arm -s -c test_credential_lookup.conf 26gnunet-arm -s -c test_credential_lookup.conf
25gnunet-identity -C testissuer -c test_credential_lookup.conf 27gnunet-identity -C service -c test_credential_lookup.conf
26gnunet-identity -C testsubject -c test_credential_lookup.conf 28gnunet-identity -C alice -c test_credential_lookup.conf
27gnunet-identity -C testintermediate -c test_credential_lookup.conf 29gnunet-identity -C gnu -c test_credential_lookup.conf
28gnunet-identity -C testauthority -c test_credential_lookup.conf 30gnunet-identity -C gnunet -c test_credential_lookup.conf
29 31
30TEST_ATTR="user" 32GNU_KEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep gnu | grep -v gnunet | awk '{print $3}')
31INTERMEDIATE_KEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep testintermediate | awk '{print $3}') 33ALICE_KEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep alice | awk '{print $3}')
32SUBJECT_KEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep testsubject | awk '{print $3}') 34GNUNET_KEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep gnunet | awk '{print $3}')
33ISSUER_KEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep testissuer | awk '{print $3}') 35SERVICE_KEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep service | awk '{print $3}')
34AUTHORITY_KEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep testauthority | awk '{print $3}')
35CRED=`$DO_TIMEOUT gnunet-credential --issue --ego=testissuer --subject=$SUBJECT_KEY --attribute=$TEST_ATTR --ttl=5m -c test_credential_lookup.conf`
36 36
37TEST_CREDENTIAL="t1" 37USER_ATTR="user"
38gnunet-namestore -p -z testsubject -a -n $TEST_CREDENTIAL -t CRED -V "$CRED" -e 5m -c test_credential_lookup.conf 38GNU_PROJECT_ATTR="project"
39MEMBER_ATTR="member"
40DEVELOPER_ATTR="developer"
41DEV_ATTR="developer"
42TEST_CREDENTIAL="mygnunetcreds"
39 43
40INTERMEDIATE_ATTR="org" 44# (1) A service assigns the attribute "user" to all entities that have been assigned "member" by entities that werde assigned "project" from GNU
41gnunet-namestore -p -z testintermediate -a -n $INTERMEDIATE_ATTR -t ATTR -V "$ISSUER_KEY" -e 5m -c test_credential_lookup.conf 45gnunet-namestore -p -z service -a -n $USER_ATTR -t ATTR -V "$GNU_KEY $GNU_PROJECT_ATTR.$MEMBER_ATTR" -e 5m -c test_credential_lookup.conf
42 46
43AUTHORITY_ATTR="test" 47# (2) GNU recognized GNUnet as a GNU project and delegates the "project" attribute
44gnunet-namestore -p -z testauthority -a -n $AUTHORITY_ATTR -t ATTR -V "$INTERMEDIATE_KEY $INTERMEDIATE_ATTR.$TEST_ATTR" -e 5m -c test_credential_lookup.conf 48gnunet-namestore -p -z gnu -a -n $GNU_PROJECT_ATTR -t ATTR -V "$GNUNET_KEY" -e 5m -c test_credential_lookup.conf
49
50# (3+4) GNUnet assigns the attribute "member" to all entities gnunet has also assigned "developer" or "user"
51gnunet-namestore -p -z gnunet -a -n $MEMBER_ATTR -t ATTR -V "$GNUNET_KEY $DEVELOPER_ATTR" -e 5m -c test_credential_lookup.conf
52gnunet-namestore -p -z gnunet -a -n $MEMBER_ATTR -t ATTR -V "$GNUNET_KEY $USER_ATTR" -e 5m -c test_credential_lookup.conf
53
54# (5) GNUnet issues Alice the credential "developer"
55CRED=`$DO_TIMEOUT gnunet-credential --issue --ego=gnunet --subject=$ALICE_KEY --attribute=$DEV_ATTR --ttl=5m -c test_credential_lookup.conf`
56
57# Alice stores the credential under "mygnunetcreds"
58gnunet-namestore -p -z alice -a -n $TEST_CREDENTIAL -t CRED -V "$CRED" -e 5m -c test_credential_lookup.conf
45 59
46#TODO2 Add -z swich like in gnunet-gns 60#TODO2 Add -z swich like in gnunet-gns
47RES_CRED=`gnunet-credential --verify --issuer=$AUTHORITY_KEY --attribute=$AUTHORITY_ATTR --subject=$SUBJECT_KEY --credential=$TEST_CREDENTIAL -c test_credential_lookup.conf` 61RES_CRED=`gnunet-credential --verify --issuer=$SERVICE_KEY --attribute=$USER_ATTR --subject=$ALICE_KEY --credential=$TEST_CREDENTIAL -c test_credential_lookup.conf`
48 62
49#TODO cleanup properly 63#TODO cleanup properly
50gnunet-namestore -z testsubject -d -n $TEST_CREDENTIAL -t CRED -e never -c test_credential_lookup.conf 64gnunet-namestore -z alice -d -n $TEST_CREDENTIAL -t CRED -e never -c test_credential_lookup.conf
65gnunet-namestore -z gnu -d -n $GNU_PROJECT_ATTR -t ATTR -c test_credential_lookup.conf
66gnunet-namestore -z gnunet -d -n $MEMBER_ATTR -t ATTR -c test_credential_lookup.conf
67gnunet-namestore -z service -d -n $USER_ATTR -t ATTR -c test_credential_lookup.conf
51gnunet-arm -e -c test_credential_lookup.conf 68gnunet-arm -e -c test_credential_lookup.conf
52 69
53if [ "$RES_CRED" == "Successful." ] 70if [ "$RES_CRED" == "Successful." ]