diff options
author | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2016-12-06 10:58:37 +0100 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2016-12-06 10:58:37 +0100 |
commit | 14045cba92ab8167e1371f2e2447a5bcdd71f12a (patch) | |
tree | b1fdbf9542442bcc26a921eca02b818a51135f89 /src/credential | |
parent | 3fff08922ed4362751dd9de52a369cc912e7fb5c (diff) | |
download | gnunet-14045cba92ab8167e1371f2e2447a5bcdd71f12a.tar.gz gnunet-14045cba92ab8167e1371f2e2447a5bcdd71f12a.zip |
-fix
Diffstat (limited to 'src/credential')
-rw-r--r-- | src/credential/plugin_gnsrecord_credential.c | 23 | ||||
-rwxr-xr-x | src/credential/test_credential_issue.sh | 12 |
2 files changed, 24 insertions, 11 deletions
diff --git a/src/credential/plugin_gnsrecord_credential.c b/src/credential/plugin_gnsrecord_credential.c index 60b677a4e..93d8b8e83 100644 --- a/src/credential/plugin_gnsrecord_credential.c +++ b/src/credential/plugin_gnsrecord_credential.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include "gnunet_gnsrecord_lib.h" | 29 | #include "gnunet_gnsrecord_lib.h" |
30 | #include "gnunet_credential_service.h" | 30 | #include "gnunet_credential_service.h" |
31 | #include "gnunet_gnsrecord_plugin.h" | 31 | #include "gnunet_gnsrecord_plugin.h" |
32 | #include "gnunet_signatures.h" | ||
32 | 33 | ||
33 | 34 | ||
34 | /** | 35 | /** |
@@ -96,12 +97,12 @@ credential_value_to_string (void *cls, | |||
96 | sizeof (struct GNUNET_CRYPTO_EcdsaSignature), | 97 | sizeof (struct GNUNET_CRYPTO_EcdsaSignature), |
97 | &signature); | 98 | &signature); |
98 | GNUNET_asprintf (&cred_str, | 99 | GNUNET_asprintf (&cred_str, |
99 | "%s.%s -> %s exp:%s sig:%s", | 100 | "%s.%s -> %s | %s | %s", |
100 | issuer_pkey, | 101 | issuer_pkey, |
101 | &cdata[sizeof (cred)], | 102 | &cdata[sizeof (cred)], |
102 | subject_pkey, | 103 | subject_pkey, |
103 | expiration, | 104 | signature, |
104 | signature); | 105 | expiration); |
105 | GNUNET_free (subject_pkey); | 106 | GNUNET_free (subject_pkey); |
106 | GNUNET_free (issuer_pkey); | 107 | GNUNET_free (issuer_pkey); |
107 | GNUNET_free (signature); | 108 | GNUNET_free (signature); |
@@ -153,18 +154,21 @@ credential_string_to_value (void *cls, | |||
153 | struct GNUNET_TIME_Absolute etime_abs; | 154 | struct GNUNET_TIME_Absolute etime_abs; |
154 | 155 | ||
155 | if (5 != SSCANF (s, | 156 | if (5 != SSCANF (s, |
156 | "%52s.%253s -> %52s exp:%255s sig:%127s", | 157 | "%52s.%253s -> %52s | %s | %255[0-9a-zA-Z: ]", |
157 | issuer_pkey, | 158 | issuer_pkey, |
158 | name, | 159 | name, |
159 | subject_pkey, | 160 | subject_pkey, |
160 | expiration, | 161 | signature, |
161 | signature)) | 162 | expiration)) |
162 | { | 163 | { |
163 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 164 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
164 | _("Unable to parse CRED record string `%s'\n"), | 165 | _("Unable to parse CRED record string `%s'\n"), |
165 | s); | 166 | s); |
166 | return GNUNET_SYSERR; | 167 | return GNUNET_SYSERR; |
167 | } | 168 | } |
169 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
170 | "Found %s, %s, %s, %s, %s\n", | ||
171 | issuer_pkey, name, subject_pkey, signature, expiration); | ||
168 | *data_size = sizeof (struct GNUNET_CREDENTIAL_CredentialRecordData) + strlen (name) + 1; | 172 | *data_size = sizeof (struct GNUNET_CREDENTIAL_CredentialRecordData) + strlen (name) + 1; |
169 | *data = cred = GNUNET_malloc (*data_size); | 173 | *data = cred = GNUNET_malloc (*data_size); |
170 | GNUNET_CRYPTO_ecdsa_public_key_from_string (subject_pkey, | 174 | GNUNET_CRYPTO_ecdsa_public_key_from_string (subject_pkey, |
@@ -179,15 +183,16 @@ credential_string_to_value (void *cls, | |||
179 | strlen (signature), | 183 | strlen (signature), |
180 | (char**)&sig); | 184 | (char**)&sig); |
181 | cred->sig = *sig; | 185 | cred->sig = *sig; |
182 | cred->expiration = htonl (etime_abs.abs_value_us); | 186 | cred->expiration = GNUNET_htonll (etime_abs.abs_value_us); |
187 | cred->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_CREDENTIAL); | ||
188 | cred->purpose.size = strlen (name) + 1 + sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose) + | ||
189 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey) + sizeof (uint64_t); | ||
183 | GNUNET_free (sig); | 190 | GNUNET_free (sig); |
184 | GNUNET_memcpy (&cred[1], | 191 | GNUNET_memcpy (&cred[1], |
185 | name, | 192 | name, |
186 | strlen (name)); | 193 | strlen (name)); |
187 | 194 | ||
188 | 195 | ||
189 | *data = GNUNET_strdup (s); | ||
190 | *data_size = strlen (s); | ||
191 | return GNUNET_OK; | 196 | return GNUNET_OK; |
192 | } | 197 | } |
193 | default: | 198 | default: |
diff --git a/src/credential/test_credential_issue.sh b/src/credential/test_credential_issue.sh index 4d1ba67c7..b2ced204a 100755 --- a/src/credential/test_credential_issue.sh +++ b/src/credential/test_credential_issue.sh | |||
@@ -29,8 +29,16 @@ gnunet-identity -C testsubject -c test_credential_lookup.conf | |||
29 | SUBJECT_KEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep testsubject | awk '{print $3}') | 29 | SUBJECT_KEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep testsubject | awk '{print $3}') |
30 | ISSUER_KEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep testissuer | awk '{print $3}') | 30 | ISSUER_KEY=$(gnunet-identity -d -c test_credential_lookup.conf | grep testissuer | awk '{print $3}') |
31 | #TODO1 Get credential and store it with subject (3) | 31 | #TODO1 Get credential and store it with subject (3) |
32 | $DO_TIMEOUT valgrind gnunet-credential --issue --ego=testissuer --subject=$SUBJECT_KEY --attribute=$TEST_ATTR --ttl=5m -c test_credential_lookup.conf | 32 | CRED=`$DO_TIMEOUT gnunet-credential --issue --ego=testissuer --subject=$SUBJECT_KEY --attribute=$TEST_ATTR --ttl=5m -c test_credential_lookup.conf` |
33 | STATUS=$? | 33 | STATUS=$? |
34 | 34 | ||
35 | if test $? != 0 | ||
36 | then | ||
37 | echo "Error issuing..." | ||
38 | exit 1 | ||
39 | fi | ||
40 | #Try import | ||
41 | $DO_TIMEOUT gnunet-namestore -a -z testsubject -n c1 -t CRED -V "$CRED" -e 5m -c test_credential_lookup.conf | ||
42 | |||
35 | gnunet-arm -e -c test_credential_lookup.conf | 43 | gnunet-arm -e -c test_credential_lookup.conf |
36 | exit $STATUS | 44 | exit $? |