GNUnet 0.25.2-12-g8d1cef5f6
 
Loading...
Searching...
No Matches
json_helper.c
Go to the documentation of this file.
1/*
2 This file is part of GNUnet
3 Copyright (C) 2014-2022 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
27#include "platform.h"
28#include "gnunet_util_lib.h"
29#include "gnunet_json_lib.h"
30#include "gnunet_common.h"
31
32
35{
37 .parser = NULL,
38 };
39
40 return ret;
41}
42
43
51string_to_cipher (const char *cipher_s)
52{
53 if ((0 == strcasecmp (cipher_s,
54 "RSA")) ||
55 (0 == strcasecmp (cipher_s,
56 "RSA+age_restricted")))
58 if ((0 == strcasecmp (cipher_s,
59 "CS")) ||
60 (0 == strcasecmp (cipher_s,
61 "CS+age_restricted")))
64}
65
66
77 json_t *root,
78 struct GNUNET_JSON_Specification *spec)
79{
80 const char *enc;
81 size_t len;
82
83 if (NULL == (enc = json_string_value (root)))
84 {
86 return GNUNET_SYSERR;
87 }
88 len = strlen (enc);
89 if (len >= SIZE_MAX / 5)
90 {
92 return GNUNET_SYSERR;
93 }
94 if (((len * 5) / 8) != spec->ptr_size)
95 {
98 "Field `%s' has wrong length\n",
99 spec->field);
100 return GNUNET_SYSERR;
101 }
102 if (GNUNET_OK !=
104 len,
105 spec->ptr,
106 spec->ptr_size))
107 {
108 GNUNET_break_op (0);
109 return GNUNET_SYSERR;
110 }
111 return GNUNET_OK;
112}
113
114
117 void *obj,
118 size_t size)
119{
122 .field = name,
123 .ptr = obj,
124 .ptr_size = size,
125 };
126
127 return ret;
128}
129
130
141 json_t *root,
142 struct GNUNET_JSON_Specification *spec)
143{
144 const char *enc;
145 unsigned int len;
146 void *output;
147 size_t olen;
148
149 if (NULL == (enc = json_string_value (root)))
150 {
151 GNUNET_break_op (0);
152 return GNUNET_SYSERR;
153 }
154 len = strlen (enc);
155 output = NULL;
157 len,
158 &output);
159 if (olen != spec->ptr_size)
160 {
161 GNUNET_break_op (0);
163 "Field `%s' has wrong length\n",
164 spec->field);
165 GNUNET_free (output);
166 return GNUNET_SYSERR;
167 }
168 memcpy (spec->ptr,
169 output,
170 olen);
171 GNUNET_free (output);
172 return GNUNET_OK;
173}
174
175
178 void *obj,
179 size_t size)
180{
183 .field = name,
184 .ptr = obj,
185 .ptr_size = size,
186 };
187
188 return ret;
189}
190
191
202 json_t *root,
203 struct GNUNET_JSON_Specification *spec)
204{
205 const char *str;
206 size_t size;
207 void *data;
208
209 str = json_string_value (root);
210 if (NULL == str)
211 {
212 GNUNET_break_op (0);
213 return GNUNET_SYSERR;
214 }
215 if (GNUNET_OK !=
217 strlen (str),
218 &data,
219 &size))
220 {
221 GNUNET_break_op (0);
222 return GNUNET_SYSERR;
223 }
224 *(void **) spec->ptr = data;
225 *spec->size_ptr = size;
226 return GNUNET_OK;
227}
228
229
236static void
238 struct GNUNET_JSON_Specification *spec)
239{
240 (void) cls;
241 if (0 != *spec->size_ptr)
242 {
243 GNUNET_free (*(void **) spec->ptr);
244 *(void **) spec->ptr = NULL;
245 *spec->size_ptr = 0;
246 }
247}
248
249
252 void **obj,
253 size_t *size)
254{
257 .cleaner = &clean_variable_data,
258 .field = name,
259 .ptr = obj,
260 .size_ptr = size
261 };
262
263 *obj = NULL;
264 *size = 0;
265 return ret;
266}
267
268
279 json_t *root,
280 struct GNUNET_JSON_Specification *spec)
281{
282 const char *str;
283
284 (void) cls;
285 str = json_string_value (root);
286 if (NULL == str)
287 {
288 GNUNET_break_op (0);
289 return GNUNET_SYSERR;
290 }
291 *(const char **) spec->ptr = str;
292 return GNUNET_OK;
293}
294
295
298 const char **strptr)
299{
302 .field = name,
303 .ptr = strptr
304 };
305
306 *strptr = NULL;
307 return ret;
308}
309
310
321 json_t *root,
322 struct GNUNET_JSON_Specification *spec)
323{
324 const char *str;
325
326 (void) cls;
327 str = json_string_value (root);
328 if (NULL == str)
329 {
330 GNUNET_break_op (0);
331 return GNUNET_SYSERR;
332 }
333 *((char **) spec->ptr) = GNUNET_strdup (str);
334 return GNUNET_OK;
335}
336
337
340 char **strptr)
341{
344 .field = name,
345 .ptr = strptr
346 };
347
348 *strptr = NULL;
349 return ret;
350}
351
352
363 json_t *root,
364 struct GNUNET_JSON_Specification *spec)
365{
366 if (! (json_is_object (root) || json_is_array (root)))
367 {
368 GNUNET_break_op (0);
369 return GNUNET_SYSERR;
370 }
371 *(json_t **) spec->ptr = json_incref (root);
372 return GNUNET_OK;
373}
374
375
382static void
384 struct GNUNET_JSON_Specification *spec)
385{
386 json_t **ptr = (json_t **) spec->ptr;
387
388 if (NULL != *ptr)
389 {
390 json_decref (*ptr);
391 *ptr = NULL;
392 }
393}
394
395
398 json_t **jsonp)
399{
401 .parser = &parse_json,
402 .cleaner = &clean_json,
403 .field = name,
404 .ptr = jsonp,
405 };
406
407 *jsonp = NULL;
408 return ret;
409}
410
411
422 json_t *root,
423 struct GNUNET_JSON_Specification *spec)
424{
425 if (NULL == root)
426 return GNUNET_OK;
427 if (! json_is_object (root))
428 {
429 GNUNET_break_op (0);
430 return GNUNET_SYSERR;
431 }
432 *(const json_t **) spec->ptr = (const json_t *) root;
433 return GNUNET_OK;
434}
435
436
439 const json_t **jsonp)
440{
443 .field = name,
444 .ptr = jsonp,
445 };
446
447 *jsonp = NULL;
448 return ret;
449}
450
451
462 json_t *root,
463 struct GNUNET_JSON_Specification *spec)
464{
465 if (NULL == root)
466 return GNUNET_OK;
467 if (! json_is_object (root))
468 {
469 GNUNET_break_op (0);
470 return GNUNET_SYSERR;
471 }
472 *((json_t **) spec->ptr) = json_incref (root);
473 return GNUNET_OK;
474}
475
476
479 json_t **jsonp)
480{
483 .cls = &clean_json,
484 .field = name,
485 .ptr = jsonp,
486 };
487
488 *jsonp = NULL;
489 return ret;
490}
491
492
503 json_t *root,
504 struct GNUNET_JSON_Specification *spec)
505{
506 if (NULL == root)
507 return GNUNET_OK;
508 if (! json_is_array (root))
509 {
510 GNUNET_break_op (0);
511 return GNUNET_SYSERR;
512 }
513 *(const json_t **) spec->ptr = (const json_t *) root;
514 return GNUNET_OK;
515}
516
517
520 const json_t **jsonp)
521{
524 .field = name,
525 .ptr = jsonp
526 };
527
528 *jsonp = NULL;
529 return ret;
530}
531
532
543 json_t *root,
544 struct GNUNET_JSON_Specification *spec)
545{
546 if (NULL == root)
547 return GNUNET_OK;
548 if (! json_is_array (root))
549 {
550 GNUNET_break_op (0);
551 return GNUNET_SYSERR;
552 }
553 *((json_t **) spec->ptr) = json_incref (root);
554 return GNUNET_OK;
555}
556
557
560 json_t **jsonp)
561{
564 .cleaner = &clean_json,
565 .field = name,
566 .ptr = jsonp
567 };
568
569 *jsonp = NULL;
570 return ret;
571}
572
573
584 json_t *root,
585 struct GNUNET_JSON_Specification *spec)
586{
587 bool *b = spec->ptr;
588
589 if (json_true () == root)
590 {
591 *b = true;
592 return GNUNET_OK;
593 }
594 if (json_false () == root)
595 {
596 *b = false;
597 return GNUNET_OK;
598 }
599 GNUNET_break_op (0);
600 return GNUNET_SYSERR;
601}
602
603
606 bool *b)
607{
609 .parser = &parse_bool,
610 .field = name,
611 .ptr = b,
612 .ptr_size = sizeof(bool),
613 };
614
615 return ret;
616}
617
618
629 json_t *root,
630 struct GNUNET_JSON_Specification *spec)
631{
632 double *f = spec->ptr;
633
634 if (! json_is_real (root))
635 {
636 GNUNET_break_op (0);
637 return GNUNET_SYSERR;
638 }
639 *f = json_real_value (root);
640 return GNUNET_OK;
641}
642
643
646 double *f)
647{
650 .field = name,
651 .ptr = f,
652 .ptr_size = sizeof(double),
653 };
654
655 return ret;
656}
657
658
669 json_t *root,
670 struct GNUNET_JSON_Specification *spec)
671{
672 json_int_t val;
673 uint8_t *up = spec->ptr;
674
675 if (! json_is_integer (root))
676 {
677 GNUNET_break_op (0);
678 return GNUNET_SYSERR;
679 }
680 val = json_integer_value (root);
681 if ((0 > val) || (val > UINT8_MAX))
682 {
683 GNUNET_break_op (0);
684 return GNUNET_SYSERR;
685 }
686 *up = (uint8_t) val;
687 return GNUNET_OK;
688}
689
690
693 uint8_t *u8)
694{
696 .parser = &parse_u8,
697 .field = name,
698 .ptr = u8,
699 .ptr_size = sizeof(uint8_t),
700 };
701
702 return ret;
703}
704
705
716 json_t *root,
717 struct GNUNET_JSON_Specification *spec)
718{
719 json_int_t val;
720 uint16_t *up = spec->ptr;
721
722 if (! json_is_integer (root))
723 {
724 GNUNET_break_op (0);
725 return GNUNET_SYSERR;
726 }
727 val = json_integer_value (root);
728 if ((0 > val) || (val > UINT16_MAX))
729 {
730 GNUNET_break_op (0);
731 return GNUNET_SYSERR;
732 }
733 *up = (uint16_t) val;
734 return GNUNET_OK;
735}
736
737
740 uint16_t *u16)
741{
743 .parser = &parse_u16,
744 .field = name,
745 .ptr = u16,
746 .ptr_size = sizeof(uint16_t),
747 };
748
749 return ret;
750}
751
752
763 json_t *root,
764 struct GNUNET_JSON_Specification *spec)
765{
766 json_int_t val;
767 uint32_t *up = spec->ptr;
768
769 if (! json_is_integer (root))
770 {
771 GNUNET_break_op (0);
772 return GNUNET_SYSERR;
773 }
774 val = json_integer_value (root);
775 if ((0 > val) || (val > UINT32_MAX))
776 {
777 GNUNET_break_op (0);
778 return GNUNET_SYSERR;
779 }
780 *up = (uint32_t) val;
781 return GNUNET_OK;
782}
783
784
787 uint32_t *u32)
788{
790 .parser = &parse_u32,
791 .field = name,
792 .ptr = u32,
793 .ptr_size = sizeof(uint32_t),
794 };
795
796 return ret;
797}
798
799
810 json_t *root,
811 struct GNUNET_JSON_Specification *spec)
812{
813 json_int_t val;
814 unsigned int *up = spec->ptr;
815
816 if (! json_is_integer (root))
817 {
818 GNUNET_break_op (0);
819 return GNUNET_SYSERR;
820 }
821 val = json_integer_value (root);
822 if ((0 > val) || (val > UINT_MAX))
823 {
824 GNUNET_break_op (0);
825 return GNUNET_SYSERR;
826 }
827 *up = (unsigned int) val;
828 return GNUNET_OK;
829}
830
831
834 unsigned int *ui)
835{
837 .parser = &parse_ui,
838 .field = name,
839 .ptr = ui,
840 .ptr_size = sizeof(unsigned int),
841 };
842
843 return ret;
844}
845
846
857 json_t *root,
858 struct GNUNET_JSON_Specification *spec)
859{
860 json_int_t val;
861 unsigned long long *up = spec->ptr;
862
863 if (! json_is_integer (root))
864 {
865 GNUNET_break_op (0);
866 return GNUNET_SYSERR;
867 }
868 val = json_integer_value (root);
869 if ((0 > val) || (val > ULLONG_MAX))
870 {
871 GNUNET_break_op (0);
872 return GNUNET_SYSERR;
873 }
874 *up = (unsigned long long) val;
875 return GNUNET_OK;
876}
877
878
881 unsigned long long *ull)
882{
884 .parser = &parse_ull,
885 .field = name,
886 .ptr = ull,
887 .ptr_size = sizeof(unsigned long long),
888 };
889
890 return ret;
891}
892
893
904 json_t *root,
905 struct GNUNET_JSON_Specification *spec)
906{
907 json_int_t val;
908 uint64_t *up = spec->ptr;
909
910 if (! json_is_integer (root))
911 {
912 GNUNET_break_op (0);
913 return GNUNET_SYSERR;
914 }
915 val = json_integer_value (root);
916 *up = (uint64_t) val;
917 return GNUNET_OK;
918}
919
920
923 uint64_t *u64)
924{
926 .parser = &parse_u64,
927 .field = name,
928 .ptr = u64,
929 .ptr_size = sizeof(uint64_t),
930 };
931
932 return ret;
933}
934
935
946 json_t *root,
947 struct GNUNET_JSON_Specification *spec)
948{
949 json_int_t val;
950 int16_t *up = spec->ptr;
951
952 if (! json_is_integer (root))
953 {
954 GNUNET_break_op (0);
955 return GNUNET_SYSERR;
956 }
957 val = json_integer_value (root);
958 if ( (val < INT16_MIN) ||
959 (val > INT16_MAX) )
960 {
961 GNUNET_break_op (0);
962 return GNUNET_SYSERR;
963 }
964 *up = (int16_t) val;
965 return GNUNET_OK;
966}
967
968
971 int16_t *i16)
972{
974 .parser = &parse_i16,
975 .field = name,
976 .ptr = i16,
977 .ptr_size = sizeof(int16_t),
978 };
979
980 return ret;
981}
982
983
994 json_t *root,
995 struct GNUNET_JSON_Specification *spec)
996{
997 json_int_t val;
998 int64_t *up = spec->ptr;
999
1000 if (! json_is_integer (root))
1001 {
1002 GNUNET_break_op (0);
1003 return GNUNET_SYSERR;
1004 }
1005 val = json_integer_value (root);
1006 *up = (int64_t) val;
1007 return GNUNET_OK;
1008}
1009
1010
1013 int64_t *i64)
1014{
1016 .parser = &parse_i64,
1017 .field = name,
1018 .ptr = i64,
1019 .ptr_size = sizeof(int64_t),
1020 };
1021
1022 return ret;
1023}
1024
1025
1026/* ************ GNUnet-specific parser specifications ******************* */
1027
1036static enum GNUNET_GenericReturnValue
1038 json_t *root,
1039 struct GNUNET_JSON_Specification *spec)
1040{
1041 struct GNUNET_TIME_Timestamp *ts = spec->ptr;
1042 json_t *json_t_s;
1043 unsigned long long int tval;
1044
1045 if (! json_is_object (root))
1046 {
1047 GNUNET_break_op (0);
1048 return GNUNET_SYSERR;
1049 }
1050 json_t_s = json_object_get (root,
1051 "t_s");
1052 if (json_is_integer (json_t_s))
1053 {
1054 tval = json_integer_value (json_t_s);
1055 /* Time is in seconds in JSON, but in microseconds in GNUNET_TIME_Absolute */
1057 = tval * GNUNET_TIME_UNIT_SECONDS.rel_value_us;
1058 if (ts->abs_time.abs_value_us
1059 / GNUNET_TIME_UNIT_SECONDS.rel_value_us
1060 != tval)
1061 {
1062 /* Integer overflow */
1063 GNUNET_break_op (0);
1064 return GNUNET_SYSERR;
1065 }
1066 return GNUNET_OK;
1067 }
1068 if (json_is_string (json_t_s))
1069 {
1070 const char *val;
1071
1072 val = json_string_value (json_t_s);
1073 if ((0 == strcasecmp (val,
1074 "never")))
1075 {
1077 return GNUNET_OK;
1078 }
1079 GNUNET_break_op (0);
1080 return GNUNET_SYSERR;
1081 }
1082 GNUNET_break_op (0);
1083 return GNUNET_SYSERR;
1084}
1085
1086
1089 struct GNUNET_TIME_Timestamp *t)
1090{
1093 .field = name,
1094 .ptr = t,
1095 .ptr_size = sizeof(struct GNUNET_TIME_Timestamp)
1096 };
1097
1098 return ret;
1099}
1100
1101
1110static enum GNUNET_GenericReturnValue
1112 json_t *root,
1113 struct GNUNET_JSON_Specification *spec)
1114{
1115 struct GNUNET_TIME_TimestampNBO *ts = spec->ptr;
1116 struct GNUNET_TIME_Timestamp a;
1117 struct GNUNET_JSON_Specification ispec;
1118
1119 ispec = *spec;
1120 ispec.parser = &parse_timestamp;
1121 ispec.ptr = &a;
1122 if (GNUNET_OK !=
1123 parse_timestamp (NULL,
1124 root,
1125 &ispec))
1126 return GNUNET_SYSERR;
1128 return GNUNET_OK;
1129}
1130
1131
1134 struct GNUNET_TIME_TimestampNBO *at)
1135{
1138 .field = name,
1139 .ptr = at,
1140 .ptr_size = sizeof(struct GNUNET_TIME_TimestampNBO)
1141 };
1142
1143 return ret;
1144}
1145
1146
1155static enum GNUNET_GenericReturnValue
1157 json_t *root,
1158 struct GNUNET_JSON_Specification *spec)
1159{
1160 struct GNUNET_TIME_Relative *rel = spec->ptr;
1161 json_t *json_d_us;
1162 unsigned long long int tval;
1163
1164 if (! json_is_object (root))
1165 {
1166 GNUNET_break_op (0);
1167 return GNUNET_SYSERR;
1168 }
1169 json_d_us = json_object_get (root,
1170 "d_us");
1171 if (json_is_integer (json_d_us))
1172 {
1173 tval = json_integer_value (json_d_us);
1174 if (tval >= (1LLU << 53))
1175 {
1176 /* value is larger than allowed */
1177 GNUNET_break_op (0);
1178 return GNUNET_SYSERR;
1179 }
1180 rel->rel_value_us = tval;
1181 return GNUNET_OK;
1182 }
1183 if (json_is_string (json_d_us))
1184 {
1185 const char *val;
1186
1187 val = json_string_value (json_d_us);
1188 if ((0 == strcasecmp (val,
1189 "forever")))
1190 {
1192 return GNUNET_OK;
1193 }
1194 GNUNET_break_op (0);
1195 return GNUNET_SYSERR;
1196 }
1197 GNUNET_break_op (0);
1198 return GNUNET_SYSERR;
1199}
1200
1201
1204 struct GNUNET_TIME_Relative *rt)
1205{
1208 .field = name,
1209 .ptr = rt,
1210 .ptr_size = sizeof(struct GNUNET_TIME_Relative)
1211 };
1212
1213 return ret;
1214}
1215
1216
1225static enum GNUNET_GenericReturnValue
1227 json_t *root,
1228 struct GNUNET_JSON_Specification *spec)
1229{
1230 struct GNUNET_CRYPTO_RsaPublicKey **pk = spec->ptr;
1231 const char *enc;
1232 char *buf;
1233 size_t len;
1234 size_t buf_len;
1235
1236 if (NULL == (enc = json_string_value (root)))
1237 {
1238 GNUNET_break_op (0);
1239 return GNUNET_SYSERR;
1240 }
1241 len = strlen (enc);
1242 buf_len = (len * 5) / 8;
1243 buf = GNUNET_malloc (buf_len);
1244 if (GNUNET_OK !=
1246 len,
1247 buf,
1248 buf_len))
1249 {
1250 GNUNET_break_op (0);
1251 GNUNET_free (buf);
1252 return GNUNET_SYSERR;
1253 }
1254 if (NULL == (*pk = GNUNET_CRYPTO_rsa_public_key_decode (buf,
1255 buf_len)))
1256 {
1257 GNUNET_break_op (0);
1258 GNUNET_free (buf);
1259 return GNUNET_SYSERR;
1260 }
1261 GNUNET_free (buf);
1262 return GNUNET_OK;
1263}
1264
1265
1272static void
1274 struct GNUNET_JSON_Specification *spec)
1275{
1276 struct GNUNET_CRYPTO_RsaPublicKey **pk = spec->ptr;
1277
1278 if (NULL != *pk)
1279 {
1281 *pk = NULL;
1282 }
1283}
1284
1285
1289{
1292 .cleaner = &clean_rsa_public_key,
1293 .field = name,
1294 .ptr = pk
1295 };
1296
1297 *pk = NULL;
1298 return ret;
1299}
1300
1301
1310static enum GNUNET_GenericReturnValue
1312 json_t *root,
1313 struct GNUNET_JSON_Specification *spec)
1314{
1315 struct GNUNET_CRYPTO_RsaSignature **sig = spec->ptr;
1316 size_t size;
1317 const char *str;
1318 int res;
1319 void *buf;
1320
1321 str = json_string_value (root);
1322 if (NULL == str)
1323 {
1324 GNUNET_break_op (0);
1325 return GNUNET_SYSERR;
1326 }
1327 size = (strlen (str) * 5) / 8;
1328 buf = GNUNET_malloc (size);
1330 strlen (str),
1331 buf,
1332 size);
1333 if (GNUNET_OK != res)
1334 {
1335 GNUNET_free (buf);
1336 GNUNET_break_op (0);
1337 return GNUNET_SYSERR;
1338 }
1339 if (NULL == (*sig = GNUNET_CRYPTO_rsa_signature_decode (buf,
1340 size)))
1341 {
1342 GNUNET_break_op (0);
1343 GNUNET_free (buf);
1344 return GNUNET_SYSERR;
1345 }
1346 GNUNET_free (buf);
1347 return GNUNET_OK;
1348}
1349
1350
1357static void
1359 struct GNUNET_JSON_Specification *spec)
1360{
1361 struct GNUNET_CRYPTO_RsaSignature **sig = spec->ptr;
1362
1363 if (NULL != *sig)
1364 {
1366 *sig = NULL;
1367 }
1368}
1369
1370
1373 struct GNUNET_CRYPTO_RsaSignature **sig)
1374{
1377 .cleaner = &clean_rsa_signature,
1378 .cls = NULL,
1379 .field = name,
1380 .ptr = sig,
1381 .ptr_size = 0,
1382 .size_ptr = NULL
1383 };
1384
1385 *sig = NULL;
1386 return ret;
1387}
1388
1389
1398static enum GNUNET_GenericReturnValue
1400 json_t *root,
1401 struct GNUNET_JSON_Specification *spec)
1402{
1403 int *bp = spec->ptr;
1404
1405 if (! json_is_boolean (root))
1406 {
1407 GNUNET_break_op (0);
1408 return GNUNET_SYSERR;
1409 }
1410 *bp = json_boolean_value (root) ? GNUNET_YES : GNUNET_NO;
1411 return GNUNET_OK;
1412}
1413
1414
1417 int *boolean)
1418{
1421 .field = name,
1422 .ptr = boolean,
1423 .ptr_size = sizeof(int),
1424 };
1425
1426 return ret;
1427}
1428
1429
1438static enum GNUNET_GenericReturnValue
1440 json_t *root,
1441 struct GNUNET_JSON_Specification *spec)
1442{
1443 struct GNUNET_CRYPTO_BlindedMessage **target = spec->ptr;
1444 struct GNUNET_CRYPTO_BlindedMessage *blinded_message;
1445 const char *cipher;
1446 struct GNUNET_JSON_Specification dspec[] = {
1447 GNUNET_JSON_spec_string ("cipher",
1448 &cipher),
1450 };
1451 const char *emsg;
1452 unsigned int eline;
1453
1454 (void) cls;
1455 if (GNUNET_OK !=
1456 GNUNET_JSON_parse (root,
1457 dspec,
1458 &emsg,
1459 &eline))
1460 {
1461 GNUNET_break_op (0);
1462 return GNUNET_SYSERR;
1463 }
1464 blinded_message = GNUNET_new (struct GNUNET_CRYPTO_BlindedMessage);
1465 blinded_message->rc = 1;
1466 blinded_message->cipher = string_to_cipher (cipher);
1467 switch (blinded_message->cipher)
1468 {
1470 break;
1472 {
1473 struct GNUNET_JSON_Specification ispec[] = {
1475 /* TODO: Change this field name to something
1476 more generic / pass in as argument. */
1477 "rsa_blinded_planchet",
1478 &blinded_message->details.rsa_blinded_message.blinded_msg,
1479 &blinded_message->details.rsa_blinded_message.blinded_msg_size),
1481 };
1482
1483 if (GNUNET_OK !=
1484 GNUNET_JSON_parse (root,
1485 ispec,
1486 &emsg,
1487 &eline))
1488 {
1489 GNUNET_break_op (0);
1490 GNUNET_free (blinded_message);
1491 return GNUNET_SYSERR;
1492 }
1493 *target = blinded_message;
1494 return GNUNET_OK;
1495 }
1497 {
1498 struct GNUNET_JSON_Specification ispec[] = {
1500 "cs_nonce",
1501 &blinded_message->details.cs_blinded_message.nonce),
1503 "cs_blinded_c0",
1504 &blinded_message->details.cs_blinded_message.c[0]),
1506 "cs_blinded_c1",
1507 &blinded_message->details.cs_blinded_message.c[1]),
1509 };
1510
1511 if (GNUNET_OK !=
1512 GNUNET_JSON_parse (root,
1513 ispec,
1514 &emsg,
1515 &eline))
1516 {
1517 GNUNET_break_op (0);
1518 GNUNET_free (blinded_message);
1519 return GNUNET_SYSERR;
1520 }
1521 *target = blinded_message;
1522 return GNUNET_OK;
1523 }
1524 }
1525 GNUNET_break_op (0);
1526 GNUNET_free (blinded_message);
1527 return GNUNET_SYSERR;
1528}
1529
1530
1537static void
1539 struct GNUNET_JSON_Specification *spec)
1540{
1541 struct GNUNET_CRYPTO_BlindedMessage **blinded_message = spec->ptr;
1542
1543 (void) cls;
1544 if (NULL != blinded_message)
1545 {
1546 GNUNET_CRYPTO_blinded_message_decref (*blinded_message);
1547 *blinded_message = NULL;
1548 }
1549}
1550
1551
1555{
1558 .cleaner = &clean_blinded_message,
1559 .cls = NULL,
1560 .field = name,
1561 .ptr = msg,
1562 .ptr_size = 0,
1563 .size_ptr = NULL
1564 };
1565
1566 *msg = NULL;
1567 return ret;
1568}
1569
1570
1579static enum GNUNET_GenericReturnValue
1581 json_t *root,
1582 struct GNUNET_JSON_Specification *spec)
1583{
1584 struct GNUNET_CRYPTO_BlindedSignature **target = spec->ptr;
1585 struct GNUNET_CRYPTO_BlindedSignature *blinded_sig;
1586 const char *cipher;
1587 struct GNUNET_JSON_Specification dspec[] = {
1588 GNUNET_JSON_spec_string ("cipher",
1589 &cipher),
1591 };
1592 const char *emsg;
1593 unsigned int eline;
1594
1595 (void) cls;
1596 if (GNUNET_OK !=
1597 GNUNET_JSON_parse (root,
1598 dspec,
1599 &emsg,
1600 &eline))
1601 {
1602 GNUNET_break_op (0);
1603 return GNUNET_SYSERR;
1604 }
1605 blinded_sig = GNUNET_new (struct GNUNET_CRYPTO_BlindedSignature);
1606 blinded_sig->cipher = string_to_cipher (cipher);
1607 blinded_sig->rc = 1;
1608 switch (blinded_sig->cipher)
1609 {
1611 break;
1613 {
1614 struct GNUNET_JSON_Specification ispec[] = {
1616 "blinded_rsa_signature",
1617 &blinded_sig->details.blinded_rsa_signature),
1619 };
1620
1621 if (GNUNET_OK !=
1622 GNUNET_JSON_parse (root,
1623 ispec,
1624 &emsg,
1625 &eline))
1626 {
1627 GNUNET_break_op (0);
1628 GNUNET_free (blinded_sig);
1629 return GNUNET_SYSERR;
1630 }
1631 *target = blinded_sig;
1632 return GNUNET_OK;
1633 }
1635 {
1636 struct GNUNET_JSON_Specification ispec[] = {
1638 &blinded_sig->details.blinded_cs_answer.b),
1640 &blinded_sig->details.blinded_cs_answer.
1641 s_scalar),
1643 };
1644
1645 if (GNUNET_OK !=
1646 GNUNET_JSON_parse (root,
1647 ispec,
1648 &emsg,
1649 &eline))
1650 {
1651 GNUNET_break_op (0);
1652 GNUNET_free (blinded_sig);
1653 return GNUNET_SYSERR;
1654 }
1655 *target = blinded_sig;
1656 return GNUNET_OK;
1657 }
1658 }
1659 GNUNET_break_op (0);
1660 GNUNET_free (blinded_sig);
1661 return GNUNET_SYSERR;
1662}
1663
1664
1671static void
1673 struct GNUNET_JSON_Specification *spec)
1674{
1675 struct GNUNET_CRYPTO_BlindedSignature **b_sig = spec->ptr;
1676
1677 (void) cls;
1678
1679 if (NULL != *b_sig)
1680 {
1682 *b_sig = NULL;
1683 }
1684}
1685
1686
1690 b_sig)
1691{
1694 .cleaner = &clean_blinded_sig,
1695 .field = field,
1696 .ptr = b_sig
1697 };
1698
1699 *b_sig = NULL;
1700 return ret;
1701}
1702
1703
1712static enum GNUNET_GenericReturnValue
1714 json_t *root,
1715 struct GNUNET_JSON_Specification *spec)
1716{
1717 struct GNUNET_CRYPTO_UnblindedSignature **target = spec->ptr;
1718 struct GNUNET_CRYPTO_UnblindedSignature *unblinded_sig;
1719 const char *cipher;
1720 struct GNUNET_JSON_Specification dspec[] = {
1721 GNUNET_JSON_spec_string ("cipher",
1722 &cipher),
1724 };
1725 const char *emsg;
1726 unsigned int eline;
1727
1728 (void) cls;
1729 if (GNUNET_OK !=
1730 GNUNET_JSON_parse (root,
1731 dspec,
1732 &emsg,
1733 &eline))
1734 {
1735 GNUNET_break_op (0);
1736 return GNUNET_SYSERR;
1737 }
1738 unblinded_sig = GNUNET_new (struct GNUNET_CRYPTO_UnblindedSignature);
1739 unblinded_sig->cipher = string_to_cipher (cipher);
1740 unblinded_sig->rc = 1;
1741 switch (unblinded_sig->cipher)
1742 {
1744 break;
1746 {
1747 struct GNUNET_JSON_Specification ispec[] = {
1749 "rsa_signature",
1750 &unblinded_sig->details.rsa_signature),
1752 };
1753
1754 if (GNUNET_OK !=
1755 GNUNET_JSON_parse (root,
1756 ispec,
1757 &emsg,
1758 &eline))
1759 {
1760 GNUNET_break_op (0);
1761 GNUNET_free (unblinded_sig);
1762 return GNUNET_SYSERR;
1763 }
1764 *target = unblinded_sig;
1765 return GNUNET_OK;
1766 }
1768 {
1769 struct GNUNET_JSON_Specification ispec[] = {
1770 GNUNET_JSON_spec_fixed_auto ("cs_signature_r",
1771 &unblinded_sig->details.cs_signature.
1772 r_point),
1773 GNUNET_JSON_spec_fixed_auto ("cs_signature_s",
1774 &unblinded_sig->details.cs_signature.
1775 s_scalar),
1777 };
1778
1779 if (GNUNET_OK !=
1780 GNUNET_JSON_parse (root,
1781 ispec,
1782 &emsg,
1783 &eline))
1784 {
1785 GNUNET_break_op (0);
1786 GNUNET_free (unblinded_sig);
1787 return GNUNET_SYSERR;
1788 }
1789 *target = unblinded_sig;
1790 return GNUNET_OK;
1791 }
1792 }
1793 GNUNET_break_op (0);
1794 GNUNET_free (unblinded_sig);
1795 return GNUNET_SYSERR;
1796}
1797
1798
1805static void
1807 struct GNUNET_JSON_Specification *spec)
1808{
1809 struct GNUNET_CRYPTO_UnblindedSignature **ub_sig = spec->ptr;
1810
1811 (void) cls;
1812 if (NULL != *ub_sig)
1813 {
1815 *ub_sig = NULL;
1816 }
1817}
1818
1819
1823 ub_sig)
1824{
1827 .cleaner = &clean_unblinded_sig,
1828 .field = field,
1829 .ptr = ub_sig
1830 };
1831
1832 *ub_sig = NULL;
1833 return ret;
1834}
1835
1836
1845static enum GNUNET_GenericReturnValue
1847 json_t *root,
1848 struct GNUNET_JSON_Specification *spec)
1849{
1851 = (enum GNUNET_TIME_RounderInterval *) spec->ptr;
1852
1853 (void) cls;
1854 if (json_is_string (root))
1855 {
1856 const char *str;
1857
1858 str = json_string_value (root);
1859 if (NULL == str)
1860 {
1861 GNUNET_break_op (0);
1862 return GNUNET_SYSERR;
1863 }
1864 if (GNUNET_OK !=
1866 res))
1867 {
1868 GNUNET_break_op (0);
1869 return GNUNET_SYSERR;
1870 }
1871 return GNUNET_OK;
1872 }
1873 return GNUNET_SYSERR;
1874}
1875
1876
1879 const char *name,
1881{
1883 .parser = &parse_tri,
1884 .field = name,
1885 .ptr = ri
1886 };
1887
1889 return ret;
1890
1891}
1892
1893
1894/* end of json_helper.c */
struct GNUNET_MessageHeader * msg
Definition 005.c:2
static int ret
Final status code.
Definition gnunet-arm.c:93
static char * data
The data to insert into the dht.
static OpusEncoder * enc
OPUS encoder.
struct GNUNET_CRYPTO_BlindablePrivateKey pk
Private key from command line option, or NULL.
static char * name
Name (label) of the records to list.
static struct GNUNET_SCHEDULER_Task * t
Main task.
static char * res
Currently read line or NULL on EOF.
commonly used definitions; globals in this file are exempt from the rule that the module name ("commo...
functions to parse JSON objects into GNUnet objects
#define GNUNET_JSON_spec_fixed_auto(name, obj)
Fixed size object (in network byte order, encoded using Crockford Base32hex encoding).
enum GNUNET_GenericReturnValue GNUNET_JSON_parse(const json_t *root, struct GNUNET_JSON_Specification *spec, const char **error_json_name, unsigned int *error_line)
Navigate and parse data in a JSON tree.
Definition json.c:32
void GNUNET_CRYPTO_blinded_message_decref(struct GNUNET_CRYPTO_BlindedMessage *bm)
Decrement reference counter of a bm, and free it if it reaches zero.
#define GNUNET_log(kind,...)
void GNUNET_CRYPTO_rsa_signature_free(struct GNUNET_CRYPTO_RsaSignature *sig)
Free memory occupied by signature.
struct GNUNET_CRYPTO_RsaSignature * GNUNET_CRYPTO_rsa_signature_decode(const void *buf, size_t buf_size)
Decode the signature from the data-format back to the "normal", internal format.
GNUNET_CRYPTO_BlindSignatureAlgorithm
Types of public keys used for blind signatures.
struct GNUNET_CRYPTO_RsaPublicKey * GNUNET_CRYPTO_rsa_public_key_decode(const char *buf, size_t len)
Decode the public key from the data-format back to the "normal", internal format.
Definition crypto_rsa.c:423
void GNUNET_CRYPTO_rsa_public_key_free(struct GNUNET_CRYPTO_RsaPublicKey *key)
Free memory occupied by the public key.
Definition crypto_rsa.c:268
void GNUNET_CRYPTO_unblinded_sig_decref(struct GNUNET_CRYPTO_UnblindedSignature *ub_sig)
Decrement reference counter of a ub_sig, and free it if it reaches zero.
void GNUNET_CRYPTO_blinded_sig_decref(struct GNUNET_CRYPTO_BlindedSignature *blind_sig)
Decrement reference counter of a blind_sig, and free it if it reaches zero.
GNUNET_GenericReturnValue
Named constants for return values.
@ GNUNET_CRYPTO_BSA_INVALID
Invalid type of signature.
@ GNUNET_CRYPTO_BSA_CS
Clause Blind Schnorr signature.
@ GNUNET_CRYPTO_BSA_RSA
RSA blind signature.
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_NO
@ GNUNET_SYSERR
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
@ GNUNET_ERROR_TYPE_WARNING
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
enum GNUNET_GenericReturnValue GNUNET_STRINGS_string_to_data_alloc(const char *enc, size_t enclen, void **out, size_t *out_size)
Convert CrockfordBase32 encoding back to data.
Definition strings.c:898
enum GNUNET_GenericReturnValue GNUNET_STRINGS_string_to_data(const char *enc, size_t enclen, void *out, size_t out_size)
Convert CrockfordBase32 encoding back to data.
Definition strings.c:832
size_t GNUNET_STRINGS_base64_decode(const char *data, size_t len, void **output)
Decode from Base64.
Definition strings.c:1720
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
enum GNUNET_GenericReturnValue GNUNET_TIME_string_to_round_interval(const char *ri_str, enum GNUNET_TIME_RounderInterval *ri)
Convert rounding interval given as a string to the enum value.
Definition time.c:1268
#define GNUNET_TIME_UNIT_SECONDS
One second.
GNUNET_TIME_RounderInterval
Quantities by which we support round up absolute time values.
struct GNUNET_TIME_TimestampNBO GNUNET_TIME_timestamp_hton(struct GNUNET_TIME_Timestamp t)
Convert timestamp to network byte order.
Definition time.c:91
#define GNUNET_TIME_UNIT_FOREVER_ABS
Constant used to specify "forever".
@ GNUNET_TIME_RI_NONE
No rounding up.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_object_const(const char *name, const json_t **jsonp)
JSON object, reference counter not incremented.
static enum GNUNET_GenericReturnValue parse_object_copy(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to a JSON object and increment the reference counter.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_string_copy(const char *name, char **strptr)
The expected field stores a string.
static enum GNUNET_GenericReturnValue parse_string_copy(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to string, and make a copy.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_blinded_message(const char *name, struct GNUNET_CRYPTO_BlindedMessage **msg)
Specification for parsing a blinded message.
static enum GNUNET_GenericReturnValue parse_u32(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to a uint32_t.
static void clean_unblinded_sig(void *cls, struct GNUNET_JSON_Specification *spec)
Cleanup data left from parsing unblinded signature.
static enum GNUNET_GenericReturnValue parse_blinded_sig(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to a blinded signature.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_varsize(const char *name, void **obj, size_t *size)
Variable size object (in network byte order, encoded using Crockford Base32hex encoding).
struct GNUNET_JSON_Specification GNUNET_JSON_spec_fixed(const char *name, void *obj, size_t size)
Variable size object (in network byte order, encoded using Crockford Base32hex encoding).
static enum GNUNET_GenericReturnValue parse_u16(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to a uint16_t.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_end()
End of a parser specification.
Definition json_helper.c:34
static enum GNUNET_GenericReturnValue parse_i64(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to a int64_t.
static enum GNUNET_GenericReturnValue parse_blinded_message(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to a blinded message.
static enum GNUNET_GenericReturnValue parse_rsa_signature(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to RSA signature.
static enum GNUNET_GenericReturnValue parse_double(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to a double.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_json(const char *name, json_t **jsonp)
JSON object or array.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_int16(const char *name, int16_t *i16)
16-bit signed integer.
static enum GNUNET_GenericReturnValue parse_unblinded_sig(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to unblinded signature.
static void clean_rsa_public_key(void *cls, struct GNUNET_JSON_Specification *spec)
Cleanup data left from parsing RSA public key.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_blinded_signature(const char *field, struct GNUNET_CRYPTO_BlindedSignature **b_sig)
Specification for parsing a blinded signature.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_ull(const char *name, unsigned long long *ull)
Unsigned long long.
static void clean_rsa_signature(void *cls, struct GNUNET_JSON_Specification *spec)
Cleanup data left from parsing RSA signature.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_boolean(const char *name, int *boolean)
Boolean (true mapped to GNUNET_YES, false mapped to GNUNET_NO).
static enum GNUNET_GenericReturnValue parse_timestamp(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to a timestamp.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_rsa_public_key(const char *name, struct GNUNET_CRYPTO_RsaPublicKey **pk)
Specification for parsing an RSA public key.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_uint16(const char *name, uint16_t *u16)
16-bit integer.
static enum GNUNET_GenericReturnValue parse_u8(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to a uint8_t.
static enum GNUNET_GenericReturnValue parse_timestamp_nbo(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to absolute time.
static void clean_blinded_message(void *cls, struct GNUNET_JSON_Specification *spec)
Cleanup data left from parsing blinded message.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_timestamp_nbo(const char *name, struct GNUNET_TIME_TimestampNBO *at)
Timestamp in network byte order.
static enum GNUNET_GenericReturnValue parse_tri(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to enum GNUNET_TIME_RounderInterval
struct GNUNET_JSON_Specification GNUNET_JSON_spec_uint32(const char *name, uint32_t *u32)
32-bit integer.
static enum GNUNET_GenericReturnValue parse_ui(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to an unsigned int.
static enum GNUNET_GenericReturnValue parse_string(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to string.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_string(const char *name, const char **strptr)
The expected field stores a string.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_array_copy(const char *name, json_t **jsonp)
JSON array, reference counter incremented.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_double(const char *name, double *f)
double.
static enum GNUNET_GenericReturnValue parse_object_const(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to a JSON object.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_int64(const char *name, int64_t *i64)
64-bit signed integer.
static enum GNUNET_GenericReturnValue parse_boolean(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to an int as a boolean.
static enum GNUNET_CRYPTO_BlindSignatureAlgorithm string_to_cipher(const char *cipher_s)
Convert string value to numeric cipher value.
Definition json_helper.c:51
struct GNUNET_JSON_Specification GNUNET_JSON_spec_rsa_signature(const char *name, struct GNUNET_CRYPTO_RsaSignature **sig)
Specification for parsing an RSA signature.
static enum GNUNET_GenericReturnValue parse_fixed64_data(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to fixed size data.
static void clean_blinded_sig(void *cls, struct GNUNET_JSON_Specification *spec)
Cleanup data left from parsing blinded sig.
static enum GNUNET_GenericReturnValue parse_ull(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to an unsigned long long.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_uint(const char *name, unsigned int *ui)
Unsigned integer.
static enum GNUNET_GenericReturnValue parse_array_copy(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON to a JSON array and increment the reference counter.
static void clean_json(void *cls, struct GNUNET_JSON_Specification *spec)
Cleanup data left from parsing JSON object.
static enum GNUNET_GenericReturnValue parse_i16(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to a int16_t.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_timestamp(const char *name, struct GNUNET_TIME_Timestamp *t)
Timestamp.
static enum GNUNET_GenericReturnValue parse_array_const(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON to a JSON array.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_unblinded_signature(const char *field, struct GNUNET_CRYPTO_UnblindedSignature **ub_sig)
Specification for parsing an unblinded signature.
static enum GNUNET_GenericReturnValue parse_fixed_data(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to fixed size data.
Definition json_helper.c:76
struct GNUNET_JSON_Specification GNUNET_JSON_spec_array_const(const char *name, const json_t **jsonp)
JSON array, reference counter not incremented.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_fixed64(const char *name, void *obj, size_t size)
Variable size object (in network byte order, encoded using base64 encoding).
static enum GNUNET_GenericReturnValue parse_u64(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to a uint64_t.
static enum GNUNET_GenericReturnValue parse_bool(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to a bool.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_time_rounder_interval(const char *name, enum GNUNET_TIME_RounderInterval *ri)
Provide specification to parse a time rounder interval.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_bool(const char *name, bool *b)
boolean.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_relative_time(const char *name, struct GNUNET_TIME_Relative *rt)
Relative time.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_uint8(const char *name, uint8_t *u8)
8-bit integer.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_uint64(const char *name, uint64_t *u64)
64-bit integer.
static enum GNUNET_GenericReturnValue parse_rel_time(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to relative time.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_object_copy(const char *name, json_t **jsonp)
JSON object, reference counter incremented.
static enum GNUNET_GenericReturnValue parse_json(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to a JSON object.
static enum GNUNET_GenericReturnValue parse_rsa_public_key(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to RSA public key.
static void clean_variable_data(void *cls, struct GNUNET_JSON_Specification *spec)
Cleanup data left from parsing variable size data.
static enum GNUNET_GenericReturnValue parse_variable_data(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to variable size data.
static unsigned int size
Size of the "table".
Definition peer.c:68
#define SIZE_MAX
Definition platform.h:209
Blinded message ready for blind signing.
unsigned int rc
Reference counter.
enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher
Type of the sign blinded message.
struct GNUNET_CRYPTO_CsBlindedMessage cs_blinded_message
If we use GNUNET_CRYPTO_BSA_CS in cipher.
union GNUNET_CRYPTO_BlindedMessage::@22 details
Details, depending on cipher.
struct GNUNET_CRYPTO_RsaBlindedMessage rsa_blinded_message
If we use GNUNET_CRYPTO_BSA_RSA in cipher.
Type for blinded signatures.
unsigned int rc
Reference counter.
struct GNUNET_CRYPTO_CsBlindSignature blinded_cs_answer
If we use GNUNET_CRYPTO_BSA_CS in cipher.
enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher
Type of the signature.
struct GNUNET_CRYPTO_RsaSignature * blinded_rsa_signature
If we use GNUNET_CRYPTO_BSA_RSA in cipher.
union GNUNET_CRYPTO_BlindedSignature::@19 details
Details, depending on cipher.
unsigned int b
To make ROS problem harder, the signer chooses an unpredictable b and only calculates signature of c_...
struct GNUNET_CRYPTO_CsC c[2]
The Clause Schnorr c_0 and c_1 containing the blinded message.
struct GNUNET_CRYPTO_CsSessionNonce nonce
Nonce used in initial request.
size_t blinded_msg_size
Size of the blinded_msg to be signed.
void * blinded_msg
Blinded message to be signed Note: is malloc()'ed!
The public information of an RSA key pair.
Definition crypto_rsa.c:53
Type of (unblinded) signatures.
union GNUNET_CRYPTO_UnblindedSignature::@18 details
Details, depending on cipher.
struct GNUNET_CRYPTO_RsaSignature * rsa_signature
If we use GNUNET_CRYPTO_BSA_RSA in cipher.
unsigned int rc
Reference counter.
struct GNUNET_CRYPTO_CsSignature cs_signature
If we use GNUNET_CRYPTO_BSA_CS in cipher.
enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher
Type of the signature.
Entry in parser specification for GNUNET_JSON_parse().
void * ptr
Pointer, details specific to the parser.
const char * field
Name of the field to parse, use NULL to get the JSON of the main object instead of the JSON of an ind...
size_t ptr_size
Number of bytes available in ptr.
size_t * size_ptr
Where should we store the final size of ptr.
void * cls
Closure for parser and cleaner.
GNUNET_JSON_Parser parser
Function for how to parse this type of entry.
uint64_t abs_value_us
The actual value.
Time for relative time used by GNUnet, in microseconds.
uint64_t rel_value_us
The actual value.
Time for timestamps used by GNUnet, in seconds and in network byte order.
Time for timestamps used by GNUnet, in microseconds rounded to seconds.
struct GNUNET_TIME_Absolute abs_time
The actual value.
enum GNUNET_TIME_RounderInterval ri
Definition time.c:1251
const char * str
Definition time.c:1252