aboutsummaryrefslogtreecommitdiff
path: root/src/reclaim/oidc_helper.c
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2020-08-06 14:40:17 +0200
committerMartin Schanzenbach <mschanzenbach@posteo.de>2020-08-06 14:40:17 +0200
commit6ab14a20690a499ad32e3f2ad448d64d4e6b65fc (patch)
tree7866fb31e10cd49b2bb00eaf23134945b506624d /src/reclaim/oidc_helper.c
parent1d4f5263ae72c12a42ec166ec8b1769620baaeda (diff)
downloadgnunet-6ab14a20690a499ad32e3f2ad448d64d4e6b65fc.tar.gz
gnunet-6ab14a20690a499ad32e3f2ad448d64d4e6b65fc.zip
-fix various bugs
Diffstat (limited to 'src/reclaim/oidc_helper.c')
-rw-r--r--src/reclaim/oidc_helper.c33
1 files changed, 10 insertions, 23 deletions
diff --git a/src/reclaim/oidc_helper.c b/src/reclaim/oidc_helper.c
index cb99a749d..9b5938c43 100644
--- a/src/reclaim/oidc_helper.c
+++ b/src/reclaim/oidc_helper.c
@@ -162,8 +162,6 @@ generate_userinfo_json(const struct GNUNET_CRYPTO_EcdsaPublicKey *sub_key,
162 struct GNUNET_RECLAIM_AttributeListEntry *le; 162 struct GNUNET_RECLAIM_AttributeListEntry *le;
163 struct GNUNET_RECLAIM_AttestationListEntry *ale; 163 struct GNUNET_RECLAIM_AttestationListEntry *ale;
164 char *subject; 164 char *subject;
165 char *aggr_names_str;
166 char *aggr_sources_str;
167 char *source_name; 165 char *source_name;
168 char *attr_val_str; 166 char *attr_val_str;
169 char *attest_val_str; 167 char *attest_val_str;
@@ -171,7 +169,7 @@ generate_userinfo_json(const struct GNUNET_CRYPTO_EcdsaPublicKey *sub_key,
171 json_t *aggr_names; 169 json_t *aggr_names;
172 json_t *aggr_sources; 170 json_t *aggr_sources;
173 json_t *aggr_sources_jwt; 171 json_t *aggr_sources_jwt;
174 json_t *addr_claim; 172 json_t *addr_claim = NULL;
175 int num_attestations = 0; 173 int num_attestations = 0;
176 for (le = attrs->list_head; NULL != le; le = le->next) 174 for (le = attrs->list_head; NULL != le; le = le->next)
177 { 175 {
@@ -194,8 +192,6 @@ generate_userinfo_json(const struct GNUNET_CRYPTO_EcdsaPublicKey *sub_key,
194 // sub REQUIRED public key identity, not exceed 255 ASCII length 192 // sub REQUIRED public key identity, not exceed 255 ASCII length
195 json_object_set_new (body, "sub", json_string (subject)); 193 json_object_set_new (body, "sub", json_string (subject));
196 attest_val_str = NULL; 194 attest_val_str = NULL;
197 aggr_names_str = NULL;
198 aggr_sources_str = NULL;
199 source_name = NULL; 195 source_name = NULL;
200 int i = 0; 196 int i = 0;
201 for (ale = attests->list_head; NULL != ale; ale = ale->next) 197 for (ale = attests->list_head; NULL != ale; ale = ale->next)
@@ -237,8 +233,6 @@ generate_userinfo_json(const struct GNUNET_CRYPTO_EcdsaPublicKey *sub_key,
237 if (NULL == addr_claim) 233 if (NULL == addr_claim)
238 { 234 {
239 addr_claim = json_object (); 235 addr_claim = json_object ();
240 json_object_set_new (body, "address",
241 addr_claim);
242 } 236 }
243 json_object_set_new (addr_claim, le->attribute->name, 237 json_object_set_new (addr_claim, le->attribute->name,
244 json_string (attr_val_str)); 238 json_string (attr_val_str));
@@ -273,21 +267,17 @@ generate_userinfo_json(const struct GNUNET_CRYPTO_EcdsaPublicKey *sub_key,
273 GNUNET_free (source_name); 267 GNUNET_free (source_name);
274 } 268 }
275 } 269 }
270 if (NULL != addr_claim)
271 json_object_set_new (body, "address", addr_claim);
276 272
277 if (NULL != attest_val_str) 273 if (NULL != attest_val_str)
278 GNUNET_free (attest_val_str); 274 GNUNET_free (attest_val_str);
279 if (0 != i) 275 if (0 != i)
280 { 276 {
281 aggr_names_str = json_dumps (aggr_names, JSON_INDENT (0) | JSON_COMPACT); 277 json_object_set_new (body, "_claim_names", aggr_names);
282 aggr_sources_str = json_dumps (aggr_sources, JSON_INDENT (0) 278 json_object_set_new (body, "_claim_sources", aggr_sources);
283 | JSON_COMPACT);
284 json_object_set_new (body, "_claim_names", json_string (aggr_names_str));
285 json_object_set_new (body, "_claim_sources", json_string (
286 aggr_sources_str));
287 } 279 }
288 280
289 json_decref (aggr_names);
290 json_decref (aggr_sources);
291 return body; 281 return body;
292} 282}
293 283
@@ -611,7 +601,6 @@ OIDC_parse_authz_code (const struct GNUNET_CRYPTO_EcdsaPublicKey *audience,
611 GNUNET_STRINGS_base64url_decode (code, strlen (code), 601 GNUNET_STRINGS_base64url_decode (code, strlen (code),
612 (void **) &code_payload); 602 (void **) &code_payload);
613 if (code_payload_len < sizeof(struct GNUNET_CRYPTO_EccSignaturePurpose) 603 if (code_payload_len < sizeof(struct GNUNET_CRYPTO_EccSignaturePurpose)
614 + sizeof(struct GNUNET_CRYPTO_EcdhePublicKey)
615 + sizeof(struct OIDC_Parameters) 604 + sizeof(struct OIDC_Parameters)
616 + sizeof(struct GNUNET_CRYPTO_EcdsaSignature)) 605 + sizeof(struct GNUNET_CRYPTO_EcdsaSignature))
617 { 606 {
@@ -624,8 +613,6 @@ OIDC_parse_authz_code (const struct GNUNET_CRYPTO_EcdsaPublicKey *audience,
624 plaintext_len = code_payload_len; 613 plaintext_len = code_payload_len;
625 plaintext_len -= sizeof(struct GNUNET_CRYPTO_EccSignaturePurpose); 614 plaintext_len -= sizeof(struct GNUNET_CRYPTO_EccSignaturePurpose);
626 ptr = (char *) &purpose[1]; 615 ptr = (char *) &purpose[1];
627 plaintext_len -= sizeof(struct GNUNET_CRYPTO_EcdhePublicKey);
628
629 plaintext_len -= sizeof(struct GNUNET_CRYPTO_EcdsaSignature); 616 plaintext_len -= sizeof(struct GNUNET_CRYPTO_EcdsaSignature);
630 plaintext = ptr; 617 plaintext = ptr;
631 ptr += plaintext_len; 618 ptr += plaintext_len;
@@ -683,8 +670,8 @@ OIDC_parse_authz_code (const struct GNUNET_CRYPTO_EcdsaPublicKey *audience,
683 if (0 != GNUNET_memcmp (audience, &ticket->audience)) 670 if (0 != GNUNET_memcmp (audience, &ticket->audience))
684 { 671 {
685 GNUNET_free (code_payload); 672 GNUNET_free (code_payload);
686 if (NULL != nonce_str) 673 if (NULL != *nonce_str)
687 GNUNET_free (nonce_str); 674 GNUNET_free (*nonce_str);
688 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 675 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
689 "Audience in ticket does not match client!\n"); 676 "Audience in ticket does not match client!\n");
690 return GNUNET_SYSERR; 677 return GNUNET_SYSERR;
@@ -696,8 +683,8 @@ OIDC_parse_authz_code (const struct GNUNET_CRYPTO_EcdsaPublicKey *audience,
696 &ticket->identity)) 683 &ticket->identity))
697 { 684 {
698 GNUNET_free (code_payload); 685 GNUNET_free (code_payload);
699 if (NULL != nonce_str) 686 if (NULL != *nonce_str)
700 GNUNET_free (nonce_str); 687 GNUNET_free (*nonce_str);
701 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Signature of AuthZ code invalid!\n"); 688 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Signature of AuthZ code invalid!\n");
702 return GNUNET_SYSERR; 689 return GNUNET_SYSERR;
703 } 690 }
@@ -768,7 +755,7 @@ OIDC_access_token_new (const struct GNUNET_RECLAIM_Ticket *ticket)
768 * Parse an access token 755 * Parse an access token
769 */ 756 */
770int 757int
771OIDC_access_token_parse (const char*token, 758OIDC_access_token_parse (const char *token,
772 struct GNUNET_RECLAIM_Ticket **ticket) 759 struct GNUNET_RECLAIM_Ticket **ticket)
773{ 760{
774 if (sizeof (struct GNUNET_RECLAIM_Ticket) != 761 if (sizeof (struct GNUNET_RECLAIM_Ticket) !=