53 if ((0 == strcasecmp (cipher_s,
55 (0 == strcasecmp (cipher_s,
56 "RSA+age_restricted")))
58 if ((0 == strcasecmp (cipher_s,
60 (0 == strcasecmp (cipher_s,
61 "CS+age_restricted")))
83 if (NULL == (
enc = json_string_value (root)))
94 if (((len * 5) / 8) != spec->
ptr_size)
98 "Field `%s' has wrong length\n",
149 if (NULL == (
enc = json_string_value (root)))
163 "Field `%s' has wrong length\n",
209 str = json_string_value (root);
244 *(
void **) spec->
ptr = NULL;
285 str = json_string_value (root);
291 *(
const char **) spec->
ptr =
str;
327 str = json_string_value (root);
366 if (! (json_is_object (root) || json_is_array (root)))
371 *(json_t **) spec->
ptr = json_incref (root);
386 json_t **
ptr = (json_t **) spec->
ptr;
427 if (! json_is_object (root))
432 *(
const json_t **) spec->
ptr = (
const json_t *) root;
439 const json_t **jsonp)
467 if (! json_is_object (root))
472 *((json_t **) spec->
ptr) = json_incref (root);
508 if (! json_is_array (root))
513 *(
const json_t **) spec->
ptr = (
const json_t *) root;
520 const json_t **jsonp)
548 if (! json_is_array (root))
553 *((json_t **) spec->
ptr) = json_incref (root);
589 if (json_true () == root)
594 if (json_false () == root)
612 .ptr_size =
sizeof(bool),
632 double *f = spec->
ptr;
634 if (! json_is_real (root))
639 *f = json_real_value (root);
652 .ptr_size =
sizeof(double),
673 uint8_t *up = spec->
ptr;
675 if (! json_is_integer (root))
680 val = json_integer_value (root);
681 if ((0 > val) || (val > UINT8_MAX))
699 .ptr_size =
sizeof(uint8_t),
720 uint16_t *up = spec->
ptr;
722 if (! json_is_integer (root))
727 val = json_integer_value (root);
728 if ((0 > val) || (val > UINT16_MAX))
733 *up = (uint16_t) val;
746 .ptr_size =
sizeof(uint16_t),
767 uint32_t *up = spec->
ptr;
769 if (! json_is_integer (root))
774 val = json_integer_value (root);
775 if ((0 > val) || (val > UINT32_MAX))
780 *up = (uint32_t) val;
793 .ptr_size =
sizeof(uint32_t),
814 unsigned int *up = spec->
ptr;
816 if (! json_is_integer (root))
821 val = json_integer_value (root);
822 if ((0 > val) || (val > UINT_MAX))
827 *up = (
unsigned int) val;
840 .ptr_size =
sizeof(
unsigned int),
861 unsigned long long *up = spec->
ptr;
863 if (! json_is_integer (root))
868 val = json_integer_value (root);
869 if ((0 > val) || (val > ULLONG_MAX))
874 *up = (
unsigned long long) val;
881 unsigned long long *ull)
887 .ptr_size =
sizeof(
unsigned long long),
908 uint64_t *up = spec->
ptr;
910 if (! json_is_integer (root))
915 val = json_integer_value (root);
916 *up = (uint64_t) val;
929 .ptr_size =
sizeof(uint64_t),
950 int16_t *up = spec->
ptr;
952 if (! json_is_integer (root))
957 val = json_integer_value (root);
958 if ( (val < INT16_MIN) ||
977 .ptr_size =
sizeof(int16_t),
998 int64_t *up = spec->
ptr;
1000 if (! json_is_integer (root))
1005 val = json_integer_value (root);
1006 *up = (int64_t) val;
1019 .ptr_size =
sizeof(int64_t),
1043 unsigned long long int tval;
1045 if (! json_is_object (root))
1050 json_t_s = json_object_get (root,
1052 if (json_is_integer (json_t_s))
1054 tval = json_integer_value (json_t_s);
1068 if (json_is_string (json_t_s))
1072 val = json_string_value (json_t_s);
1073 if ((0 == strcasecmp (val,
1162 unsigned long long int tval;
1164 if (! json_is_object (root))
1169 json_d_us = json_object_get (root,
1171 if (json_is_integer (json_d_us))
1173 tval = json_integer_value (json_d_us);
1174 if (tval >= (1LLU << 53))
1183 if (json_is_string (json_d_us))
1187 val = json_string_value (json_d_us);
1188 if ((0 == strcasecmp (val,
1236 if (NULL == (
enc = json_string_value (root)))
1242 buf_len = (len * 5) / 8;
1321 str = json_string_value (root);
1327 size = (strlen (
str) * 5) / 8;
1403 int *bp = spec->
ptr;
1405 if (! json_is_boolean (root))
1423 .ptr_size =
sizeof(int),
1465 blinded_message->
rc = 1;
1467 switch (blinded_message->
cipher)
1477 "rsa_blinded_planchet",
1493 *target = blinded_message;
1521 *target = blinded_message;
1544 if (NULL != blinded_message)
1547 *blinded_message = NULL;
1607 blinded_sig->
rc = 1;
1608 switch (blinded_sig->
cipher)
1616 "blinded_rsa_signature",
1631 *target = blinded_sig;
1655 *target = blinded_sig;
1740 unblinded_sig->
rc = 1;
1741 switch (unblinded_sig->
cipher)
1764 *target = unblinded_sig;
1789 *target = unblinded_sig;
1812 if (NULL != *ub_sig)
1854 if (json_is_string (root))
1858 str = json_string_value (root);
struct GNUNET_MessageHeader * msg
static int ret
Final status code.
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.
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.
void GNUNET_CRYPTO_rsa_public_key_free(struct GNUNET_CRYPTO_RsaPublicKey *key)
Free memory occupied by the public key.
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.
#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.
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.
size_t GNUNET_STRINGS_base64_decode(const char *data, size_t len, void **output)
Decode from Base64.
#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.
#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.
#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.
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.
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.
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".
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.
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