aboutsummaryrefslogtreecommitdiff
path: root/src/reclaim/oidc_helper.c
diff options
context:
space:
mode:
authorMartin Schanzenbach <schanzen@gnunet.org>2022-09-08 14:24:05 +0200
committerMartin Schanzenbach <schanzen@gnunet.org>2022-09-08 14:24:05 +0200
commit0b07a5569648e37633fedd3abd06592d19d41dee (patch)
tree10989be04f7cd902c0a72e5ec7b1c98ef46e9297 /src/reclaim/oidc_helper.c
parent2d47dafa073559622e40fbf0b1231f3b84b8a3e4 (diff)
downloadgnunet-0b07a5569648e37633fedd3abd06592d19d41dee.tar.gz
gnunet-0b07a5569648e37633fedd3abd06592d19d41dee.zip
-coverity
Diffstat (limited to 'src/reclaim/oidc_helper.c')
-rw-r--r--src/reclaim/oidc_helper.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/reclaim/oidc_helper.c b/src/reclaim/oidc_helper.c
index cfa71b26c..c87514a6b 100644
--- a/src/reclaim/oidc_helper.c
+++ b/src/reclaim/oidc_helper.c
@@ -457,30 +457,32 @@ OIDC_generate_id_token_rsa (const struct GNUNET_IDENTITY_PublicKey *aud_key,
457 expiration_time, 457 expiration_time,
458 nonce); 458 nonce);
459 459
460 if (! body_str) 460 if (NULL == body_str)
461 { 461 {
462 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 462 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
463 "Body for the JWS could not be generated\n"); 463 "Body for the JWS could not be generated\n");
464 return NULL;
464 } 465 }
465 466
466 // Creating the JSON Web Signature. 467 // Creating the JSON Web Signature.
467 jws = json_pack ("{s:o}", "payload", 468 jws = json_pack ("{s:o}", "payload",
468 jose_b64_enc (body_str, strlen (body_str))); 469 jose_b64_enc (body_str, strlen (body_str)));
470 GNUNET_free (body_str);
469 471
470 if (! jose_jws_sig (NULL, jws, NULL, secret_rsa_key)) 472 if (! jose_jws_sig (NULL, jws, NULL, secret_rsa_key))
471 { 473 {
472 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 474 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
473 "Signature generation failed\n"); 475 "Signature generation failed\n");
476 return NULL;
474 } 477 }
475 478
476 // Encoding JSON as compact JSON Web Signature 479 // Encoding JSON as compact JSON Web Signature
477 GNUNET_asprintf (&result, "%s.%s.%s", 480 GNUNET_asprintf (&result, "%s.%s.%s",
478 json_string_value (json_object_get (jws, "protected")), 481 json_string_value (json_object_get (jws, "protected")),
479 json_string_value (json_object_get (jws, "payload")), 482 json_string_value (json_object_get (jws, "payload")),
480 json_string_value (json_object_get (jws, "signature")) ); 483 json_string_value (json_object_get (jws, "signature")) );
481 484
482 json_decref(jws); 485 json_decref (jws);
483 GNUNET_free(body_str);
484 return result; 486 return result;
485} 487}
486 488
@@ -518,7 +520,14 @@ OIDC_generate_id_token_hmac (const struct GNUNET_IDENTITY_PublicKey *aud_key,
518 520
519 // Generate and encode Header 521 // Generate and encode Header
520 header = create_jwt_hmac_header (); 522 header = create_jwt_hmac_header ();
523 if (NULL == header)
524 {
525 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
526 "Header for the JWS could not be generated\n");
527 return NULL;
528 }
521 GNUNET_STRINGS_base64url_encode (header, strlen (header), &header_base64); 529 GNUNET_STRINGS_base64url_encode (header, strlen (header), &header_base64);
530 GNUNET_free (header);
522 fix_base64 (header_base64); 531 fix_base64 (header_base64);
523 532
524 // Generate and encode the body of the JSON Web Signature 533 // Generate and encode the body of the JSON Web Signature
@@ -529,10 +538,12 @@ OIDC_generate_id_token_hmac (const struct GNUNET_IDENTITY_PublicKey *aud_key,
529 expiration_time, 538 expiration_time,
530 nonce); 539 nonce);
531 540
532 if (! body_str) 541 if (NULL == body_str)
533 { 542 {
534 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 543 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
535 "Body for the JWS could not be generated\n"); 544 "Body for the JWS could not be generated\n");
545 GNUNET_free (header_base64);
546 return NULL;
536 } 547 }
537 548
538 GNUNET_STRINGS_base64url_encode (body_str, strlen (body_str), &body_base64); 549 GNUNET_STRINGS_base64url_encode (body_str, strlen (body_str), &body_base64);
@@ -559,7 +570,6 @@ OIDC_generate_id_token_hmac (const struct GNUNET_IDENTITY_PublicKey *aud_key,
559 body_base64, 570 body_base64,
560 signature_base64); 571 signature_base64);
561 572
562 GNUNET_free (header);
563 GNUNET_free (header_base64); 573 GNUNET_free (header_base64);
564 GNUNET_free (body_str); 574 GNUNET_free (body_str);
565 GNUNET_free (body_base64); 575 GNUNET_free (body_base64);