diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/include/gnunet_json_lib.h | 4 | ||||
-rw-r--r-- | src/json/json.c | 2 | ||||
-rw-r--r-- | src/pq/pq_result_helper.c | 43 | ||||
-rw-r--r-- | src/util/crypto_rsa.c | 23 |
4 files changed, 47 insertions, 25 deletions
diff --git a/src/include/gnunet_json_lib.h b/src/include/gnunet_json_lib.h index 92f696e08..5ef4592e5 100644 --- a/src/include/gnunet_json_lib.h +++ b/src/include/gnunet_json_lib.h | |||
@@ -107,9 +107,9 @@ struct GNUNET_JSON_Specification | |||
107 | size_t *size_ptr; | 107 | size_t *size_ptr; |
108 | 108 | ||
109 | /** | 109 | /** |
110 | * Set to #GNUNET_YES if this component is optional. | 110 | * Set to true if this component is optional. |
111 | */ | 111 | */ |
112 | int is_optional; | 112 | bool is_optional; |
113 | }; | 113 | }; |
114 | 114 | ||
115 | 115 | ||
diff --git a/src/json/json.c b/src/json/json.c index 51d5c0c72..6d11b4fdd 100644 --- a/src/json/json.c +++ b/src/json/json.c | |||
@@ -77,7 +77,7 @@ GNUNET_JSON_spec_mark_optional (struct GNUNET_JSON_Specification spec) | |||
77 | { | 77 | { |
78 | struct GNUNET_JSON_Specification ret = spec; | 78 | struct GNUNET_JSON_Specification ret = spec; |
79 | 79 | ||
80 | ret.is_optional = GNUNET_YES; | 80 | ret.is_optional = true; |
81 | return ret; | 81 | return ret; |
82 | } | 82 | } |
83 | 83 | ||
diff --git a/src/pq/pq_result_helper.c b/src/pq/pq_result_helper.c index 23fb4f96e..f264603f4 100644 --- a/src/pq/pq_result_helper.c +++ b/src/pq/pq_result_helper.c | |||
@@ -127,10 +127,13 @@ GNUNET_PQ_result_spec_variable_size (const char *name, | |||
127 | void **dst, | 127 | void **dst, |
128 | size_t *sptr) | 128 | size_t *sptr) |
129 | { | 129 | { |
130 | struct GNUNET_PQ_ResultSpec res = | 130 | struct GNUNET_PQ_ResultSpec res = { |
131 | { &extract_varsize_blob, | 131 | .conv = &extract_varsize_blob, |
132 | &clean_varsize_blob, NULL, | 132 | .cleaner = &clean_varsize_blob, |
133 | (void *) (dst), 0, name, sptr }; | 133 | .dst = (void *) (dst), |
134 | .fname = name, | ||
135 | .result_size = sptr | ||
136 | }; | ||
134 | 137 | ||
135 | return res; | 138 | return res; |
136 | } | 139 | } |
@@ -207,10 +210,12 @@ GNUNET_PQ_result_spec_fixed_size (const char *name, | |||
207 | void *dst, | 210 | void *dst, |
208 | size_t dst_size) | 211 | size_t dst_size) |
209 | { | 212 | { |
210 | struct GNUNET_PQ_ResultSpec res = | 213 | struct GNUNET_PQ_ResultSpec res = { |
211 | { &extract_fixed_blob, | 214 | .conv = &extract_fixed_blob, |
212 | NULL, NULL, | 215 | .dst = (dst), |
213 | (dst), dst_size, name, NULL }; | 216 | .dst_size = dst_size, |
217 | .fname = name | ||
218 | }; | ||
214 | 219 | ||
215 | return res; | 220 | return res; |
216 | } | 221 | } |
@@ -301,11 +306,12 @@ struct GNUNET_PQ_ResultSpec | |||
301 | GNUNET_PQ_result_spec_rsa_public_key (const char *name, | 306 | GNUNET_PQ_result_spec_rsa_public_key (const char *name, |
302 | struct GNUNET_CRYPTO_RsaPublicKey **rsa) | 307 | struct GNUNET_CRYPTO_RsaPublicKey **rsa) |
303 | { | 308 | { |
304 | struct GNUNET_PQ_ResultSpec res = | 309 | struct GNUNET_PQ_ResultSpec res = { |
305 | { &extract_rsa_public_key, | 310 | .conv = &extract_rsa_public_key, |
306 | &clean_rsa_public_key, | 311 | .cleaner = &clean_rsa_public_key, |
307 | NULL, | 312 | .dst = (void *) rsa, |
308 | (void *) rsa, 0, name, NULL }; | 313 | .fname = name |
314 | }; | ||
309 | 315 | ||
310 | return res; | 316 | return res; |
311 | } | 317 | } |
@@ -395,11 +401,12 @@ struct GNUNET_PQ_ResultSpec | |||
395 | GNUNET_PQ_result_spec_rsa_signature (const char *name, | 401 | GNUNET_PQ_result_spec_rsa_signature (const char *name, |
396 | struct GNUNET_CRYPTO_RsaSignature **sig) | 402 | struct GNUNET_CRYPTO_RsaSignature **sig) |
397 | { | 403 | { |
398 | struct GNUNET_PQ_ResultSpec res = | 404 | struct GNUNET_PQ_ResultSpec res = { |
399 | { &extract_rsa_signature, | 405 | .conv = &extract_rsa_signature, |
400 | &clean_rsa_signature, | 406 | .cleaner = &clean_rsa_signature, |
401 | NULL, | 407 | .dst = (void *) sig, |
402 | (void *) sig, 0, (name), NULL }; | 408 | .fname = name |
409 | }; | ||
403 | 410 | ||
404 | return res; | 411 | return res; |
405 | } | 412 | } |
diff --git a/src/util/crypto_rsa.c b/src/util/crypto_rsa.c index 4d3de00bc..f017d1f10 100644 --- a/src/util/crypto_rsa.c +++ b/src/util/crypto_rsa.c | |||
@@ -310,9 +310,15 @@ GNUNET_CRYPTO_rsa_public_key_encode ( | |||
310 | struct GNUNET_CRYPTO_RsaPublicKeyHeaderP hdr; | 310 | struct GNUNET_CRYPTO_RsaPublicKeyHeaderP hdr; |
311 | int ret; | 311 | int ret; |
312 | 312 | ||
313 | ret = key_from_sexp (ne, key->sexp, "public-key", "ne"); | 313 | ret = key_from_sexp (ne, |
314 | key->sexp, | ||
315 | "public-key", | ||
316 | "ne"); | ||
314 | if (0 != ret) | 317 | if (0 != ret) |
315 | ret = key_from_sexp (ne, key->sexp, "rsa", "ne"); | 318 | ret = key_from_sexp (ne, |
319 | key->sexp, | ||
320 | "rsa", | ||
321 | "ne"); | ||
316 | if (0 != ret) | 322 | if (0 != ret) |
317 | { | 323 | { |
318 | GNUNET_break (0); | 324 | GNUNET_break (0); |
@@ -333,16 +339,25 @@ GNUNET_CRYPTO_rsa_public_key_encode ( | |||
333 | (n_size > UINT16_MAX) ) | 339 | (n_size > UINT16_MAX) ) |
334 | { | 340 | { |
335 | GNUNET_break (0); | 341 | GNUNET_break (0); |
336 | *buffer = NULL; | 342 | if (NULL != buffer) |
343 | *buffer = NULL; | ||
337 | gcry_mpi_release (ne[0]); | 344 | gcry_mpi_release (ne[0]); |
338 | gcry_mpi_release (ne[1]); | 345 | gcry_mpi_release (ne[1]); |
339 | return 0; | 346 | return 0; |
340 | } | 347 | } |
341 | buf_size = n_size + e_size + sizeof (hdr); | 348 | buf_size = n_size + e_size + sizeof (hdr); |
349 | if (NULL == buffer) | ||
350 | { | ||
351 | gcry_mpi_release (ne[0]); | ||
352 | gcry_mpi_release (ne[1]); | ||
353 | return buf_size; | ||
354 | } | ||
342 | buf = GNUNET_malloc (buf_size); | 355 | buf = GNUNET_malloc (buf_size); |
343 | hdr.modulus_length = htons ((uint16_t) n_size); | 356 | hdr.modulus_length = htons ((uint16_t) n_size); |
344 | hdr.public_exponent_length = htons ((uint16_t) e_size); | 357 | hdr.public_exponent_length = htons ((uint16_t) e_size); |
345 | memcpy (buf, &hdr, sizeof (hdr)); | 358 | memcpy (buf, |
359 | &hdr, | ||
360 | sizeof (hdr)); | ||
346 | GNUNET_assert (0 == | 361 | GNUNET_assert (0 == |
347 | gcry_mpi_print (GCRYMPI_FMT_USG, | 362 | gcry_mpi_print (GCRYMPI_FMT_USG, |
348 | (unsigned char *) &buf[sizeof (hdr)], | 363 | (unsigned char *) &buf[sizeof (hdr)], |