GNUnet  0.10.x
json_helper.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet
3  Copyright (C) 2014, 2015, 2016 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 
30 
36 {
37  struct GNUNET_JSON_Specification ret = {
38  .parser = NULL,
39  .cleaner = NULL,
40  .cls = NULL
41  };
42  return ret;
43 }
44 
45 
54 static int
56  json_t *root,
57  struct GNUNET_JSON_Specification *spec)
58 {
59  const char *enc;
60  unsigned int len;
61 
62  if (NULL == (enc = json_string_value (root)))
63  {
64  GNUNET_break_op (0);
65  return GNUNET_SYSERR;
66  }
67  len = strlen (enc);
68  if (((len * 5) / 8) != spec->ptr_size)
69  {
70  GNUNET_break_op (0);
71  return GNUNET_SYSERR;
72  }
73  if (GNUNET_OK !=
75  len,
76  spec->ptr,
77  spec->ptr_size))
78  {
79  GNUNET_break_op (0);
80  return GNUNET_SYSERR;
81  }
82  return GNUNET_OK;
83 }
84 
85 
96  void *obj,
97  size_t size)
98 {
99  struct GNUNET_JSON_Specification ret = {
101  .cleaner = NULL,
102  .cls = NULL,
103  .field = name,
104  .ptr = obj,
105  .ptr_size = size,
106  .size_ptr = NULL
107  };
108  return ret;
109 }
110 
111 
120 static int
122  json_t *root,
123  struct GNUNET_JSON_Specification *spec)
124 {
125  const char *str;
126  size_t size;
127  void *data;
128  int res;
129 
130  str = json_string_value (root);
131  if (NULL == str)
132  {
133  GNUNET_break_op (0);
134  return GNUNET_SYSERR;
135  }
136  size = (strlen (str) * 5) / 8;
137  if (size >= 1024)
138  {
139  GNUNET_break_op (0);
140  return GNUNET_SYSERR;
141  }
142  data = GNUNET_malloc (size);
144  strlen (str),
145  data,
146  size);
147  if (GNUNET_OK != res)
148  {
149  GNUNET_break_op (0);
150  GNUNET_free (data);
151  return GNUNET_SYSERR;
152  }
153  *(void**) spec->ptr = data;
154  *spec->size_ptr = size;
155  return GNUNET_OK;
156 }
157 
158 
165 static void
167  struct GNUNET_JSON_Specification *spec)
168 {
169  if (0 != *spec->size_ptr)
170  {
171  GNUNET_free (*(void **) spec->ptr);
172  *(void**) spec->ptr = NULL;
173  *spec->size_ptr = 0;
174  }
175 }
176 
177 
188  void **obj,
189  size_t *size)
190 {
191  struct GNUNET_JSON_Specification ret = {
193  .cleaner = &clean_variable_data,
194  .cls = NULL,
195  .field = name,
196  .ptr = obj,
197  .ptr_size = 0,
198  .size_ptr = size
199  };
200  *obj = NULL;
201  *size = 0;
202  return ret;
203 }
204 
205 
214 static int
216  json_t *root,
217  struct GNUNET_JSON_Specification *spec)
218 {
219  const char *str;
220 
221  str = json_string_value (root);
222  if (NULL == str)
223  {
224  GNUNET_break_op (0);
225  return GNUNET_SYSERR;
226  }
227  *(const char **) spec->ptr = str;
228  return GNUNET_OK;
229 }
230 
231 
240  const char **strptr)
241 {
242  struct GNUNET_JSON_Specification ret = {
243  .parser = &parse_string,
244  .cleaner = NULL,
245  .cls = NULL,
246  .field = name,
247  .ptr = strptr,
248  .ptr_size = 0,
249  .size_ptr = NULL
250  };
251  *strptr = NULL;
252  return ret;
253 }
254 
255 
264 static int
266  json_t *root,
267  struct GNUNET_JSON_Specification *spec)
268 {
269  if (! (json_is_object (root) || json_is_array (root)) )
270  {
271  GNUNET_break_op (0);
272  return GNUNET_SYSERR;
273  }
274  json_incref (root);
275  *(json_t **) spec->ptr = root;
276  return GNUNET_OK;
277 }
278 
279 
286 static void
288  struct GNUNET_JSON_Specification *spec)
289 {
290  json_t **ptr = (json_t **) spec->ptr;
291 
292  if (NULL != *ptr)
293  {
294  json_decref (*ptr);
295  *ptr = NULL;
296  }
297 }
298 
299 
308  json_t **jsonp)
309 {
310  struct GNUNET_JSON_Specification ret = {
311  .parser = &parse_object,
312  .cleaner = &clean_object,
313  .cls = NULL,
314  .field = name,
315  .ptr = jsonp,
316  .ptr_size = 0,
317  .size_ptr = NULL
318  };
319  *jsonp = NULL;
320  return ret;
321 }
322 
323 
332 static int
333 parse_u8 (void *cls,
334  json_t *root,
335  struct GNUNET_JSON_Specification *spec)
336 {
337  json_int_t val;
338  uint8_t *up = spec->ptr;
339 
340  if (! json_is_integer (root))
341  {
342  GNUNET_break_op (0);
343  return GNUNET_SYSERR;
344  }
345  val = json_integer_value (root);
346  if ( (0 > val) || (val > UINT8_MAX) )
347  {
348  GNUNET_break_op (0);
349  return GNUNET_SYSERR;
350  }
351  *up = (uint8_t) val;
352  return GNUNET_OK;
353 }
354 
355 
364  uint8_t *u8)
365 {
366  struct GNUNET_JSON_Specification ret = {
367  .parser = &parse_u8,
368  .cleaner = NULL,
369  .cls = NULL,
370  .field = name,
371  .ptr = u8,
372  .ptr_size = sizeof (uint8_t),
373  .size_ptr = NULL
374  };
375  return ret;
376 }
377 
378 
387 static int
388 parse_u16 (void *cls,
389  json_t *root,
390  struct GNUNET_JSON_Specification *spec)
391 {
392  json_int_t val;
393  uint16_t *up = spec->ptr;
394 
395  if (! json_is_integer (root))
396  {
397  GNUNET_break_op (0);
398  return GNUNET_SYSERR;
399  }
400  val = json_integer_value (root);
401  if ( (0 > val) || (val > UINT16_MAX) )
402  {
403  GNUNET_break_op (0);
404  return GNUNET_SYSERR;
405  }
406  *up = (uint16_t) val;
407  return GNUNET_OK;
408 }
409 
410 
419  uint16_t *u16)
420 {
421  struct GNUNET_JSON_Specification ret = {
422  .parser = &parse_u16,
423  .cleaner = NULL,
424  .cls = NULL,
425  .field = name,
426  .ptr = u16,
427  .ptr_size = sizeof (uint16_t),
428  .size_ptr = NULL
429  };
430  return ret;
431 }
432 
433 
442 static int
443 parse_u32 (void *cls,
444  json_t *root,
445  struct GNUNET_JSON_Specification *spec)
446 {
447  json_int_t val;
448  uint32_t *up = spec->ptr;
449 
450  if (! json_is_integer (root))
451  {
452  GNUNET_break_op (0);
453  return GNUNET_SYSERR;
454  }
455  val = json_integer_value (root);
456  if ( (0 > val) || (val > UINT32_MAX) )
457  {
458  GNUNET_break_op (0);
459  return GNUNET_SYSERR;
460  }
461  *up = (uint32_t) val;
462  return GNUNET_OK;
463 }
464 
465 
474  uint32_t *u32)
475 {
476  struct GNUNET_JSON_Specification ret = {
477  .parser = &parse_u32,
478  .cleaner = NULL,
479  .cls = NULL,
480  .field = name,
481  .ptr = u32,
482  .ptr_size = sizeof (uint32_t),
483  .size_ptr = NULL
484  };
485  return ret;
486 }
487 
488 
497 static int
498 parse_u64 (void *cls,
499  json_t *root,
500  struct GNUNET_JSON_Specification *spec)
501 {
502  json_int_t val;
503  uint64_t *up = spec->ptr;
504 
505  if (! json_is_integer (root))
506  {
507  GNUNET_break_op (0);
508  return GNUNET_SYSERR;
509  }
510  val = json_integer_value (root);
511  *up = (uint64_t) val;
512  return GNUNET_OK;
513 }
514 
515 
524  uint64_t *u64)
525 {
526  struct GNUNET_JSON_Specification ret = {
527  .parser = &parse_u64,
528  .cleaner = NULL,
529  .cls = NULL,
530  .field = name,
531  .ptr = u64,
532  .ptr_size = sizeof (uint64_t),
533  .size_ptr = NULL
534  };
535  return ret;
536 }
537 
538 
539 /* ************ GNUnet-specific parser specifications ******************* */
540 
549 static int
551  json_t *root,
552  struct GNUNET_JSON_Specification *spec)
553 {
554  struct GNUNET_TIME_Absolute *abs = spec->ptr;
555  const char *val;
556  unsigned long long int tval;
557 
558  val = json_string_value (root);
559  if (NULL == val)
560  {
561  GNUNET_break_op (0);
562  return GNUNET_SYSERR;
563  }
564  if ( (0 == strcasecmp (val,
565  "/forever/")) ||
566  (0 == strcasecmp (val,
567  "/end of time/")) ||
568  (0 == strcasecmp (val,
569  "/never/")) )
570  {
572  return GNUNET_OK;
573  }
574  if (1 != sscanf (val,
575  "/Date(%llu)/",
576  &tval))
577  {
578  GNUNET_break_op (0);
579  return GNUNET_SYSERR;
580  }
581  /* Time is in seconds in JSON, but in microseconds in GNUNET_TIME_Absolute */
582  abs->abs_value_us = tval * 1000LL * 1000LL;
583  if ( (abs->abs_value_us) / 1000LL / 1000LL != tval)
584  {
585  /* Integer overflow */
586  GNUNET_break_op (0);
587  return GNUNET_SYSERR;
588  }
589  return GNUNET_OK;
590 }
591 
592 
601  struct GNUNET_TIME_Absolute *at)
602 {
603  struct GNUNET_JSON_Specification ret = {
605  .cleaner = NULL,
606  .cls = NULL,
607  .field = name,
608  .ptr = at,
609  .ptr_size = sizeof (uint64_t),
610  .size_ptr = NULL
611  };
612  return ret;
613 }
614 
615 
624 static int
626  json_t *root,
627  struct GNUNET_JSON_Specification *spec)
628 {
629  struct GNUNET_TIME_AbsoluteNBO *abs = spec->ptr;
630  const char *val;
631  unsigned long long int tval;
632  struct GNUNET_TIME_Absolute a;
633 
634  val = json_string_value (root);
635  if (NULL == val)
636  {
637  GNUNET_break_op (0);
638  return GNUNET_SYSERR;
639  }
640  if ( (0 == strcasecmp (val,
641  "/forever/")) ||
642  (0 == strcasecmp (val,
643  "/end of time/")) ||
644  (0 == strcasecmp (val,
645  "/never/")) )
646  {
648  return GNUNET_OK;
649  }
650  if (1 != sscanf (val,
651  "/Date(%llu)/",
652  &tval))
653  {
654  GNUNET_break_op (0);
655  return GNUNET_SYSERR;
656  }
657  /* Time is in seconds in JSON, but in microseconds in GNUNET_TIME_Absolute */
658  a.abs_value_us = tval * 1000LL * 1000LL;
659  if ( (a.abs_value_us) / 1000LL / 1000LL != tval)
660  {
661  /* Integer overflow */
662  GNUNET_break_op (0);
663  return GNUNET_SYSERR;
664  }
665  *abs = GNUNET_TIME_absolute_hton (a);
666  return GNUNET_OK;
667 }
668 
669 
678  struct GNUNET_TIME_AbsoluteNBO *at)
679 {
680  struct GNUNET_JSON_Specification ret = {
682  .cleaner = NULL,
683  .cls = NULL,
684  .field = name,
685  .ptr = at,
686  .ptr_size = sizeof (uint64_t),
687  .size_ptr = NULL
688  };
689  return ret;
690 }
691 
692 
701 static int
703  json_t *root,
704  struct GNUNET_JSON_Specification *spec)
705 {
706  struct GNUNET_TIME_Relative *rel = spec->ptr;
707  const char *val;
708  unsigned long long int tval;
709 
710  val = json_string_value (root);
711  if (NULL == val)
712  {
713  GNUNET_break_op (0);
714  return GNUNET_SYSERR;
715  }
716  if ( (0 == strcasecmp (val,
717  "/forever/")) )
718  {
720  return GNUNET_OK;
721  }
722  if (1 != sscanf (val,
723  "/Delay(%llu)/",
724  &tval))
725  {
726  GNUNET_break_op (0);
727  return GNUNET_SYSERR;
728  }
729  /* Time is in seconds in JSON, but in microseconds in GNUNET_TIME_Relative */
730  rel->rel_value_us = tval * 1000LL * 1000LL;
731  if ( (rel->rel_value_us) / 1000LL / 1000LL != tval)
732  {
733  /* Integer overflow */
734  GNUNET_break_op (0);
735  return GNUNET_SYSERR;
736  }
737  return GNUNET_OK;
738 }
739 
740 
749  struct GNUNET_TIME_Relative *rt)
750 {
751  struct GNUNET_JSON_Specification ret = {
753  .cleaner = NULL,
754  .cls = NULL,
755  .field = name,
756  .ptr = rt,
757  .ptr_size = sizeof (uint64_t),
758  .size_ptr = NULL
759  };
760  return ret;
761 }
762 
763 
772 static int
774  json_t *root,
775  struct GNUNET_JSON_Specification *spec)
776 {
777  struct GNUNET_CRYPTO_RsaPublicKey **pk = spec->ptr;
778  const char *enc;
779  char *buf;
780  size_t len;
781  size_t buf_len;
782 
783  if (NULL == (enc = json_string_value (root)))
784  {
785  GNUNET_break_op (0);
786  return GNUNET_SYSERR;
787  }
788  len = strlen (enc);
789  buf_len = (len * 5) / 8;
790  buf = GNUNET_malloc (buf_len);
791  if (GNUNET_OK !=
793  len,
794  buf,
795  buf_len))
796  {
797  GNUNET_break_op (0);
798  GNUNET_free (buf);
799  return GNUNET_SYSERR;
800  }
801  if (NULL == (*pk = GNUNET_CRYPTO_rsa_public_key_decode (buf,
802  buf_len)))
803  {
804  GNUNET_break_op (0);
805  GNUNET_free (buf);
806  return GNUNET_SYSERR;
807  }
808  GNUNET_free (buf);
809  return GNUNET_OK;
810 }
811 
812 
819 static void
821  struct GNUNET_JSON_Specification *spec)
822 {
823  struct GNUNET_CRYPTO_RsaPublicKey **pk = spec->ptr;
824 
825  if (NULL != *pk)
826  {
828  *pk = NULL;
829  }
830 }
831 
832 
842 {
843  struct GNUNET_JSON_Specification ret = {
845  .cleaner = &clean_rsa_public_key,
846  .cls = NULL,
847  .field = name,
848  .ptr = pk,
849  .ptr_size = 0,
850  .size_ptr = NULL
851  };
852  *pk = NULL;
853  return ret;
854 }
855 
856 
865 static int
867  json_t *root,
868  struct GNUNET_JSON_Specification *spec)
869 {
870  struct GNUNET_CRYPTO_RsaSignature **sig = spec->ptr;
871  size_t size;
872  const char *str;
873  int res;
874  void *buf;
875 
876  str = json_string_value (root);
877  if (NULL == str)
878  {
879  GNUNET_break_op (0);
880  return GNUNET_SYSERR;
881  }
882  size = (strlen (str) * 5) / 8;
883  buf = GNUNET_malloc (size);
885  strlen (str),
886  buf,
887  size);
888  if (GNUNET_OK != res)
889  {
890  GNUNET_free (buf);
891  GNUNET_break_op (0);
892  return GNUNET_SYSERR;
893  }
894  if (NULL == (*sig = GNUNET_CRYPTO_rsa_signature_decode (buf,
895  size)))
896  {
897  GNUNET_break_op (0);
898  GNUNET_free (buf);
899  return GNUNET_SYSERR;
900  }
901  GNUNET_free (buf);
902  return GNUNET_OK;
903 }
904 
905 
912 static void
914  struct GNUNET_JSON_Specification *spec)
915 {
916  struct GNUNET_CRYPTO_RsaSignature **sig = spec->ptr;
917 
918  if (NULL != *sig)
919  {
921  *sig = NULL;
922  }
923 }
924 
925 
934  struct GNUNET_CRYPTO_RsaSignature **sig)
935 {
936  struct GNUNET_JSON_Specification ret = {
938  .cleaner = &clean_rsa_signature,
939  .cls = NULL,
940  .field = name,
941  .ptr = sig,
942  .ptr_size = 0,
943  .size_ptr = NULL
944  };
945  *sig = NULL;
946  return ret;
947 }
948 
949 
958 static int
960  json_t *root,
961  struct GNUNET_JSON_Specification *spec)
962 {
963  int *bp = spec->ptr;
964 
965  if (! json_is_boolean (root))
966  {
967  GNUNET_break_op (0);
968  return GNUNET_SYSERR;
969  }
970  *bp = json_boolean_value (root) ? GNUNET_YES : GNUNET_NO;
971  return GNUNET_OK;
972 }
973 
974 
983  int *boolean)
984 {
985  struct GNUNET_JSON_Specification ret = {
986  .parser = &parse_boolean,
987  .cleaner = NULL,
988  .cls = NULL,
989  .field = name,
990  .ptr = boolean,
991  .ptr_size = sizeof (int),
992  .size_ptr = NULL
993  };
994  return ret;
995 }
996 
997 
998 /* end of json_helper.c */
void * cls
Closure for parser and cleaner.
static void clean_variable_data(void *cls, struct GNUNET_JSON_Specification *spec)
Cleanup data left from parsing variable size data.
Definition: json_helper.c:166
struct GNUNET_JSON_Specification GNUNET_JSON_spec_uint32(const char *name, uint32_t *u32)
32-bit integer.
Definition: json_helper.c:473
static struct GNUNET_CRYPTO_EddsaPrivateKey * pk
Private key of this peer.
uint64_t rel_value_us
The actual value.
an RSA signature
Definition: crypto_rsa.c:63
void GNUNET_CRYPTO_rsa_signature_free(struct GNUNET_CRYPTO_RsaSignature *sig)
Free memory occupied by signature.
Definition: crypto_rsa.c:951
functions to parse JSON objects into GNUnet objects
static int 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:773
struct GNUNET_JSON_Specification GNUNET_JSON_spec_json(const char *name, json_t **jsonp)
JSON object.
Definition: json_helper.c:307
static int parse_u16(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to a uint16_t.
Definition: json_helper.c:388
struct GNUNET_JSON_Specification GNUNET_JSON_spec_uint16(const char *name, uint16_t *u16)
16-bit integer.
Definition: json_helper.c:418
struct GNUNET_JSON_Specification GNUNET_JSON_spec_absolute_time_nbo(const char *name, struct GNUNET_TIME_AbsoluteNBO *at)
Absolute time in network byte order.
Definition: json_helper.c:677
#define GNUNET_NO
Definition: gnunet_common.h:81
Entry in parser specification for GNUNET_JSON_parse().
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
static int parse_rsa_signature(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to RSA signature.
Definition: json_helper.c:866
static void clean_rsa_signature(void *cls, struct GNUNET_JSON_Specification *spec)
Cleanup data left from parsing RSA signature.
Definition: json_helper.c:913
static int ret
Final status code.
Definition: gnunet-arm.c:89
Time for absolute time used by GNUnet, in microseconds and in network byte order. ...
uint64_t abs_value_us
The actual value.
The public information of an RSA key pair.
Definition: crypto_rsa.c:51
#define GNUNET_TIME_UNIT_FOREVER_ABS
Constant used to specify "forever".
static int parse_u32(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to a uint32_t.
Definition: json_helper.c:443
static int parse_object(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to a JSON object.
Definition: json_helper.c:265
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
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:370
static char buf[2048]
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:820
static void clean_object(void *cls, struct GNUNET_JSON_Specification *spec)
Cleanup data left from parsing JSON object.
Definition: json_helper.c:287
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
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:95
GNUNET_JSON_Parser parser
Function for how to parse this type of entry.
static int res
struct GNUNET_JSON_Specification GNUNET_JSON_spec_end()
End of a parser specification.
Definition: json_helper.c:35
static int 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:959
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
static unsigned int size
Size of the "table".
Definition: peer.c:67
static int 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:121
const char * name
void * ptr
Pointer, details specific to the parser.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_uint8(const char *name, uint8_t *u8)
8-bit integer.
Definition: json_helper.c:363
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:933
static int parse_u64(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to a uint8_t.
Definition: json_helper.c:498
static int parse_string(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to string.
Definition: json_helper.c:215
struct GNUNET_JSON_Specification GNUNET_JSON_spec_uint64(const char *name, uint64_t *u64)
64-bit integer.
Definition: json_helper.c:523
struct GNUNET_JSON_Specification GNUNET_JSON_spec_string(const char *name, const char **strptr)
The expected field stores a string.
Definition: json_helper.c:239
static int parse_rel_time(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to relative time.
Definition: json_helper.c:702
struct GNUNET_JSON_Specification GNUNET_JSON_spec_relative_time(const char *name, struct GNUNET_TIME_Relative *rt)
Relative time.
Definition: json_helper.c:748
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:982
struct GNUNET_CRYPTO_RsaSignature * GNUNET_CRYPTO_rsa_signature_decode(const char *buf, size_t len)
Decode the signature from the data-format back to the "normal", internal format.
Definition: crypto_rsa.c:996
static int 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:55
static OpusEncoder * enc
OPUS encoder.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_absolute_time(const char *name, struct GNUNET_TIME_Absolute *at)
Absolute time.
Definition: json_helper.c:600
size_t ptr_size
Number of bytes available in ptr.
size_t * size_ptr
Where should we store the final size of ptr.
static int parse_u8(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to a uint8_t.
Definition: json_helper.c:333
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:187
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:840
void GNUNET_CRYPTO_rsa_public_key_free(struct GNUNET_CRYPTO_RsaPublicKey *key)
Free memory occupied by the public key.
Definition: crypto_rsa.c:302
Time for absolute times used by GNUnet, in microseconds.
#define GNUNET_YES
Definition: gnunet_common.h:80
static int parse_abs_time_nbo(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to absolute time.
Definition: json_helper.c:625
uint32_t data
The data value.
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition: time.c:654
static int parse_abs_time(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to absolute time.
Definition: json_helper.c:550
#define GNUNET_malloc(size)
Wrapper around malloc.
int 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:1021
#define GNUNET_free(ptr)
Wrapper around free.
Time for relative time used by GNUnet, in microseconds.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...