aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_crypto_lib.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-08-14 23:43:53 +0000
committerChristian Grothoff <christian@grothoff.org>2013-08-14 23:43:53 +0000
commit0c7015a6d8d2b3bf021c216b24d7062cd7375a71 (patch)
tree18bddea280e5e85d09389e9275c5efd15f17c840 /src/include/gnunet_crypto_lib.h
parentca173048a26a418866163d14c9159b9ad712644b (diff)
downloadgnunet-0c7015a6d8d2b3bf021c216b24d7062cd7375a71.tar.gz
gnunet-0c7015a6d8d2b3bf021c216b24d7062cd7375a71.zip
-playing with doxygen groups
Diffstat (limited to 'src/include/gnunet_crypto_lib.h')
-rw-r--r--src/include/gnunet_crypto_lib.h64
1 files changed, 59 insertions, 5 deletions
diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h
index 19813a693..73a3db382 100644
--- a/src/include/gnunet_crypto_lib.h
+++ b/src/include/gnunet_crypto_lib.h
@@ -27,6 +27,9 @@
27 * @author Gerd Knorr <kraxel@bytesex.org> 27 * @author Gerd Knorr <kraxel@bytesex.org>
28 * @author Ioana Patrascu 28 * @author Ioana Patrascu
29 * @author Tzvetan Horozov 29 * @author Tzvetan Horozov
30 *
31 * @defgroup crypto Cryptographic operations
32 * @defgroup hash Hashing and operations on hashes
30 */ 33 */
31 34
32#ifndef GNUNET_CRYPTO_LIB_H 35#ifndef GNUNET_CRYPTO_LIB_H
@@ -220,6 +223,7 @@ struct GNUNET_CRYPTO_AuthKey
220/* **************** Functions and Macros ************* */ 223/* **************** Functions and Macros ************* */
221 224
222/** 225/**
226 * @ingroup crypto
223 * Seed a weak random generator. Only #GNUNET_CRYPTO_QUALITY_WEAK-mode generator 227 * Seed a weak random generator. Only #GNUNET_CRYPTO_QUALITY_WEAK-mode generator
224 * can be seeded. 228 * can be seeded.
225 * 229 *
@@ -252,6 +256,7 @@ GNUNET_CRYPTO_crc16_finish (uint32_t sum);
252 256
253 257
254/** 258/**
259 * @ingroup hash
255 * Calculate the checksum of a buffer in one step. 260 * Calculate the checksum of a buffer in one step.
256 * 261 *
257 * @param buf buffer to calculate CRC over (must be 16-bit aligned) 262 * @param buf buffer to calculate CRC over (must be 16-bit aligned)
@@ -263,11 +268,12 @@ GNUNET_CRYPTO_crc16_n (const void *buf, size_t len);
263 268
264 269
265/** 270/**
271 * @ingroup hash
266 * Compute the CRC32 checksum for the first len 272 * Compute the CRC32 checksum for the first len
267 * bytes of the buffer. 273 * bytes of the buffer.
268 * 274 *
269 * @param buf the data over which we're taking the CRC 275 * @param buf the data over which we're taking the CRC
270 * @param len the length of the buffer @buf in bytes 276 * @param len the length of the buffer @a buf in bytes
271 * @return the resulting CRC32 checksum 277 * @return the resulting CRC32 checksum
272 */ 278 */
273int32_t 279int32_t
@@ -275,6 +281,7 @@ GNUNET_CRYPTO_crc32_n (const void *buf, size_t len);
275 281
276 282
277/** 283/**
284 * @ingroup crypto
278 * Produce a random value. 285 * Produce a random value.
279 * 286 *
280 * @param mode desired quality of the random number 287 * @param mode desired quality of the random number
@@ -286,6 +293,7 @@ GNUNET_CRYPTO_random_u32 (enum GNUNET_CRYPTO_Quality mode, uint32_t i);
286 293
287 294
288/** 295/**
296 * @ingroup crypto
289 * Random on unsigned 64-bit values. 297 * Random on unsigned 64-bit values.
290 * 298 *
291 * @param mode desired quality of the random number 299 * @param mode desired quality of the random number
@@ -297,6 +305,7 @@ GNUNET_CRYPTO_random_u64 (enum GNUNET_CRYPTO_Quality mode, uint64_t max);
297 305
298 306
299/** 307/**
308 * @ingroup crypto
300 * Get an array with a random permutation of the 309 * Get an array with a random permutation of the
301 * numbers 0...n-1. 310 * numbers 0...n-1.
302 * @param mode #GNUNET_CRYPTO_QUALITY_STRONG if the strong (but expensive) PRNG should be used, 311 * @param mode #GNUNET_CRYPTO_QUALITY_STRONG if the strong (but expensive) PRNG should be used,
@@ -309,7 +318,8 @@ GNUNET_CRYPTO_random_permute (enum GNUNET_CRYPTO_Quality mode, unsigned int n);
309 318
310 319
311/** 320/**
312 * Create a new Session key. 321 * @ingroup crypto
322 * Create a new random session key.
313 * 323 *
314 * @param key key to initialize 324 * @param key key to initialize
315 */ 325 */
@@ -318,8 +328,8 @@ GNUNET_CRYPTO_aes_create_session_key (struct GNUNET_CRYPTO_AesSessionKey *key);
318 328
319 329
320/** 330/**
321 * Encrypt a block with the public key of another 331 * @ingroup crypto
322 * host that uses the same cyper. 332 * Encrypt a block using a symmetric sessionkey.
323 * 333 *
324 * @param block the block to encrypt 334 * @param block the block to encrypt
325 * @param len the size of the block 335 * @param len the size of the block
@@ -336,7 +346,8 @@ GNUNET_CRYPTO_aes_encrypt (const void *block, size_t len,
336 346
337 347
338/** 348/**
339 * Decrypt a given block with the sessionkey. 349 * @ingroup crypto
350 * Decrypt a given block using a symmetric sessionkey.
340 * 351 *
341 * @param block the data to decrypt, encoded as returned by encrypt 352 * @param block the data to decrypt, encoded as returned by encrypt
342 * @param size how big is the block? 353 * @param size how big is the block?
@@ -353,6 +364,7 @@ GNUNET_CRYPTO_aes_decrypt (const void *block, size_t size,
353 364
354 365
355/** 366/**
367 * @ingroup crypto
356 * @brief Derive an IV 368 * @brief Derive an IV
357 * @param iv initialization vector 369 * @param iv initialization vector
358 * @param skey session key 370 * @param skey session key
@@ -381,6 +393,7 @@ GNUNET_CRYPTO_aes_derive_iv_v (struct GNUNET_CRYPTO_AesInitializationVector *iv,
381 393
382 394
383/** 395/**
396 * @ingroup hash
384 * Convert hash to ASCII encoding. 397 * Convert hash to ASCII encoding.
385 * @param block the hash code 398 * @param block the hash code
386 * @param result where to store the encoding (struct GNUNET_CRYPTO_HashAsciiEncoded can be 399 * @param result where to store the encoding (struct GNUNET_CRYPTO_HashAsciiEncoded can be
@@ -392,6 +405,7 @@ GNUNET_CRYPTO_hash_to_enc (const struct GNUNET_HashCode * block,
392 405
393 406
394/** 407/**
408 * @ingroup hash
395 * Convert short hash to ASCII encoding. 409 * Convert short hash to ASCII encoding.
396 * 410 *
397 * @param block the hash code 411 * @param block the hash code
@@ -404,6 +418,7 @@ GNUNET_CRYPTO_short_hash_to_enc (const struct GNUNET_CRYPTO_ShortHashCode * bloc
404 418
405 419
406/** 420/**
421 * @ingroup hash
407 * Convert ASCII encoding back to a 'struct GNUNET_HashCode' 422 * Convert ASCII encoding back to a 'struct GNUNET_HashCode'
408 * 423 *
409 * @param enc the encoding 424 * @param enc the encoding
@@ -417,6 +432,7 @@ GNUNET_CRYPTO_hash_from_string2 (const char *enc, size_t enclen,
417 432
418 433
419/** 434/**
435 * @ingroup hash
420 * Convert ASCII encoding back to a 'struct GNUNET_CRYPTO_ShortHash' 436 * Convert ASCII encoding back to a 'struct GNUNET_CRYPTO_ShortHash'
421 * 437 *
422 * @param enc the encoding 438 * @param enc the encoding
@@ -430,6 +446,7 @@ GNUNET_CRYPTO_short_hash_from_string2 (const char *enc, size_t enclen,
430 446
431 447
432/** 448/**
449 * @ingroup hash
433 * Convert ASCII encoding back to struct GNUNET_HashCode 450 * Convert ASCII encoding back to struct GNUNET_HashCode
434 * 451 *
435 * @param enc the encoding 452 * @param enc the encoding
@@ -441,6 +458,7 @@ GNUNET_CRYPTO_short_hash_from_string2 (const char *enc, size_t enclen,
441 458
442 459
443/** 460/**
461 * @ingroup hash
444 * Convert ASCII encoding back to a 'struct GNUNET_CRYPTO_ShortHash' 462 * Convert ASCII encoding back to a 'struct GNUNET_CRYPTO_ShortHash'
445 * 463 *
446 * @param enc the encoding 464 * @param enc the encoding
@@ -452,6 +470,7 @@ GNUNET_CRYPTO_short_hash_from_string2 (const char *enc, size_t enclen,
452 470
453 471
454/** 472/**
473 * @ingroup hash
455 * Compare function for ShortHashCodes, producing a total ordering 474 * Compare function for ShortHashCodes, producing a total ordering
456 * of all hashcodes. 475 * of all hashcodes.
457 * 476 *
@@ -464,6 +483,7 @@ GNUNET_CRYPTO_short_hash_cmp (const struct GNUNET_CRYPTO_ShortHashCode * h1,
464 const struct GNUNET_CRYPTO_ShortHashCode * h2); 483 const struct GNUNET_CRYPTO_ShortHashCode * h2);
465 484
466/** 485/**
486 * @ingroup hash
467 * Compute the distance between 2 hashcodes. 487 * Compute the distance between 2 hashcodes.
468 * The computation must be fast, not involve 488 * The computation must be fast, not involve
469 * a.a or a.e (they're used elsewhere), and 489 * a.a or a.e (they're used elsewhere), and
@@ -480,6 +500,7 @@ GNUNET_CRYPTO_hash_distance_u32 (const struct GNUNET_HashCode * a,
480 500
481 501
482/** 502/**
503 * @ingroup hash
483 * Compute hash of a given block. 504 * Compute hash of a given block.
484 * 505 *
485 * @param block the data to hash 506 * @param block the data to hash
@@ -491,6 +512,7 @@ GNUNET_CRYPTO_hash (const void *block, size_t size, struct GNUNET_HashCode * ret
491 512
492 513
493/** 514/**
515 * @ingroup hash
494 * Compute short (256-bit) hash of a given block. 516 * Compute short (256-bit) hash of a given block.
495 * 517 *
496 * @param block the data to hash 518 * @param block the data to hash
@@ -503,6 +525,7 @@ GNUNET_CRYPTO_short_hash (const void *block, size_t size,
503 525
504 526
505/** 527/**
528 * @ingroup hash
506 * Double short (256-bit) hash to create a long hash. 529 * Double short (256-bit) hash to create a long hash.
507 * 530 *
508 * @param sh short hash to double 531 * @param sh short hash to double
@@ -514,6 +537,7 @@ GNUNET_CRYPTO_short_hash_double (const struct GNUNET_CRYPTO_ShortHashCode *sh,
514 537
515 538
516/** 539/**
540 * @ingroup hash
517 * Truncate doubled short hash back to a short hash. 541 * Truncate doubled short hash back to a short hash.
518 * 542 *
519 * @param dh doubled short hash to reduce again 543 * @param dh doubled short hash to reduce again
@@ -527,6 +551,7 @@ GNUNET_CRYPTO_short_hash_from_truncation (const struct GNUNET_HashCode *dh,
527 551
528 552
529/** 553/**
554 * @ingroup hash
530 * Calculate HMAC of a message (RFC 2104) 555 * Calculate HMAC of a message (RFC 2104)
531 * 556 *
532 * @param key secret key 557 * @param key secret key
@@ -557,7 +582,9 @@ typedef void (*GNUNET_CRYPTO_HashCompletedCallback) (void *cls,
557 */ 582 */
558struct GNUNET_CRYPTO_FileHashContext; 583struct GNUNET_CRYPTO_FileHashContext;
559 584
585
560/** 586/**
587 * @ingroup hash
561 * Compute the hash of an entire file. 588 * Compute the hash of an entire file.
562 * 589 *
563 * @param priority scheduling priority to use 590 * @param priority scheduling priority to use
@@ -584,6 +611,7 @@ GNUNET_CRYPTO_hash_file_cancel (struct GNUNET_CRYPTO_FileHashContext *fhc);
584 611
585 612
586/** 613/**
614 * @ingroup hash
587 * Create a random hash code. 615 * Create a random hash code.
588 * 616 *
589 * @param mode desired quality level 617 * @param mode desired quality level
@@ -595,6 +623,7 @@ GNUNET_CRYPTO_hash_create_random (enum GNUNET_CRYPTO_Quality mode,
595 623
596 624
597/** 625/**
626 * @ingroup hash
598 * compute result(delta) = b - a 627 * compute result(delta) = b - a
599 * 628 *
600 * @param a some hash code 629 * @param a some hash code
@@ -608,6 +637,7 @@ GNUNET_CRYPTO_hash_difference (const struct GNUNET_HashCode * a,
608 637
609 638
610/** 639/**
640 * @ingroup hash
611 * compute result(b) = a + delta 641 * compute result(b) = a + delta
612 * 642 *
613 * @param a some hash code 643 * @param a some hash code
@@ -621,6 +651,7 @@ GNUNET_CRYPTO_hash_sum (const struct GNUNET_HashCode * a,
621 651
622 652
623/** 653/**
654 * @ingroup hash
624 * compute result = a ^ b 655 * compute result = a ^ b
625 * 656 *
626 * @param a some hash code 657 * @param a some hash code
@@ -633,6 +664,7 @@ GNUNET_CRYPTO_hash_xor (const struct GNUNET_HashCode * a, const struct GNUNET_Ha
633 664
634 665
635/** 666/**
667 * @ingroup hash
636 * Convert a hashcode into a key. 668 * Convert a hashcode into a key.
637 * 669 *
638 * @param hc hash code that serves to generate the key 670 * @param hc hash code that serves to generate the key
@@ -647,6 +679,7 @@ GNUNET_CRYPTO_hash_to_aes_key (const struct GNUNET_HashCode * hc,
647 679
648 680
649/** 681/**
682 * @ingroup hash
650 * Obtain a bit from a hashcode. 683 * Obtain a bit from a hashcode.
651 * 684 *
652 * @param code the GNUNET_CRYPTO_hash to index bit-wise 685 * @param code the GNUNET_CRYPTO_hash to index bit-wise
@@ -658,6 +691,7 @@ GNUNET_CRYPTO_hash_get_bit (const struct GNUNET_HashCode * code, unsigned int bi
658 691
659 692
660/** 693/**
694 * @ingroup hash
661 * Determine how many low order bits match in two 695 * Determine how many low order bits match in two
662 * struct GNUNET_HashCodes. i.e. - 010011 and 011111 share 696 * struct GNUNET_HashCodes. i.e. - 010011 and 011111 share
663 * the first two lowest order bits, and therefore the 697 * the first two lowest order bits, and therefore the
@@ -674,6 +708,7 @@ GNUNET_CRYPTO_hash_matching_bits (const struct GNUNET_HashCode * first,
674 708
675 709
676/** 710/**
711 * @ingroup hash
677 * Compare function for HashCodes, producing a total ordering 712 * Compare function for HashCodes, producing a total ordering
678 * of all hashcodes. 713 * of all hashcodes.
679 * 714 *
@@ -686,6 +721,7 @@ GNUNET_CRYPTO_hash_cmp (const struct GNUNET_HashCode * h1, const struct GNUNET_H
686 721
687 722
688/** 723/**
724 * @ingroup hash
689 * Find out which of the two GNUNET_CRYPTO_hash codes is closer to target 725 * Find out which of the two GNUNET_CRYPTO_hash codes is closer to target
690 * in the XOR metric (Kademlia). 726 * in the XOR metric (Kademlia).
691 * 727 *
@@ -701,6 +737,7 @@ GNUNET_CRYPTO_hash_xorcmp (const struct GNUNET_HashCode * h1,
701 737
702 738
703/** 739/**
740 * @ingroup hash
704 * @brief Derive an authentication key 741 * @brief Derive an authentication key
705 * @param key authentication key 742 * @param key authentication key
706 * @param rkey root key 743 * @param rkey root key
@@ -716,6 +753,7 @@ GNUNET_CRYPTO_hmac_derive_key_v (struct GNUNET_CRYPTO_AuthKey *key,
716 753
717 754
718/** 755/**
756 * @ingroup hash
719 * @brief Derive an authentication key 757 * @brief Derive an authentication key
720 * @param key authentication key 758 * @param key authentication key
721 * @param rkey root key 759 * @param rkey root key
@@ -730,6 +768,7 @@ GNUNET_CRYPTO_hmac_derive_key (struct GNUNET_CRYPTO_AuthKey *key,
730 768
731 769
732/** 770/**
771 * @ingroup hash
733 * @brief Derive key 772 * @brief Derive key
734 * @param result buffer for the derived key, allocated by caller 773 * @param result buffer for the derived key, allocated by caller
735 * @param out_len desired length of the derived key 774 * @param out_len desired length of the derived key
@@ -749,6 +788,7 @@ GNUNET_CRYPTO_hkdf (void *result, size_t out_len, int xtr_algo, int prf_algo,
749 788
750 789
751/** 790/**
791 * @ingroup hash
752 * @brief Derive key 792 * @brief Derive key
753 * @param result buffer for the derived key, allocated by caller 793 * @param result buffer for the derived key, allocated by caller
754 * @param out_len desired length of the derived key 794 * @param out_len desired length of the derived key
@@ -785,6 +825,7 @@ GNUNET_CRYPTO_kdf_v (void *result, size_t out_len, const void *xts,
785 825
786 826
787/** 827/**
828 * @ingroup hash
788 * @brief Derive key 829 * @brief Derive key
789 * @param result buffer for the derived key, allocated by caller 830 * @param result buffer for the derived key, allocated by caller
790 * @param out_len desired length of the derived key 831 * @param out_len desired length of the derived key
@@ -813,6 +854,7 @@ typedef void (*GNUNET_CRYPTO_EccKeyCallback)(void *cls,
813 854
814 855
815/** 856/**
857 * @ingroup crypto
816 * Free memory occupied by ECC key 858 * Free memory occupied by ECC key
817 * 859 *
818 * @param priv pointer to the memory to free 860 * @param priv pointer to the memory to free
@@ -822,6 +864,7 @@ GNUNET_CRYPTO_ecc_key_free (struct GNUNET_CRYPTO_EccPrivateKey *priv);
822 864
823 865
824/** 866/**
867 * @ingroup crypto
825 * Extract the public key for the given private key. 868 * Extract the public key for the given private key.
826 * 869 *
827 * @param priv the private key 870 * @param priv the private key
@@ -857,6 +900,7 @@ GNUNET_CRYPTO_ecc_public_key_from_string (const char *enc,
857 900
858 901
859/** 902/**
903 * @ingroup crypto
860 * Create a new private key by reading it from a file. If the 904 * Create a new private key by reading it from a file. If the
861 * files does not exist, create a new key and write it to the 905 * files does not exist, create a new key and write it to the
862 * file. Caller must free return value. Note that this function 906 * file. Caller must free return value. Note that this function
@@ -875,6 +919,7 @@ GNUNET_CRYPTO_ecc_key_create_from_file (const char *filename);
875 919
876 920
877/** 921/**
922 * @ingroup crypto
878 * Create a new private key by reading our peer's key from 923 * Create a new private key by reading our peer's key from
879 * the file specified in the configuration. 924 * the file specified in the configuration.
880 * 925 *
@@ -886,6 +931,7 @@ GNUNET_CRYPTO_ecc_key_create_from_configuration (const struct GNUNET_CONFIGURATI
886 931
887 932
888/** 933/**
934 * @ingroup crypto
889 * Create a new private key. Caller must free return value. 935 * Create a new private key. Caller must free return value.
890 * 936 *
891 * @return fresh private key 937 * @return fresh private key
@@ -895,6 +941,7 @@ GNUNET_CRYPTO_ecc_key_create (void);
895 941
896 942
897/** 943/**
944 * @ingroup crypto
898 * Get the shared private key we use for anonymous users. 945 * Get the shared private key we use for anonymous users.
899 * 946 *
900 * @return "anonymous" private key 947 * @return "anonymous" private key
@@ -904,6 +951,7 @@ GNUNET_CRYPTO_ecc_key_get_anonymous (void);
904 951
905 952
906/** 953/**
954 * @ingroup crypto
907 * Setup a hostkey file for a peer given the name of the 955 * Setup a hostkey file for a peer given the name of the
908 * configuration file (!). This function is used so that 956 * configuration file (!). This function is used so that
909 * at a later point code can be certain that reading a 957 * at a later point code can be certain that reading a
@@ -916,6 +964,7 @@ GNUNET_CRYPTO_ecc_setup_hostkey (const char *cfg_name);
916 964
917 965
918/** 966/**
967 * @ingroup crypto
919 * Retrieve the identity of the host's peer. 968 * Retrieve the identity of the host's peer.
920 * 969 *
921 * @param cfg configuration to use 970 * @param cfg configuration to use
@@ -929,6 +978,7 @@ GNUNET_CRYPTO_get_host_identity (const struct GNUNET_CONFIGURATION_Handle *cfg,
929 978
930 979
931/** 980/**
981 * @ingroup crypto
932 * Derive key material from a public and a private ECC key. 982 * Derive key material from a public and a private ECC key.
933 * 983 *
934 * @param priv private key to use for the ECDH (x) 984 * @param priv private key to use for the ECDH (x)
@@ -943,6 +993,7 @@ GNUNET_CRYPTO_ecc_ecdh (const struct GNUNET_CRYPTO_EccPrivateKey *priv,
943 993
944 994
945/** 995/**
996 * @ingroup crypto
946 * Sign a given block. 997 * Sign a given block.
947 * 998 *
948 * @param priv private key to use for the signing 999 * @param priv private key to use for the signing
@@ -957,6 +1008,7 @@ GNUNET_CRYPTO_ecc_sign (const struct GNUNET_CRYPTO_EccPrivateKey *priv,
957 1008
958 1009
959/** 1010/**
1011 * @ingroup crypto
960 * Verify signature. 1012 * Verify signature.
961 * 1013 *
962 * @param purpose what is the purpose that the signature should have? 1014 * @param purpose what is the purpose that the signature should have?
@@ -974,6 +1026,7 @@ GNUNET_CRYPTO_ecc_verify (uint32_t purpose,
974 1026
975 1027
976/** 1028/**
1029 * @ingroup crypto
977 * Derive a private key from a given private key and a label. 1030 * Derive a private key from a given private key and a label.
978 * Essentially calculates a private key 'h = H(l,P) * d mod n' 1031 * Essentially calculates a private key 'h = H(l,P) * d mod n'
979 * where n is the size of the ECC group and P is the public 1032 * where n is the size of the ECC group and P is the public
@@ -992,6 +1045,7 @@ GNUNET_CRYPTO_ecc_key_derive (const struct GNUNET_CRYPTO_EccPrivateKey *priv,
992 1045
993 1046
994/** 1047/**
1048 * @ingroup crypto
995 * Derive a public key from a given public key and a label. 1049 * Derive a public key from a given public key and a label.
996 * Essentially calculates a public key 'V = H(l,P) * P'. 1050 * Essentially calculates a public key 'V = H(l,P) * P'.
997 * 1051 *