aboutsummaryrefslogtreecommitdiff
path: root/src/credential
diff options
context:
space:
mode:
authorSchanzenbach, Martin <mschanzenbach@posteo.de>2016-12-05 21:55:23 +0100
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2016-12-05 21:55:23 +0100
commit6d96eb580bec0831222811f3841174c39e437709 (patch)
tree74c0626ea95d93a13f66db15f6b091eb220b0746 /src/credential
parente2351f98490794db3e04c83106899781feb3edf2 (diff)
downloadgnunet-6d96eb580bec0831222811f3841174c39e437709.tar.gz
gnunet-6d96eb580bec0831222811f3841174c39e437709.zip
- add signature to cred
Diffstat (limited to 'src/credential')
-rw-r--r--src/credential/plugin_gnsrecord_credential.c31
-rwxr-xr-xsrc/credential/test_credential_issue.sh13
2 files changed, 25 insertions, 19 deletions
diff --git a/src/credential/plugin_gnsrecord_credential.c b/src/credential/plugin_gnsrecord_credential.c
index 721e19fdb..f6aec9bcc 100644
--- a/src/credential/plugin_gnsrecord_credential.c
+++ b/src/credential/plugin_gnsrecord_credential.c
@@ -77,6 +77,8 @@ credential_value_to_string (void *cls,
77 char *cred_str; 77 char *cred_str;
78 char *subject_pkey; 78 char *subject_pkey;
79 char *issuer_pkey; 79 char *issuer_pkey;
80 char *signature;
81
80 if (data_size < sizeof (struct GNUNET_CREDENTIAL_CredentialRecordData)) 82 if (data_size < sizeof (struct GNUNET_CREDENTIAL_CredentialRecordData))
81 return NULL; /* malformed */ 83 return NULL; /* malformed */
82 memcpy (&cred, 84 memcpy (&cred,
@@ -85,15 +87,18 @@ credential_value_to_string (void *cls,
85 cdata = data; 87 cdata = data;
86 subject_pkey = GNUNET_CRYPTO_ecdsa_public_key_to_string (&cred.subject_key); 88 subject_pkey = GNUNET_CRYPTO_ecdsa_public_key_to_string (&cred.subject_key);
87 issuer_pkey = GNUNET_CRYPTO_ecdsa_public_key_to_string (&cred.issuer_key); 89 issuer_pkey = GNUNET_CRYPTO_ecdsa_public_key_to_string (&cred.issuer_key);
88 90 GNUNET_STRINGS_base64_encode ((char*)&cred.sig,
91 sizeof (struct GNUNET_CRYPTO_EcdsaSignature),
92 &signature);
89 GNUNET_asprintf (&cred_str, 93 GNUNET_asprintf (&cred_str,
90 "%s %s %s", 94 "%s.%s -> %s sig:%s",
91 subject_pkey,
92 issuer_pkey, 95 issuer_pkey,
93 &cdata[sizeof (cred)]); 96 &cdata[sizeof (cred)],
97 subject_pkey,
98 signature);
94 GNUNET_free (subject_pkey); 99 GNUNET_free (subject_pkey);
95 GNUNET_free (issuer_pkey); 100 GNUNET_free (issuer_pkey);
96 101 GNUNET_free (signature);
97 return cred_str; 102 return cred_str;
98 } 103 }
99 default: 104 default:
@@ -135,12 +140,15 @@ credential_string_to_value (void *cls,
135 char subject_pkey[enclen + 1]; 140 char subject_pkey[enclen + 1];
136 char issuer_pkey[enclen + 1]; 141 char issuer_pkey[enclen + 1];
137 char name[253 + 1]; 142 char name[253 + 1];
143 char signature[128]; //TODO max payload size
144 struct GNUNET_CRYPTO_EcdsaSignature *sig;
138 145
139 if (3 != SSCANF (s, 146 if (4 != SSCANF (s,
140 "%52s %52s %253s", 147 "%52s.%253s -> %52s sig:%s",
141 subject_pkey,
142 issuer_pkey, 148 issuer_pkey,
143 name)) 149 name,
150 subject_pkey,
151 signature))
144 { 152 {
145 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 153 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
146 _("Unable to parse CRED record string `%s'\n"), 154 _("Unable to parse CRED record string `%s'\n"),
@@ -155,6 +163,11 @@ credential_string_to_value (void *cls,
155 GNUNET_CRYPTO_ecdsa_public_key_from_string (issuer_pkey, 163 GNUNET_CRYPTO_ecdsa_public_key_from_string (issuer_pkey,
156 strlen (issuer_pkey), 164 strlen (issuer_pkey),
157 &cred->issuer_key); 165 &cred->issuer_key);
166 GNUNET_STRINGS_base64_decode (signature,
167 strlen (signature),
168 (char**)&sig);
169 cred->sig = *sig;
170 GNUNET_free (sig);
158 GNUNET_memcpy (&cred[1], 171 GNUNET_memcpy (&cred[1],
159 name, 172 name,
160 strlen (name)); 173 strlen (name));
diff --git a/src/credential/test_credential_issue.sh b/src/credential/test_credential_issue.sh
index a78bde6ed..95eac2957 100755
--- a/src/credential/test_credential_issue.sh
+++ b/src/credential/test_credential_issue.sh
@@ -28,16 +28,9 @@ gnunet-identity -C testissuer -c test_credential_lookup.conf
28gnunet-identity -C testsubject -c test_credential_lookup.conf 28gnunet-identity -C testsubject -c test_credential_lookup.conf
29SUBJECT_KEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep testsubject | awk '{print $3}') 29SUBJECT_KEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep testsubject | awk '{print $3}')
30ISSUER_KEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep testissuer | awk '{print $3}') 30ISSUER_KEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep testissuer | awk '{print $3}')
31EXPECTED="$SUBJECT_KEY $ISSUER_KEY $TEST_ATTR"
32#TODO1 Get credential and store it with subject (3) 31#TODO1 Get credential and store it with subject (3)
33CRED=`$DO_TIMEOUT gnunet-credential --issue --ego=testissuer --subject=$SUBJECT_KEY --attribute=$TEST_ATTR -c test_credential_lookup.conf` 32$DO_TIMEOUT gnunet-credential --issue --ego=testissuer --subject=$SUBJECT_KEY --attribute=$TEST_ATTR -c test_credential_lookup.conf
33STATUS=$?
34 34
35gnunet-arm -e -c test_credential_lookup.conf 35gnunet-arm -e -c test_credential_lookup.conf
36 36exit $STATUS
37if [ "$EXPECTED" == "$CRED" ]
38then
39 exit 0
40else
41 echo "FAIL: Failed to issue credential, got $CRED."
42 exit 1
43fi