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