aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_crypto_lib.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-03-19 13:12:55 +0000
committerChristian Grothoff <christian@grothoff.org>2015-03-19 13:12:55 +0000
commit1df06d38ea760384514cd2eb37df1400baa6e2d0 (patch)
treec50b046dd77d91092f6acb15c1648c019d571dbd /src/include/gnunet_crypto_lib.h
parent56af9c4ba537faf4c0a4a3acf8447a49673eec64 (diff)
downloadgnunet-1df06d38ea760384514cd2eb37df1400baa6e2d0.tar.gz
gnunet-1df06d38ea760384514cd2eb37df1400baa6e2d0.zip
-get test to work, but with ecdsa instead of eddsa
Diffstat (limited to 'src/include/gnunet_crypto_lib.h')
-rw-r--r--src/include/gnunet_crypto_lib.h107
1 files changed, 79 insertions, 28 deletions
diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h
index 1ebcfec97..274612a84 100644
--- a/src/include/gnunet_crypto_lib.h
+++ b/src/include/gnunet_crypto_lib.h
@@ -405,7 +405,9 @@ GNUNET_CRYPTO_seed_weak_random (int32_t seed);
405 * @return updated crc sum (must be subjected to #GNUNET_CRYPTO_crc16_finish to get actual crc16) 405 * @return updated crc sum (must be subjected to #GNUNET_CRYPTO_crc16_finish to get actual crc16)
406 */ 406 */
407uint32_t 407uint32_t
408GNUNET_CRYPTO_crc16_step (uint32_t sum, const void *buf, size_t len); 408GNUNET_CRYPTO_crc16_step (uint32_t sum,
409 const void *buf,
410 size_t len);
409 411
410 412
411/** 413/**
@@ -427,7 +429,8 @@ GNUNET_CRYPTO_crc16_finish (uint32_t sum);
427 * @return crc16 value 429 * @return crc16 value
428 */ 430 */
429uint16_t 431uint16_t
430GNUNET_CRYPTO_crc16_n (const void *buf, size_t len); 432GNUNET_CRYPTO_crc16_n (const void *buf,
433 size_t len);
431 434
432 435
433/** 436/**
@@ -440,7 +443,8 @@ GNUNET_CRYPTO_crc16_n (const void *buf, size_t len);
440 * @return the resulting CRC32 checksum 443 * @return the resulting CRC32 checksum
441 */ 444 */
442int32_t 445int32_t
443GNUNET_CRYPTO_crc32_n (const void *buf, size_t len); 446GNUNET_CRYPTO_crc32_n (const void *buf,
447 size_t len);
444 448
445 449
446/** 450/**
@@ -452,7 +456,9 @@ GNUNET_CRYPTO_crc32_n (const void *buf, size_t len);
452 * @param length buffer length 456 * @param length buffer length
453 */ 457 */
454void 458void
455GNUNET_CRYPTO_random_block (enum GNUNET_CRYPTO_Quality mode, void *buffer, size_t length); 459GNUNET_CRYPTO_random_block (enum GNUNET_CRYPTO_Quality mode,
460 void *buffer,
461 size_t length);
456 462
457/** 463/**
458 * @ingroup crypto 464 * @ingroup crypto
@@ -463,7 +469,8 @@ GNUNET_CRYPTO_random_block (enum GNUNET_CRYPTO_Quality mode, void *buffer, size_
463 * @return a random value in the interval [0,@a i) (exclusive). 469 * @return a random value in the interval [0,@a i) (exclusive).
464 */ 470 */
465uint32_t 471uint32_t
466GNUNET_CRYPTO_random_u32 (enum GNUNET_CRYPTO_Quality mode, uint32_t i); 472GNUNET_CRYPTO_random_u32 (enum GNUNET_CRYPTO_Quality mode,
473 uint32_t i);
467 474
468 475
469/** 476/**
@@ -475,7 +482,8 @@ GNUNET_CRYPTO_random_u32 (enum GNUNET_CRYPTO_Quality mode, uint32_t i);
475 * @return random 64-bit number 482 * @return random 64-bit number
476 */ 483 */
477uint64_t 484uint64_t
478GNUNET_CRYPTO_random_u64 (enum GNUNET_CRYPTO_Quality mode, uint64_t max); 485GNUNET_CRYPTO_random_u64 (enum GNUNET_CRYPTO_Quality mode,
486 uint64_t max);
479 487
480 488
481/** 489/**
@@ -488,7 +496,8 @@ GNUNET_CRYPTO_random_u64 (enum GNUNET_CRYPTO_Quality mode, uint64_t max);
488 * @return the permutation array (allocated from heap) 496 * @return the permutation array (allocated from heap)
489 */ 497 */
490unsigned int * 498unsigned int *
491GNUNET_CRYPTO_random_permute (enum GNUNET_CRYPTO_Quality mode, unsigned int n); 499GNUNET_CRYPTO_random_permute (enum GNUNET_CRYPTO_Quality mode,
500 unsigned int n);
492 501
493 502
494/** 503/**
@@ -513,7 +522,8 @@ GNUNET_CRYPTO_symmetric_create_session_key (struct GNUNET_CRYPTO_SymmetricSessio
513 * @return the size of the encrypted block, -1 for errors 522 * @return the size of the encrypted block, -1 for errors
514 */ 523 */
515ssize_t 524ssize_t
516GNUNET_CRYPTO_symmetric_encrypt (const void *block, size_t size, 525GNUNET_CRYPTO_symmetric_encrypt (const void *block,
526 size_t size,
517 const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey, 527 const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey,
518 const struct GNUNET_CRYPTO_SymmetricInitializationVector *iv, 528 const struct GNUNET_CRYPTO_SymmetricInitializationVector *iv,
519 void *result); 529 void *result);
@@ -531,7 +541,8 @@ GNUNET_CRYPTO_symmetric_encrypt (const void *block, size_t size,
531 * @return -1 on failure, size of decrypted block on success 541 * @return -1 on failure, size of decrypted block on success
532 */ 542 */
533ssize_t 543ssize_t
534GNUNET_CRYPTO_symmetric_decrypt (const void *block, size_t size, 544GNUNET_CRYPTO_symmetric_decrypt (const void *block,
545 size_t size,
535 const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey, 546 const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey,
536 const struct GNUNET_CRYPTO_SymmetricInitializationVector *iv, 547 const struct GNUNET_CRYPTO_SymmetricInitializationVector *iv,
537 void *result); 548 void *result);
@@ -577,7 +588,7 @@ GNUNET_CRYPTO_symmetric_derive_iv_v (struct GNUNET_CRYPTO_SymmetricInitializatio
577 * safely cast to char*, a '\\0' termination is set). 588 * safely cast to char*, a '\\0' termination is set).
578 */ 589 */
579void 590void
580GNUNET_CRYPTO_hash_to_enc (const struct GNUNET_HashCode * block, 591GNUNET_CRYPTO_hash_to_enc (const struct GNUNET_HashCode *block,
581 struct GNUNET_CRYPTO_HashAsciiEncoded *result); 592 struct GNUNET_CRYPTO_HashAsciiEncoded *result);
582 593
583 594
@@ -591,7 +602,8 @@ GNUNET_CRYPTO_hash_to_enc (const struct GNUNET_HashCode * block,
591 * @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
592 */ 603 */
593int 604int
594GNUNET_CRYPTO_hash_from_string2 (const char *enc, size_t enclen, 605GNUNET_CRYPTO_hash_from_string2 (const char *enc,
606 size_t enclen,
595 struct GNUNET_HashCode *result); 607 struct GNUNET_HashCode *result);
596 608
597 609
@@ -662,8 +674,8 @@ GNUNET_CRYPTO_hash_context_start (void);
662 */ 674 */
663void 675void
664GNUNET_CRYPTO_hash_context_read (struct GNUNET_HashContext *hc, 676GNUNET_CRYPTO_hash_context_read (struct GNUNET_HashContext *hc,
665 const void *buf, 677 const void *buf,
666 size_t size); 678 size_t size);
667 679
668 680
669/** 681/**
@@ -674,7 +686,7 @@ GNUNET_CRYPTO_hash_context_read (struct GNUNET_HashContext *hc,
674 */ 686 */
675void 687void
676GNUNET_CRYPTO_hash_context_finish (struct GNUNET_HashContext *hc, 688GNUNET_CRYPTO_hash_context_finish (struct GNUNET_HashContext *hc,
677 struct GNUNET_HashCode *r_hash); 689 struct GNUNET_HashCode *r_hash);
678 690
679 691
680/** 692/**
@@ -697,8 +709,9 @@ GNUNET_CRYPTO_hash_context_abort (struct GNUNET_HashContext *hc);
697 */ 709 */
698void 710void
699GNUNET_CRYPTO_hmac (const struct GNUNET_CRYPTO_AuthKey *key, 711GNUNET_CRYPTO_hmac (const struct GNUNET_CRYPTO_AuthKey *key,
700 const void *plaintext, size_t plaintext_len, 712 const void *plaintext,
701 struct GNUNET_HashCode * hmac); 713 size_t plaintext_len,
714 struct GNUNET_HashCode *hmac);
702 715
703 716
704/** 717/**
@@ -732,7 +745,8 @@ struct GNUNET_CRYPTO_FileHashContext;
732 */ 745 */
733struct GNUNET_CRYPTO_FileHashContext * 746struct GNUNET_CRYPTO_FileHashContext *
734GNUNET_CRYPTO_hash_file (enum GNUNET_SCHEDULER_Priority priority, 747GNUNET_CRYPTO_hash_file (enum GNUNET_SCHEDULER_Priority priority,
735 const char *filename, size_t blocksize, 748 const char *filename,
749 size_t blocksize,
736 GNUNET_CRYPTO_HashCompletedCallback callback, 750 GNUNET_CRYPTO_HashCompletedCallback callback,
737 void *callback_cls); 751 void *callback_cls);
738 752
@@ -902,7 +916,8 @@ GNUNET_CRYPTO_hmac_derive_key_v (struct GNUNET_CRYPTO_AuthKey *key,
902void 916void
903GNUNET_CRYPTO_hmac_derive_key (struct GNUNET_CRYPTO_AuthKey *key, 917GNUNET_CRYPTO_hmac_derive_key (struct GNUNET_CRYPTO_AuthKey *key,
904 const struct GNUNET_CRYPTO_SymmetricSessionKey *rkey, 918 const struct GNUNET_CRYPTO_SymmetricSessionKey *rkey,
905 const void *salt, size_t salt_len, ...); 919 const void *salt, size_t salt_len,
920 ...);
906 921
907 922
908/** 923/**
@@ -920,9 +935,15 @@ GNUNET_CRYPTO_hmac_derive_key (struct GNUNET_CRYPTO_AuthKey *key,
920 * @return #GNUNET_YES on success 935 * @return #GNUNET_YES on success
921 */ 936 */
922int 937int
923GNUNET_CRYPTO_hkdf (void *result, size_t out_len, int xtr_algo, int prf_algo, 938GNUNET_CRYPTO_hkdf (void *result,
924 const void *xts, size_t xts_len, const void *skm, 939 size_t out_len,
925 size_t skm_len, ...); 940 int xtr_algo,
941 int prf_algo,
942 const void *xts,
943 size_t xts_len,
944 const void *skm,
945 size_t skm_len,
946 ...);
926 947
927 948
928/** 949/**
@@ -940,9 +961,15 @@ GNUNET_CRYPTO_hkdf (void *result, size_t out_len, int xtr_algo, int prf_algo,
940 * @return #GNUNET_YES on success 961 * @return #GNUNET_YES on success
941 */ 962 */
942int 963int
943GNUNET_CRYPTO_hkdf_v (void *result, size_t out_len, int xtr_algo, int prf_algo, 964GNUNET_CRYPTO_hkdf_v (void *result,
944 const void *xts, size_t xts_len, const void *skm, 965 size_t out_len,
945 size_t skm_len, va_list argp); 966 int xtr_algo,
967 int prf_algo,
968 const void *xts,
969 size_t xts_len,
970 const void *skm,
971 size_t skm_len,
972 va_list argp);
946 973
947 974
948/** 975/**
@@ -957,8 +984,12 @@ GNUNET_CRYPTO_hkdf_v (void *result, size_t out_len, int xtr_algo, int prf_algo,
957 * @return #GNUNET_YES on success 984 * @return #GNUNET_YES on success
958 */ 985 */
959int 986int
960GNUNET_CRYPTO_kdf_v (void *result, size_t out_len, const void *xts, 987GNUNET_CRYPTO_kdf_v (void *result,
961 size_t xts_len, const void *skm, size_t skm_len, 988 size_t out_len,
989 const void *xts,
990 size_t xts_len,
991 const void *skm,
992 size_t skm_len,
962 va_list argp); 993 va_list argp);
963 994
964 995
@@ -975,8 +1006,13 @@ GNUNET_CRYPTO_kdf_v (void *result, size_t out_len, const void *xts,
975 * @return #GNUNET_YES on success 1006 * @return #GNUNET_YES on success
976 */ 1007 */
977int 1008int
978GNUNET_CRYPTO_kdf (void *result, size_t out_len, const void *xts, 1009GNUNET_CRYPTO_kdf (void *result,
979 size_t xts_len, const void *skm, size_t skm_len, ...); 1010 size_t out_len,
1011 const void *xts,
1012 size_t xts_len,
1013 const void *skm,
1014 size_t skm_len,
1015 ...);
980 1016
981 1017
982/** 1018/**
@@ -1002,6 +1038,21 @@ GNUNET_CRYPTO_eddsa_key_get_public (const struct GNUNET_CRYPTO_EddsaPrivateKey *
1002 struct GNUNET_CRYPTO_EddsaPublicKey *pub); 1038 struct GNUNET_CRYPTO_EddsaPublicKey *pub);
1003 1039
1004 1040
1041
1042/**
1043 * @ingroup crypto
1044 * Convert ECDSA public key to ECDHE public key.
1045 * Please be very careful when using this function, as mixing
1046 * cryptographic primitives is not always healthy.
1047 *
1048 * @param ecdsa ecdsa public key
1049 * @param ecdhe[OUT] ecdhe public key
1050 */
1051void
1052GNUNET_CRYPTO_ecdsa_public_to_ecdhe (const struct GNUNET_CRYPTO_EcdsaPublicKey *ecdsa,
1053 struct GNUNET_CRYPTO_EcdhePublicKey *ecdhe);
1054
1055
1005/** 1056/**
1006 * @ingroup crypto 1057 * @ingroup crypto
1007 * Extract the public key for the given private key. 1058 * Extract the public key for the given private key.