aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Schwieren <tristan.schwieren@tum.de>2022-01-10 15:02:30 +0100
committerTristan Schwieren <tristan.schwieren@tum.de>2022-01-10 15:02:30 +0100
commit54eea8dc8c714db6d518068213d5da6e1df6e1a6 (patch)
treed8614ff25192e9cf52b2c5cb64b70bf0c2fa6e16
parenta3579be4e2a4193e4ba5df5bac71a1f88fef9219 (diff)
downloadgnunet-54eea8dc8c714db6d518068213d5da6e1df6e1a6.tar.gz
gnunet-54eea8dc8c714db6d518068213d5da6e1df6e1a6.zip
-w3cvc zero character bug
-rw-r--r--src/reclaim/plugin_reclaim_credential_vc.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/reclaim/plugin_reclaim_credential_vc.c b/src/reclaim/plugin_reclaim_credential_vc.c
index 3c85a9498..db30a3745 100644
--- a/src/reclaim/plugin_reclaim_credential_vc.c
+++ b/src/reclaim/plugin_reclaim_credential_vc.c
@@ -461,6 +461,7 @@ vc_create_presentation (void *cls,
461 json_t * credential; 461 json_t * credential;
462 json_t * proof; 462 json_t * proof;
463 463
464 char * json_str;
464 char * presentation_str; 465 char * presentation_str;
465 const char * now; 466 const char * now;
466 467
@@ -486,18 +487,23 @@ vc_create_presentation (void *cls,
486 json_object_set(proof, "type", json_string("EDdSASignature2021")); 487 json_object_set(proof, "type", json_string("EDdSASignature2021"));
487 json_object_set(proof, "created", json_string(now)); 488 json_object_set(proof, "created", json_string(now));
488 json_object_set(proof, "proofPurpose", json_string("assertionMethod")); 489 json_object_set(proof, "proofPurpose", json_string("assertionMethod"));
489 json_object_set(proof, "verificationMethod", json_string("did:reclaim:1234key-1")); 490 json_object_set(proof, "verificationMethod", json_string("did:reclaim:1234#key-1"));
490 // FIXME: # inside the verificationMethod value makes the encoded json not decodeable by jannson
491 // json_object_set(proof, "verificationMethod", json_string("did:reclaim:1234#key-1"));
492 json_object_set(proof, "signature", json_string("abc")); 491 json_object_set(proof, "signature", json_string("abc"));
493 json_object_set(root, "proof", proof); 492 json_object_set(root, "proof", proof);
494 493
495 presentation_str = json_dumps(root, JSON_INDENT(2)); 494 // Encode JSON and append \0 character
495 json_str = json_dumps(root, JSON_INDENT(2));
496 presentation_str = malloc(strlen(json_str) + 1);
497 strcpy(presentation_str, json_str);
498 presentation_str[strlen(json_str)] = '\0';
496 499
497 *presentation = GNUNET_RECLAIM_presentation_new ( 500 *presentation = GNUNET_RECLAIM_presentation_new (
498 GNUNET_RECLAIM_CREDENTIAL_TYPE_VC, 501 GNUNET_RECLAIM_CREDENTIAL_TYPE_VC,
499 (void *) presentation_str, 502 (void *) presentation_str,
500 strlen(presentation_str)); 503 strlen(presentation_str));
504
505 free(presentation_str);
506 free(json_str);
501 return GNUNET_OK; 507 return GNUNET_OK;
502} 508}
503 509