diff options
Diffstat (limited to 'src/include/gnunet_crypto_lib.h')
-rw-r--r-- | src/include/gnunet_crypto_lib.h | 530 |
1 files changed, 254 insertions, 276 deletions
diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h index 140a1b48c..6e347c52b 100644 --- a/src/include/gnunet_crypto_lib.h +++ b/src/include/gnunet_crypto_lib.h | |||
@@ -16,7 +16,7 @@ | |||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file include/gnunet_crypto_lib.h | 22 | * @file include/gnunet_crypto_lib.h |
@@ -71,8 +71,7 @@ struct GNUNET_PeerIdentity; | |||
71 | * Desired quality level for random numbers. | 71 | * Desired quality level for random numbers. |
72 | * @ingroup crypto | 72 | * @ingroup crypto |
73 | */ | 73 | */ |
74 | enum GNUNET_CRYPTO_Quality | 74 | enum GNUNET_CRYPTO_Quality { |
75 | { | ||
76 | /** | 75 | /** |
77 | * No good quality of the operation is needed (i.e., | 76 | * No good quality of the operation is needed (i.e., |
78 | * random numbers can be pseudo-random). | 77 | * random numbers can be pseudo-random). |
@@ -113,8 +112,7 @@ enum GNUNET_CRYPTO_Quality | |||
113 | /** | 112 | /** |
114 | * @brief 0-terminated ASCII encoding of a struct GNUNET_HashCode. | 113 | * @brief 0-terminated ASCII encoding of a struct GNUNET_HashCode. |
115 | */ | 114 | */ |
116 | struct GNUNET_CRYPTO_HashAsciiEncoded | 115 | struct GNUNET_CRYPTO_HashAsciiEncoded { |
117 | { | ||
118 | unsigned char encoding[104]; | 116 | unsigned char encoding[104]; |
119 | }; | 117 | }; |
120 | 118 | ||
@@ -127,8 +125,7 @@ GNUNET_NETWORK_STRUCT_BEGIN | |||
127 | * this must be followed by "size - 8" bytes of | 125 | * this must be followed by "size - 8" bytes of |
128 | * the actual signed data | 126 | * the actual signed data |
129 | */ | 127 | */ |
130 | struct GNUNET_CRYPTO_EccSignaturePurpose | 128 | struct GNUNET_CRYPTO_EccSignaturePurpose { |
131 | { | ||
132 | /** | 129 | /** |
133 | * How many bytes does this signature sign? | 130 | * How many bytes does this signature sign? |
134 | * (including this purpose header); in network | 131 | * (including this purpose header); in network |
@@ -150,9 +147,7 @@ struct GNUNET_CRYPTO_EccSignaturePurpose | |||
150 | * @brief an ECC signature using EdDSA. | 147 | * @brief an ECC signature using EdDSA. |
151 | * See cr.yp.to/papers.html#ed25519 | 148 | * See cr.yp.to/papers.html#ed25519 |
152 | */ | 149 | */ |
153 | struct GNUNET_CRYPTO_EddsaSignature | 150 | struct GNUNET_CRYPTO_EddsaSignature { |
154 | { | ||
155 | |||
156 | /** | 151 | /** |
157 | * R value. | 152 | * R value. |
158 | */ | 153 | */ |
@@ -168,9 +163,7 @@ struct GNUNET_CRYPTO_EddsaSignature | |||
168 | /** | 163 | /** |
169 | * @brief an ECC signature using ECDSA | 164 | * @brief an ECC signature using ECDSA |
170 | */ | 165 | */ |
171 | struct GNUNET_CRYPTO_EcdsaSignature | 166 | struct GNUNET_CRYPTO_EcdsaSignature { |
172 | { | ||
173 | |||
174 | /** | 167 | /** |
175 | * R value. | 168 | * R value. |
176 | */ | 169 | */ |
@@ -187,8 +180,7 @@ struct GNUNET_CRYPTO_EcdsaSignature | |||
187 | * Public ECC key (always for curve Ed25519) encoded in a format | 180 | * Public ECC key (always for curve Ed25519) encoded in a format |
188 | * suitable for network transmission and EdDSA signatures. | 181 | * suitable for network transmission and EdDSA signatures. |
189 | */ | 182 | */ |
190 | struct GNUNET_CRYPTO_EddsaPublicKey | 183 | struct GNUNET_CRYPTO_EddsaPublicKey { |
191 | { | ||
192 | /** | 184 | /** |
193 | * Point Q consists of a y-value mod p (256 bits); the x-value is | 185 | * Point Q consists of a y-value mod p (256 bits); the x-value is |
194 | * always positive. The point is stored in Ed25519 standard | 186 | * always positive. The point is stored in Ed25519 standard |
@@ -202,8 +194,7 @@ struct GNUNET_CRYPTO_EddsaPublicKey | |||
202 | * Public ECC key (always for Curve25519) encoded in a format suitable | 194 | * Public ECC key (always for Curve25519) encoded in a format suitable |
203 | * for network transmission and ECDSA signatures. | 195 | * for network transmission and ECDSA signatures. |
204 | */ | 196 | */ |
205 | struct GNUNET_CRYPTO_EcdsaPublicKey | 197 | struct GNUNET_CRYPTO_EcdsaPublicKey { |
206 | { | ||
207 | /** | 198 | /** |
208 | * Q consists of an x- and a y-value, each mod p (256 bits), given | 199 | * Q consists of an x- and a y-value, each mod p (256 bits), given |
209 | * here in affine coordinates and Ed25519 standard compact format. | 200 | * here in affine coordinates and Ed25519 standard compact format. |
@@ -215,8 +206,7 @@ struct GNUNET_CRYPTO_EcdsaPublicKey | |||
215 | /** | 206 | /** |
216 | * The identity of the host (wraps the signing key of the peer). | 207 | * The identity of the host (wraps the signing key of the peer). |
217 | */ | 208 | */ |
218 | struct GNUNET_PeerIdentity | 209 | struct GNUNET_PeerIdentity { |
219 | { | ||
220 | struct GNUNET_CRYPTO_EddsaPublicKey public_key; | 210 | struct GNUNET_CRYPTO_EddsaPublicKey public_key; |
221 | }; | 211 | }; |
222 | 212 | ||
@@ -226,8 +216,7 @@ struct GNUNET_PeerIdentity | |||
226 | * for network transmission and encryption (ECDH), | 216 | * for network transmission and encryption (ECDH), |
227 | * See http://cr.yp.to/ecdh.html | 217 | * See http://cr.yp.to/ecdh.html |
228 | */ | 218 | */ |
229 | struct GNUNET_CRYPTO_EcdhePublicKey | 219 | struct GNUNET_CRYPTO_EcdhePublicKey { |
230 | { | ||
231 | /** | 220 | /** |
232 | * Q consists of an x- and a y-value, each mod p (256 bits), given | 221 | * Q consists of an x- and a y-value, each mod p (256 bits), given |
233 | * here in affine coordinates and Ed25519 standard compact format. | 222 | * here in affine coordinates and Ed25519 standard compact format. |
@@ -240,8 +229,7 @@ struct GNUNET_CRYPTO_EcdhePublicKey | |||
240 | * Private ECC key encoded for transmission. To be used only for ECDH | 229 | * Private ECC key encoded for transmission. To be used only for ECDH |
241 | * key exchange (ECDHE to be precise). | 230 | * key exchange (ECDHE to be precise). |
242 | */ | 231 | */ |
243 | struct GNUNET_CRYPTO_EcdhePrivateKey | 232 | struct GNUNET_CRYPTO_EcdhePrivateKey { |
244 | { | ||
245 | /** | 233 | /** |
246 | * d is a value mod n, where n has at most 256 bits. | 234 | * d is a value mod n, where n has at most 256 bits. |
247 | */ | 235 | */ |
@@ -252,8 +240,7 @@ struct GNUNET_CRYPTO_EcdhePrivateKey | |||
252 | * Private ECC key encoded for transmission. To be used only for ECDSA | 240 | * Private ECC key encoded for transmission. To be used only for ECDSA |
253 | * signatures. | 241 | * signatures. |
254 | */ | 242 | */ |
255 | struct GNUNET_CRYPTO_EcdsaPrivateKey | 243 | struct GNUNET_CRYPTO_EcdsaPrivateKey { |
256 | { | ||
257 | /** | 244 | /** |
258 | * d is a value mod n, where n has at most 256 bits. | 245 | * d is a value mod n, where n has at most 256 bits. |
259 | */ | 246 | */ |
@@ -264,8 +251,7 @@ struct GNUNET_CRYPTO_EcdsaPrivateKey | |||
264 | * Private ECC key encoded for transmission. To be used only for EdDSA | 251 | * Private ECC key encoded for transmission. To be used only for EdDSA |
265 | * signatures. | 252 | * signatures. |
266 | */ | 253 | */ |
267 | struct GNUNET_CRYPTO_EddsaPrivateKey | 254 | struct GNUNET_CRYPTO_EddsaPrivateKey { |
268 | { | ||
269 | /** | 255 | /** |
270 | * d is a value mod n, where n has at most 256 bits. | 256 | * d is a value mod n, where n has at most 256 bits. |
271 | */ | 257 | */ |
@@ -276,8 +262,7 @@ struct GNUNET_CRYPTO_EddsaPrivateKey | |||
276 | /** | 262 | /** |
277 | * @brief type for session keys | 263 | * @brief type for session keys |
278 | */ | 264 | */ |
279 | struct GNUNET_CRYPTO_SymmetricSessionKey | 265 | struct GNUNET_CRYPTO_SymmetricSessionKey { |
280 | { | ||
281 | /** | 266 | /** |
282 | * Actual key for AES. | 267 | * Actual key for AES. |
283 | */ | 268 | */ |
@@ -297,8 +282,7 @@ GNUNET_NETWORK_STRUCT_END | |||
297 | * NOTE: must be smaller (!) in size than the | 282 | * NOTE: must be smaller (!) in size than the |
298 | * `struct GNUNET_HashCode`. | 283 | * `struct GNUNET_HashCode`. |
299 | */ | 284 | */ |
300 | struct GNUNET_CRYPTO_SymmetricInitializationVector | 285 | struct GNUNET_CRYPTO_SymmetricInitializationVector { |
301 | { | ||
302 | unsigned char aes_iv[GNUNET_CRYPTO_AES_KEY_LENGTH / 2]; | 286 | unsigned char aes_iv[GNUNET_CRYPTO_AES_KEY_LENGTH / 2]; |
303 | 287 | ||
304 | unsigned char twofish_iv[GNUNET_CRYPTO_AES_KEY_LENGTH / 2]; | 288 | unsigned char twofish_iv[GNUNET_CRYPTO_AES_KEY_LENGTH / 2]; |
@@ -308,8 +292,7 @@ struct GNUNET_CRYPTO_SymmetricInitializationVector | |||
308 | /** | 292 | /** |
309 | * @brief type for (message) authentication keys | 293 | * @brief type for (message) authentication keys |
310 | */ | 294 | */ |
311 | struct GNUNET_CRYPTO_AuthKey | 295 | struct GNUNET_CRYPTO_AuthKey { |
312 | { | ||
313 | unsigned char key[GNUNET_CRYPTO_HASH_LENGTH]; | 296 | unsigned char key[GNUNET_CRYPTO_HASH_LENGTH]; |
314 | }; | 297 | }; |
315 | 298 | ||
@@ -324,8 +307,7 @@ struct GNUNET_CRYPTO_AuthKey | |||
324 | /** | 307 | /** |
325 | * Paillier public key. | 308 | * Paillier public key. |
326 | */ | 309 | */ |
327 | struct GNUNET_CRYPTO_PaillierPublicKey | 310 | struct GNUNET_CRYPTO_PaillierPublicKey { |
328 | { | ||
329 | /** | 311 | /** |
330 | * N value. | 312 | * N value. |
331 | */ | 313 | */ |
@@ -336,8 +318,7 @@ struct GNUNET_CRYPTO_PaillierPublicKey | |||
336 | /** | 318 | /** |
337 | * Paillier private key. | 319 | * Paillier private key. |
338 | */ | 320 | */ |
339 | struct GNUNET_CRYPTO_PaillierPrivateKey | 321 | struct GNUNET_CRYPTO_PaillierPrivateKey { |
340 | { | ||
341 | /** | 322 | /** |
342 | * Lambda-component of the private key. | 323 | * Lambda-component of the private key. |
343 | */ | 324 | */ |
@@ -352,8 +333,7 @@ struct GNUNET_CRYPTO_PaillierPrivateKey | |||
352 | /** | 333 | /** |
353 | * Paillier ciphertext. | 334 | * Paillier ciphertext. |
354 | */ | 335 | */ |
355 | struct GNUNET_CRYPTO_PaillierCiphertext | 336 | struct GNUNET_CRYPTO_PaillierCiphertext { |
356 | { | ||
357 | /** | 337 | /** |
358 | * Guaranteed minimum number of homomorphic operations with this ciphertext, | 338 | * Guaranteed minimum number of homomorphic operations with this ciphertext, |
359 | * in network byte order (NBO). | 339 | * in network byte order (NBO). |
@@ -377,7 +357,7 @@ struct GNUNET_CRYPTO_PaillierCiphertext | |||
377 | * @param seed the seed to use | 357 | * @param seed the seed to use |
378 | */ | 358 | */ |
379 | void | 359 | void |
380 | GNUNET_CRYPTO_seed_weak_random (int32_t seed); | 360 | GNUNET_CRYPTO_seed_weak_random(int32_t seed); |
381 | 361 | ||
382 | 362 | ||
383 | /** | 363 | /** |
@@ -389,7 +369,7 @@ GNUNET_CRYPTO_seed_weak_random (int32_t seed); | |||
389 | * @return crc8 value | 369 | * @return crc8 value |
390 | */ | 370 | */ |
391 | uint8_t | 371 | uint8_t |
392 | GNUNET_CRYPTO_crc8_n (const void *buf, size_t len); | 372 | GNUNET_CRYPTO_crc8_n(const void *buf, size_t len); |
393 | 373 | ||
394 | 374 | ||
395 | /** | 375 | /** |
@@ -401,7 +381,7 @@ GNUNET_CRYPTO_crc8_n (const void *buf, size_t len); | |||
401 | * @return updated crc sum (must be subjected to #GNUNET_CRYPTO_crc16_finish to get actual crc16) | 381 | * @return updated crc sum (must be subjected to #GNUNET_CRYPTO_crc16_finish to get actual crc16) |
402 | */ | 382 | */ |
403 | uint32_t | 383 | uint32_t |
404 | GNUNET_CRYPTO_crc16_step (uint32_t sum, const void *buf, size_t len); | 384 | GNUNET_CRYPTO_crc16_step(uint32_t sum, const void *buf, size_t len); |
405 | 385 | ||
406 | 386 | ||
407 | /** | 387 | /** |
@@ -411,7 +391,7 @@ GNUNET_CRYPTO_crc16_step (uint32_t sum, const void *buf, size_t len); | |||
411 | * @return crc16 value | 391 | * @return crc16 value |
412 | */ | 392 | */ |
413 | uint16_t | 393 | uint16_t |
414 | GNUNET_CRYPTO_crc16_finish (uint32_t sum); | 394 | GNUNET_CRYPTO_crc16_finish(uint32_t sum); |
415 | 395 | ||
416 | 396 | ||
417 | /** | 397 | /** |
@@ -423,7 +403,7 @@ GNUNET_CRYPTO_crc16_finish (uint32_t sum); | |||
423 | * @return crc16 value | 403 | * @return crc16 value |
424 | */ | 404 | */ |
425 | uint16_t | 405 | uint16_t |
426 | GNUNET_CRYPTO_crc16_n (const void *buf, size_t len); | 406 | GNUNET_CRYPTO_crc16_n(const void *buf, size_t len); |
427 | 407 | ||
428 | 408 | ||
429 | /** | 409 | /** |
@@ -436,7 +416,7 @@ GNUNET_CRYPTO_crc16_n (const void *buf, size_t len); | |||
436 | * @return the resulting CRC32 checksum | 416 | * @return the resulting CRC32 checksum |
437 | */ | 417 | */ |
438 | int32_t | 418 | int32_t |
439 | GNUNET_CRYPTO_crc32_n (const void *buf, size_t len); | 419 | GNUNET_CRYPTO_crc32_n(const void *buf, size_t len); |
440 | 420 | ||
441 | /** | 421 | /** |
442 | * @ingroup crypto | 422 | * @ingroup crypto |
@@ -447,7 +427,7 @@ GNUNET_CRYPTO_crc32_n (const void *buf, size_t len); | |||
447 | * @param length buffer length | 427 | * @param length buffer length |
448 | */ | 428 | */ |
449 | void | 429 | void |
450 | GNUNET_CRYPTO_zero_keys (void *buffer, size_t length); | 430 | GNUNET_CRYPTO_zero_keys(void *buffer, size_t length); |
451 | 431 | ||
452 | 432 | ||
453 | /** | 433 | /** |
@@ -459,9 +439,9 @@ GNUNET_CRYPTO_zero_keys (void *buffer, size_t length); | |||
459 | * @param length buffer length | 439 | * @param length buffer length |
460 | */ | 440 | */ |
461 | void | 441 | void |
462 | GNUNET_CRYPTO_random_block (enum GNUNET_CRYPTO_Quality mode, | 442 | GNUNET_CRYPTO_random_block(enum GNUNET_CRYPTO_Quality mode, |
463 | void *buffer, | 443 | void *buffer, |
464 | size_t length); | 444 | size_t length); |
465 | 445 | ||
466 | /** | 446 | /** |
467 | * @ingroup crypto | 447 | * @ingroup crypto |
@@ -472,7 +452,7 @@ GNUNET_CRYPTO_random_block (enum GNUNET_CRYPTO_Quality mode, | |||
472 | * @return a random value in the interval [0,@a i) (exclusive). | 452 | * @return a random value in the interval [0,@a i) (exclusive). |
473 | */ | 453 | */ |
474 | uint32_t | 454 | uint32_t |
475 | GNUNET_CRYPTO_random_u32 (enum GNUNET_CRYPTO_Quality mode, uint32_t i); | 455 | GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i); |
476 | 456 | ||
477 | 457 | ||
478 | /** | 458 | /** |
@@ -484,7 +464,7 @@ GNUNET_CRYPTO_random_u32 (enum GNUNET_CRYPTO_Quality mode, uint32_t i); | |||
484 | * @return random 64-bit number | 464 | * @return random 64-bit number |
485 | */ | 465 | */ |
486 | uint64_t | 466 | uint64_t |
487 | GNUNET_CRYPTO_random_u64 (enum GNUNET_CRYPTO_Quality mode, uint64_t max); | 467 | GNUNET_CRYPTO_random_u64(enum GNUNET_CRYPTO_Quality mode, uint64_t max); |
488 | 468 | ||
489 | 469 | ||
490 | /** | 470 | /** |
@@ -497,7 +477,7 @@ GNUNET_CRYPTO_random_u64 (enum GNUNET_CRYPTO_Quality mode, uint64_t max); | |||
497 | * @return the permutation array (allocated from heap) | 477 | * @return the permutation array (allocated from heap) |
498 | */ | 478 | */ |
499 | unsigned int * | 479 | unsigned int * |
500 | GNUNET_CRYPTO_random_permute (enum GNUNET_CRYPTO_Quality mode, unsigned int n); | 480 | GNUNET_CRYPTO_random_permute(enum GNUNET_CRYPTO_Quality mode, unsigned int n); |
501 | 481 | ||
502 | 482 | ||
503 | /** | 483 | /** |
@@ -507,7 +487,7 @@ GNUNET_CRYPTO_random_permute (enum GNUNET_CRYPTO_Quality mode, unsigned int n); | |||
507 | * @param key key to initialize | 487 | * @param key key to initialize |
508 | */ | 488 | */ |
509 | void | 489 | void |
510 | GNUNET_CRYPTO_symmetric_create_session_key ( | 490 | GNUNET_CRYPTO_symmetric_create_session_key( |
511 | struct GNUNET_CRYPTO_SymmetricSessionKey *key); | 491 | struct GNUNET_CRYPTO_SymmetricSessionKey *key); |
512 | 492 | ||
513 | 493 | ||
@@ -523,7 +503,7 @@ GNUNET_CRYPTO_symmetric_create_session_key ( | |||
523 | * @return the size of the encrypted block, -1 for errors | 503 | * @return the size of the encrypted block, -1 for errors |
524 | */ | 504 | */ |
525 | ssize_t | 505 | ssize_t |
526 | GNUNET_CRYPTO_symmetric_encrypt ( | 506 | GNUNET_CRYPTO_symmetric_encrypt( |
527 | const void *block, | 507 | const void *block, |
528 | size_t size, | 508 | size_t size, |
529 | const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey, | 509 | const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey, |
@@ -543,7 +523,7 @@ GNUNET_CRYPTO_symmetric_encrypt ( | |||
543 | * @return -1 on failure, size of decrypted block on success | 523 | * @return -1 on failure, size of decrypted block on success |
544 | */ | 524 | */ |
545 | ssize_t | 525 | ssize_t |
546 | GNUNET_CRYPTO_symmetric_decrypt ( | 526 | GNUNET_CRYPTO_symmetric_decrypt( |
547 | const void *block, | 527 | const void *block, |
548 | size_t size, | 528 | size_t size, |
549 | const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey, | 529 | const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey, |
@@ -561,7 +541,7 @@ GNUNET_CRYPTO_symmetric_decrypt ( | |||
561 | * @param ... pairs of void * & size_t for context chunks, terminated by NULL | 541 | * @param ... pairs of void * & size_t for context chunks, terminated by NULL |
562 | */ | 542 | */ |
563 | void | 543 | void |
564 | GNUNET_CRYPTO_symmetric_derive_iv ( | 544 | GNUNET_CRYPTO_symmetric_derive_iv( |
565 | struct GNUNET_CRYPTO_SymmetricInitializationVector *iv, | 545 | struct GNUNET_CRYPTO_SymmetricInitializationVector *iv, |
566 | const struct GNUNET_CRYPTO_SymmetricSessionKey *skey, | 546 | const struct GNUNET_CRYPTO_SymmetricSessionKey *skey, |
567 | const void *salt, | 547 | const void *salt, |
@@ -578,7 +558,7 @@ GNUNET_CRYPTO_symmetric_derive_iv ( | |||
578 | * @param argp pairs of void * & size_t for context chunks, terminated by NULL | 558 | * @param argp pairs of void * & size_t for context chunks, terminated by NULL |
579 | */ | 559 | */ |
580 | void | 560 | void |
581 | GNUNET_CRYPTO_symmetric_derive_iv_v ( | 561 | GNUNET_CRYPTO_symmetric_derive_iv_v( |
582 | struct GNUNET_CRYPTO_SymmetricInitializationVector *iv, | 562 | struct GNUNET_CRYPTO_SymmetricInitializationVector *iv, |
583 | const struct GNUNET_CRYPTO_SymmetricSessionKey *skey, | 563 | const struct GNUNET_CRYPTO_SymmetricSessionKey *skey, |
584 | const void *salt, | 564 | const void *salt, |
@@ -594,8 +574,8 @@ GNUNET_CRYPTO_symmetric_derive_iv_v ( | |||
594 | * safely cast to char*, a '\\0' termination is set). | 574 | * safely cast to char*, a '\\0' termination is set). |
595 | */ | 575 | */ |
596 | void | 576 | void |
597 | GNUNET_CRYPTO_hash_to_enc (const struct GNUNET_HashCode *block, | 577 | GNUNET_CRYPTO_hash_to_enc(const struct GNUNET_HashCode *block, |
598 | struct GNUNET_CRYPTO_HashAsciiEncoded *result); | 578 | struct GNUNET_CRYPTO_HashAsciiEncoded *result); |
599 | 579 | ||
600 | 580 | ||
601 | /** | 581 | /** |
@@ -608,9 +588,9 @@ GNUNET_CRYPTO_hash_to_enc (const struct GNUNET_HashCode *block, | |||
608 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if result has the wrong encoding | 588 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if result has the wrong encoding |
609 | */ | 589 | */ |
610 | int | 590 | int |
611 | GNUNET_CRYPTO_hash_from_string2 (const char *enc, | 591 | GNUNET_CRYPTO_hash_from_string2(const char *enc, |
612 | size_t enclen, | 592 | size_t enclen, |
613 | struct GNUNET_HashCode *result); | 593 | struct GNUNET_HashCode *result); |
614 | 594 | ||
615 | 595 | ||
616 | /** | 596 | /** |
@@ -622,7 +602,7 @@ GNUNET_CRYPTO_hash_from_string2 (const char *enc, | |||
622 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if result has the wrong encoding | 602 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if result has the wrong encoding |
623 | */ | 603 | */ |
624 | #define GNUNET_CRYPTO_hash_from_string(enc, result) \ | 604 | #define GNUNET_CRYPTO_hash_from_string(enc, result) \ |
625 | GNUNET_CRYPTO_hash_from_string2 (enc, strlen (enc), result) | 605 | GNUNET_CRYPTO_hash_from_string2(enc, strlen(enc), result) |
626 | 606 | ||
627 | 607 | ||
628 | /** | 608 | /** |
@@ -638,8 +618,8 @@ GNUNET_CRYPTO_hash_from_string2 (const char *enc, | |||
638 | * @return number between 0 and UINT32_MAX | 618 | * @return number between 0 and UINT32_MAX |
639 | */ | 619 | */ |
640 | uint32_t | 620 | uint32_t |
641 | GNUNET_CRYPTO_hash_distance_u32 (const struct GNUNET_HashCode *a, | 621 | GNUNET_CRYPTO_hash_distance_u32(const struct GNUNET_HashCode *a, |
642 | const struct GNUNET_HashCode *b); | 622 | const struct GNUNET_HashCode *b); |
643 | 623 | ||
644 | 624 | ||
645 | /** | 625 | /** |
@@ -651,9 +631,9 @@ GNUNET_CRYPTO_hash_distance_u32 (const struct GNUNET_HashCode *a, | |||
651 | * @param ret pointer to where to write the hashcode | 631 | * @param ret pointer to where to write the hashcode |
652 | */ | 632 | */ |
653 | void | 633 | void |
654 | GNUNET_CRYPTO_hash (const void *block, | 634 | GNUNET_CRYPTO_hash(const void *block, |
655 | size_t size, | 635 | size_t size, |
656 | struct GNUNET_HashCode *ret); | 636 | struct GNUNET_HashCode *ret); |
657 | 637 | ||
658 | 638 | ||
659 | /** | 639 | /** |
@@ -668,7 +648,7 @@ struct GNUNET_HashContext; | |||
668 | * @return context for incremental hash computation | 648 | * @return context for incremental hash computation |
669 | */ | 649 | */ |
670 | struct GNUNET_HashContext * | 650 | struct GNUNET_HashContext * |
671 | GNUNET_CRYPTO_hash_context_start (void); | 651 | GNUNET_CRYPTO_hash_context_start(void); |
672 | 652 | ||
673 | 653 | ||
674 | /** | 654 | /** |
@@ -679,9 +659,9 @@ GNUNET_CRYPTO_hash_context_start (void); | |||
679 | * @param size number of bytes in @a buf | 659 | * @param size number of bytes in @a buf |
680 | */ | 660 | */ |
681 | void | 661 | void |
682 | GNUNET_CRYPTO_hash_context_read (struct GNUNET_HashContext *hc, | 662 | GNUNET_CRYPTO_hash_context_read(struct GNUNET_HashContext *hc, |
683 | const void *buf, | 663 | const void *buf, |
684 | size_t size); | 664 | size_t size); |
685 | 665 | ||
686 | 666 | ||
687 | /** | 667 | /** |
@@ -691,8 +671,8 @@ GNUNET_CRYPTO_hash_context_read (struct GNUNET_HashContext *hc, | |||
691 | * @param r_hash where to write the latest / final hash code | 671 | * @param r_hash where to write the latest / final hash code |
692 | */ | 672 | */ |
693 | void | 673 | void |
694 | GNUNET_CRYPTO_hash_context_finish (struct GNUNET_HashContext *hc, | 674 | GNUNET_CRYPTO_hash_context_finish(struct GNUNET_HashContext *hc, |
695 | struct GNUNET_HashCode *r_hash); | 675 | struct GNUNET_HashCode *r_hash); |
696 | 676 | ||
697 | 677 | ||
698 | /** | 678 | /** |
@@ -701,7 +681,7 @@ GNUNET_CRYPTO_hash_context_finish (struct GNUNET_HashContext *hc, | |||
701 | * @param hc hash context to destroy | 681 | * @param hc hash context to destroy |
702 | */ | 682 | */ |
703 | void | 683 | void |
704 | GNUNET_CRYPTO_hash_context_abort (struct GNUNET_HashContext *hc); | 684 | GNUNET_CRYPTO_hash_context_abort(struct GNUNET_HashContext *hc); |
705 | 685 | ||
706 | 686 | ||
707 | /** | 687 | /** |
@@ -716,11 +696,11 @@ GNUNET_CRYPTO_hash_context_abort (struct GNUNET_HashContext *hc); | |||
716 | * @param hmac where to store the hmac | 696 | * @param hmac where to store the hmac |
717 | */ | 697 | */ |
718 | void | 698 | void |
719 | GNUNET_CRYPTO_hmac_raw (const void *key, | 699 | GNUNET_CRYPTO_hmac_raw(const void *key, |
720 | size_t key_len, | 700 | size_t key_len, |
721 | const void *plaintext, | 701 | const void *plaintext, |
722 | size_t plaintext_len, | 702 | size_t plaintext_len, |
723 | struct GNUNET_HashCode *hmac); | 703 | struct GNUNET_HashCode *hmac); |
724 | 704 | ||
725 | 705 | ||
726 | /** | 706 | /** |
@@ -733,10 +713,10 @@ GNUNET_CRYPTO_hmac_raw (const void *key, | |||
733 | * @param hmac where to store the hmac | 713 | * @param hmac where to store the hmac |
734 | */ | 714 | */ |
735 | void | 715 | void |
736 | GNUNET_CRYPTO_hmac (const struct GNUNET_CRYPTO_AuthKey *key, | 716 | GNUNET_CRYPTO_hmac(const struct GNUNET_CRYPTO_AuthKey *key, |
737 | const void *plaintext, | 717 | const void *plaintext, |
738 | size_t plaintext_len, | 718 | size_t plaintext_len, |
739 | struct GNUNET_HashCode *hmac); | 719 | struct GNUNET_HashCode *hmac); |
740 | 720 | ||
741 | 721 | ||
742 | /** | 722 | /** |
@@ -769,11 +749,11 @@ struct GNUNET_CRYPTO_FileHashContext; | |||
769 | * @return NULL on (immediate) errror | 749 | * @return NULL on (immediate) errror |
770 | */ | 750 | */ |
771 | struct GNUNET_CRYPTO_FileHashContext * | 751 | struct GNUNET_CRYPTO_FileHashContext * |
772 | GNUNET_CRYPTO_hash_file (enum GNUNET_SCHEDULER_Priority priority, | 752 | GNUNET_CRYPTO_hash_file(enum GNUNET_SCHEDULER_Priority priority, |
773 | const char *filename, | 753 | const char *filename, |
774 | size_t blocksize, | 754 | size_t blocksize, |
775 | GNUNET_CRYPTO_HashCompletedCallback callback, | 755 | GNUNET_CRYPTO_HashCompletedCallback callback, |
776 | void *callback_cls); | 756 | void *callback_cls); |
777 | 757 | ||
778 | 758 | ||
779 | /** | 759 | /** |
@@ -782,7 +762,7 @@ GNUNET_CRYPTO_hash_file (enum GNUNET_SCHEDULER_Priority priority, | |||
782 | * @param fhc operation to cancel (callback must not yet have been invoked) | 762 | * @param fhc operation to cancel (callback must not yet have been invoked) |
783 | */ | 763 | */ |
784 | void | 764 | void |
785 | GNUNET_CRYPTO_hash_file_cancel (struct GNUNET_CRYPTO_FileHashContext *fhc); | 765 | GNUNET_CRYPTO_hash_file_cancel(struct GNUNET_CRYPTO_FileHashContext *fhc); |
786 | 766 | ||
787 | 767 | ||
788 | /** | 768 | /** |
@@ -793,8 +773,8 @@ GNUNET_CRYPTO_hash_file_cancel (struct GNUNET_CRYPTO_FileHashContext *fhc); | |||
793 | * @param result hash code that is randomized | 773 | * @param result hash code that is randomized |
794 | */ | 774 | */ |
795 | void | 775 | void |
796 | GNUNET_CRYPTO_hash_create_random (enum GNUNET_CRYPTO_Quality mode, | 776 | GNUNET_CRYPTO_hash_create_random(enum GNUNET_CRYPTO_Quality mode, |
797 | struct GNUNET_HashCode *result); | 777 | struct GNUNET_HashCode *result); |
798 | 778 | ||
799 | 779 | ||
800 | /** | 780 | /** |
@@ -806,9 +786,9 @@ GNUNET_CRYPTO_hash_create_random (enum GNUNET_CRYPTO_Quality mode, | |||
806 | * @param result set to @a b - @a a | 786 | * @param result set to @a b - @a a |
807 | */ | 787 | */ |
808 | void | 788 | void |
809 | GNUNET_CRYPTO_hash_difference (const struct GNUNET_HashCode *a, | 789 | GNUNET_CRYPTO_hash_difference(const struct GNUNET_HashCode *a, |
810 | const struct GNUNET_HashCode *b, | 790 | const struct GNUNET_HashCode *b, |
811 | struct GNUNET_HashCode *result); | 791 | struct GNUNET_HashCode *result); |
812 | 792 | ||
813 | 793 | ||
814 | /** | 794 | /** |
@@ -820,9 +800,9 @@ GNUNET_CRYPTO_hash_difference (const struct GNUNET_HashCode *a, | |||
820 | * @param result set to @a a + @a delta | 800 | * @param result set to @a a + @a delta |
821 | */ | 801 | */ |
822 | void | 802 | void |
823 | GNUNET_CRYPTO_hash_sum (const struct GNUNET_HashCode *a, | 803 | GNUNET_CRYPTO_hash_sum(const struct GNUNET_HashCode *a, |
824 | const struct GNUNET_HashCode *delta, | 804 | const struct GNUNET_HashCode *delta, |
825 | struct GNUNET_HashCode *result); | 805 | struct GNUNET_HashCode *result); |
826 | 806 | ||
827 | 807 | ||
828 | /** | 808 | /** |
@@ -834,9 +814,9 @@ GNUNET_CRYPTO_hash_sum (const struct GNUNET_HashCode *a, | |||
834 | * @param result set to @a a ^ @a b | 814 | * @param result set to @a a ^ @a b |
835 | */ | 815 | */ |
836 | void | 816 | void |
837 | GNUNET_CRYPTO_hash_xor (const struct GNUNET_HashCode *a, | 817 | GNUNET_CRYPTO_hash_xor(const struct GNUNET_HashCode *a, |
838 | const struct GNUNET_HashCode *b, | 818 | const struct GNUNET_HashCode *b, |
839 | struct GNUNET_HashCode *result); | 819 | struct GNUNET_HashCode *result); |
840 | 820 | ||
841 | 821 | ||
842 | /** | 822 | /** |
@@ -848,7 +828,7 @@ GNUNET_CRYPTO_hash_xor (const struct GNUNET_HashCode *a, | |||
848 | * @param iv set to a valid initialization vector | 828 | * @param iv set to a valid initialization vector |
849 | */ | 829 | */ |
850 | void | 830 | void |
851 | GNUNET_CRYPTO_hash_to_aes_key ( | 831 | GNUNET_CRYPTO_hash_to_aes_key( |
852 | const struct GNUNET_HashCode *hc, | 832 | const struct GNUNET_HashCode *hc, |
853 | struct GNUNET_CRYPTO_SymmetricSessionKey *skey, | 833 | struct GNUNET_CRYPTO_SymmetricSessionKey *skey, |
854 | struct GNUNET_CRYPTO_SymmetricInitializationVector *iv); | 834 | struct GNUNET_CRYPTO_SymmetricInitializationVector *iv); |
@@ -863,8 +843,8 @@ GNUNET_CRYPTO_hash_to_aes_key ( | |||
863 | * @return Bit \a bit from hashcode \a code, -1 for invalid index | 843 | * @return Bit \a bit from hashcode \a code, -1 for invalid index |
864 | */ | 844 | */ |
865 | int | 845 | int |
866 | GNUNET_CRYPTO_hash_get_bit (const struct GNUNET_HashCode *code, | 846 | GNUNET_CRYPTO_hash_get_bit(const struct GNUNET_HashCode *code, |
867 | unsigned int bit); | 847 | unsigned int bit); |
868 | 848 | ||
869 | 849 | ||
870 | /** | 850 | /** |
@@ -880,8 +860,8 @@ GNUNET_CRYPTO_hash_get_bit (const struct GNUNET_HashCode *code, | |||
880 | * @return the number of bits that match | 860 | * @return the number of bits that match |
881 | */ | 861 | */ |
882 | unsigned int | 862 | unsigned int |
883 | GNUNET_CRYPTO_hash_matching_bits (const struct GNUNET_HashCode *first, | 863 | GNUNET_CRYPTO_hash_matching_bits(const struct GNUNET_HashCode *first, |
884 | const struct GNUNET_HashCode *second); | 864 | const struct GNUNET_HashCode *second); |
885 | 865 | ||
886 | 866 | ||
887 | /** | 867 | /** |
@@ -894,8 +874,8 @@ GNUNET_CRYPTO_hash_matching_bits (const struct GNUNET_HashCode *first, | |||
894 | * @return 1 if @a h1 > @a h2, -1 if @a h1 < @a h2 and 0 if @a h1 == @a h2. | 874 | * @return 1 if @a h1 > @a h2, -1 if @a h1 < @a h2 and 0 if @a h1 == @a h2. |
895 | */ | 875 | */ |
896 | int | 876 | int |
897 | GNUNET_CRYPTO_hash_cmp (const struct GNUNET_HashCode *h1, | 877 | GNUNET_CRYPTO_hash_cmp(const struct GNUNET_HashCode *h1, |
898 | const struct GNUNET_HashCode *h2); | 878 | const struct GNUNET_HashCode *h2); |
899 | 879 | ||
900 | 880 | ||
901 | /** | 881 | /** |
@@ -909,9 +889,9 @@ GNUNET_CRYPTO_hash_cmp (const struct GNUNET_HashCode *h1, | |||
909 | * @return -1 if @a h1 is closer, 1 if @a h2 is closer and 0 if @a h1== @a h2. | 889 | * @return -1 if @a h1 is closer, 1 if @a h2 is closer and 0 if @a h1== @a h2. |
910 | */ | 890 | */ |
911 | int | 891 | int |
912 | GNUNET_CRYPTO_hash_xorcmp (const struct GNUNET_HashCode *h1, | 892 | GNUNET_CRYPTO_hash_xorcmp(const struct GNUNET_HashCode *h1, |
913 | const struct GNUNET_HashCode *h2, | 893 | const struct GNUNET_HashCode *h2, |
914 | const struct GNUNET_HashCode *target); | 894 | const struct GNUNET_HashCode *target); |
915 | 895 | ||
916 | 896 | ||
917 | /** | 897 | /** |
@@ -924,7 +904,7 @@ GNUNET_CRYPTO_hash_xorcmp (const struct GNUNET_HashCode *h1, | |||
924 | * @param argp pair of void * & size_t for context chunks, terminated by NULL | 904 | * @param argp pair of void * & size_t for context chunks, terminated by NULL |
925 | */ | 905 | */ |
926 | void | 906 | void |
927 | GNUNET_CRYPTO_hmac_derive_key_v ( | 907 | GNUNET_CRYPTO_hmac_derive_key_v( |
928 | struct GNUNET_CRYPTO_AuthKey *key, | 908 | struct GNUNET_CRYPTO_AuthKey *key, |
929 | const struct GNUNET_CRYPTO_SymmetricSessionKey *rkey, | 909 | const struct GNUNET_CRYPTO_SymmetricSessionKey *rkey, |
930 | const void *salt, | 910 | const void *salt, |
@@ -942,7 +922,7 @@ GNUNET_CRYPTO_hmac_derive_key_v ( | |||
942 | * @param ... pair of void * & size_t for context chunks, terminated by NULL | 922 | * @param ... pair of void * & size_t for context chunks, terminated by NULL |
943 | */ | 923 | */ |
944 | void | 924 | void |
945 | GNUNET_CRYPTO_hmac_derive_key ( | 925 | GNUNET_CRYPTO_hmac_derive_key( |
946 | struct GNUNET_CRYPTO_AuthKey *key, | 926 | struct GNUNET_CRYPTO_AuthKey *key, |
947 | const struct GNUNET_CRYPTO_SymmetricSessionKey *rkey, | 927 | const struct GNUNET_CRYPTO_SymmetricSessionKey *rkey, |
948 | const void *salt, | 928 | const void *salt, |
@@ -965,15 +945,15 @@ GNUNET_CRYPTO_hmac_derive_key ( | |||
965 | * @return #GNUNET_YES on success | 945 | * @return #GNUNET_YES on success |
966 | */ | 946 | */ |
967 | int | 947 | int |
968 | GNUNET_CRYPTO_hkdf (void *result, | 948 | GNUNET_CRYPTO_hkdf(void *result, |
969 | size_t out_len, | 949 | size_t out_len, |
970 | int xtr_algo, | 950 | int xtr_algo, |
971 | int prf_algo, | 951 | int prf_algo, |
972 | const void *xts, | 952 | const void *xts, |
973 | size_t xts_len, | 953 | size_t xts_len, |
974 | const void *skm, | 954 | const void *skm, |
975 | size_t skm_len, | 955 | size_t skm_len, |
976 | ...); | 956 | ...); |
977 | 957 | ||
978 | 958 | ||
979 | /** | 959 | /** |
@@ -991,15 +971,15 @@ GNUNET_CRYPTO_hkdf (void *result, | |||
991 | * @return #GNUNET_YES on success | 971 | * @return #GNUNET_YES on success |
992 | */ | 972 | */ |
993 | int | 973 | int |
994 | GNUNET_CRYPTO_hkdf_v (void *result, | 974 | GNUNET_CRYPTO_hkdf_v(void *result, |
995 | size_t out_len, | 975 | size_t out_len, |
996 | int xtr_algo, | 976 | int xtr_algo, |
997 | int prf_algo, | 977 | int prf_algo, |
998 | const void *xts, | 978 | const void *xts, |
999 | size_t xts_len, | 979 | size_t xts_len, |
1000 | const void *skm, | 980 | const void *skm, |
1001 | size_t skm_len, | 981 | size_t skm_len, |
1002 | va_list argp); | 982 | va_list argp); |
1003 | 983 | ||
1004 | 984 | ||
1005 | /** | 985 | /** |
@@ -1014,13 +994,13 @@ GNUNET_CRYPTO_hkdf_v (void *result, | |||
1014 | * @return #GNUNET_YES on success | 994 | * @return #GNUNET_YES on success |
1015 | */ | 995 | */ |
1016 | int | 996 | int |
1017 | GNUNET_CRYPTO_kdf_v (void *result, | 997 | GNUNET_CRYPTO_kdf_v(void *result, |
1018 | size_t out_len, | 998 | size_t out_len, |
1019 | const void *xts, | 999 | const void *xts, |
1020 | size_t xts_len, | 1000 | size_t xts_len, |
1021 | const void *skm, | 1001 | const void *skm, |
1022 | size_t skm_len, | 1002 | size_t skm_len, |
1023 | va_list argp); | 1003 | va_list argp); |
1024 | 1004 | ||
1025 | 1005 | ||
1026 | /** | 1006 | /** |
@@ -1036,13 +1016,13 @@ GNUNET_CRYPTO_kdf_v (void *result, | |||
1036 | * @param ctx context string | 1016 | * @param ctx context string |
1037 | */ | 1017 | */ |
1038 | void | 1018 | void |
1039 | GNUNET_CRYPTO_kdf_mod_mpi (gcry_mpi_t *r, | 1019 | GNUNET_CRYPTO_kdf_mod_mpi(gcry_mpi_t *r, |
1040 | gcry_mpi_t n, | 1020 | gcry_mpi_t n, |
1041 | const void *xts, | 1021 | const void *xts, |
1042 | size_t xts_len, | 1022 | size_t xts_len, |
1043 | const void *skm, | 1023 | const void *skm, |
1044 | size_t skm_len, | 1024 | size_t skm_len, |
1045 | const char *ctx); | 1025 | const char *ctx); |
1046 | 1026 | ||
1047 | 1027 | ||
1048 | /** | 1028 | /** |
@@ -1058,13 +1038,13 @@ GNUNET_CRYPTO_kdf_mod_mpi (gcry_mpi_t *r, | |||
1058 | * @return #GNUNET_YES on success | 1038 | * @return #GNUNET_YES on success |
1059 | */ | 1039 | */ |
1060 | int | 1040 | int |
1061 | GNUNET_CRYPTO_kdf (void *result, | 1041 | GNUNET_CRYPTO_kdf(void *result, |
1062 | size_t out_len, | 1042 | size_t out_len, |
1063 | const void *xts, | 1043 | const void *xts, |
1064 | size_t xts_len, | 1044 | size_t xts_len, |
1065 | const void *skm, | 1045 | const void *skm, |
1066 | size_t skm_len, | 1046 | size_t skm_len, |
1067 | ...); | 1047 | ...); |
1068 | 1048 | ||
1069 | 1049 | ||
1070 | /** | 1050 | /** |
@@ -1075,7 +1055,7 @@ GNUNET_CRYPTO_kdf (void *result, | |||
1075 | * @param pub where to write the public key | 1055 | * @param pub where to write the public key |
1076 | */ | 1056 | */ |
1077 | void | 1057 | void |
1078 | GNUNET_CRYPTO_ecdsa_key_get_public ( | 1058 | GNUNET_CRYPTO_ecdsa_key_get_public( |
1079 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, | 1059 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, |
1080 | struct GNUNET_CRYPTO_EcdsaPublicKey *pub); | 1060 | struct GNUNET_CRYPTO_EcdsaPublicKey *pub); |
1081 | 1061 | ||
@@ -1087,7 +1067,7 @@ GNUNET_CRYPTO_ecdsa_key_get_public ( | |||
1087 | * @param pub where to write the public key | 1067 | * @param pub where to write the public key |
1088 | */ | 1068 | */ |
1089 | void | 1069 | void |
1090 | GNUNET_CRYPTO_eddsa_key_get_public ( | 1070 | GNUNET_CRYPTO_eddsa_key_get_public( |
1091 | const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, | 1071 | const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, |
1092 | struct GNUNET_CRYPTO_EddsaPublicKey *pub); | 1072 | struct GNUNET_CRYPTO_EddsaPublicKey *pub); |
1093 | 1073 | ||
@@ -1100,7 +1080,7 @@ GNUNET_CRYPTO_eddsa_key_get_public ( | |||
1100 | * @param pub where to write the public key | 1080 | * @param pub where to write the public key |
1101 | */ | 1081 | */ |
1102 | void | 1082 | void |
1103 | GNUNET_CRYPTO_ecdhe_key_get_public ( | 1083 | GNUNET_CRYPTO_ecdhe_key_get_public( |
1104 | const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, | 1084 | const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, |
1105 | struct GNUNET_CRYPTO_EcdhePublicKey *pub); | 1085 | struct GNUNET_CRYPTO_EcdhePublicKey *pub); |
1106 | 1086 | ||
@@ -1112,7 +1092,7 @@ GNUNET_CRYPTO_ecdhe_key_get_public ( | |||
1112 | * @return string representing @a pub | 1092 | * @return string representing @a pub |
1113 | */ | 1093 | */ |
1114 | char * | 1094 | char * |
1115 | GNUNET_CRYPTO_ecdsa_public_key_to_string ( | 1095 | GNUNET_CRYPTO_ecdsa_public_key_to_string( |
1116 | const struct GNUNET_CRYPTO_EcdsaPublicKey *pub); | 1096 | const struct GNUNET_CRYPTO_EcdsaPublicKey *pub); |
1117 | 1097 | ||
1118 | /** | 1098 | /** |
@@ -1122,7 +1102,7 @@ GNUNET_CRYPTO_ecdsa_public_key_to_string ( | |||
1122 | * @return string representing @a priv | 1102 | * @return string representing @a priv |
1123 | */ | 1103 | */ |
1124 | char * | 1104 | char * |
1125 | GNUNET_CRYPTO_ecdsa_private_key_to_string ( | 1105 | GNUNET_CRYPTO_ecdsa_private_key_to_string( |
1126 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv); | 1106 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv); |
1127 | 1107 | ||
1128 | 1108 | ||
@@ -1133,7 +1113,7 @@ GNUNET_CRYPTO_ecdsa_private_key_to_string ( | |||
1133 | * @return string representing @a pub | 1113 | * @return string representing @a pub |
1134 | */ | 1114 | */ |
1135 | char * | 1115 | char * |
1136 | GNUNET_CRYPTO_eddsa_private_key_to_string ( | 1116 | GNUNET_CRYPTO_eddsa_private_key_to_string( |
1137 | const struct GNUNET_CRYPTO_EddsaPrivateKey *priv); | 1117 | const struct GNUNET_CRYPTO_EddsaPrivateKey *priv); |
1138 | 1118 | ||
1139 | 1119 | ||
@@ -1144,7 +1124,7 @@ GNUNET_CRYPTO_eddsa_private_key_to_string ( | |||
1144 | * @return string representing @a pub | 1124 | * @return string representing @a pub |
1145 | */ | 1125 | */ |
1146 | char * | 1126 | char * |
1147 | GNUNET_CRYPTO_eddsa_public_key_to_string ( | 1127 | GNUNET_CRYPTO_eddsa_public_key_to_string( |
1148 | const struct GNUNET_CRYPTO_EddsaPublicKey *pub); | 1128 | const struct GNUNET_CRYPTO_EddsaPublicKey *pub); |
1149 | 1129 | ||
1150 | 1130 | ||
@@ -1157,7 +1137,7 @@ GNUNET_CRYPTO_eddsa_public_key_to_string ( | |||
1157 | * @return #GNUNET_OK on success | 1137 | * @return #GNUNET_OK on success |
1158 | */ | 1138 | */ |
1159 | int | 1139 | int |
1160 | GNUNET_CRYPTO_ecdsa_public_key_from_string ( | 1140 | GNUNET_CRYPTO_ecdsa_public_key_from_string( |
1161 | const char *enc, | 1141 | const char *enc, |
1162 | size_t enclen, | 1142 | size_t enclen, |
1163 | struct GNUNET_CRYPTO_EcdsaPublicKey *pub); | 1143 | struct GNUNET_CRYPTO_EcdsaPublicKey *pub); |
@@ -1172,7 +1152,7 @@ GNUNET_CRYPTO_ecdsa_public_key_from_string ( | |||
1172 | * @return #GNUNET_OK on success | 1152 | * @return #GNUNET_OK on success |
1173 | */ | 1153 | */ |
1174 | int | 1154 | int |
1175 | GNUNET_CRYPTO_eddsa_private_key_from_string ( | 1155 | GNUNET_CRYPTO_eddsa_private_key_from_string( |
1176 | const char *enc, | 1156 | const char *enc, |
1177 | size_t enclen, | 1157 | size_t enclen, |
1178 | struct GNUNET_CRYPTO_EddsaPrivateKey *pub); | 1158 | struct GNUNET_CRYPTO_EddsaPrivateKey *pub); |
@@ -1187,7 +1167,7 @@ GNUNET_CRYPTO_eddsa_private_key_from_string ( | |||
1187 | * @return #GNUNET_OK on success | 1167 | * @return #GNUNET_OK on success |
1188 | */ | 1168 | */ |
1189 | int | 1169 | int |
1190 | GNUNET_CRYPTO_eddsa_public_key_from_string ( | 1170 | GNUNET_CRYPTO_eddsa_public_key_from_string( |
1191 | const char *enc, | 1171 | const char *enc, |
1192 | size_t enclen, | 1172 | size_t enclen, |
1193 | struct GNUNET_CRYPTO_EddsaPublicKey *pub); | 1173 | struct GNUNET_CRYPTO_EddsaPublicKey *pub); |
@@ -1209,7 +1189,7 @@ GNUNET_CRYPTO_eddsa_public_key_from_string ( | |||
1209 | * permission denied); free using #GNUNET_free | 1189 | * permission denied); free using #GNUNET_free |
1210 | */ | 1190 | */ |
1211 | struct GNUNET_CRYPTO_EcdsaPrivateKey * | 1191 | struct GNUNET_CRYPTO_EcdsaPrivateKey * |
1212 | GNUNET_CRYPTO_ecdsa_key_create_from_file (const char *filename); | 1192 | GNUNET_CRYPTO_ecdsa_key_create_from_file(const char *filename); |
1213 | 1193 | ||
1214 | 1194 | ||
1215 | /** | 1195 | /** |
@@ -1228,7 +1208,7 @@ GNUNET_CRYPTO_ecdsa_key_create_from_file (const char *filename); | |||
1228 | * permission denied); free using #GNUNET_free | 1208 | * permission denied); free using #GNUNET_free |
1229 | */ | 1209 | */ |
1230 | struct GNUNET_CRYPTO_EddsaPrivateKey * | 1210 | struct GNUNET_CRYPTO_EddsaPrivateKey * |
1231 | GNUNET_CRYPTO_eddsa_key_create_from_file (const char *filename); | 1211 | GNUNET_CRYPTO_eddsa_key_create_from_file(const char *filename); |
1232 | 1212 | ||
1233 | 1213 | ||
1234 | /** | 1214 | /** |
@@ -1247,7 +1227,7 @@ struct GNUNET_CONFIGURATION_Handle; | |||
1247 | * permission denied); free using #GNUNET_free | 1227 | * permission denied); free using #GNUNET_free |
1248 | */ | 1228 | */ |
1249 | struct GNUNET_CRYPTO_EddsaPrivateKey * | 1229 | struct GNUNET_CRYPTO_EddsaPrivateKey * |
1250 | GNUNET_CRYPTO_eddsa_key_create_from_configuration ( | 1230 | GNUNET_CRYPTO_eddsa_key_create_from_configuration( |
1251 | const struct GNUNET_CONFIGURATION_Handle *cfg); | 1231 | const struct GNUNET_CONFIGURATION_Handle *cfg); |
1252 | 1232 | ||
1253 | 1233 | ||
@@ -1258,7 +1238,7 @@ GNUNET_CRYPTO_eddsa_key_create_from_configuration ( | |||
1258 | * @return fresh private key; free using #GNUNET_free | 1238 | * @return fresh private key; free using #GNUNET_free |
1259 | */ | 1239 | */ |
1260 | struct GNUNET_CRYPTO_EcdsaPrivateKey * | 1240 | struct GNUNET_CRYPTO_EcdsaPrivateKey * |
1261 | GNUNET_CRYPTO_ecdsa_key_create (void); | 1241 | GNUNET_CRYPTO_ecdsa_key_create(void); |
1262 | 1242 | ||
1263 | 1243 | ||
1264 | /** | 1244 | /** |
@@ -1268,7 +1248,7 @@ GNUNET_CRYPTO_ecdsa_key_create (void); | |||
1268 | * @return fresh private key; free using #GNUNET_free | 1248 | * @return fresh private key; free using #GNUNET_free |
1269 | */ | 1249 | */ |
1270 | struct GNUNET_CRYPTO_EddsaPrivateKey * | 1250 | struct GNUNET_CRYPTO_EddsaPrivateKey * |
1271 | GNUNET_CRYPTO_eddsa_key_create (void); | 1251 | GNUNET_CRYPTO_eddsa_key_create(void); |
1272 | 1252 | ||
1273 | 1253 | ||
1274 | /** | 1254 | /** |
@@ -1279,7 +1259,7 @@ GNUNET_CRYPTO_eddsa_key_create (void); | |||
1279 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure | 1259 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure |
1280 | */ | 1260 | */ |
1281 | int | 1261 | int |
1282 | GNUNET_CRYPTO_ecdhe_key_create2 (struct GNUNET_CRYPTO_EcdhePrivateKey *pk); | 1262 | GNUNET_CRYPTO_ecdhe_key_create2(struct GNUNET_CRYPTO_EcdhePrivateKey *pk); |
1283 | 1263 | ||
1284 | 1264 | ||
1285 | /** | 1265 | /** |
@@ -1289,7 +1269,7 @@ GNUNET_CRYPTO_ecdhe_key_create2 (struct GNUNET_CRYPTO_EcdhePrivateKey *pk); | |||
1289 | * @return fresh private key; free using #GNUNET_free | 1269 | * @return fresh private key; free using #GNUNET_free |
1290 | */ | 1270 | */ |
1291 | struct GNUNET_CRYPTO_EcdhePrivateKey * | 1271 | struct GNUNET_CRYPTO_EcdhePrivateKey * |
1292 | GNUNET_CRYPTO_ecdhe_key_create (void); | 1272 | GNUNET_CRYPTO_ecdhe_key_create(void); |
1293 | 1273 | ||
1294 | 1274 | ||
1295 | /** | 1275 | /** |
@@ -1299,7 +1279,7 @@ GNUNET_CRYPTO_ecdhe_key_create (void); | |||
1299 | * @param pk location of the key | 1279 | * @param pk location of the key |
1300 | */ | 1280 | */ |
1301 | void | 1281 | void |
1302 | GNUNET_CRYPTO_eddsa_key_clear (struct GNUNET_CRYPTO_EddsaPrivateKey *pk); | 1282 | GNUNET_CRYPTO_eddsa_key_clear(struct GNUNET_CRYPTO_EddsaPrivateKey *pk); |
1303 | 1283 | ||
1304 | 1284 | ||
1305 | /** | 1285 | /** |
@@ -1309,7 +1289,7 @@ GNUNET_CRYPTO_eddsa_key_clear (struct GNUNET_CRYPTO_EddsaPrivateKey *pk); | |||
1309 | * @param pk location of the key | 1289 | * @param pk location of the key |
1310 | */ | 1290 | */ |
1311 | void | 1291 | void |
1312 | GNUNET_CRYPTO_ecdsa_key_clear (struct GNUNET_CRYPTO_EcdsaPrivateKey *pk); | 1292 | GNUNET_CRYPTO_ecdsa_key_clear(struct GNUNET_CRYPTO_EcdsaPrivateKey *pk); |
1313 | 1293 | ||
1314 | 1294 | ||
1315 | /** | 1295 | /** |
@@ -1319,7 +1299,7 @@ GNUNET_CRYPTO_ecdsa_key_clear (struct GNUNET_CRYPTO_EcdsaPrivateKey *pk); | |||
1319 | * @param pk location of the key | 1299 | * @param pk location of the key |
1320 | */ | 1300 | */ |
1321 | void | 1301 | void |
1322 | GNUNET_CRYPTO_ecdhe_key_clear (struct GNUNET_CRYPTO_EcdhePrivateKey *pk); | 1302 | GNUNET_CRYPTO_ecdhe_key_clear(struct GNUNET_CRYPTO_EcdhePrivateKey *pk); |
1323 | 1303 | ||
1324 | 1304 | ||
1325 | /** | 1305 | /** |
@@ -1329,7 +1309,7 @@ GNUNET_CRYPTO_ecdhe_key_clear (struct GNUNET_CRYPTO_EcdhePrivateKey *pk); | |||
1329 | * @return "anonymous" private key; do not free | 1309 | * @return "anonymous" private key; do not free |
1330 | */ | 1310 | */ |
1331 | const struct GNUNET_CRYPTO_EcdsaPrivateKey * | 1311 | const struct GNUNET_CRYPTO_EcdsaPrivateKey * |
1332 | GNUNET_CRYPTO_ecdsa_key_get_anonymous (void); | 1312 | GNUNET_CRYPTO_ecdsa_key_get_anonymous(void); |
1333 | 1313 | ||
1334 | 1314 | ||
1335 | /** | 1315 | /** |
@@ -1338,11 +1318,11 @@ GNUNET_CRYPTO_ecdsa_key_get_anonymous (void); | |||
1338 | * configuration file (!). This function is used so that | 1318 | * configuration file (!). This function is used so that |
1339 | * at a later point code can be certain that reading a | 1319 | * at a later point code can be certain that reading a |
1340 | * hostkey is fast (for example in time-dependent testcases). | 1320 | * hostkey is fast (for example in time-dependent testcases). |
1341 | * | 1321 | * |
1342 | * @param cfg_name name of the configuration file to use | 1322 | * @param cfg_name name of the configuration file to use |
1343 | */ | 1323 | */ |
1344 | void | 1324 | void |
1345 | GNUNET_CRYPTO_eddsa_setup_hostkey (const char *cfg_name); | 1325 | GNUNET_CRYPTO_eddsa_setup_hostkey(const char *cfg_name); |
1346 | 1326 | ||
1347 | 1327 | ||
1348 | /** | 1328 | /** |
@@ -1355,8 +1335,8 @@ GNUNET_CRYPTO_eddsa_setup_hostkey (const char *cfg_name); | |||
1355 | * could not be retrieved | 1335 | * could not be retrieved |
1356 | */ | 1336 | */ |
1357 | int | 1337 | int |
1358 | GNUNET_CRYPTO_get_peer_identity (const struct GNUNET_CONFIGURATION_Handle *cfg, | 1338 | GNUNET_CRYPTO_get_peer_identity(const struct GNUNET_CONFIGURATION_Handle *cfg, |
1359 | struct GNUNET_PeerIdentity *dst); | 1339 | struct GNUNET_PeerIdentity *dst); |
1360 | 1340 | ||
1361 | 1341 | ||
1362 | /** | 1342 | /** |
@@ -1369,8 +1349,7 @@ struct GNUNET_CRYPTO_EccDlogContext; | |||
1369 | * Point on a curve (always for Curve25519) encoded in a format suitable | 1349 | * Point on a curve (always for Curve25519) encoded in a format suitable |
1370 | * for network transmission (ECDH), see http://cr.yp.to/ecdh.html. | 1350 | * for network transmission (ECDH), see http://cr.yp.to/ecdh.html. |
1371 | */ | 1351 | */ |
1372 | struct GNUNET_CRYPTO_EccPoint | 1352 | struct GNUNET_CRYPTO_EccPoint { |
1373 | { | ||
1374 | /** | 1353 | /** |
1375 | * Q consists of an x- and a y-value, each mod p (256 bits), given | 1354 | * Q consists of an x- and a y-value, each mod p (256 bits), given |
1376 | * here in affine coordinates and Ed25519 standard compact format. | 1355 | * here in affine coordinates and Ed25519 standard compact format. |
@@ -1387,7 +1366,7 @@ struct GNUNET_CRYPTO_EccPoint | |||
1387 | * @return NULL on error | 1366 | * @return NULL on error |
1388 | */ | 1367 | */ |
1389 | struct GNUNET_CRYPTO_EccDlogContext * | 1368 | struct GNUNET_CRYPTO_EccDlogContext * |
1390 | GNUNET_CRYPTO_ecc_dlog_prepare (unsigned int max, unsigned int mem); | 1369 | GNUNET_CRYPTO_ecc_dlog_prepare(unsigned int max, unsigned int mem); |
1391 | 1370 | ||
1392 | 1371 | ||
1393 | /** | 1372 | /** |
@@ -1399,8 +1378,8 @@ GNUNET_CRYPTO_ecc_dlog_prepare (unsigned int max, unsigned int mem); | |||
1399 | * @return INT_MAX if dlog failed, otherwise the factor | 1378 | * @return INT_MAX if dlog failed, otherwise the factor |
1400 | */ | 1379 | */ |
1401 | int | 1380 | int |
1402 | GNUNET_CRYPTO_ecc_dlog (struct GNUNET_CRYPTO_EccDlogContext *edc, | 1381 | GNUNET_CRYPTO_ecc_dlog(struct GNUNET_CRYPTO_EccDlogContext *edc, |
1403 | gcry_mpi_point_t input); | 1382 | gcry_mpi_point_t input); |
1404 | 1383 | ||
1405 | 1384 | ||
1406 | /** | 1385 | /** |
@@ -1417,7 +1396,7 @@ GNUNET_CRYPTO_ecc_dlog (struct GNUNET_CRYPTO_EccDlogContext *edc, | |||
1417 | * must be freed using #GNUNET_CRYPTO_ecc_free() | 1396 | * must be freed using #GNUNET_CRYPTO_ecc_free() |
1418 | */ | 1397 | */ |
1419 | gcry_mpi_point_t | 1398 | gcry_mpi_point_t |
1420 | GNUNET_CRYPTO_ecc_dexp (struct GNUNET_CRYPTO_EccDlogContext *edc, int val); | 1399 | GNUNET_CRYPTO_ecc_dexp(struct GNUNET_CRYPTO_EccDlogContext *edc, int val); |
1421 | 1400 | ||
1422 | 1401 | ||
1423 | /** | 1402 | /** |
@@ -1430,8 +1409,8 @@ GNUNET_CRYPTO_ecc_dexp (struct GNUNET_CRYPTO_EccDlogContext *edc, int val); | |||
1430 | * must be freed using #GNUNET_CRYPTO_ecc_free() | 1409 | * must be freed using #GNUNET_CRYPTO_ecc_free() |
1431 | */ | 1410 | */ |
1432 | gcry_mpi_point_t | 1411 | gcry_mpi_point_t |
1433 | GNUNET_CRYPTO_ecc_dexp_mpi (struct GNUNET_CRYPTO_EccDlogContext *edc, | 1412 | GNUNET_CRYPTO_ecc_dexp_mpi(struct GNUNET_CRYPTO_EccDlogContext *edc, |
1434 | gcry_mpi_t val); | 1413 | gcry_mpi_t val); |
1435 | 1414 | ||
1436 | 1415 | ||
1437 | /** | 1416 | /** |
@@ -1444,9 +1423,9 @@ GNUNET_CRYPTO_ecc_dexp_mpi (struct GNUNET_CRYPTO_EccDlogContext *edc, | |||
1444 | * must be freed using #GNUNET_CRYPTO_ecc_free() | 1423 | * must be freed using #GNUNET_CRYPTO_ecc_free() |
1445 | */ | 1424 | */ |
1446 | gcry_mpi_point_t | 1425 | gcry_mpi_point_t |
1447 | GNUNET_CRYPTO_ecc_pmul_mpi (struct GNUNET_CRYPTO_EccDlogContext *edc, | 1426 | GNUNET_CRYPTO_ecc_pmul_mpi(struct GNUNET_CRYPTO_EccDlogContext *edc, |
1448 | gcry_mpi_point_t p, | 1427 | gcry_mpi_point_t p, |
1449 | gcry_mpi_t val); | 1428 | gcry_mpi_t val); |
1450 | 1429 | ||
1451 | 1430 | ||
1452 | /** | 1431 | /** |
@@ -1457,9 +1436,9 @@ GNUNET_CRYPTO_ecc_pmul_mpi (struct GNUNET_CRYPTO_EccDlogContext *edc, | |||
1457 | * @param[out] bin binary point representation | 1436 | * @param[out] bin binary point representation |
1458 | */ | 1437 | */ |
1459 | void | 1438 | void |
1460 | GNUNET_CRYPTO_ecc_point_to_bin (struct GNUNET_CRYPTO_EccDlogContext *edc, | 1439 | GNUNET_CRYPTO_ecc_point_to_bin(struct GNUNET_CRYPTO_EccDlogContext *edc, |
1461 | gcry_mpi_point_t point, | 1440 | gcry_mpi_point_t point, |
1462 | struct GNUNET_CRYPTO_EccPoint *bin); | 1441 | struct GNUNET_CRYPTO_EccPoint *bin); |
1463 | 1442 | ||
1464 | 1443 | ||
1465 | /** | 1444 | /** |
@@ -1470,8 +1449,8 @@ GNUNET_CRYPTO_ecc_point_to_bin (struct GNUNET_CRYPTO_EccDlogContext *edc, | |||
1470 | * @return computational representation | 1449 | * @return computational representation |
1471 | */ | 1450 | */ |
1472 | gcry_mpi_point_t | 1451 | gcry_mpi_point_t |
1473 | GNUNET_CRYPTO_ecc_bin_to_point (struct GNUNET_CRYPTO_EccDlogContext *edc, | 1452 | GNUNET_CRYPTO_ecc_bin_to_point(struct GNUNET_CRYPTO_EccDlogContext *edc, |
1474 | const struct GNUNET_CRYPTO_EccPoint *bin); | 1453 | const struct GNUNET_CRYPTO_EccPoint *bin); |
1475 | 1454 | ||
1476 | 1455 | ||
1477 | /** | 1456 | /** |
@@ -1483,9 +1462,9 @@ GNUNET_CRYPTO_ecc_bin_to_point (struct GNUNET_CRYPTO_EccDlogContext *edc, | |||
1483 | * @return @a a + @a b, must be freed using #GNUNET_CRYPTO_ecc_free() | 1462 | * @return @a a + @a b, must be freed using #GNUNET_CRYPTO_ecc_free() |
1484 | */ | 1463 | */ |
1485 | gcry_mpi_point_t | 1464 | gcry_mpi_point_t |
1486 | GNUNET_CRYPTO_ecc_add (struct GNUNET_CRYPTO_EccDlogContext *edc, | 1465 | GNUNET_CRYPTO_ecc_add(struct GNUNET_CRYPTO_EccDlogContext *edc, |
1487 | gcry_mpi_point_t a, | 1466 | gcry_mpi_point_t a, |
1488 | gcry_mpi_point_t b); | 1467 | gcry_mpi_point_t b); |
1489 | 1468 | ||
1490 | 1469 | ||
1491 | /** | 1470 | /** |
@@ -1498,9 +1477,9 @@ GNUNET_CRYPTO_ecc_add (struct GNUNET_CRYPTO_EccDlogContext *edc, | |||
1498 | * @param[out] r_inv set to the additive inverse of @a r | 1477 | * @param[out] r_inv set to the additive inverse of @a r |
1499 | */ | 1478 | */ |
1500 | void | 1479 | void |
1501 | GNUNET_CRYPTO_ecc_rnd (struct GNUNET_CRYPTO_EccDlogContext *edc, | 1480 | GNUNET_CRYPTO_ecc_rnd(struct GNUNET_CRYPTO_EccDlogContext *edc, |
1502 | gcry_mpi_point_t *r, | 1481 | gcry_mpi_point_t *r, |
1503 | gcry_mpi_point_t *r_inv); | 1482 | gcry_mpi_point_t *r_inv); |
1504 | 1483 | ||
1505 | 1484 | ||
1506 | /** | 1485 | /** |
@@ -1512,9 +1491,9 @@ GNUNET_CRYPTO_ecc_rnd (struct GNUNET_CRYPTO_EccDlogContext *edc, | |||
1512 | * @param[out] r_inv set to the multiplicative inverse of @a r | 1491 | * @param[out] r_inv set to the multiplicative inverse of @a r |
1513 | */ | 1492 | */ |
1514 | void | 1493 | void |
1515 | GNUNET_CRYPTO_ecc_rnd_mpi (struct GNUNET_CRYPTO_EccDlogContext *edc, | 1494 | GNUNET_CRYPTO_ecc_rnd_mpi(struct GNUNET_CRYPTO_EccDlogContext *edc, |
1516 | gcry_mpi_t *r, | 1495 | gcry_mpi_t *r, |
1517 | gcry_mpi_t *r_inv); | 1496 | gcry_mpi_t *r_inv); |
1518 | 1497 | ||
1519 | 1498 | ||
1520 | /** | 1499 | /** |
@@ -1524,7 +1503,7 @@ GNUNET_CRYPTO_ecc_rnd_mpi (struct GNUNET_CRYPTO_EccDlogContext *edc, | |||
1524 | * @return random value mod n. | 1503 | * @return random value mod n. |
1525 | */ | 1504 | */ |
1526 | gcry_mpi_t | 1505 | gcry_mpi_t |
1527 | GNUNET_CRYPTO_ecc_random_mod_n (struct GNUNET_CRYPTO_EccDlogContext *edc); | 1506 | GNUNET_CRYPTO_ecc_random_mod_n(struct GNUNET_CRYPTO_EccDlogContext *edc); |
1528 | 1507 | ||
1529 | 1508 | ||
1530 | /** | 1509 | /** |
@@ -1533,7 +1512,7 @@ GNUNET_CRYPTO_ecc_random_mod_n (struct GNUNET_CRYPTO_EccDlogContext *edc); | |||
1533 | * @param p point to free | 1512 | * @param p point to free |
1534 | */ | 1513 | */ |
1535 | void | 1514 | void |
1536 | GNUNET_CRYPTO_ecc_free (gcry_mpi_point_t p); | 1515 | GNUNET_CRYPTO_ecc_free(gcry_mpi_point_t p); |
1537 | 1516 | ||
1538 | 1517 | ||
1539 | /** | 1518 | /** |
@@ -1542,7 +1521,7 @@ GNUNET_CRYPTO_ecc_free (gcry_mpi_point_t p); | |||
1542 | * @param dlc dlog context | 1521 | * @param dlc dlog context |
1543 | */ | 1522 | */ |
1544 | void | 1523 | void |
1545 | GNUNET_CRYPTO_ecc_dlog_release (struct GNUNET_CRYPTO_EccDlogContext *dlc); | 1524 | GNUNET_CRYPTO_ecc_dlog_release(struct GNUNET_CRYPTO_EccDlogContext *dlc); |
1546 | 1525 | ||
1547 | 1526 | ||
1548 | /** | 1527 | /** |
@@ -1555,9 +1534,9 @@ GNUNET_CRYPTO_ecc_dlog_release (struct GNUNET_CRYPTO_EccDlogContext *dlc); | |||
1555 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | 1534 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success |
1556 | */ | 1535 | */ |
1557 | int | 1536 | int |
1558 | GNUNET_CRYPTO_ecc_ecdh (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, | 1537 | GNUNET_CRYPTO_ecc_ecdh(const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, |
1559 | const struct GNUNET_CRYPTO_EcdhePublicKey *pub, | 1538 | const struct GNUNET_CRYPTO_EcdhePublicKey *pub, |
1560 | struct GNUNET_HashCode *key_material); | 1539 | struct GNUNET_HashCode *key_material); |
1561 | 1540 | ||
1562 | 1541 | ||
1563 | /** | 1542 | /** |
@@ -1571,9 +1550,9 @@ GNUNET_CRYPTO_ecc_ecdh (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, | |||
1571 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | 1550 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success |
1572 | */ | 1551 | */ |
1573 | int | 1552 | int |
1574 | GNUNET_CRYPTO_eddsa_ecdh (const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, | 1553 | GNUNET_CRYPTO_eddsa_ecdh(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, |
1575 | const struct GNUNET_CRYPTO_EcdhePublicKey *pub, | 1554 | const struct GNUNET_CRYPTO_EcdhePublicKey *pub, |
1576 | struct GNUNET_HashCode *key_material); | 1555 | struct GNUNET_HashCode *key_material); |
1577 | 1556 | ||
1578 | /** | 1557 | /** |
1579 | * @ingroup crypto | 1558 | * @ingroup crypto |
@@ -1586,9 +1565,9 @@ GNUNET_CRYPTO_eddsa_ecdh (const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, | |||
1586 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | 1565 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success |
1587 | */ | 1566 | */ |
1588 | int | 1567 | int |
1589 | GNUNET_CRYPTO_ecdsa_ecdh (const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, | 1568 | GNUNET_CRYPTO_ecdsa_ecdh(const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, |
1590 | const struct GNUNET_CRYPTO_EcdhePublicKey *pub, | 1569 | const struct GNUNET_CRYPTO_EcdhePublicKey *pub, |
1591 | struct GNUNET_HashCode *key_material); | 1570 | struct GNUNET_HashCode *key_material); |
1592 | 1571 | ||
1593 | 1572 | ||
1594 | /** | 1573 | /** |
@@ -1602,9 +1581,9 @@ GNUNET_CRYPTO_ecdsa_ecdh (const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, | |||
1602 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | 1581 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success |
1603 | */ | 1582 | */ |
1604 | int | 1583 | int |
1605 | GNUNET_CRYPTO_ecdh_eddsa (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, | 1584 | GNUNET_CRYPTO_ecdh_eddsa(const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, |
1606 | const struct GNUNET_CRYPTO_EddsaPublicKey *pub, | 1585 | const struct GNUNET_CRYPTO_EddsaPublicKey *pub, |
1607 | struct GNUNET_HashCode *key_material); | 1586 | struct GNUNET_HashCode *key_material); |
1608 | 1587 | ||
1609 | /** | 1588 | /** |
1610 | * @ingroup crypto | 1589 | * @ingroup crypto |
@@ -1617,9 +1596,9 @@ GNUNET_CRYPTO_ecdh_eddsa (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, | |||
1617 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | 1596 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success |
1618 | */ | 1597 | */ |
1619 | int | 1598 | int |
1620 | GNUNET_CRYPTO_ecdh_ecdsa (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, | 1599 | GNUNET_CRYPTO_ecdh_ecdsa(const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, |
1621 | const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, | 1600 | const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, |
1622 | struct GNUNET_HashCode *key_material); | 1601 | struct GNUNET_HashCode *key_material); |
1623 | 1602 | ||
1624 | 1603 | ||
1625 | /** | 1604 | /** |
@@ -1632,7 +1611,7 @@ GNUNET_CRYPTO_ecdh_ecdsa (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, | |||
1632 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | 1611 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success |
1633 | */ | 1612 | */ |
1634 | int | 1613 | int |
1635 | GNUNET_CRYPTO_eddsa_sign ( | 1614 | GNUNET_CRYPTO_eddsa_sign( |
1636 | const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, | 1615 | const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, |
1637 | const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, | 1616 | const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, |
1638 | struct GNUNET_CRYPTO_EddsaSignature *sig); | 1617 | struct GNUNET_CRYPTO_EddsaSignature *sig); |
@@ -1648,7 +1627,7 @@ GNUNET_CRYPTO_eddsa_sign ( | |||
1648 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | 1627 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success |
1649 | */ | 1628 | */ |
1650 | int | 1629 | int |
1651 | GNUNET_CRYPTO_ecdsa_sign ( | 1630 | GNUNET_CRYPTO_ecdsa_sign( |
1652 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, | 1631 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, |
1653 | const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, | 1632 | const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, |
1654 | struct GNUNET_CRYPTO_EcdsaSignature *sig); | 1633 | struct GNUNET_CRYPTO_EcdsaSignature *sig); |
@@ -1664,7 +1643,7 @@ GNUNET_CRYPTO_ecdsa_sign ( | |||
1664 | * @returns #GNUNET_OK if ok, #GNUNET_SYSERR if invalid | 1643 | * @returns #GNUNET_OK if ok, #GNUNET_SYSERR if invalid |
1665 | */ | 1644 | */ |
1666 | int | 1645 | int |
1667 | GNUNET_CRYPTO_eddsa_verify ( | 1646 | GNUNET_CRYPTO_eddsa_verify( |
1668 | uint32_t purpose, | 1647 | uint32_t purpose, |
1669 | const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, | 1648 | const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, |
1670 | const struct GNUNET_CRYPTO_EddsaSignature *sig, | 1649 | const struct GNUNET_CRYPTO_EddsaSignature *sig, |
@@ -1682,7 +1661,7 @@ GNUNET_CRYPTO_eddsa_verify ( | |||
1682 | * @returns #GNUNET_OK if ok, #GNUNET_SYSERR if invalid | 1661 | * @returns #GNUNET_OK if ok, #GNUNET_SYSERR if invalid |
1683 | */ | 1662 | */ |
1684 | int | 1663 | int |
1685 | GNUNET_CRYPTO_ecdsa_verify ( | 1664 | GNUNET_CRYPTO_ecdsa_verify( |
1686 | uint32_t purpose, | 1665 | uint32_t purpose, |
1687 | const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, | 1666 | const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, |
1688 | const struct GNUNET_CRYPTO_EcdsaSignature *sig, | 1667 | const struct GNUNET_CRYPTO_EcdsaSignature *sig, |
@@ -1703,7 +1682,7 @@ GNUNET_CRYPTO_ecdsa_verify ( | |||
1703 | * @return derived private key | 1682 | * @return derived private key |
1704 | */ | 1683 | */ |
1705 | struct GNUNET_CRYPTO_EcdsaPrivateKey * | 1684 | struct GNUNET_CRYPTO_EcdsaPrivateKey * |
1706 | GNUNET_CRYPTO_ecdsa_private_key_derive ( | 1685 | GNUNET_CRYPTO_ecdsa_private_key_derive( |
1707 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, | 1686 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, |
1708 | const char *label, | 1687 | const char *label, |
1709 | const char *context); | 1688 | const char *context); |
@@ -1721,7 +1700,7 @@ GNUNET_CRYPTO_ecdsa_private_key_derive ( | |||
1721 | * @param result where to write the derived public key | 1700 | * @param result where to write the derived public key |
1722 | */ | 1701 | */ |
1723 | void | 1702 | void |
1724 | GNUNET_CRYPTO_ecdsa_public_key_derive ( | 1703 | GNUNET_CRYPTO_ecdsa_public_key_derive( |
1725 | const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, | 1704 | const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, |
1726 | const char *label, | 1705 | const char *label, |
1727 | const char *context, | 1706 | const char *context, |
@@ -1737,7 +1716,7 @@ GNUNET_CRYPTO_ecdsa_public_key_derive ( | |||
1737 | * @param val value to write to @a buf | 1716 | * @param val value to write to @a buf |
1738 | */ | 1717 | */ |
1739 | void | 1718 | void |
1740 | GNUNET_CRYPTO_mpi_print_unsigned (void *buf, size_t size, gcry_mpi_t val); | 1719 | GNUNET_CRYPTO_mpi_print_unsigned(void *buf, size_t size, gcry_mpi_t val); |
1741 | 1720 | ||
1742 | 1721 | ||
1743 | /** | 1722 | /** |
@@ -1750,9 +1729,9 @@ GNUNET_CRYPTO_mpi_print_unsigned (void *buf, size_t size, gcry_mpi_t val); | |||
1750 | * @param size number of bytes in @a data | 1729 | * @param size number of bytes in @a data |
1751 | */ | 1730 | */ |
1752 | void | 1731 | void |
1753 | GNUNET_CRYPTO_mpi_scan_unsigned (gcry_mpi_t *result, | 1732 | GNUNET_CRYPTO_mpi_scan_unsigned(gcry_mpi_t *result, |
1754 | const void *data, | 1733 | const void *data, |
1755 | size_t size); | 1734 | size_t size); |
1756 | 1735 | ||
1757 | 1736 | ||
1758 | /** | 1737 | /** |
@@ -1762,7 +1741,7 @@ GNUNET_CRYPTO_mpi_scan_unsigned (gcry_mpi_t *result, | |||
1762 | * @param[out] private_key Where to store the private key? | 1741 | * @param[out] private_key Where to store the private key? |
1763 | */ | 1742 | */ |
1764 | void | 1743 | void |
1765 | GNUNET_CRYPTO_paillier_create ( | 1744 | GNUNET_CRYPTO_paillier_create( |
1766 | struct GNUNET_CRYPTO_PaillierPublicKey *public_key, | 1745 | struct GNUNET_CRYPTO_PaillierPublicKey *public_key, |
1767 | struct GNUNET_CRYPTO_PaillierPrivateKey *private_key); | 1746 | struct GNUNET_CRYPTO_PaillierPrivateKey *private_key); |
1768 | 1747 | ||
@@ -1779,7 +1758,7 @@ GNUNET_CRYPTO_paillier_create ( | |||
1779 | * or -1 if less than one homomorphic operation is possible | 1758 | * or -1 if less than one homomorphic operation is possible |
1780 | */ | 1759 | */ |
1781 | int | 1760 | int |
1782 | GNUNET_CRYPTO_paillier_encrypt ( | 1761 | GNUNET_CRYPTO_paillier_encrypt( |
1783 | const struct GNUNET_CRYPTO_PaillierPublicKey *public_key, | 1762 | const struct GNUNET_CRYPTO_PaillierPublicKey *public_key, |
1784 | const gcry_mpi_t m, | 1763 | const gcry_mpi_t m, |
1785 | int desired_ops, | 1764 | int desired_ops, |
@@ -1795,7 +1774,7 @@ GNUNET_CRYPTO_paillier_encrypt ( | |||
1795 | * @param[out] m Decryption of @a ciphertext with @private_key. | 1774 | * @param[out] m Decryption of @a ciphertext with @private_key. |
1796 | */ | 1775 | */ |
1797 | void | 1776 | void |
1798 | GNUNET_CRYPTO_paillier_decrypt ( | 1777 | GNUNET_CRYPTO_paillier_decrypt( |
1799 | const struct GNUNET_CRYPTO_PaillierPrivateKey *private_key, | 1778 | const struct GNUNET_CRYPTO_PaillierPrivateKey *private_key, |
1800 | const struct GNUNET_CRYPTO_PaillierPublicKey *public_key, | 1779 | const struct GNUNET_CRYPTO_PaillierPublicKey *public_key, |
1801 | const struct GNUNET_CRYPTO_PaillierCiphertext *ciphertext, | 1780 | const struct GNUNET_CRYPTO_PaillierCiphertext *ciphertext, |
@@ -1816,7 +1795,7 @@ GNUNET_CRYPTO_paillier_decrypt ( | |||
1816 | * #GNUNET_SYSERR if no more homomorphic operations are remaining. | 1795 | * #GNUNET_SYSERR if no more homomorphic operations are remaining. |
1817 | */ | 1796 | */ |
1818 | int | 1797 | int |
1819 | GNUNET_CRYPTO_paillier_hom_add ( | 1798 | GNUNET_CRYPTO_paillier_hom_add( |
1820 | const struct GNUNET_CRYPTO_PaillierPublicKey *public_key, | 1799 | const struct GNUNET_CRYPTO_PaillierPublicKey *public_key, |
1821 | const struct GNUNET_CRYPTO_PaillierCiphertext *c1, | 1800 | const struct GNUNET_CRYPTO_PaillierCiphertext *c1, |
1822 | const struct GNUNET_CRYPTO_PaillierCiphertext *c2, | 1801 | const struct GNUNET_CRYPTO_PaillierCiphertext *c2, |
@@ -1830,7 +1809,7 @@ GNUNET_CRYPTO_paillier_hom_add ( | |||
1830 | * @return the number of remaining homomorphic operations | 1809 | * @return the number of remaining homomorphic operations |
1831 | */ | 1810 | */ |
1832 | int | 1811 | int |
1833 | GNUNET_CRYPTO_paillier_hom_get_remaining ( | 1812 | GNUNET_CRYPTO_paillier_hom_get_remaining( |
1834 | const struct GNUNET_CRYPTO_PaillierCiphertext *c); | 1813 | const struct GNUNET_CRYPTO_PaillierCiphertext *c); |
1835 | 1814 | ||
1836 | 1815 | ||
@@ -1850,8 +1829,7 @@ struct GNUNET_CRYPTO_RsaPublicKey; | |||
1850 | /** | 1829 | /** |
1851 | * Constant-size pre-secret for blinding key generation. | 1830 | * Constant-size pre-secret for blinding key generation. |
1852 | */ | 1831 | */ |
1853 | struct GNUNET_CRYPTO_RsaBlindingKeySecret | 1832 | struct GNUNET_CRYPTO_RsaBlindingKeySecret { |
1854 | { | ||
1855 | /** | 1833 | /** |
1856 | * Bits used to generate the blinding key. 256 bits | 1834 | * Bits used to generate the blinding key. 256 bits |
1857 | * of entropy is enough. | 1835 | * of entropy is enough. |
@@ -1872,7 +1850,7 @@ struct GNUNET_CRYPTO_RsaSignature; | |||
1872 | * @return fresh private key | 1850 | * @return fresh private key |
1873 | */ | 1851 | */ |
1874 | struct GNUNET_CRYPTO_RsaPrivateKey * | 1852 | struct GNUNET_CRYPTO_RsaPrivateKey * |
1875 | GNUNET_CRYPTO_rsa_private_key_create (unsigned int len); | 1853 | GNUNET_CRYPTO_rsa_private_key_create(unsigned int len); |
1876 | 1854 | ||
1877 | 1855 | ||
1878 | /** | 1856 | /** |
@@ -1881,7 +1859,7 @@ GNUNET_CRYPTO_rsa_private_key_create (unsigned int len); | |||
1881 | * @param key pointer to the memory to free | 1859 | * @param key pointer to the memory to free |
1882 | */ | 1860 | */ |
1883 | void | 1861 | void |
1884 | GNUNET_CRYPTO_rsa_private_key_free (struct GNUNET_CRYPTO_RsaPrivateKey *key); | 1862 | GNUNET_CRYPTO_rsa_private_key_free(struct GNUNET_CRYPTO_RsaPrivateKey *key); |
1885 | 1863 | ||
1886 | 1864 | ||
1887 | /** | 1865 | /** |
@@ -1893,7 +1871,7 @@ GNUNET_CRYPTO_rsa_private_key_free (struct GNUNET_CRYPTO_RsaPrivateKey *key); | |||
1893 | * @return size of memory allocatedin @a buffer | 1871 | * @return size of memory allocatedin @a buffer |
1894 | */ | 1872 | */ |
1895 | size_t | 1873 | size_t |
1896 | GNUNET_CRYPTO_rsa_private_key_encode ( | 1874 | GNUNET_CRYPTO_rsa_private_key_encode( |
1897 | const struct GNUNET_CRYPTO_RsaPrivateKey *key, | 1875 | const struct GNUNET_CRYPTO_RsaPrivateKey *key, |
1898 | char **buffer); | 1876 | char **buffer); |
1899 | 1877 | ||
@@ -1907,7 +1885,7 @@ GNUNET_CRYPTO_rsa_private_key_encode ( | |||
1907 | * @return NULL on error | 1885 | * @return NULL on error |
1908 | */ | 1886 | */ |
1909 | struct GNUNET_CRYPTO_RsaPrivateKey * | 1887 | struct GNUNET_CRYPTO_RsaPrivateKey * |
1910 | GNUNET_CRYPTO_rsa_private_key_decode (const char *buf, size_t len); | 1888 | GNUNET_CRYPTO_rsa_private_key_decode(const char *buf, size_t len); |
1911 | 1889 | ||
1912 | 1890 | ||
1913 | /** | 1891 | /** |
@@ -1917,7 +1895,7 @@ GNUNET_CRYPTO_rsa_private_key_decode (const char *buf, size_t len); | |||
1917 | * @return the duplicate key; NULL upon error | 1895 | * @return the duplicate key; NULL upon error |
1918 | */ | 1896 | */ |
1919 | struct GNUNET_CRYPTO_RsaPrivateKey * | 1897 | struct GNUNET_CRYPTO_RsaPrivateKey * |
1920 | GNUNET_CRYPTO_rsa_private_key_dup ( | 1898 | GNUNET_CRYPTO_rsa_private_key_dup( |
1921 | const struct GNUNET_CRYPTO_RsaPrivateKey *key); | 1899 | const struct GNUNET_CRYPTO_RsaPrivateKey *key); |
1922 | 1900 | ||
1923 | 1901 | ||
@@ -1928,7 +1906,7 @@ GNUNET_CRYPTO_rsa_private_key_dup ( | |||
1928 | * @retur NULL on error, otherwise the public key | 1906 | * @retur NULL on error, otherwise the public key |
1929 | */ | 1907 | */ |
1930 | struct GNUNET_CRYPTO_RsaPublicKey * | 1908 | struct GNUNET_CRYPTO_RsaPublicKey * |
1931 | GNUNET_CRYPTO_rsa_private_key_get_public ( | 1909 | GNUNET_CRYPTO_rsa_private_key_get_public( |
1932 | const struct GNUNET_CRYPTO_RsaPrivateKey *priv); | 1910 | const struct GNUNET_CRYPTO_RsaPrivateKey *priv); |
1933 | 1911 | ||
1934 | 1912 | ||
@@ -1939,8 +1917,8 @@ GNUNET_CRYPTO_rsa_private_key_get_public ( | |||
1939 | * @param hc where to store the hash code | 1917 | * @param hc where to store the hash code |
1940 | */ | 1918 | */ |
1941 | void | 1919 | void |
1942 | GNUNET_CRYPTO_rsa_public_key_hash (const struct GNUNET_CRYPTO_RsaPublicKey *key, | 1920 | GNUNET_CRYPTO_rsa_public_key_hash(const struct GNUNET_CRYPTO_RsaPublicKey *key, |
1943 | struct GNUNET_HashCode *hc); | 1921 | struct GNUNET_HashCode *hc); |
1944 | 1922 | ||
1945 | 1923 | ||
1946 | /** | 1924 | /** |
@@ -1950,7 +1928,7 @@ GNUNET_CRYPTO_rsa_public_key_hash (const struct GNUNET_CRYPTO_RsaPublicKey *key, | |||
1950 | * @return length of the key in bits | 1928 | * @return length of the key in bits |
1951 | */ | 1929 | */ |
1952 | unsigned int | 1930 | unsigned int |
1953 | GNUNET_CRYPTO_rsa_public_key_len (const struct GNUNET_CRYPTO_RsaPublicKey *key); | 1931 | GNUNET_CRYPTO_rsa_public_key_len(const struct GNUNET_CRYPTO_RsaPublicKey *key); |
1954 | 1932 | ||
1955 | 1933 | ||
1956 | /** | 1934 | /** |
@@ -1959,7 +1937,7 @@ GNUNET_CRYPTO_rsa_public_key_len (const struct GNUNET_CRYPTO_RsaPublicKey *key); | |||
1959 | * @param key pointer to the memory to free | 1937 | * @param key pointer to the memory to free |
1960 | */ | 1938 | */ |
1961 | void | 1939 | void |
1962 | GNUNET_CRYPTO_rsa_public_key_free (struct GNUNET_CRYPTO_RsaPublicKey *key); | 1940 | GNUNET_CRYPTO_rsa_public_key_free(struct GNUNET_CRYPTO_RsaPublicKey *key); |
1963 | 1941 | ||
1964 | 1942 | ||
1965 | /** | 1943 | /** |
@@ -1971,7 +1949,7 @@ GNUNET_CRYPTO_rsa_public_key_free (struct GNUNET_CRYPTO_RsaPublicKey *key); | |||
1971 | * @return size of memory allocated in @a buffer | 1949 | * @return size of memory allocated in @a buffer |
1972 | */ | 1950 | */ |
1973 | size_t | 1951 | size_t |
1974 | GNUNET_CRYPTO_rsa_public_key_encode ( | 1952 | GNUNET_CRYPTO_rsa_public_key_encode( |
1975 | const struct GNUNET_CRYPTO_RsaPublicKey *key, | 1953 | const struct GNUNET_CRYPTO_RsaPublicKey *key, |
1976 | char **buffer); | 1954 | char **buffer); |
1977 | 1955 | ||
@@ -1985,7 +1963,7 @@ GNUNET_CRYPTO_rsa_public_key_encode ( | |||
1985 | * @return NULL on error | 1963 | * @return NULL on error |
1986 | */ | 1964 | */ |
1987 | struct GNUNET_CRYPTO_RsaPublicKey * | 1965 | struct GNUNET_CRYPTO_RsaPublicKey * |
1988 | GNUNET_CRYPTO_rsa_public_key_decode (const char *buf, size_t len); | 1966 | GNUNET_CRYPTO_rsa_public_key_decode(const char *buf, size_t len); |
1989 | 1967 | ||
1990 | 1968 | ||
1991 | /** | 1969 | /** |
@@ -1995,7 +1973,7 @@ GNUNET_CRYPTO_rsa_public_key_decode (const char *buf, size_t len); | |||
1995 | * @return the duplicate key; NULL upon error | 1973 | * @return the duplicate key; NULL upon error |
1996 | */ | 1974 | */ |
1997 | struct GNUNET_CRYPTO_RsaPublicKey * | 1975 | struct GNUNET_CRYPTO_RsaPublicKey * |
1998 | GNUNET_CRYPTO_rsa_public_key_dup (const struct GNUNET_CRYPTO_RsaPublicKey *key); | 1976 | GNUNET_CRYPTO_rsa_public_key_dup(const struct GNUNET_CRYPTO_RsaPublicKey *key); |
1999 | 1977 | ||
2000 | 1978 | ||
2001 | /** | 1979 | /** |
@@ -2006,8 +1984,8 @@ GNUNET_CRYPTO_rsa_public_key_dup (const struct GNUNET_CRYPTO_RsaPublicKey *key); | |||
2006 | * @return 0 if the two are equal | 1984 | * @return 0 if the two are equal |
2007 | */ | 1985 | */ |
2008 | int | 1986 | int |
2009 | GNUNET_CRYPTO_rsa_signature_cmp (struct GNUNET_CRYPTO_RsaSignature *s1, | 1987 | GNUNET_CRYPTO_rsa_signature_cmp(struct GNUNET_CRYPTO_RsaSignature *s1, |
2010 | struct GNUNET_CRYPTO_RsaSignature *s2); | 1988 | struct GNUNET_CRYPTO_RsaSignature *s2); |
2011 | 1989 | ||
2012 | /** | 1990 | /** |
2013 | * Compare the values of two private keys. | 1991 | * Compare the values of two private keys. |
@@ -2017,8 +1995,8 @@ GNUNET_CRYPTO_rsa_signature_cmp (struct GNUNET_CRYPTO_RsaSignature *s1, | |||
2017 | * @return 0 if the two are equal | 1995 | * @return 0 if the two are equal |
2018 | */ | 1996 | */ |
2019 | int | 1997 | int |
2020 | GNUNET_CRYPTO_rsa_private_key_cmp (struct GNUNET_CRYPTO_RsaPrivateKey *p1, | 1998 | GNUNET_CRYPTO_rsa_private_key_cmp(struct GNUNET_CRYPTO_RsaPrivateKey *p1, |
2021 | struct GNUNET_CRYPTO_RsaPrivateKey *p2); | 1999 | struct GNUNET_CRYPTO_RsaPrivateKey *p2); |
2022 | 2000 | ||
2023 | 2001 | ||
2024 | /** | 2002 | /** |
@@ -2029,8 +2007,8 @@ GNUNET_CRYPTO_rsa_private_key_cmp (struct GNUNET_CRYPTO_RsaPrivateKey *p1, | |||
2029 | * @return 0 if the two are equal | 2007 | * @return 0 if the two are equal |
2030 | */ | 2008 | */ |
2031 | int | 2009 | int |
2032 | GNUNET_CRYPTO_rsa_public_key_cmp (struct GNUNET_CRYPTO_RsaPublicKey *p1, | 2010 | GNUNET_CRYPTO_rsa_public_key_cmp(struct GNUNET_CRYPTO_RsaPublicKey *p1, |
2033 | struct GNUNET_CRYPTO_RsaPublicKey *p2); | 2011 | struct GNUNET_CRYPTO_RsaPublicKey *p2); |
2034 | 2012 | ||
2035 | 2013 | ||
2036 | /** | 2014 | /** |
@@ -2044,11 +2022,11 @@ GNUNET_CRYPTO_rsa_public_key_cmp (struct GNUNET_CRYPTO_RsaPublicKey *p1, | |||
2044 | * @return #GNUNET_YES if successful, #GNUNET_NO if RSA key is malicious | 2022 | * @return #GNUNET_YES if successful, #GNUNET_NO if RSA key is malicious |
2045 | */ | 2023 | */ |
2046 | int | 2024 | int |
2047 | GNUNET_CRYPTO_rsa_blind (const struct GNUNET_HashCode *hash, | 2025 | GNUNET_CRYPTO_rsa_blind(const struct GNUNET_HashCode *hash, |
2048 | const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks, | 2026 | const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks, |
2049 | struct GNUNET_CRYPTO_RsaPublicKey *pkey, | 2027 | struct GNUNET_CRYPTO_RsaPublicKey *pkey, |
2050 | char **buf, | 2028 | char **buf, |
2051 | size_t *buf_size); | 2029 | size_t *buf_size); |
2052 | 2030 | ||
2053 | 2031 | ||
2054 | /** | 2032 | /** |
@@ -2060,9 +2038,9 @@ GNUNET_CRYPTO_rsa_blind (const struct GNUNET_HashCode *hash, | |||
2060 | * @return NULL on error, signature on success | 2038 | * @return NULL on error, signature on success |
2061 | */ | 2039 | */ |
2062 | struct GNUNET_CRYPTO_RsaSignature * | 2040 | struct GNUNET_CRYPTO_RsaSignature * |
2063 | GNUNET_CRYPTO_rsa_sign_blinded (const struct GNUNET_CRYPTO_RsaPrivateKey *key, | 2041 | GNUNET_CRYPTO_rsa_sign_blinded(const struct GNUNET_CRYPTO_RsaPrivateKey *key, |
2064 | const void *msg, | 2042 | const void *msg, |
2065 | size_t msg_len); | 2043 | size_t msg_len); |
2066 | 2044 | ||
2067 | 2045 | ||
2068 | /** | 2046 | /** |
@@ -2073,8 +2051,8 @@ GNUNET_CRYPTO_rsa_sign_blinded (const struct GNUNET_CRYPTO_RsaPrivateKey *key, | |||
2073 | * @return NULL on error, including a malicious RSA key, signature on success | 2051 | * @return NULL on error, including a malicious RSA key, signature on success |
2074 | */ | 2052 | */ |
2075 | struct GNUNET_CRYPTO_RsaSignature * | 2053 | struct GNUNET_CRYPTO_RsaSignature * |
2076 | GNUNET_CRYPTO_rsa_sign_fdh (const struct GNUNET_CRYPTO_RsaPrivateKey *key, | 2054 | GNUNET_CRYPTO_rsa_sign_fdh(const struct GNUNET_CRYPTO_RsaPrivateKey *key, |
2077 | const struct GNUNET_HashCode *hash); | 2055 | const struct GNUNET_HashCode *hash); |
2078 | 2056 | ||
2079 | 2057 | ||
2080 | /** | 2058 | /** |
@@ -2083,7 +2061,7 @@ GNUNET_CRYPTO_rsa_sign_fdh (const struct GNUNET_CRYPTO_RsaPrivateKey *key, | |||
2083 | * @param sig memory to free | 2061 | * @param sig memory to free |
2084 | */ | 2062 | */ |
2085 | void | 2063 | void |
2086 | GNUNET_CRYPTO_rsa_signature_free (struct GNUNET_CRYPTO_RsaSignature *sig); | 2064 | GNUNET_CRYPTO_rsa_signature_free(struct GNUNET_CRYPTO_RsaSignature *sig); |
2087 | 2065 | ||
2088 | 2066 | ||
2089 | /** | 2067 | /** |
@@ -2094,7 +2072,7 @@ GNUNET_CRYPTO_rsa_signature_free (struct GNUNET_CRYPTO_RsaSignature *sig); | |||
2094 | * @return size of memory allocated in @a buffer | 2072 | * @return size of memory allocated in @a buffer |
2095 | */ | 2073 | */ |
2096 | size_t | 2074 | size_t |
2097 | GNUNET_CRYPTO_rsa_signature_encode ( | 2075 | GNUNET_CRYPTO_rsa_signature_encode( |
2098 | const struct GNUNET_CRYPTO_RsaSignature *sig, | 2076 | const struct GNUNET_CRYPTO_RsaSignature *sig, |
2099 | char **buffer); | 2077 | char **buffer); |
2100 | 2078 | ||
@@ -2108,7 +2086,7 @@ GNUNET_CRYPTO_rsa_signature_encode ( | |||
2108 | * @return NULL on error | 2086 | * @return NULL on error |
2109 | */ | 2087 | */ |
2110 | struct GNUNET_CRYPTO_RsaSignature * | 2088 | struct GNUNET_CRYPTO_RsaSignature * |
2111 | GNUNET_CRYPTO_rsa_signature_decode (const char *buf, size_t len); | 2089 | GNUNET_CRYPTO_rsa_signature_decode(const char *buf, size_t len); |
2112 | 2090 | ||
2113 | 2091 | ||
2114 | /** | 2092 | /** |
@@ -2118,7 +2096,7 @@ GNUNET_CRYPTO_rsa_signature_decode (const char *buf, size_t len); | |||
2118 | * @return the duplicate key; NULL upon error | 2096 | * @return the duplicate key; NULL upon error |
2119 | */ | 2097 | */ |
2120 | struct GNUNET_CRYPTO_RsaSignature * | 2098 | struct GNUNET_CRYPTO_RsaSignature * |
2121 | GNUNET_CRYPTO_rsa_signature_dup (const struct GNUNET_CRYPTO_RsaSignature *sig); | 2099 | GNUNET_CRYPTO_rsa_signature_dup(const struct GNUNET_CRYPTO_RsaSignature *sig); |
2122 | 2100 | ||
2123 | 2101 | ||
2124 | /** | 2102 | /** |
@@ -2132,9 +2110,9 @@ GNUNET_CRYPTO_rsa_signature_dup (const struct GNUNET_CRYPTO_RsaSignature *sig); | |||
2132 | * @return unblinded signature on success, NULL if RSA key is bad or malicious. | 2110 | * @return unblinded signature on success, NULL if RSA key is bad or malicious. |
2133 | */ | 2111 | */ |
2134 | struct GNUNET_CRYPTO_RsaSignature * | 2112 | struct GNUNET_CRYPTO_RsaSignature * |
2135 | GNUNET_CRYPTO_rsa_unblind (const struct GNUNET_CRYPTO_RsaSignature *sig, | 2113 | GNUNET_CRYPTO_rsa_unblind(const struct GNUNET_CRYPTO_RsaSignature *sig, |
2136 | const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks, | 2114 | const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks, |
2137 | struct GNUNET_CRYPTO_RsaPublicKey *pkey); | 2115 | struct GNUNET_CRYPTO_RsaPublicKey *pkey); |
2138 | 2116 | ||
2139 | 2117 | ||
2140 | /** | 2118 | /** |
@@ -2147,9 +2125,9 @@ GNUNET_CRYPTO_rsa_unblind (const struct GNUNET_CRYPTO_RsaSignature *sig, | |||
2147 | * @returns #GNUNET_YES if ok, #GNUNET_NO if RSA key is malicious, #GNUNET_SYSERR if signature | 2125 | * @returns #GNUNET_YES if ok, #GNUNET_NO if RSA key is malicious, #GNUNET_SYSERR if signature |
2148 | */ | 2126 | */ |
2149 | int | 2127 | int |
2150 | GNUNET_CRYPTO_rsa_verify (const struct GNUNET_HashCode *hash, | 2128 | GNUNET_CRYPTO_rsa_verify(const struct GNUNET_HashCode *hash, |
2151 | const struct GNUNET_CRYPTO_RsaSignature *sig, | 2129 | const struct GNUNET_CRYPTO_RsaSignature *sig, |
2152 | const struct GNUNET_CRYPTO_RsaPublicKey *public_key); | 2130 | const struct GNUNET_CRYPTO_RsaPublicKey *public_key); |
2153 | 2131 | ||
2154 | 2132 | ||
2155 | #if 0 /* keep Emacsens' auto-indent happy */ | 2133 | #if 0 /* keep Emacsens' auto-indent happy */ |