diff options
author | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2016-12-06 10:09:21 +0100 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2016-12-06 10:09:21 +0100 |
commit | 10b2bbf99b0dc611a735ad0a04d3ab5109a090f0 (patch) | |
tree | c7cd07943c91d5a995aaca588259069449cbd7b3 /src/credential/gnunet-credential.c | |
parent | 8c1425aa729914e0b2695fcab1ce29ea0aebffbb (diff) | |
download | gnunet-10b2bbf99b0dc611a735ad0a04d3ab5109a090f0.tar.gz gnunet-10b2bbf99b0dc611a735ad0a04d3ab5109a090f0.zip |
-add expiration to cred
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; |