diff options
author | Christian Blättler <blatc2@bfh.ch> | 2024-05-06 21:11:35 +0200 |
---|---|---|
committer | Christian Blättler <blatc2@bfh.ch> | 2024-05-06 21:11:35 +0200 |
commit | dbfd21c2f14d439ce897edb427222a4445a07072 (patch) | |
tree | 77f1708fed873fcc90c7ebf48c99584f2a376f5e | |
parent | 0f1aa84f60d360a3e3aac17eb8fdb269bd80e866 (diff) | |
download | gnunet-dbfd21c2f14d439ce897edb427222a4445a07072.tar.gz gnunet-dbfd21c2f14d439ce897edb427222a4445a07072.zip |
add pack helper for blinded sig
-rw-r--r-- | src/include/gnunet_json_lib.h | 12 | ||||
-rw-r--r-- | src/lib/json/json_helper.c | 2 | ||||
-rw-r--r-- | src/lib/json/json_pack.c | 37 |
3 files changed, 51 insertions, 0 deletions
diff --git a/src/include/gnunet_json_lib.h b/src/include/gnunet_json_lib.h index 44dbf8965..e9c17eef9 100644 --- a/src/include/gnunet_json_lib.h +++ b/src/include/gnunet_json_lib.h | |||
@@ -1003,6 +1003,18 @@ GNUNET_JSON_pack_blinded_message (const char *name, | |||
1003 | const struct GNUNET_CRYPTO_BlindedMessage *msg); | 1003 | const struct GNUNET_CRYPTO_BlindedMessage *msg); |
1004 | 1004 | ||
1005 | 1005 | ||
1006 | /** | ||
1007 | * Generate packer instruction for a JSON field of type | ||
1008 | * blinded signature. | ||
1009 | * | ||
1010 | * @param name name of the field to add to the object | ||
1011 | * @param sig blinded signature | ||
1012 | * @return json pack specification | ||
1013 | */ | ||
1014 | struct GNUNET_JSON_PackSpec | ||
1015 | GNUNET_JSON_pack_blinded_sig (const char *name, | ||
1016 | const struct GNUNET_CRYPTO_BlindedSignature *sig); | ||
1017 | |||
1006 | #endif | 1018 | #endif |
1007 | 1019 | ||
1008 | /* end of gnunet_json_lib.h */ | 1020 | /* end of gnunet_json_lib.h */ |
diff --git a/src/lib/json/json_helper.c b/src/lib/json/json_helper.c index a5adcddc6..ce73fb316 100644 --- a/src/lib/json/json_helper.c +++ b/src/lib/json/json_helper.c | |||
@@ -1249,6 +1249,8 @@ parse_blinded_message (void *cls, | |||
1249 | { | 1249 | { |
1250 | struct GNUNET_JSON_Specification ispec[] = { | 1250 | struct GNUNET_JSON_Specification ispec[] = { |
1251 | GNUNET_JSON_spec_varsize ( | 1251 | GNUNET_JSON_spec_varsize ( |
1252 | /* TODO: Change this field name to something | ||
1253 | more generic / pass in as argument. */ | ||
1252 | "rsa_blinded_planchet", | 1254 | "rsa_blinded_planchet", |
1253 | &blinded_message->details.rsa_blinded_message.blinded_msg, | 1255 | &blinded_message->details.rsa_blinded_message.blinded_msg, |
1254 | &blinded_message->details.rsa_blinded_message.blinded_msg_size), | 1256 | &blinded_message->details.rsa_blinded_message.blinded_msg_size), |
diff --git a/src/lib/json/json_pack.c b/src/lib/json/json_pack.c index 7b41a967e..d298e6efe 100644 --- a/src/lib/json/json_pack.c +++ b/src/lib/json/json_pack.c | |||
@@ -440,4 +440,41 @@ GNUNET_JSON_pack_blinded_message (const char *name, | |||
440 | return ps; | 440 | return ps; |
441 | } | 441 | } |
442 | 442 | ||
443 | |||
444 | struct GNUNET_JSON_PackSpec | ||
445 | GNUNET_JSON_pack_blinded_sig ( | ||
446 | const char *name, | ||
447 | const struct GNUNET_CRYPTO_BlindedSignature *sig) | ||
448 | { | ||
449 | struct GNUNET_JSON_PackSpec ps = { | ||
450 | .field_name = name, | ||
451 | }; | ||
452 | |||
453 | if (NULL == sig) | ||
454 | return ps; | ||
455 | switch (sig->cipher) | ||
456 | { | ||
457 | case GNUNET_CRYPTO_BSA_INVALID: | ||
458 | break; | ||
459 | case GNUNET_CRYPTO_BSA_RSA: | ||
460 | ps.object = GNUNET_JSON_PACK ( | ||
461 | GNUNET_JSON_pack_string ("cipher", | ||
462 | "RSA"), | ||
463 | GNUNET_JSON_pack_rsa_signature ("blinded_rsa_signature", | ||
464 | sig->details.blinded_rsa_signature)); | ||
465 | return ps; | ||
466 | case GNUNET_CRYPTO_BSA_CS: | ||
467 | ps.object = GNUNET_JSON_PACK ( | ||
468 | GNUNET_JSON_pack_string ("cipher", | ||
469 | "CS"), | ||
470 | GNUNET_JSON_pack_uint64 ("b", | ||
471 | sig->details.blinded_cs_answer.b), | ||
472 | GNUNET_JSON_pack_data_auto ("s", | ||
473 | &sig->details.blinded_cs_answer.s_scalar)); | ||
474 | return ps; | ||
475 | } | ||
476 | GNUNET_assert (0); | ||
477 | return ps; | ||
478 | } | ||
479 | |||
443 | /* end of json_pack.c */ | 480 | /* end of json_pack.c */ |