diff options
Diffstat (limited to 'src/identity-token/gnunet-service-identity-token.c')
-rw-r--r-- | src/identity-token/gnunet-service-identity-token.c | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/src/identity-token/gnunet-service-identity-token.c b/src/identity-token/gnunet-service-identity-token.c index 00fc25852..039d1c7e0 100644 --- a/src/identity-token/gnunet-service-identity-token.c +++ b/src/identity-token/gnunet-service-identity-token.c | |||
@@ -30,7 +30,7 @@ | |||
30 | #include "gnunet_namestore_service.h" | 30 | #include "gnunet_namestore_service.h" |
31 | #include <jansson.h> | 31 | #include <jansson.h> |
32 | #include "gnunet_signatures.h" | 32 | #include "gnunet_signatures.h" |
33 | #include "identity-token.h" | 33 | #include "gnunet_identity_provider_lib.h" |
34 | 34 | ||
35 | /** | 35 | /** |
36 | * First pass state | 36 | * First pass state |
@@ -102,7 +102,7 @@ static struct GNUNET_TIME_Relative min_rel_exp; | |||
102 | /** | 102 | /** |
103 | * Currently processed token | 103 | * Currently processed token |
104 | */ | 104 | */ |
105 | static struct IdentityToken *token; | 105 | static struct GNUNET_IDENTITY_PROVIDER_Token *token; |
106 | 106 | ||
107 | /** | 107 | /** |
108 | * Label for currently processed token | 108 | * Label for currently processed token |
@@ -201,9 +201,8 @@ handle_token_update (void *cls, | |||
201 | char *write_ptr; | 201 | char *write_ptr; |
202 | char *enc_token_str; | 202 | char *enc_token_str; |
203 | const char *key; | 203 | const char *key; |
204 | const char *iss; | ||
205 | const char *aud; | ||
206 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key; | 204 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key; |
205 | struct GNUNET_CRYPTO_EcdsaPublicKey pub_key; | ||
207 | struct GNUNET_CRYPTO_EcdhePrivateKey *new_ecdhe_privkey; | 206 | struct GNUNET_CRYPTO_EcdhePrivateKey *new_ecdhe_privkey; |
208 | struct EgoEntry *ego_entry = cls; | 207 | struct EgoEntry *ego_entry = cls; |
209 | struct GNUNET_GNSRECORD_Data token_record[2]; | 208 | struct GNUNET_GNSRECORD_Data token_record[2]; |
@@ -215,7 +214,7 @@ handle_token_update (void *cls, | |||
215 | struct GNUNET_TIME_Absolute new_exp; | 214 | struct GNUNET_TIME_Absolute new_exp; |
216 | struct GNUNET_TIME_Absolute new_iat; | 215 | struct GNUNET_TIME_Absolute new_iat; |
217 | struct GNUNET_TIME_Absolute new_nbf; | 216 | struct GNUNET_TIME_Absolute new_nbf; |
218 | struct IdentityToken *new_token; | 217 | struct GNUNET_IDENTITY_PROVIDER_Token *new_token; |
219 | json_t *payload_json; | 218 | json_t *payload_json; |
220 | json_t *value; | 219 | json_t *value; |
221 | json_t *cur_value; | 220 | json_t *cur_value; |
@@ -224,6 +223,8 @@ handle_token_update (void *cls, | |||
224 | size_t token_metadata_len; | 223 | size_t token_metadata_len; |
225 | 224 | ||
226 | priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); | 225 | priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); |
226 | GNUNET_IDENTITY_ego_get_public_key (ego_entry->ego, | ||
227 | &pub_key); | ||
227 | 228 | ||
228 | //Note: We need the token expiration time here. Not the record expiration | 229 | //Note: We need the token expiration time here. Not the record expiration |
229 | //time. | 230 | //time. |
@@ -262,9 +263,8 @@ handle_token_update (void *cls, | |||
262 | } | 263 | } |
263 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 264 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
264 | "Token is expired. Create a new one\n"); | 265 | "Token is expired. Create a new one\n"); |
265 | iss = json_string_value (json_object_get (payload_json, "iss")); | 266 | new_token = GNUNET_IDENTITY_PROVIDER_token_create (&pub_key, |
266 | aud = json_string_value (json_object_get (payload_json, "aud")); | 267 | &token->aud_key); |
267 | new_token = identity_token_create (iss, aud); | ||
268 | new_exp = GNUNET_TIME_relative_to_absolute (token_rel_exp); | 268 | new_exp = GNUNET_TIME_relative_to_absolute (token_rel_exp); |
269 | new_nbf = GNUNET_TIME_absolute_get (); | 269 | new_nbf = GNUNET_TIME_absolute_get (); |
270 | new_iat = new_nbf; | 270 | new_iat = new_nbf; |
@@ -272,15 +272,15 @@ handle_token_update (void *cls, | |||
272 | json_object_foreach(payload_json, key, value) { | 272 | json_object_foreach(payload_json, key, value) { |
273 | if (0 == strcmp (key, "exp")) | 273 | if (0 == strcmp (key, "exp")) |
274 | { | 274 | { |
275 | identity_token_add_json (new_token, key, json_integer (new_exp.abs_value_us)); | 275 | GNUNET_IDENTITY_PROVIDER_token_add_json (new_token, key, json_integer (new_exp.abs_value_us)); |
276 | } | 276 | } |
277 | else if (0 == strcmp (key, "nbf")) | 277 | else if (0 == strcmp (key, "nbf")) |
278 | { | 278 | { |
279 | identity_token_add_json (new_token, key, json_integer (new_nbf.abs_value_us)); | 279 | GNUNET_IDENTITY_PROVIDER_token_add_json (new_token, key, json_integer (new_nbf.abs_value_us)); |
280 | } | 280 | } |
281 | else if (0 == strcmp (key, "iat")) | 281 | else if (0 == strcmp (key, "iat")) |
282 | { | 282 | { |
283 | identity_token_add_json (new_token, key, json_integer (new_iat.abs_value_us)); | 283 | GNUNET_IDENTITY_PROVIDER_token_add_json (new_token, key, json_integer (new_iat.abs_value_us)); |
284 | } | 284 | } |
285 | else if ((0 == strcmp (key, "iss")) | 285 | else if ((0 == strcmp (key, "iss")) |
286 | || (0 == strcmp (key, "aud"))) | 286 | || (0 == strcmp (key, "aud"))) |
@@ -290,7 +290,7 @@ handle_token_update (void *cls, | |||
290 | else if ((0 == strcmp (key, "sub")) | 290 | else if ((0 == strcmp (key, "sub")) |
291 | || (0 == strcmp (key, "rnl"))) | 291 | || (0 == strcmp (key, "rnl"))) |
292 | { | 292 | { |
293 | identity_token_add_json (new_token, key, value); | 293 | GNUNET_IDENTITY_PROVIDER_token_add_json (new_token, key, value); |
294 | } | 294 | } |
295 | else { | 295 | else { |
296 | GNUNET_CRYPTO_hash (key, | 296 | GNUNET_CRYPTO_hash (key, |
@@ -302,16 +302,16 @@ handle_token_update (void *cls, | |||
302 | { | 302 | { |
303 | cur_value = GNUNET_CONTAINER_multihashmap_get (ego_entry->attr_map, | 303 | cur_value = GNUNET_CONTAINER_multihashmap_get (ego_entry->attr_map, |
304 | &key_hash); | 304 | &key_hash); |
305 | identity_token_add_json (new_token, key, cur_value); | 305 | GNUNET_IDENTITY_PROVIDER_token_add_json (new_token, key, cur_value); |
306 | } | 306 | } |
307 | } | 307 | } |
308 | } | 308 | } |
309 | 309 | ||
310 | // reassemble and set | 310 | // reassemble and set |
311 | GNUNET_assert (identity_token_serialize (new_token, | 311 | GNUNET_assert (GNUNET_IDENTITY_PROVIDER_token_serialize (new_token, |
312 | priv_key, | 312 | priv_key, |
313 | &new_ecdhe_privkey, | 313 | &new_ecdhe_privkey, |
314 | &enc_token_str)); | 314 | &enc_token_str)); |
315 | 315 | ||
316 | json_decref (payload_json); | 316 | json_decref (payload_json); |
317 | 317 | ||
@@ -347,10 +347,10 @@ handle_token_update (void *cls, | |||
347 | &store_token_cont, | 347 | &store_token_cont, |
348 | ego_entry); | 348 | ego_entry); |
349 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, ">>> Updating Token w/ %s\n", new_token); | 349 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, ">>> Updating Token w/ %s\n", new_token); |
350 | identity_token_destroy (new_token); | 350 | GNUNET_IDENTITY_PROVIDER_token_destroy (new_token); |
351 | GNUNET_IDENTITY_PROVIDER_token_destroy (token); | ||
351 | GNUNET_free (new_ecdhe_privkey); | 352 | GNUNET_free (new_ecdhe_privkey); |
352 | GNUNET_free (enc_token_str); | 353 | GNUNET_free (enc_token_str); |
353 | GNUNET_free (token); | ||
354 | token = NULL; | 354 | token = NULL; |
355 | GNUNET_free (label); | 355 | GNUNET_free (label); |
356 | label = NULL; | 356 | label = NULL; |
@@ -438,16 +438,16 @@ token_collect (void *cls, | |||
438 | } | 438 | } |
439 | GNUNET_assert (token_metadata_record->record_type == GNUNET_GNSRECORD_TYPE_ID_TOKEN_METADATA); | 439 | GNUNET_assert (token_metadata_record->record_type == GNUNET_GNSRECORD_TYPE_ID_TOKEN_METADATA); |
440 | GNUNET_assert (token_record->record_type == GNUNET_GNSRECORD_TYPE_ID_TOKEN); | 440 | GNUNET_assert (token_record->record_type == GNUNET_GNSRECORD_TYPE_ID_TOKEN); |
441 | 441 | ||
442 | //Get metadata and decrypt token | 442 | //Get metadata and decrypt token |
443 | ecdhe_privkey = *((struct GNUNET_CRYPTO_EcdhePrivateKey *)token_metadata_record->data); | 443 | ecdhe_privkey = *((struct GNUNET_CRYPTO_EcdhePrivateKey *)token_metadata_record->data); |
444 | aud_key = (struct GNUNET_CRYPTO_EcdsaPublicKey *)&ecdhe_privkey+sizeof(struct GNUNET_CRYPTO_EcdhePrivateKey); | 444 | aud_key = (struct GNUNET_CRYPTO_EcdsaPublicKey *)&ecdhe_privkey+sizeof(struct GNUNET_CRYPTO_EcdhePrivateKey); |
445 | scopes = GNUNET_strdup ((char*) aud_key+sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)); | 445 | scopes = GNUNET_strdup ((char*) aud_key+sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)); |
446 | 446 | ||
447 | identity_token_parse2 (token_record->data, | 447 | GNUNET_IDENTITY_PROVIDER_token_parse2 (token_record->data, |
448 | &ecdhe_privkey, | 448 | &ecdhe_privkey, |
449 | aud_key, | 449 | aud_key, |
450 | &token); | 450 | &token); |
451 | 451 | ||
452 | //token = GNUNET_GNSRECORD_value_to_string (rd->record_type, | 452 | //token = GNUNET_GNSRECORD_value_to_string (rd->record_type, |
453 | // rd->data, | 453 | // rd->data, |