aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_crypto_lib.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/gnunet_crypto_lib.h')
-rw-r--r--src/include/gnunet_crypto_lib.h530
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 */
74enum GNUNET_CRYPTO_Quality 74enum 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 */
116struct GNUNET_CRYPTO_HashAsciiEncoded 115struct 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 */
130struct GNUNET_CRYPTO_EccSignaturePurpose 128struct 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 */
153struct GNUNET_CRYPTO_EddsaSignature 150struct 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 */
171struct GNUNET_CRYPTO_EcdsaSignature 166struct 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 */
190struct GNUNET_CRYPTO_EddsaPublicKey 183struct 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 */
205struct GNUNET_CRYPTO_EcdsaPublicKey 197struct 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 */
218struct GNUNET_PeerIdentity 209struct 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 */
229struct GNUNET_CRYPTO_EcdhePublicKey 219struct 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 */
243struct GNUNET_CRYPTO_EcdhePrivateKey 232struct 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 */
255struct GNUNET_CRYPTO_EcdsaPrivateKey 243struct 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 */
267struct GNUNET_CRYPTO_EddsaPrivateKey 254struct 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 */
279struct GNUNET_CRYPTO_SymmetricSessionKey 265struct 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 */
300struct GNUNET_CRYPTO_SymmetricInitializationVector 285struct 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 */
311struct GNUNET_CRYPTO_AuthKey 295struct 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 */
327struct GNUNET_CRYPTO_PaillierPublicKey 310struct 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 */
339struct GNUNET_CRYPTO_PaillierPrivateKey 321struct 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 */
355struct GNUNET_CRYPTO_PaillierCiphertext 336struct 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 */
379void 359void
380GNUNET_CRYPTO_seed_weak_random (int32_t seed); 360GNUNET_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 */
391uint8_t 371uint8_t
392GNUNET_CRYPTO_crc8_n (const void *buf, size_t len); 372GNUNET_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 */
403uint32_t 383uint32_t
404GNUNET_CRYPTO_crc16_step (uint32_t sum, const void *buf, size_t len); 384GNUNET_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 */
413uint16_t 393uint16_t
414GNUNET_CRYPTO_crc16_finish (uint32_t sum); 394GNUNET_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 */
425uint16_t 405uint16_t
426GNUNET_CRYPTO_crc16_n (const void *buf, size_t len); 406GNUNET_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 */
438int32_t 418int32_t
439GNUNET_CRYPTO_crc32_n (const void *buf, size_t len); 419GNUNET_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 */
449void 429void
450GNUNET_CRYPTO_zero_keys (void *buffer, size_t length); 430GNUNET_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 */
461void 441void
462GNUNET_CRYPTO_random_block (enum GNUNET_CRYPTO_Quality mode, 442GNUNET_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 */
474uint32_t 454uint32_t
475GNUNET_CRYPTO_random_u32 (enum GNUNET_CRYPTO_Quality mode, uint32_t i); 455GNUNET_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 */
486uint64_t 466uint64_t
487GNUNET_CRYPTO_random_u64 (enum GNUNET_CRYPTO_Quality mode, uint64_t max); 467GNUNET_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 */
499unsigned int * 479unsigned int *
500GNUNET_CRYPTO_random_permute (enum GNUNET_CRYPTO_Quality mode, unsigned int n); 480GNUNET_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 */
509void 489void
510GNUNET_CRYPTO_symmetric_create_session_key ( 490GNUNET_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 */
525ssize_t 505ssize_t
526GNUNET_CRYPTO_symmetric_encrypt ( 506GNUNET_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 */
545ssize_t 525ssize_t
546GNUNET_CRYPTO_symmetric_decrypt ( 526GNUNET_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 */
563void 543void
564GNUNET_CRYPTO_symmetric_derive_iv ( 544GNUNET_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 */
580void 560void
581GNUNET_CRYPTO_symmetric_derive_iv_v ( 561GNUNET_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 */
596void 576void
597GNUNET_CRYPTO_hash_to_enc (const struct GNUNET_HashCode *block, 577GNUNET_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 */
610int 590int
611GNUNET_CRYPTO_hash_from_string2 (const char *enc, 591GNUNET_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 */
640uint32_t 620uint32_t
641GNUNET_CRYPTO_hash_distance_u32 (const struct GNUNET_HashCode *a, 621GNUNET_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 */
653void 633void
654GNUNET_CRYPTO_hash (const void *block, 634GNUNET_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 */
670struct GNUNET_HashContext * 650struct GNUNET_HashContext *
671GNUNET_CRYPTO_hash_context_start (void); 651GNUNET_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 */
681void 661void
682GNUNET_CRYPTO_hash_context_read (struct GNUNET_HashContext *hc, 662GNUNET_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 */
693void 673void
694GNUNET_CRYPTO_hash_context_finish (struct GNUNET_HashContext *hc, 674GNUNET_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 */
703void 683void
704GNUNET_CRYPTO_hash_context_abort (struct GNUNET_HashContext *hc); 684GNUNET_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 */
718void 698void
719GNUNET_CRYPTO_hmac_raw (const void *key, 699GNUNET_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 */
735void 715void
736GNUNET_CRYPTO_hmac (const struct GNUNET_CRYPTO_AuthKey *key, 716GNUNET_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 */
771struct GNUNET_CRYPTO_FileHashContext * 751struct GNUNET_CRYPTO_FileHashContext *
772GNUNET_CRYPTO_hash_file (enum GNUNET_SCHEDULER_Priority priority, 752GNUNET_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 */
784void 764void
785GNUNET_CRYPTO_hash_file_cancel (struct GNUNET_CRYPTO_FileHashContext *fhc); 765GNUNET_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 */
795void 775void
796GNUNET_CRYPTO_hash_create_random (enum GNUNET_CRYPTO_Quality mode, 776GNUNET_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 */
808void 788void
809GNUNET_CRYPTO_hash_difference (const struct GNUNET_HashCode *a, 789GNUNET_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 */
822void 802void
823GNUNET_CRYPTO_hash_sum (const struct GNUNET_HashCode *a, 803GNUNET_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 */
836void 816void
837GNUNET_CRYPTO_hash_xor (const struct GNUNET_HashCode *a, 817GNUNET_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 */
850void 830void
851GNUNET_CRYPTO_hash_to_aes_key ( 831GNUNET_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 */
865int 845int
866GNUNET_CRYPTO_hash_get_bit (const struct GNUNET_HashCode *code, 846GNUNET_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 */
882unsigned int 862unsigned int
883GNUNET_CRYPTO_hash_matching_bits (const struct GNUNET_HashCode *first, 863GNUNET_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 */
896int 876int
897GNUNET_CRYPTO_hash_cmp (const struct GNUNET_HashCode *h1, 877GNUNET_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 */
911int 891int
912GNUNET_CRYPTO_hash_xorcmp (const struct GNUNET_HashCode *h1, 892GNUNET_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 */
926void 906void
927GNUNET_CRYPTO_hmac_derive_key_v ( 907GNUNET_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 */
944void 924void
945GNUNET_CRYPTO_hmac_derive_key ( 925GNUNET_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 */
967int 947int
968GNUNET_CRYPTO_hkdf (void *result, 948GNUNET_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 */
993int 973int
994GNUNET_CRYPTO_hkdf_v (void *result, 974GNUNET_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 */
1016int 996int
1017GNUNET_CRYPTO_kdf_v (void *result, 997GNUNET_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 */
1038void 1018void
1039GNUNET_CRYPTO_kdf_mod_mpi (gcry_mpi_t *r, 1019GNUNET_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 */
1060int 1040int
1061GNUNET_CRYPTO_kdf (void *result, 1041GNUNET_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 */
1077void 1057void
1078GNUNET_CRYPTO_ecdsa_key_get_public ( 1058GNUNET_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 */
1089void 1069void
1090GNUNET_CRYPTO_eddsa_key_get_public ( 1070GNUNET_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 */
1102void 1082void
1103GNUNET_CRYPTO_ecdhe_key_get_public ( 1083GNUNET_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 */
1114char * 1094char *
1115GNUNET_CRYPTO_ecdsa_public_key_to_string ( 1095GNUNET_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 */
1124char * 1104char *
1125GNUNET_CRYPTO_ecdsa_private_key_to_string ( 1105GNUNET_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 */
1135char * 1115char *
1136GNUNET_CRYPTO_eddsa_private_key_to_string ( 1116GNUNET_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 */
1146char * 1126char *
1147GNUNET_CRYPTO_eddsa_public_key_to_string ( 1127GNUNET_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 */
1159int 1139int
1160GNUNET_CRYPTO_ecdsa_public_key_from_string ( 1140GNUNET_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 */
1174int 1154int
1175GNUNET_CRYPTO_eddsa_private_key_from_string ( 1155GNUNET_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 */
1189int 1169int
1190GNUNET_CRYPTO_eddsa_public_key_from_string ( 1170GNUNET_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 */
1211struct GNUNET_CRYPTO_EcdsaPrivateKey * 1191struct GNUNET_CRYPTO_EcdsaPrivateKey *
1212GNUNET_CRYPTO_ecdsa_key_create_from_file (const char *filename); 1192GNUNET_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 */
1230struct GNUNET_CRYPTO_EddsaPrivateKey * 1210struct GNUNET_CRYPTO_EddsaPrivateKey *
1231GNUNET_CRYPTO_eddsa_key_create_from_file (const char *filename); 1211GNUNET_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 */
1249struct GNUNET_CRYPTO_EddsaPrivateKey * 1229struct GNUNET_CRYPTO_EddsaPrivateKey *
1250GNUNET_CRYPTO_eddsa_key_create_from_configuration ( 1230GNUNET_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 */
1260struct GNUNET_CRYPTO_EcdsaPrivateKey * 1240struct GNUNET_CRYPTO_EcdsaPrivateKey *
1261GNUNET_CRYPTO_ecdsa_key_create (void); 1241GNUNET_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 */
1270struct GNUNET_CRYPTO_EddsaPrivateKey * 1250struct GNUNET_CRYPTO_EddsaPrivateKey *
1271GNUNET_CRYPTO_eddsa_key_create (void); 1251GNUNET_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 */
1281int 1261int
1282GNUNET_CRYPTO_ecdhe_key_create2 (struct GNUNET_CRYPTO_EcdhePrivateKey *pk); 1262GNUNET_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 */
1291struct GNUNET_CRYPTO_EcdhePrivateKey * 1271struct GNUNET_CRYPTO_EcdhePrivateKey *
1292GNUNET_CRYPTO_ecdhe_key_create (void); 1272GNUNET_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 */
1301void 1281void
1302GNUNET_CRYPTO_eddsa_key_clear (struct GNUNET_CRYPTO_EddsaPrivateKey *pk); 1282GNUNET_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 */
1311void 1291void
1312GNUNET_CRYPTO_ecdsa_key_clear (struct GNUNET_CRYPTO_EcdsaPrivateKey *pk); 1292GNUNET_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 */
1321void 1301void
1322GNUNET_CRYPTO_ecdhe_key_clear (struct GNUNET_CRYPTO_EcdhePrivateKey *pk); 1302GNUNET_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 */
1331const struct GNUNET_CRYPTO_EcdsaPrivateKey * 1311const struct GNUNET_CRYPTO_EcdsaPrivateKey *
1332GNUNET_CRYPTO_ecdsa_key_get_anonymous (void); 1312GNUNET_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 */
1344void 1324void
1345GNUNET_CRYPTO_eddsa_setup_hostkey (const char *cfg_name); 1325GNUNET_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 */
1357int 1337int
1358GNUNET_CRYPTO_get_peer_identity (const struct GNUNET_CONFIGURATION_Handle *cfg, 1338GNUNET_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 */
1372struct GNUNET_CRYPTO_EccPoint 1352struct 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 */
1389struct GNUNET_CRYPTO_EccDlogContext * 1368struct GNUNET_CRYPTO_EccDlogContext *
1390GNUNET_CRYPTO_ecc_dlog_prepare (unsigned int max, unsigned int mem); 1369GNUNET_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 */
1401int 1380int
1402GNUNET_CRYPTO_ecc_dlog (struct GNUNET_CRYPTO_EccDlogContext *edc, 1381GNUNET_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 */
1419gcry_mpi_point_t 1398gcry_mpi_point_t
1420GNUNET_CRYPTO_ecc_dexp (struct GNUNET_CRYPTO_EccDlogContext *edc, int val); 1399GNUNET_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 */
1432gcry_mpi_point_t 1411gcry_mpi_point_t
1433GNUNET_CRYPTO_ecc_dexp_mpi (struct GNUNET_CRYPTO_EccDlogContext *edc, 1412GNUNET_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 */
1446gcry_mpi_point_t 1425gcry_mpi_point_t
1447GNUNET_CRYPTO_ecc_pmul_mpi (struct GNUNET_CRYPTO_EccDlogContext *edc, 1426GNUNET_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 */
1459void 1438void
1460GNUNET_CRYPTO_ecc_point_to_bin (struct GNUNET_CRYPTO_EccDlogContext *edc, 1439GNUNET_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 */
1472gcry_mpi_point_t 1451gcry_mpi_point_t
1473GNUNET_CRYPTO_ecc_bin_to_point (struct GNUNET_CRYPTO_EccDlogContext *edc, 1452GNUNET_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 */
1485gcry_mpi_point_t 1464gcry_mpi_point_t
1486GNUNET_CRYPTO_ecc_add (struct GNUNET_CRYPTO_EccDlogContext *edc, 1465GNUNET_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 */
1500void 1479void
1501GNUNET_CRYPTO_ecc_rnd (struct GNUNET_CRYPTO_EccDlogContext *edc, 1480GNUNET_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 */
1514void 1493void
1515GNUNET_CRYPTO_ecc_rnd_mpi (struct GNUNET_CRYPTO_EccDlogContext *edc, 1494GNUNET_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 */
1526gcry_mpi_t 1505gcry_mpi_t
1527GNUNET_CRYPTO_ecc_random_mod_n (struct GNUNET_CRYPTO_EccDlogContext *edc); 1506GNUNET_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 */
1535void 1514void
1536GNUNET_CRYPTO_ecc_free (gcry_mpi_point_t p); 1515GNUNET_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 */
1544void 1523void
1545GNUNET_CRYPTO_ecc_dlog_release (struct GNUNET_CRYPTO_EccDlogContext *dlc); 1524GNUNET_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 */
1557int 1536int
1558GNUNET_CRYPTO_ecc_ecdh (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, 1537GNUNET_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 */
1573int 1552int
1574GNUNET_CRYPTO_eddsa_ecdh (const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, 1553GNUNET_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 */
1588int 1567int
1589GNUNET_CRYPTO_ecdsa_ecdh (const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, 1568GNUNET_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 */
1604int 1583int
1605GNUNET_CRYPTO_ecdh_eddsa (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, 1584GNUNET_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 */
1619int 1598int
1620GNUNET_CRYPTO_ecdh_ecdsa (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, 1599GNUNET_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 */
1634int 1613int
1635GNUNET_CRYPTO_eddsa_sign ( 1614GNUNET_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 */
1650int 1629int
1651GNUNET_CRYPTO_ecdsa_sign ( 1630GNUNET_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 */
1666int 1645int
1667GNUNET_CRYPTO_eddsa_verify ( 1646GNUNET_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 */
1684int 1663int
1685GNUNET_CRYPTO_ecdsa_verify ( 1664GNUNET_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 */
1705struct GNUNET_CRYPTO_EcdsaPrivateKey * 1684struct GNUNET_CRYPTO_EcdsaPrivateKey *
1706GNUNET_CRYPTO_ecdsa_private_key_derive ( 1685GNUNET_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 */
1723void 1702void
1724GNUNET_CRYPTO_ecdsa_public_key_derive ( 1703GNUNET_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 */
1739void 1718void
1740GNUNET_CRYPTO_mpi_print_unsigned (void *buf, size_t size, gcry_mpi_t val); 1719GNUNET_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 */
1752void 1731void
1753GNUNET_CRYPTO_mpi_scan_unsigned (gcry_mpi_t *result, 1732GNUNET_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 */
1764void 1743void
1765GNUNET_CRYPTO_paillier_create ( 1744GNUNET_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 */
1781int 1760int
1782GNUNET_CRYPTO_paillier_encrypt ( 1761GNUNET_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 */
1797void 1776void
1798GNUNET_CRYPTO_paillier_decrypt ( 1777GNUNET_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 */
1818int 1797int
1819GNUNET_CRYPTO_paillier_hom_add ( 1798GNUNET_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 */
1832int 1811int
1833GNUNET_CRYPTO_paillier_hom_get_remaining ( 1812GNUNET_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 */
1853struct GNUNET_CRYPTO_RsaBlindingKeySecret 1832struct 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 */
1874struct GNUNET_CRYPTO_RsaPrivateKey * 1852struct GNUNET_CRYPTO_RsaPrivateKey *
1875GNUNET_CRYPTO_rsa_private_key_create (unsigned int len); 1853GNUNET_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 */
1883void 1861void
1884GNUNET_CRYPTO_rsa_private_key_free (struct GNUNET_CRYPTO_RsaPrivateKey *key); 1862GNUNET_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 */
1895size_t 1873size_t
1896GNUNET_CRYPTO_rsa_private_key_encode ( 1874GNUNET_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 */
1909struct GNUNET_CRYPTO_RsaPrivateKey * 1887struct GNUNET_CRYPTO_RsaPrivateKey *
1910GNUNET_CRYPTO_rsa_private_key_decode (const char *buf, size_t len); 1888GNUNET_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 */
1919struct GNUNET_CRYPTO_RsaPrivateKey * 1897struct GNUNET_CRYPTO_RsaPrivateKey *
1920GNUNET_CRYPTO_rsa_private_key_dup ( 1898GNUNET_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 */
1930struct GNUNET_CRYPTO_RsaPublicKey * 1908struct GNUNET_CRYPTO_RsaPublicKey *
1931GNUNET_CRYPTO_rsa_private_key_get_public ( 1909GNUNET_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 */
1941void 1919void
1942GNUNET_CRYPTO_rsa_public_key_hash (const struct GNUNET_CRYPTO_RsaPublicKey *key, 1920GNUNET_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 */
1952unsigned int 1930unsigned int
1953GNUNET_CRYPTO_rsa_public_key_len (const struct GNUNET_CRYPTO_RsaPublicKey *key); 1931GNUNET_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 */
1961void 1939void
1962GNUNET_CRYPTO_rsa_public_key_free (struct GNUNET_CRYPTO_RsaPublicKey *key); 1940GNUNET_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 */
1973size_t 1951size_t
1974GNUNET_CRYPTO_rsa_public_key_encode ( 1952GNUNET_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 */
1987struct GNUNET_CRYPTO_RsaPublicKey * 1965struct GNUNET_CRYPTO_RsaPublicKey *
1988GNUNET_CRYPTO_rsa_public_key_decode (const char *buf, size_t len); 1966GNUNET_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 */
1997struct GNUNET_CRYPTO_RsaPublicKey * 1975struct GNUNET_CRYPTO_RsaPublicKey *
1998GNUNET_CRYPTO_rsa_public_key_dup (const struct GNUNET_CRYPTO_RsaPublicKey *key); 1976GNUNET_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 */
2008int 1986int
2009GNUNET_CRYPTO_rsa_signature_cmp (struct GNUNET_CRYPTO_RsaSignature *s1, 1987GNUNET_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 */
2019int 1997int
2020GNUNET_CRYPTO_rsa_private_key_cmp (struct GNUNET_CRYPTO_RsaPrivateKey *p1, 1998GNUNET_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 */
2031int 2009int
2032GNUNET_CRYPTO_rsa_public_key_cmp (struct GNUNET_CRYPTO_RsaPublicKey *p1, 2010GNUNET_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 */
2046int 2024int
2047GNUNET_CRYPTO_rsa_blind (const struct GNUNET_HashCode *hash, 2025GNUNET_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 */
2062struct GNUNET_CRYPTO_RsaSignature * 2040struct GNUNET_CRYPTO_RsaSignature *
2063GNUNET_CRYPTO_rsa_sign_blinded (const struct GNUNET_CRYPTO_RsaPrivateKey *key, 2041GNUNET_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 */
2075struct GNUNET_CRYPTO_RsaSignature * 2053struct GNUNET_CRYPTO_RsaSignature *
2076GNUNET_CRYPTO_rsa_sign_fdh (const struct GNUNET_CRYPTO_RsaPrivateKey *key, 2054GNUNET_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 */
2085void 2063void
2086GNUNET_CRYPTO_rsa_signature_free (struct GNUNET_CRYPTO_RsaSignature *sig); 2064GNUNET_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 */
2096size_t 2074size_t
2097GNUNET_CRYPTO_rsa_signature_encode ( 2075GNUNET_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 */
2110struct GNUNET_CRYPTO_RsaSignature * 2088struct GNUNET_CRYPTO_RsaSignature *
2111GNUNET_CRYPTO_rsa_signature_decode (const char *buf, size_t len); 2089GNUNET_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 */
2120struct GNUNET_CRYPTO_RsaSignature * 2098struct GNUNET_CRYPTO_RsaSignature *
2121GNUNET_CRYPTO_rsa_signature_dup (const struct GNUNET_CRYPTO_RsaSignature *sig); 2099GNUNET_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 */
2134struct GNUNET_CRYPTO_RsaSignature * 2112struct GNUNET_CRYPTO_RsaSignature *
2135GNUNET_CRYPTO_rsa_unblind (const struct GNUNET_CRYPTO_RsaSignature *sig, 2113GNUNET_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 */
2149int 2127int
2150GNUNET_CRYPTO_rsa_verify (const struct GNUNET_HashCode *hash, 2128GNUNET_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 */