aboutsummaryrefslogtreecommitdiff
path: root/src/credential/plugin_gnsrecord_credential.c
diff options
context:
space:
mode:
authorSchanzenbach, Martin <mschanzenbach@posteo.de>2016-12-06 10:58:37 +0100
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2016-12-06 10:58:37 +0100
commit14045cba92ab8167e1371f2e2447a5bcdd71f12a (patch)
treeb1fdbf9542442bcc26a921eca02b818a51135f89 /src/credential/plugin_gnsrecord_credential.c
parent3fff08922ed4362751dd9de52a369cc912e7fb5c (diff)
downloadgnunet-14045cba92ab8167e1371f2e2447a5bcdd71f12a.tar.gz
gnunet-14045cba92ab8167e1371f2e2447a5bcdd71f12a.zip
-fix
Diffstat (limited to 'src/credential/plugin_gnsrecord_credential.c')
-rw-r--r--src/credential/plugin_gnsrecord_credential.c23
1 files changed, 14 insertions, 9 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: