GNUnet 0.24.1-15-gab6ed22f1
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_json_lib.h"
29#include "gnunet_common.h"
30
31
34{
36 .parser = NULL,
37 };
38
39 return ret;
40}
41
42
50string_to_cipher (const char *cipher_s)
51{
52 if ((0 == strcasecmp (cipher_s,
53 "RSA")) ||
54 (0 == strcasecmp (cipher_s,
55 "RSA+age_restricted")))
57 if ((0 == strcasecmp (cipher_s,
58 "CS")) ||
59 (0 == strcasecmp (cipher_s,
60 "CS+age_restricted")))
63}
64
65
76 json_t *root,
77 struct GNUNET_JSON_Specification *spec)
78{
79 const char *enc;
80 size_t len;
81
82 if (NULL == (enc = json_string_value (root)))
83 {
85 return GNUNET_SYSERR;
86 }
87 len = strlen (enc);
88 if (len >= SIZE_MAX / 5)
89 {
91 return GNUNET_SYSERR;
92 }
93 if (((len * 5) / 8) != spec->ptr_size)
94 {
97 "Field `%s' has wrong length\n",
98 spec->field);
99 return GNUNET_SYSERR;
100 }
101 if (GNUNET_OK !=
103 len,
104 spec->ptr,
105 spec->ptr_size))
106 {
107 GNUNET_break_op (0);
108 return GNUNET_SYSERR;
109 }
110 return GNUNET_OK;
111}
112
113
116 void *obj,
117 size_t size)
118{
120 .parser = &parse_fixed_data,
121 .field = name,
122 .ptr = obj,
123 .ptr_size = size,
124 };
125
126 return ret;
127}
128
129
140 json_t *root,
141 struct GNUNET_JSON_Specification *spec)
142{
143 const char *enc;
144 unsigned int len;
145 void *output;
146 size_t olen;
147
148 if (NULL == (enc = json_string_value (root)))
149 {
150 GNUNET_break_op (0);
151 return GNUNET_SYSERR;
152 }
153 len = strlen (enc);
154 output = NULL;
156 len,
157 &output);
158 if (olen != spec->ptr_size)
159 {
160 GNUNET_break_op (0);
162 "Field `%s' has wrong length\n",
163 spec->field);
164 GNUNET_free (output);
165 return GNUNET_SYSERR;
166 }
167 memcpy (spec->ptr,
168 output,
169 olen);
170 GNUNET_free (output);
171 return GNUNET_OK;
172}
173
174
177 void *obj,
178 size_t size)
179{
181 .parser = &parse_fixed64_data,
182 .field = name,
183 .ptr = obj,
184 .ptr_size = size,
185 };
186
187 return ret;
188}
189
190
201 json_t *root,
202 struct GNUNET_JSON_Specification *spec)
203{
204 const char *str;
205 size_t size;
206 void *data;
207
208 str = json_string_value (root);
209 if (NULL == str)
210 {
211 GNUNET_break_op (0);
212 return GNUNET_SYSERR;
213 }
214 if (GNUNET_OK !=
216 strlen (str),
217 &data,
218 &size))
219 {
220 GNUNET_break_op (0);
221 return GNUNET_SYSERR;
222 }
223 *(void **) spec->ptr = data;
224 *spec->size_ptr = size;
225 return GNUNET_OK;
226}
227
228
235static void
237 struct GNUNET_JSON_Specification *spec)
238{
239 (void) cls;
240 if (0 != *spec->size_ptr)
241 {
242 GNUNET_free (*(void **) spec->ptr);
243 *(void **) spec->ptr = NULL;
244 *spec->size_ptr = 0;
245 }
246}
247
248
251 void **obj,
252 size_t *size)
253{
255 .parser = &parse_variable_data,
256 .cleaner = &clean_variable_data,
257 .field = name,
258 .ptr = obj,
259 .size_ptr = size
260 };
261
262 *obj = NULL;
263 *size = 0;
264 return ret;
265}
266
267
278 json_t *root,
279 struct GNUNET_JSON_Specification *spec)
280{
281 const char *str;
282
283 (void) cls;
284 str = json_string_value (root);
285 if (NULL == str)
286 {
287 GNUNET_break_op (0);
288 return GNUNET_SYSERR;
289 }
290 *(const char **) spec->ptr = str;
291 return GNUNET_OK;
292}
293
294
297 const char **strptr)
298{
300 .parser = &parse_string,
301 .field = name,
302 .ptr = strptr
303 };
304
305 *strptr = NULL;
306 return ret;
307}
308
309
320 json_t *root,
321 struct GNUNET_JSON_Specification *spec)
322{
323 const char *str;
324
325 (void) cls;
326 str = json_string_value (root);
327 if (NULL == str)
328 {
329 GNUNET_break_op (0);
330 return GNUNET_SYSERR;
331 }
332 *((char **) spec->ptr) = GNUNET_strdup (str);
333 return GNUNET_OK;
334}
335
336
339 char **strptr)
340{
342 .parser = &parse_string_copy,
343 .field = name,
344 .ptr = strptr
345 };
346
347 *strptr = NULL;
348 return ret;
349}
350
351
362 json_t *root,
363 struct GNUNET_JSON_Specification *spec)
364{
365 if (! (json_is_object (root) || json_is_array (root)))
366 {
367 GNUNET_break_op (0);
368 return GNUNET_SYSERR;
369 }
370 *(json_t **) spec->ptr = json_incref (root);
371 return GNUNET_OK;
372}
373
374
381static void
383 struct GNUNET_JSON_Specification *spec)
384{
385 json_t **ptr = (json_t **) spec->ptr;
386
387 if (NULL != *ptr)
388 {
389 json_decref (*ptr);
390 *ptr = NULL;
391 }
392}
393
394
397 json_t **jsonp)
398{
400 .parser = &parse_json,
401 .cleaner = &clean_json,
402 .field = name,
403 .ptr = jsonp,
404 };
405
406 *jsonp = NULL;
407 return ret;
408}
409
410
421 json_t *root,
422 struct GNUNET_JSON_Specification *spec)
423{
424 if (NULL == root)
425 return GNUNET_OK;
426 if (! json_is_object (root))
427 {
428 GNUNET_break_op (0);
429 return GNUNET_SYSERR;
430 }
431 *(const json_t **) spec->ptr = (const json_t *) root;
432 return GNUNET_OK;
433}
434
435
438 const json_t **jsonp)
439{
441 .parser = &parse_object_const,
442 .field = name,
443 .ptr = jsonp,
444 };
445
446 *jsonp = NULL;
447 return ret;
448}
449
450
461 json_t *root,
462 struct GNUNET_JSON_Specification *spec)
463{
464 if (NULL == root)
465 return GNUNET_OK;
466 if (! json_is_object (root))
467 {
468 GNUNET_break_op (0);
469 return GNUNET_SYSERR;
470 }
471 *((json_t **) spec->ptr) = json_incref (root);
472 return GNUNET_OK;
473}
474
475
478 json_t **jsonp)
479{
481 .parser = &parse_object_copy,
482 .cls = &clean_json,
483 .field = name,
484 .ptr = jsonp,
485 };
486
487 *jsonp = NULL;
488 return ret;
489}
490
491
502 json_t *root,
503 struct GNUNET_JSON_Specification *spec)
504{
505 if (NULL == root)
506 return GNUNET_OK;
507 if (! json_is_array (root))
508 {
509 GNUNET_break_op (0);
510 return GNUNET_SYSERR;
511 }
512 *(const json_t **) spec->ptr = (const json_t *) root;
513 return GNUNET_OK;
514}
515
516
519 const json_t **jsonp)
520{
522 .parser = &parse_array_const,
523 .field = name,
524 .ptr = jsonp
525 };
526
527 *jsonp = NULL;
528 return ret;
529}
530
531
542 json_t *root,
543 struct GNUNET_JSON_Specification *spec)
544{
545 if (NULL == root)
546 return GNUNET_OK;
547 if (! json_is_array (root))
548 {
549 GNUNET_break_op (0);
550 return GNUNET_SYSERR;
551 }
552 *((json_t **) spec->ptr) = json_incref (root);
553 return GNUNET_OK;
554}
555
556
559 json_t **jsonp)
560{
562 .parser = &parse_array_copy,
563 .cleaner = &clean_json,
564 .field = name,
565 .ptr = jsonp
566 };
567
568 *jsonp = NULL;
569 return ret;
570}
571
572
583 json_t *root,
584 struct GNUNET_JSON_Specification *spec)
585{
586 bool *b = spec->ptr;
587
588 if (json_true () == root)
589 {
590 *b = true;
591 return GNUNET_OK;
592 }
593 if (json_false () == root)
594 {
595 *b = false;
596 return GNUNET_OK;
597 }
598 GNUNET_break_op (0);
599 return GNUNET_SYSERR;
600}
601
602
605 bool *b)
606{
608 .parser = &parse_bool,
609 .field = name,
610 .ptr = b,
611 .ptr_size = sizeof(bool),
612 };
613
614 return ret;
615}
616
617
628 json_t *root,
629 struct GNUNET_JSON_Specification *spec)
630{
631 double *f = spec->ptr;
632
633 if (! json_is_real (root))
634 {
635 GNUNET_break_op (0);
636 return GNUNET_SYSERR;
637 }
638 *f = json_real_value (root);
639 return GNUNET_OK;
640}
641
642
645 double *f)
646{
648 .parser = &parse_double,
649 .field = name,
650 .ptr = f,
651 .ptr_size = sizeof(double),
652 };
653
654 return ret;
655}
656
657
668 json_t *root,
669 struct GNUNET_JSON_Specification *spec)
670{
671 json_int_t val;
672 uint8_t *up = spec->ptr;
673
674 if (! json_is_integer (root))
675 {
676 GNUNET_break_op (0);
677 return GNUNET_SYSERR;
678 }
679 val = json_integer_value (root);
680 if ((0 > val) || (val > UINT8_MAX))
681 {
682 GNUNET_break_op (0);
683 return GNUNET_SYSERR;
684 }
685 *up = (uint8_t) val;
686 return GNUNET_OK;
687}
688
689
692 uint8_t *u8)
693{
695 .parser = &parse_u8,
696 .field = name,
697 .ptr = u8,
698 .ptr_size = sizeof(uint8_t),
699 };
700
701 return ret;
702}
703
704
715 json_t *root,
716 struct GNUNET_JSON_Specification *spec)
717{
718 json_int_t val;
719 uint16_t *up = spec->ptr;
720
721 if (! json_is_integer (root))
722 {
723 GNUNET_break_op (0);
724 return GNUNET_SYSERR;
725 }
726 val = json_integer_value (root);
727 if ((0 > val) || (val > UINT16_MAX))
728 {
729 GNUNET_break_op (0);
730 return GNUNET_SYSERR;
731 }
732 *up = (uint16_t) val;
733 return GNUNET_OK;
734}
735
736
739 uint16_t *u16)
740{
742 .parser = &parse_u16,
743 .field = name,
744 .ptr = u16,
745 .ptr_size = sizeof(uint16_t),
746 };
747
748 return ret;
749}
750
751
762 json_t *root,
763 struct GNUNET_JSON_Specification *spec)
764{
765 json_int_t val;
766 uint32_t *up = spec->ptr;
767
768 if (! json_is_integer (root))
769 {
770 GNUNET_break_op (0);
771 return GNUNET_SYSERR;
772 }
773 val = json_integer_value (root);
774 if ((0 > val) || (val > UINT32_MAX))
775 {
776 GNUNET_break_op (0);
777 return GNUNET_SYSERR;
778 }
779 *up = (uint32_t) val;
780 return GNUNET_OK;
781}
782
783
786 uint32_t *u32)
787{
789 .parser = &parse_u32,
790 .field = name,
791 .ptr = u32,
792 .ptr_size = sizeof(uint32_t),
793 };
794
795 return ret;
796}
797
798
809 json_t *root,
810 struct GNUNET_JSON_Specification *spec)
811{
812 json_int_t val;
813 unsigned int *up = spec->ptr;
814
815 if (! json_is_integer (root))
816 {
817 GNUNET_break_op (0);
818 return GNUNET_SYSERR;
819 }
820 val = json_integer_value (root);
821 if ((0 > val) || (val > UINT_MAX))
822 {
823 GNUNET_break_op (0);
824 return GNUNET_SYSERR;
825 }
826 *up = (unsigned int) val;
827 return GNUNET_OK;
828}
829
830
833 unsigned int *ui)
834{
836 .parser = &parse_ui,
837 .field = name,
838 .ptr = ui,
839 .ptr_size = sizeof(unsigned int),
840 };
841
842 return ret;
843}
844
845
856 json_t *root,
857 struct GNUNET_JSON_Specification *spec)
858{
859 json_int_t val;
860 unsigned long long *up = spec->ptr;
861
862 if (! json_is_integer (root))
863 {
864 GNUNET_break_op (0);
865 return GNUNET_SYSERR;
866 }
867 val = json_integer_value (root);
868 if ((0 > val) || (val > ULLONG_MAX))
869 {
870 GNUNET_break_op (0);
871 return GNUNET_SYSERR;
872 }
873 *up = (unsigned long long) val;
874 return GNUNET_OK;
875}
876
877
880 unsigned long long *ull)
881{
883 .parser = &parse_ull,
884 .field = name,
885 .ptr = ull,
886 .ptr_size = sizeof(unsigned long long),
887 };
888
889 return ret;
890}
891
892
903 json_t *root,
904 struct GNUNET_JSON_Specification *spec)
905{
906 json_int_t val;
907 uint64_t *up = spec->ptr;
908
909 if (! json_is_integer (root))
910 {
911 GNUNET_break_op (0);
912 return GNUNET_SYSERR;
913 }
914 val = json_integer_value (root);
915 *up = (uint64_t) val;
916 return GNUNET_OK;
917}
918
919
922 uint64_t *u64)
923{
925 .parser = &parse_u64,
926 .field = name,
927 .ptr = u64,
928 .ptr_size = sizeof(uint64_t),
929 };
930
931 return ret;
932}
933
934
945 json_t *root,
946 struct GNUNET_JSON_Specification *spec)
947{
948 json_int_t val;
949 int16_t *up = spec->ptr;
950
951 if (! json_is_integer (root))
952 {
953 GNUNET_break_op (0);
954 return GNUNET_SYSERR;
955 }
956 val = json_integer_value (root);
957 if ( (val < INT16_MIN) ||
958 (val > INT16_MAX) )
959 {
960 GNUNET_break_op (0);
961 return GNUNET_SYSERR;
962 }
963 *up = (int16_t) val;
964 return GNUNET_OK;
965}
966
967
970 int16_t *i16)
971{
973 .parser = &parse_i16,
974 .field = name,
975 .ptr = i16,
976 .ptr_size = sizeof(int16_t),
977 };
978
979 return ret;
980}
981
982
993 json_t *root,
994 struct GNUNET_JSON_Specification *spec)
995{
996 json_int_t val;
997 int64_t *up = spec->ptr;
998
999 if (! json_is_integer (root))
1000 {
1001 GNUNET_break_op (0);
1002 return GNUNET_SYSERR;
1003 }
1004 val = json_integer_value (root);
1005 *up = (int64_t) val;
1006 return GNUNET_OK;
1007}
1008
1009
1012 int64_t *i64)
1013{
1015 .parser = &parse_i64,
1016 .field = name,
1017 .ptr = i64,
1018 .ptr_size = sizeof(int64_t),
1019 };
1020
1021 return ret;
1022}
1023
1024
1025/* ************ GNUnet-specific parser specifications ******************* */
1026
1035static enum GNUNET_GenericReturnValue
1037 json_t *root,
1038 struct GNUNET_JSON_Specification *spec)
1039{
1040 struct GNUNET_TIME_Timestamp *ts = spec->ptr;
1041 json_t *json_t_s;
1042 unsigned long long int tval;
1043
1044 if (! json_is_object (root))
1045 {
1046 GNUNET_break_op (0);
1047 return GNUNET_SYSERR;
1048 }
1049 json_t_s = json_object_get (root,
1050 "t_s");
1051 if (json_is_integer (json_t_s))
1052 {
1053 tval = json_integer_value (json_t_s);
1054 /* Time is in seconds in JSON, but in microseconds in GNUNET_TIME_Absolute */
1056 = tval * GNUNET_TIME_UNIT_SECONDS.rel_value_us;
1057 if (ts->abs_time.abs_value_us
1058 / GNUNET_TIME_UNIT_SECONDS.rel_value_us
1059 != tval)
1060 {
1061 /* Integer overflow */
1062 GNUNET_break_op (0);
1063 return GNUNET_SYSERR;
1064 }
1065 return GNUNET_OK;
1066 }
1067 if (json_is_string (json_t_s))
1068 {
1069 const char *val;
1070
1071 val = json_string_value (json_t_s);
1072 if ((0 == strcasecmp (val,
1073 "never")))
1074 {
1076 return GNUNET_OK;
1077 }
1078 GNUNET_break_op (0);
1079 return GNUNET_SYSERR;
1080 }
1081 GNUNET_break_op (0);
1082 return GNUNET_SYSERR;
1083}
1084
1085
1088 struct GNUNET_TIME_Timestamp *t)
1089{
1091 .parser = &parse_timestamp,
1092 .field = name,
1093 .ptr = t,
1094 .ptr_size = sizeof(struct GNUNET_TIME_Timestamp)
1095 };
1096
1097 return ret;
1098}
1099
1100
1109static enum GNUNET_GenericReturnValue
1111 json_t *root,
1112 struct GNUNET_JSON_Specification *spec)
1113{
1114 struct GNUNET_TIME_TimestampNBO *ts = spec->ptr;
1115 struct GNUNET_TIME_Timestamp a;
1116 struct GNUNET_JSON_Specification ispec;
1117
1118 ispec = *spec;
1119 ispec.parser = &parse_timestamp;
1120 ispec.ptr = &a;
1121 if (GNUNET_OK !=
1122 parse_timestamp (NULL,
1123 root,
1124 &ispec))
1125 return GNUNET_SYSERR;
1127 return GNUNET_OK;
1128}
1129
1130
1133 struct GNUNET_TIME_TimestampNBO *at)
1134{
1136 .parser = &parse_timestamp_nbo,
1137 .field = name,
1138 .ptr = at,
1139 .ptr_size = sizeof(struct GNUNET_TIME_TimestampNBO)
1140 };
1141
1142 return ret;
1143}
1144
1145
1154static enum GNUNET_GenericReturnValue
1156 json_t *root,
1157 struct GNUNET_JSON_Specification *spec)
1158{
1159 struct GNUNET_TIME_Relative *rel = spec->ptr;
1160 json_t *json_d_us;
1161 unsigned long long int tval;
1162
1163 if (! json_is_object (root))
1164 {
1165 GNUNET_break_op (0);
1166 return GNUNET_SYSERR;
1167 }
1168 json_d_us = json_object_get (root,
1169 "d_us");
1170 if (json_is_integer (json_d_us))
1171 {
1172 tval = json_integer_value (json_d_us);
1173 if (tval >= (1LLU << 53))
1174 {
1175 /* value is larger than allowed */
1176 GNUNET_break_op (0);
1177 return GNUNET_SYSERR;
1178 }
1179 rel->rel_value_us = tval;
1180 return GNUNET_OK;
1181 }
1182 if (json_is_string (json_d_us))
1183 {
1184 const char *val;
1185
1186 val = json_string_value (json_d_us);
1187 if ((0 == strcasecmp (val,
1188 "forever")))
1189 {
1191 return GNUNET_OK;
1192 }
1193 GNUNET_break_op (0);
1194 return GNUNET_SYSERR;
1195 }
1196 GNUNET_break_op (0);
1197 return GNUNET_SYSERR;
1198}
1199
1200
1203 struct GNUNET_TIME_Relative *rt)
1204{
1206 .parser = &parse_rel_time,
1207 .field = name,
1208 .ptr = rt,
1209 .ptr_size = sizeof(struct GNUNET_TIME_Relative)
1210 };
1211
1212 return ret;
1213}
1214
1215
1224static enum GNUNET_GenericReturnValue
1226 json_t *root,
1227 struct GNUNET_JSON_Specification *spec)
1228{
1229 struct GNUNET_CRYPTO_RsaPublicKey **pk = spec->ptr;
1230 const char *enc;
1231 char *buf;
1232 size_t len;
1233 size_t buf_len;
1234
1235 if (NULL == (enc = json_string_value (root)))
1236 {
1237 GNUNET_break_op (0);
1238 return GNUNET_SYSERR;
1239 }
1240 len = strlen (enc);
1241 buf_len = (len * 5) / 8;
1242 buf = GNUNET_malloc (buf_len);
1243 if (GNUNET_OK !=
1245 len,
1246 buf,
1247 buf_len))
1248 {
1249 GNUNET_break_op (0);
1250 GNUNET_free (buf);
1251 return GNUNET_SYSERR;
1252 }
1253 if (NULL == (*pk = GNUNET_CRYPTO_rsa_public_key_decode (buf,
1254 buf_len)))
1255 {
1256 GNUNET_break_op (0);
1257 GNUNET_free (buf);
1258 return GNUNET_SYSERR;
1259 }
1260 GNUNET_free (buf);
1261 return GNUNET_OK;
1262}
1263
1264
1271static void
1273 struct GNUNET_JSON_Specification *spec)
1274{
1275 struct GNUNET_CRYPTO_RsaPublicKey **pk = spec->ptr;
1276
1277 if (NULL != *pk)
1278 {
1280 *pk = NULL;
1281 }
1282}
1283
1284
1288{
1290 .parser = &parse_rsa_public_key,
1291 .cleaner = &clean_rsa_public_key,
1292 .field = name,
1293 .ptr = pk
1294 };
1295
1296 *pk = NULL;
1297 return ret;
1298}
1299
1300
1309static enum GNUNET_GenericReturnValue
1311 json_t *root,
1312 struct GNUNET_JSON_Specification *spec)
1313{
1314 struct GNUNET_CRYPTO_RsaSignature **sig = spec->ptr;
1315 size_t size;
1316 const char *str;
1317 int res;
1318 void *buf;
1319
1320 str = json_string_value (root);
1321 if (NULL == str)
1322 {
1323 GNUNET_break_op (0);
1324 return GNUNET_SYSERR;
1325 }
1326 size = (strlen (str) * 5) / 8;
1327 buf = GNUNET_malloc (size);
1329 strlen (str),
1330 buf,
1331 size);
1332 if (GNUNET_OK != res)
1333 {
1334 GNUNET_free (buf);
1335 GNUNET_break_op (0);
1336 return GNUNET_SYSERR;
1337 }
1338 if (NULL == (*sig = GNUNET_CRYPTO_rsa_signature_decode (buf,
1339 size)))
1340 {
1341 GNUNET_break_op (0);
1342 GNUNET_free (buf);
1343 return GNUNET_SYSERR;
1344 }
1345 GNUNET_free (buf);
1346 return GNUNET_OK;
1347}
1348
1349
1356static void
1358 struct GNUNET_JSON_Specification *spec)
1359{
1360 struct GNUNET_CRYPTO_RsaSignature **sig = spec->ptr;
1361
1362 if (NULL != *sig)
1363 {
1365 *sig = NULL;
1366 }
1367}
1368
1369
1372 struct GNUNET_CRYPTO_RsaSignature **sig)
1373{
1375 .parser = &parse_rsa_signature,
1376 .cleaner = &clean_rsa_signature,
1377 .cls = NULL,
1378 .field = name,
1379 .ptr = sig,
1380 .ptr_size = 0,
1381 .size_ptr = NULL
1382 };
1383
1384 *sig = NULL;
1385 return ret;
1386}
1387
1388
1397static enum GNUNET_GenericReturnValue
1399 json_t *root,
1400 struct GNUNET_JSON_Specification *spec)
1401{
1402 int *bp = spec->ptr;
1403
1404 if (! json_is_boolean (root))
1405 {
1406 GNUNET_break_op (0);
1407 return GNUNET_SYSERR;
1408 }
1409 *bp = json_boolean_value (root) ? GNUNET_YES : GNUNET_NO;
1410 return GNUNET_OK;
1411}
1412
1413
1416 int *boolean)
1417{
1419 .parser = &parse_boolean,
1420 .field = name,
1421 .ptr = boolean,
1422 .ptr_size = sizeof(int),
1423 };
1424
1425 return ret;
1426}
1427
1428
1437static enum GNUNET_GenericReturnValue
1439 json_t *root,
1440 struct GNUNET_JSON_Specification *spec)
1441{
1442 struct GNUNET_CRYPTO_BlindedMessage **target = spec->ptr;
1443 struct GNUNET_CRYPTO_BlindedMessage *blinded_message;
1444 const char *cipher;
1445 struct GNUNET_JSON_Specification dspec[] = {
1446 GNUNET_JSON_spec_string ("cipher",
1447 &cipher),
1449 };
1450 const char *emsg;
1451 unsigned int eline;
1452
1453 (void) cls;
1454 if (GNUNET_OK !=
1455 GNUNET_JSON_parse (root,
1456 dspec,
1457 &emsg,
1458 &eline))
1459 {
1460 GNUNET_break_op (0);
1461 return GNUNET_SYSERR;
1462 }
1463 blinded_message = GNUNET_new (struct GNUNET_CRYPTO_BlindedMessage);
1464 blinded_message->rc = 1;
1465 blinded_message->cipher = string_to_cipher (cipher);
1466 switch (blinded_message->cipher)
1467 {
1469 break;
1471 {
1472 struct GNUNET_JSON_Specification ispec[] = {
1474 /* TODO: Change this field name to something
1475 more generic / pass in as argument. */
1476 "rsa_blinded_planchet",
1477 &blinded_message->details.rsa_blinded_message.blinded_msg,
1478 &blinded_message->details.rsa_blinded_message.blinded_msg_size),
1480 };
1481
1482 if (GNUNET_OK !=
1483 GNUNET_JSON_parse (root,
1484 ispec,
1485 &emsg,
1486 &eline))
1487 {
1488 GNUNET_break_op (0);
1489 GNUNET_free (blinded_message);
1490 return GNUNET_SYSERR;
1491 }
1492 *target = blinded_message;
1493 return GNUNET_OK;
1494 }
1496 {
1497 struct GNUNET_JSON_Specification ispec[] = {
1499 "cs_nonce",
1500 &blinded_message->details.cs_blinded_message.nonce),
1502 "cs_blinded_c0",
1503 &blinded_message->details.cs_blinded_message.c[0]),
1505 "cs_blinded_c1",
1506 &blinded_message->details.cs_blinded_message.c[1]),
1508 };
1509
1510 if (GNUNET_OK !=
1511 GNUNET_JSON_parse (root,
1512 ispec,
1513 &emsg,
1514 &eline))
1515 {
1516 GNUNET_break_op (0);
1517 GNUNET_free (blinded_message);
1518 return GNUNET_SYSERR;
1519 }
1520 *target = blinded_message;
1521 return GNUNET_OK;
1522 }
1523 }
1524 GNUNET_break_op (0);
1525 GNUNET_free (blinded_message);
1526 return GNUNET_SYSERR;
1527}
1528
1529
1536static void
1538 struct GNUNET_JSON_Specification *spec)
1539{
1540 struct GNUNET_CRYPTO_BlindedMessage **blinded_message = spec->ptr;
1541
1542 (void) cls;
1543 if (NULL != blinded_message)
1544 {
1545 GNUNET_CRYPTO_blinded_message_decref (*blinded_message);
1546 *blinded_message = NULL;
1547 }
1548}
1549
1550
1554{
1556 .parser = &parse_blinded_message,
1557 .cleaner = &clean_blinded_message,
1558 .cls = NULL,
1559 .field = name,
1560 .ptr = msg,
1561 .ptr_size = 0,
1562 .size_ptr = NULL
1563 };
1564
1565 *msg = NULL;
1566 return ret;
1567}
1568
1569
1578static enum GNUNET_GenericReturnValue
1580 json_t *root,
1581 struct GNUNET_JSON_Specification *spec)
1582{
1583 struct GNUNET_CRYPTO_BlindedSignature **target = spec->ptr;
1584 struct GNUNET_CRYPTO_BlindedSignature *blinded_sig;
1585 const char *cipher;
1586 struct GNUNET_JSON_Specification dspec[] = {
1587 GNUNET_JSON_spec_string ("cipher",
1588 &cipher),
1590 };
1591 const char *emsg;
1592 unsigned int eline;
1593
1594 (void) cls;
1595 if (GNUNET_OK !=
1596 GNUNET_JSON_parse (root,
1597 dspec,
1598 &emsg,
1599 &eline))
1600 {
1601 GNUNET_break_op (0);
1602 return GNUNET_SYSERR;
1603 }
1604 blinded_sig = GNUNET_new (struct GNUNET_CRYPTO_BlindedSignature);
1605 blinded_sig->cipher = string_to_cipher (cipher);
1606 blinded_sig->rc = 1;
1607 switch (blinded_sig->cipher)
1608 {
1610 break;
1612 {
1613 struct GNUNET_JSON_Specification ispec[] = {
1615 "blinded_rsa_signature",
1616 &blinded_sig->details.blinded_rsa_signature),
1618 };
1619
1620 if (GNUNET_OK !=
1621 GNUNET_JSON_parse (root,
1622 ispec,
1623 &emsg,
1624 &eline))
1625 {
1626 GNUNET_break_op (0);
1627 GNUNET_free (blinded_sig);
1628 return GNUNET_SYSERR;
1629 }
1630 *target = blinded_sig;
1631 return GNUNET_OK;
1632 }
1634 {
1635 struct GNUNET_JSON_Specification ispec[] = {
1637 &blinded_sig->details.blinded_cs_answer.b),
1639 &blinded_sig->details.blinded_cs_answer.
1640 s_scalar),
1642 };
1643
1644 if (GNUNET_OK !=
1645 GNUNET_JSON_parse (root,
1646 ispec,
1647 &emsg,
1648 &eline))
1649 {
1650 GNUNET_break_op (0);
1651 GNUNET_free (blinded_sig);
1652 return GNUNET_SYSERR;
1653 }
1654 *target = blinded_sig;
1655 return GNUNET_OK;
1656 }
1657 }
1658 GNUNET_break_op (0);
1659 GNUNET_free (blinded_sig);
1660 return GNUNET_SYSERR;
1661}
1662
1663
1670static void
1672 struct GNUNET_JSON_Specification *spec)
1673{
1674 struct GNUNET_CRYPTO_BlindedSignature **b_sig = spec->ptr;
1675
1676 (void) cls;
1677
1678 if (NULL != *b_sig)
1679 {
1681 *b_sig = NULL;
1682 }
1683}
1684
1685
1689 b_sig)
1690{
1692 .parser = &parse_blinded_sig,
1693 .cleaner = &clean_blinded_sig,
1694 .field = field,
1695 .ptr = b_sig
1696 };
1697
1698 *b_sig = NULL;
1699 return ret;
1700}
1701
1702
1711static enum GNUNET_GenericReturnValue
1713 json_t *root,
1714 struct GNUNET_JSON_Specification *spec)
1715{
1716 struct GNUNET_CRYPTO_UnblindedSignature **target = spec->ptr;
1717 struct GNUNET_CRYPTO_UnblindedSignature *unblinded_sig;
1718 const char *cipher;
1719 struct GNUNET_JSON_Specification dspec[] = {
1720 GNUNET_JSON_spec_string ("cipher",
1721 &cipher),
1723 };
1724 const char *emsg;
1725 unsigned int eline;
1726
1727 (void) cls;
1728 if (GNUNET_OK !=
1729 GNUNET_JSON_parse (root,
1730 dspec,
1731 &emsg,
1732 &eline))
1733 {
1734 GNUNET_break_op (0);
1735 return GNUNET_SYSERR;
1736 }
1737 unblinded_sig = GNUNET_new (struct GNUNET_CRYPTO_UnblindedSignature);
1738 unblinded_sig->cipher = string_to_cipher (cipher);
1739 unblinded_sig->rc = 1;
1740 switch (unblinded_sig->cipher)
1741 {
1743 break;
1745 {
1746 struct GNUNET_JSON_Specification ispec[] = {
1748 "rsa_signature",
1749 &unblinded_sig->details.rsa_signature),
1751 };
1752
1753 if (GNUNET_OK !=
1754 GNUNET_JSON_parse (root,
1755 ispec,
1756 &emsg,
1757 &eline))
1758 {
1759 GNUNET_break_op (0);
1760 GNUNET_free (unblinded_sig);
1761 return GNUNET_SYSERR;
1762 }
1763 *target = unblinded_sig;
1764 return GNUNET_OK;
1765 }
1767 {
1768 struct GNUNET_JSON_Specification ispec[] = {
1769 GNUNET_JSON_spec_fixed_auto ("cs_signature_r",
1770 &unblinded_sig->details.cs_signature.
1771 r_point),
1772 GNUNET_JSON_spec_fixed_auto ("cs_signature_s",
1773 &unblinded_sig->details.cs_signature.
1774 s_scalar),
1776 };
1777
1778 if (GNUNET_OK !=
1779 GNUNET_JSON_parse (root,
1780 ispec,
1781 &emsg,
1782 &eline))
1783 {
1784 GNUNET_break_op (0);
1785 GNUNET_free (unblinded_sig);
1786 return GNUNET_SYSERR;
1787 }
1788 *target = unblinded_sig;
1789 return GNUNET_OK;
1790 }
1791 }
1792 GNUNET_break_op (0);
1793 GNUNET_free (unblinded_sig);
1794 return GNUNET_SYSERR;
1795}
1796
1797
1804static void
1806 struct GNUNET_JSON_Specification *spec)
1807{
1808 struct GNUNET_CRYPTO_UnblindedSignature **ub_sig = spec->ptr;
1809
1810 (void) cls;
1811 if (NULL != *ub_sig)
1812 {
1814 *ub_sig = NULL;
1815 }
1816}
1817
1818
1822 ub_sig)
1823{
1825 .parser = &parse_unblinded_sig,
1826 .cleaner = &clean_unblinded_sig,
1827 .field = field,
1828 .ptr = ub_sig
1829 };
1830
1831 *ub_sig = NULL;
1832 return ret;
1833}
1834
1835
1836/* 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_PrivateKey pk
Private key from command line option, or NULL.
static char * name
Name (label) of the records to list.
static char * res
Currently read line or NULL on EOF.
static struct GNUNET_SCHEDULER_Task * t
Main task.
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.
Definition: crypto_rsa.c:1015
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.
Definition: crypto_rsa.c:1063
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:882
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:816
size_t GNUNET_STRINGS_base64_decode(const char *data, size_t len, void **output)
Decode from Base64.
Definition: strings.c:1704
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
#define GNUNET_TIME_UNIT_SECONDS
One second.
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".
struct GNUNET_JSON_Specification GNUNET_JSON_spec_object_const(const char *name, const json_t **jsonp)
JSON object, reference counter not incremented.
Definition: json_helper.c:437
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.
Definition: json_helper.c:460
struct GNUNET_JSON_Specification GNUNET_JSON_spec_string_copy(const char *name, char **strptr)
The expected field stores a string.
Definition: json_helper.c:338
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.
Definition: json_helper.c:319
struct GNUNET_JSON_Specification GNUNET_JSON_spec_blinded_message(const char *name, struct GNUNET_CRYPTO_BlindedMessage **msg)
Specification for parsing a blinded message.
Definition: json_helper.c:1552
static enum GNUNET_GenericReturnValue parse_u32(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to a uint32_t.
Definition: json_helper.c:761
static void clean_unblinded_sig(void *cls, struct GNUNET_JSON_Specification *spec)
Cleanup data left from parsing unblinded signature.
Definition: json_helper.c:1805
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.
Definition: json_helper.c:1579
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).
Definition: json_helper.c:250
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).
Definition: json_helper.c:115
static enum GNUNET_GenericReturnValue parse_u16(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to a uint16_t.
Definition: json_helper.c:714
struct GNUNET_JSON_Specification GNUNET_JSON_spec_end()
End of a parser specification.
Definition: json_helper.c:33
static enum GNUNET_GenericReturnValue parse_i64(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to a int64_t.
Definition: json_helper.c:992
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.
Definition: json_helper.c:1438
static enum GNUNET_GenericReturnValue parse_rsa_signature(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to RSA signature.
Definition: json_helper.c:1310
static enum GNUNET_GenericReturnValue parse_double(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to a double.
Definition: json_helper.c:627
struct GNUNET_JSON_Specification GNUNET_JSON_spec_json(const char *name, json_t **jsonp)
JSON object or array.
Definition: json_helper.c:396
struct GNUNET_JSON_Specification GNUNET_JSON_spec_int16(const char *name, int16_t *i16)
16-bit signed integer.
Definition: json_helper.c:969
static enum GNUNET_GenericReturnValue parse_unblinded_sig(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to unblinded signature.
Definition: json_helper.c:1712
static void clean_rsa_public_key(void *cls, struct GNUNET_JSON_Specification *spec)
Cleanup data left from parsing RSA public key.
Definition: json_helper.c:1272
struct GNUNET_JSON_Specification GNUNET_JSON_spec_blinded_signature(const char *field, struct GNUNET_CRYPTO_BlindedSignature **b_sig)
Specification for parsing a blinded signature.
Definition: json_helper.c:1687
struct GNUNET_JSON_Specification GNUNET_JSON_spec_ull(const char *name, unsigned long long *ull)
Unsigned long long.
Definition: json_helper.c:879
static void clean_rsa_signature(void *cls, struct GNUNET_JSON_Specification *spec)
Cleanup data left from parsing RSA signature.
Definition: json_helper.c:1357
struct GNUNET_JSON_Specification GNUNET_JSON_spec_boolean(const char *name, int *boolean)
Boolean (true mapped to GNUNET_YES, false mapped to GNUNET_NO).
Definition: json_helper.c:1415
static enum GNUNET_GenericReturnValue parse_timestamp(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to a timestamp.
Definition: json_helper.c:1036
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.
Definition: json_helper.c:1286
struct GNUNET_JSON_Specification GNUNET_JSON_spec_uint16(const char *name, uint16_t *u16)
16-bit integer.
Definition: json_helper.c:738
static enum GNUNET_GenericReturnValue parse_u8(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to a uint8_t.
Definition: json_helper.c:667
static enum GNUNET_GenericReturnValue parse_timestamp_nbo(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to absolute time.
Definition: json_helper.c:1110
static void clean_blinded_message(void *cls, struct GNUNET_JSON_Specification *spec)
Cleanup data left from parsing blinded message.
Definition: json_helper.c:1537
struct GNUNET_JSON_Specification GNUNET_JSON_spec_timestamp_nbo(const char *name, struct GNUNET_TIME_TimestampNBO *at)
Timestamp in network byte order.
Definition: json_helper.c:1132
struct GNUNET_JSON_Specification GNUNET_JSON_spec_uint32(const char *name, uint32_t *u32)
32-bit integer.
Definition: json_helper.c:785
static enum GNUNET_GenericReturnValue parse_ui(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to an unsigned int.
Definition: json_helper.c:808
static enum GNUNET_GenericReturnValue parse_string(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to string.
Definition: json_helper.c:277
struct GNUNET_JSON_Specification GNUNET_JSON_spec_string(const char *name, const char **strptr)
The expected field stores a string.
Definition: json_helper.c:296
struct GNUNET_JSON_Specification GNUNET_JSON_spec_array_copy(const char *name, json_t **jsonp)
JSON array, reference counter not incremented.
Definition: json_helper.c:558
struct GNUNET_JSON_Specification GNUNET_JSON_spec_double(const char *name, double *f)
double.
Definition: json_helper.c:644
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.
Definition: json_helper.c:420
struct GNUNET_JSON_Specification GNUNET_JSON_spec_int64(const char *name, int64_t *i64)
64-bit signed integer.
Definition: json_helper.c:1011
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.
Definition: json_helper.c:1398
static enum GNUNET_CRYPTO_BlindSignatureAlgorithm string_to_cipher(const char *cipher_s)
Convert string value to numeric cipher value.
Definition: json_helper.c:50
struct GNUNET_JSON_Specification GNUNET_JSON_spec_rsa_signature(const char *name, struct GNUNET_CRYPTO_RsaSignature **sig)
Specification for parsing an RSA signature.
Definition: json_helper.c:1371
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.
Definition: json_helper.c:139
static void clean_blinded_sig(void *cls, struct GNUNET_JSON_Specification *spec)
Cleanup data left from parsing blinded sig.
Definition: json_helper.c:1671
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.
Definition: json_helper.c:855
struct GNUNET_JSON_Specification GNUNET_JSON_spec_uint(const char *name, unsigned int *ui)
Unsigned integer.
Definition: json_helper.c:832
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.
Definition: json_helper.c:541
static void clean_json(void *cls, struct GNUNET_JSON_Specification *spec)
Cleanup data left from parsing JSON object.
Definition: json_helper.c:382
static enum GNUNET_GenericReturnValue parse_i16(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to a int16_t.
Definition: json_helper.c:944
struct GNUNET_JSON_Specification GNUNET_JSON_spec_timestamp(const char *name, struct GNUNET_TIME_Timestamp *t)
Timestamp.
Definition: json_helper.c:1087
static enum GNUNET_GenericReturnValue parse_array_const(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON to a JSON array.
Definition: json_helper.c:501
struct GNUNET_JSON_Specification GNUNET_JSON_spec_unblinded_signature(const char *field, struct GNUNET_CRYPTO_UnblindedSignature **ub_sig)
Specification for parsing an unblinded signature.
Definition: json_helper.c:1820
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:75
struct GNUNET_JSON_Specification GNUNET_JSON_spec_array_const(const char *name, const json_t **jsonp)
JSON array, reference counter not incremented.
Definition: json_helper.c:518
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).
Definition: json_helper.c:176
static enum GNUNET_GenericReturnValue parse_u64(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to a uint64_t.
Definition: json_helper.c:902
static enum GNUNET_GenericReturnValue parse_bool(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to a bool.
Definition: json_helper.c:582
struct GNUNET_JSON_Specification GNUNET_JSON_spec_bool(const char *name, bool *b)
boolean.
Definition: json_helper.c:604
struct GNUNET_JSON_Specification GNUNET_JSON_spec_relative_time(const char *name, struct GNUNET_TIME_Relative *rt)
Relative time.
Definition: json_helper.c:1202
struct GNUNET_JSON_Specification GNUNET_JSON_spec_uint8(const char *name, uint8_t *u8)
8-bit integer.
Definition: json_helper.c:691
struct GNUNET_JSON_Specification GNUNET_JSON_spec_uint64(const char *name, uint64_t *u64)
64-bit integer.
Definition: json_helper.c:921
static enum GNUNET_GenericReturnValue parse_rel_time(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to relative time.
Definition: json_helper.c:1155
struct GNUNET_JSON_Specification GNUNET_JSON_spec_object_copy(const char *name, json_t **jsonp)
JSON object, reference counter not incremented.
Definition: json_helper.c:477
static enum GNUNET_GenericReturnValue parse_json(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to a JSON object.
Definition: json_helper.c:361
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.
Definition: json_helper.c:1225
static void clean_variable_data(void *cls, struct GNUNET_JSON_Specification *spec)
Cleanup data left from parsing variable size data.
Definition: json_helper.c:236
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.
Definition: json_helper.c:200
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::@18 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.
union GNUNET_CRYPTO_BlindedSignature::@15 details
Details, depending on 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.
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
an RSA signature
Definition: crypto_rsa.c:65
Type of (unblinded) signatures.
struct GNUNET_CRYPTO_RsaSignature * rsa_signature
If we use GNUNET_CRYPTO_BSA_RSA in cipher.
unsigned int rc
Reference counter.
union GNUNET_CRYPTO_UnblindedSignature::@14 details
Details, depending on cipher.
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.