diff options
Diffstat (limited to 'src/credential/plugin_gnsrecord_credential.c')
-rw-r--r-- | src/credential/plugin_gnsrecord_credential.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/credential/plugin_gnsrecord_credential.c b/src/credential/plugin_gnsrecord_credential.c index f6aec9bcc..60b677a4e 100644 --- a/src/credential/plugin_gnsrecord_credential.c +++ b/src/credential/plugin_gnsrecord_credential.c | |||
@@ -74,10 +74,13 @@ credential_value_to_string (void *cls, | |||
74 | case GNUNET_GNSRECORD_TYPE_CREDENTIAL: | 74 | case GNUNET_GNSRECORD_TYPE_CREDENTIAL: |
75 | { | 75 | { |
76 | struct GNUNET_CREDENTIAL_CredentialRecordData cred; | 76 | struct GNUNET_CREDENTIAL_CredentialRecordData cred; |
77 | struct GNUNET_TIME_Absolute etime_abs; | ||
77 | char *cred_str; | 78 | char *cred_str; |
78 | char *subject_pkey; | 79 | char *subject_pkey; |
79 | char *issuer_pkey; | 80 | char *issuer_pkey; |
80 | char *signature; | 81 | char *signature; |
82 | const char *expiration; | ||
83 | |||
81 | 84 | ||
82 | if (data_size < sizeof (struct GNUNET_CREDENTIAL_CredentialRecordData)) | 85 | if (data_size < sizeof (struct GNUNET_CREDENTIAL_CredentialRecordData)) |
83 | return NULL; /* malformed */ | 86 | return NULL; /* malformed */ |
@@ -87,14 +90,17 @@ credential_value_to_string (void *cls, | |||
87 | cdata = data; | 90 | cdata = data; |
88 | subject_pkey = GNUNET_CRYPTO_ecdsa_public_key_to_string (&cred.subject_key); | 91 | subject_pkey = GNUNET_CRYPTO_ecdsa_public_key_to_string (&cred.subject_key); |
89 | issuer_pkey = GNUNET_CRYPTO_ecdsa_public_key_to_string (&cred.issuer_key); | 92 | issuer_pkey = GNUNET_CRYPTO_ecdsa_public_key_to_string (&cred.issuer_key); |
93 | etime_abs.abs_value_us = GNUNET_ntohll(cred.expiration); | ||
94 | expiration = GNUNET_STRINGS_absolute_time_to_string (etime_abs); | ||
90 | GNUNET_STRINGS_base64_encode ((char*)&cred.sig, | 95 | GNUNET_STRINGS_base64_encode ((char*)&cred.sig, |
91 | sizeof (struct GNUNET_CRYPTO_EcdsaSignature), | 96 | sizeof (struct GNUNET_CRYPTO_EcdsaSignature), |
92 | &signature); | 97 | &signature); |
93 | GNUNET_asprintf (&cred_str, | 98 | GNUNET_asprintf (&cred_str, |
94 | "%s.%s -> %s sig:%s", | 99 | "%s.%s -> %s exp:%s sig:%s", |
95 | issuer_pkey, | 100 | issuer_pkey, |
96 | &cdata[sizeof (cred)], | 101 | &cdata[sizeof (cred)], |
97 | subject_pkey, | 102 | subject_pkey, |
103 | expiration, | ||
98 | signature); | 104 | signature); |
99 | GNUNET_free (subject_pkey); | 105 | GNUNET_free (subject_pkey); |
100 | GNUNET_free (issuer_pkey); | 106 | GNUNET_free (issuer_pkey); |
@@ -141,13 +147,17 @@ credential_string_to_value (void *cls, | |||
141 | char issuer_pkey[enclen + 1]; | 147 | char issuer_pkey[enclen + 1]; |
142 | char name[253 + 1]; | 148 | char name[253 + 1]; |
143 | char signature[128]; //TODO max payload size | 149 | char signature[128]; //TODO max payload size |
150 | char expiration[256]; | ||
151 | |||
144 | struct GNUNET_CRYPTO_EcdsaSignature *sig; | 152 | struct GNUNET_CRYPTO_EcdsaSignature *sig; |
153 | struct GNUNET_TIME_Absolute etime_abs; | ||
145 | 154 | ||
146 | if (4 != SSCANF (s, | 155 | if (5 != SSCANF (s, |
147 | "%52s.%253s -> %52s sig:%s", | 156 | "%52s.%253s -> %52s exp:%255s sig:%127s", |
148 | issuer_pkey, | 157 | issuer_pkey, |
149 | name, | 158 | name, |
150 | subject_pkey, | 159 | subject_pkey, |
160 | expiration, | ||
151 | signature)) | 161 | signature)) |
152 | { | 162 | { |
153 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 163 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -163,10 +173,13 @@ credential_string_to_value (void *cls, | |||
163 | GNUNET_CRYPTO_ecdsa_public_key_from_string (issuer_pkey, | 173 | GNUNET_CRYPTO_ecdsa_public_key_from_string (issuer_pkey, |
164 | strlen (issuer_pkey), | 174 | strlen (issuer_pkey), |
165 | &cred->issuer_key); | 175 | &cred->issuer_key); |
176 | GNUNET_STRINGS_fancy_time_to_absolute (expiration, | ||
177 | &etime_abs); | ||
166 | GNUNET_STRINGS_base64_decode (signature, | 178 | GNUNET_STRINGS_base64_decode (signature, |
167 | strlen (signature), | 179 | strlen (signature), |
168 | (char**)&sig); | 180 | (char**)&sig); |
169 | cred->sig = *sig; | 181 | cred->sig = *sig; |
182 | cred->expiration = htonl (etime_abs.abs_value_us); | ||
170 | GNUNET_free (sig); | 183 | GNUNET_free (sig); |
171 | GNUNET_memcpy (&cred[1], | 184 | GNUNET_memcpy (&cred[1], |
172 | name, | 185 | name, |