diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-03-19 13:12:55 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-03-19 13:12:55 +0000 |
commit | 1df06d38ea760384514cd2eb37df1400baa6e2d0 (patch) | |
tree | c50b046dd77d91092f6acb15c1648c019d571dbd /src/include/gnunet_crypto_lib.h | |
parent | 56af9c4ba537faf4c0a4a3acf8447a49673eec64 (diff) | |
download | gnunet-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.h | 107 |
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 | */ |
407 | uint32_t | 407 | uint32_t |
408 | GNUNET_CRYPTO_crc16_step (uint32_t sum, const void *buf, size_t len); | 408 | GNUNET_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 | */ |
429 | uint16_t | 431 | uint16_t |
430 | GNUNET_CRYPTO_crc16_n (const void *buf, size_t len); | 432 | GNUNET_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 | */ |
442 | int32_t | 445 | int32_t |
443 | GNUNET_CRYPTO_crc32_n (const void *buf, size_t len); | 446 | GNUNET_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 | */ |
454 | void | 458 | void |
455 | GNUNET_CRYPTO_random_block (enum GNUNET_CRYPTO_Quality mode, void *buffer, size_t length); | 459 | GNUNET_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 | */ |
465 | uint32_t | 471 | uint32_t |
466 | GNUNET_CRYPTO_random_u32 (enum GNUNET_CRYPTO_Quality mode, uint32_t i); | 472 | GNUNET_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 | */ |
477 | uint64_t | 484 | uint64_t |
478 | GNUNET_CRYPTO_random_u64 (enum GNUNET_CRYPTO_Quality mode, uint64_t max); | 485 | GNUNET_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 | */ |
490 | unsigned int * | 498 | unsigned int * |
491 | GNUNET_CRYPTO_random_permute (enum GNUNET_CRYPTO_Quality mode, unsigned int n); | 499 | GNUNET_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 | */ |
515 | ssize_t | 524 | ssize_t |
516 | GNUNET_CRYPTO_symmetric_encrypt (const void *block, size_t size, | 525 | GNUNET_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 | */ |
533 | ssize_t | 543 | ssize_t |
534 | GNUNET_CRYPTO_symmetric_decrypt (const void *block, size_t size, | 544 | GNUNET_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 | */ |
579 | void | 590 | void |
580 | GNUNET_CRYPTO_hash_to_enc (const struct GNUNET_HashCode * block, | 591 | GNUNET_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 | */ |
593 | int | 604 | int |
594 | GNUNET_CRYPTO_hash_from_string2 (const char *enc, size_t enclen, | 605 | GNUNET_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 | */ |
663 | void | 675 | void |
664 | GNUNET_CRYPTO_hash_context_read (struct GNUNET_HashContext *hc, | 676 | GNUNET_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 | */ |
675 | void | 687 | void |
676 | GNUNET_CRYPTO_hash_context_finish (struct GNUNET_HashContext *hc, | 688 | GNUNET_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 | */ |
698 | void | 710 | void |
699 | GNUNET_CRYPTO_hmac (const struct GNUNET_CRYPTO_AuthKey *key, | 711 | GNUNET_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 | */ |
733 | struct GNUNET_CRYPTO_FileHashContext * | 746 | struct GNUNET_CRYPTO_FileHashContext * |
734 | GNUNET_CRYPTO_hash_file (enum GNUNET_SCHEDULER_Priority priority, | 747 | GNUNET_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, | |||
902 | void | 916 | void |
903 | GNUNET_CRYPTO_hmac_derive_key (struct GNUNET_CRYPTO_AuthKey *key, | 917 | GNUNET_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 | */ |
922 | int | 937 | int |
923 | GNUNET_CRYPTO_hkdf (void *result, size_t out_len, int xtr_algo, int prf_algo, | 938 | GNUNET_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 | */ |
942 | int | 963 | int |
943 | GNUNET_CRYPTO_hkdf_v (void *result, size_t out_len, int xtr_algo, int prf_algo, | 964 | GNUNET_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 | */ |
959 | int | 986 | int |
960 | GNUNET_CRYPTO_kdf_v (void *result, size_t out_len, const void *xts, | 987 | GNUNET_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 | */ |
977 | int | 1008 | int |
978 | GNUNET_CRYPTO_kdf (void *result, size_t out_len, const void *xts, | 1009 | GNUNET_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 | */ | ||
1051 | void | ||
1052 | GNUNET_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. |