diff options
author | Adnan H <acednan@gmail.com> | 2016-12-06 10:52:03 +0100 |
---|---|---|
committer | Adnan H <acednan@gmail.com> | 2016-12-06 10:52:03 +0100 |
commit | 3fff08922ed4362751dd9de52a369cc912e7fb5c (patch) | |
tree | 3486938c84e73c69a4e6fead65f6f9621cb16b24 /src/credential/gnunet-credential.c | |
parent | c0ccc8d723c94c6f9dbde6ed1e0ee6579989750c (diff) | |
parent | 97b457f5cbb8d4aeb7942ae23dc6dad84db30638 (diff) | |
download | gnunet-3fff08922ed4362751dd9de52a369cc912e7fb5c.tar.gz gnunet-3fff08922ed4362751dd9de52a369cc912e7fb5c.zip |
Merge branch 'credentials' of git+ssh://gnunet.org/gnunet into credentials
Diffstat (limited to 'src/credential/gnunet-credential.c')
-rw-r--r-- | src/credential/gnunet-credential.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/credential/gnunet-credential.c b/src/credential/gnunet-credential.c index a7b92447b..a2d494f2a 100644 --- a/src/credential/gnunet-credential.c +++ b/src/credential/gnunet-credential.c | |||
@@ -68,6 +68,11 @@ static char *subject_key; | |||
68 | static char *subject_credential; | 68 | static char *subject_credential; |
69 | 69 | ||
70 | /** | 70 | /** |
71 | * Credential TTL | ||
72 | */ | ||
73 | static char *expiration; | ||
74 | |||
75 | /** | ||
71 | * Subject key | 76 | * Subject key |
72 | */ | 77 | */ |
73 | struct GNUNET_CRYPTO_EcdsaPublicKey subject_pkey; | 78 | struct GNUNET_CRYPTO_EcdsaPublicKey subject_pkey; |
@@ -180,6 +185,8 @@ identity_cb (void *cls, | |||
180 | { | 185 | { |
181 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey; | 186 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey; |
182 | struct GNUNET_CREDENTIAL_CredentialRecordData *crd; | 187 | struct GNUNET_CREDENTIAL_CredentialRecordData *crd; |
188 | struct GNUNET_TIME_Absolute etime_abs; | ||
189 | struct GNUNET_TIME_Relative etime_rel; | ||
183 | char *res; | 190 | char *res; |
184 | 191 | ||
185 | el = NULL; | 192 | el = NULL; |
@@ -194,13 +201,35 @@ identity_cb (void *cls, | |||
194 | GNUNET_SCHEDULER_shutdown (); | 201 | GNUNET_SCHEDULER_shutdown (); |
195 | return; | 202 | return; |
196 | } | 203 | } |
204 | if (NULL == expiration) | ||
205 | { | ||
206 | fprintf (stderr, | ||
207 | "Please specify a TTL\n"); | ||
208 | GNUNET_SCHEDULER_shutdown (); | ||
209 | return; | ||
210 | } else if (GNUNET_OK == GNUNET_STRINGS_fancy_time_to_relative (expiration, | ||
211 | &etime_rel)) | ||
212 | { | ||
213 | etime_abs = GNUNET_TIME_relative_to_absolute (etime_rel); | ||
214 | } else if (GNUNET_OK != GNUNET_STRINGS_fancy_time_to_absolute (expiration, | ||
215 | &etime_abs)) | ||
216 | { | ||
217 | fprintf (stderr, | ||
218 | "%s is not a valid ttl!\n", | ||
219 | expiration); | ||
220 | GNUNET_SCHEDULER_shutdown (); | ||
221 | return; | ||
222 | } | ||
223 | |||
224 | |||
197 | privkey = GNUNET_IDENTITY_ego_get_private_key (ego); | 225 | privkey = GNUNET_IDENTITY_ego_get_private_key (ego); |
198 | GNUNET_free_non_null (issuer_ego_name); | 226 | GNUNET_free_non_null (issuer_ego_name); |
199 | issuer_ego_name = NULL; | 227 | issuer_ego_name = NULL; |
200 | crd = GNUNET_CREDENTIAL_issue (credential, | 228 | crd = GNUNET_CREDENTIAL_issue (credential, |
201 | privkey, | 229 | privkey, |
202 | &subject_pkey, | 230 | &subject_pkey, |
203 | issuer_attr); | 231 | issuer_attr, |
232 | &etime_abs); | ||
204 | res = GNUNET_GNSRECORD_value_to_string (GNUNET_GNSRECORD_TYPE_CREDENTIAL, | 233 | res = GNUNET_GNSRECORD_value_to_string (GNUNET_GNSRECORD_TYPE_CREDENTIAL, |
205 | crd, | 234 | crd, |
206 | sizeof (struct GNUNET_CREDENTIAL_CredentialRecordData) + strlen (issuer_attr) + 1); | 235 | sizeof (struct GNUNET_CREDENTIAL_CredentialRecordData) + strlen (issuer_attr) + 1); |
@@ -353,6 +382,9 @@ main (int argc, char *const *argv) | |||
353 | {'a', "attribute", "ATTR", | 382 | {'a', "attribute", "ATTR", |
354 | gettext_noop ("The issuer attribute to verify against or to issue"), 1, | 383 | gettext_noop ("The issuer attribute to verify against or to issue"), 1, |
355 | &GNUNET_GETOPT_set_string, &issuer_attr}, | 384 | &GNUNET_GETOPT_set_string, &issuer_attr}, |
385 | {'T', "ttl", "EXP", | ||
386 | gettext_noop ("The time to live for the credential"), 1, | ||
387 | &GNUNET_GETOPT_set_string, &expiration}, | ||
356 | GNUNET_GETOPT_OPTION_END | 388 | GNUNET_GETOPT_OPTION_END |
357 | }; | 389 | }; |
358 | int ret; | 390 | int ret; |