diff options
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/gnunet_crypto_lib.h | 352 |
1 files changed, 185 insertions, 167 deletions
diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h index 45da5f6ba..2037159e5 100644 --- a/src/include/gnunet_crypto_lib.h +++ b/src/include/gnunet_crypto_lib.h | |||
@@ -44,9 +44,8 @@ | |||
44 | #define GNUNET_CRYPTO_LIB_H | 44 | #define GNUNET_CRYPTO_LIB_H |
45 | 45 | ||
46 | #ifdef __cplusplus | 46 | #ifdef __cplusplus |
47 | extern "C" | 47 | extern "C" { |
48 | { | 48 | #if 0 /* keep Emacsens' auto-indent happy */ |
49 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
50 | } | 49 | } |
51 | #endif | 50 | #endif |
52 | #endif | 51 | #endif |
@@ -98,12 +97,12 @@ enum GNUNET_CRYPTO_Quality | |||
98 | /** | 97 | /** |
99 | * @brief length of the sessionkey in bytes (256 BIT sessionkey) | 98 | * @brief length of the sessionkey in bytes (256 BIT sessionkey) |
100 | */ | 99 | */ |
101 | #define GNUNET_CRYPTO_AES_KEY_LENGTH (256/8) | 100 | #define GNUNET_CRYPTO_AES_KEY_LENGTH (256 / 8) |
102 | 101 | ||
103 | /** | 102 | /** |
104 | * Length of a hash value | 103 | * Length of a hash value |
105 | */ | 104 | */ |
106 | #define GNUNET_CRYPTO_HASH_LENGTH (512/8) | 105 | #define GNUNET_CRYPTO_HASH_LENGTH (512 / 8) |
107 | 106 | ||
108 | /** | 107 | /** |
109 | * How many characters (without 0-terminator) are our ASCII-encoded | 108 | * How many characters (without 0-terminator) are our ASCII-encoded |
@@ -144,7 +143,6 @@ struct GNUNET_CRYPTO_EccSignaturePurpose | |||
144 | * network byte order! | 143 | * network byte order! |
145 | */ | 144 | */ |
146 | uint32_t purpose GNUNET_PACKED; | 145 | uint32_t purpose GNUNET_PACKED; |
147 | |||
148 | }; | 146 | }; |
149 | 147 | ||
150 | 148 | ||
@@ -164,11 +162,9 @@ struct GNUNET_CRYPTO_EddsaSignature | |||
164 | * S value. | 162 | * S value. |
165 | */ | 163 | */ |
166 | unsigned char s[256 / 8]; | 164 | unsigned char s[256 / 8]; |
167 | |||
168 | }; | 165 | }; |
169 | 166 | ||
170 | 167 | ||
171 | |||
172 | /** | 168 | /** |
173 | * @brief an ECC signature using ECDSA | 169 | * @brief an ECC signature using ECDSA |
174 | */ | 170 | */ |
@@ -184,7 +180,6 @@ struct GNUNET_CRYPTO_EcdsaSignature | |||
184 | * S value. | 180 | * S value. |
185 | */ | 181 | */ |
186 | unsigned char s[256 / 8]; | 182 | unsigned char s[256 / 8]; |
187 | |||
188 | }; | 183 | }; |
189 | 184 | ||
190 | 185 | ||
@@ -200,7 +195,6 @@ struct GNUNET_CRYPTO_EddsaPublicKey | |||
200 | * compact format. | 195 | * compact format. |
201 | */ | 196 | */ |
202 | unsigned char q_y[256 / 8]; | 197 | unsigned char q_y[256 / 8]; |
203 | |||
204 | }; | 198 | }; |
205 | 199 | ||
206 | 200 | ||
@@ -215,7 +209,6 @@ struct GNUNET_CRYPTO_EcdsaPublicKey | |||
215 | * here in affine coordinates and Ed25519 standard compact format. | 209 | * here in affine coordinates and Ed25519 standard compact format. |
216 | */ | 210 | */ |
217 | unsigned char q_y[256 / 8]; | 211 | unsigned char q_y[256 / 8]; |
218 | |||
219 | }; | 212 | }; |
220 | 213 | ||
221 | 214 | ||
@@ -253,7 +246,6 @@ struct GNUNET_CRYPTO_EcdhePrivateKey | |||
253 | * d is a value mod n, where n has at most 256 bits. | 246 | * d is a value mod n, where n has at most 256 bits. |
254 | */ | 247 | */ |
255 | unsigned char d[256 / 8]; | 248 | unsigned char d[256 / 8]; |
256 | |||
257 | }; | 249 | }; |
258 | 250 | ||
259 | /** | 251 | /** |
@@ -266,7 +258,6 @@ struct GNUNET_CRYPTO_EcdsaPrivateKey | |||
266 | * d is a value mod n, where n has at most 256 bits. | 258 | * d is a value mod n, where n has at most 256 bits. |
267 | */ | 259 | */ |
268 | unsigned char d[256 / 8]; | 260 | unsigned char d[256 / 8]; |
269 | |||
270 | }; | 261 | }; |
271 | 262 | ||
272 | /** | 263 | /** |
@@ -279,7 +270,6 @@ struct GNUNET_CRYPTO_EddsaPrivateKey | |||
279 | * d is a value mod n, where n has at most 256 bits. | 270 | * d is a value mod n, where n has at most 256 bits. |
280 | */ | 271 | */ |
281 | unsigned char d[256 / 8]; | 272 | unsigned char d[256 / 8]; |
282 | |||
283 | }; | 273 | }; |
284 | 274 | ||
285 | 275 | ||
@@ -297,7 +287,6 @@ struct GNUNET_CRYPTO_SymmetricSessionKey | |||
297 | * Actual key for TwoFish. | 287 | * Actual key for TwoFish. |
298 | */ | 288 | */ |
299 | unsigned char twofish_key[GNUNET_CRYPTO_AES_KEY_LENGTH]; | 289 | unsigned char twofish_key[GNUNET_CRYPTO_AES_KEY_LENGTH]; |
300 | |||
301 | }; | 290 | }; |
302 | 291 | ||
303 | GNUNET_NETWORK_STRUCT_END | 292 | GNUNET_NETWORK_STRUCT_END |
@@ -400,8 +389,7 @@ GNUNET_CRYPTO_seed_weak_random (int32_t seed); | |||
400 | * @return crc8 value | 389 | * @return crc8 value |
401 | */ | 390 | */ |
402 | uint8_t | 391 | uint8_t |
403 | GNUNET_CRYPTO_crc8_n (const void *buf, | 392 | GNUNET_CRYPTO_crc8_n (const void *buf, size_t len); |
404 | size_t len); | ||
405 | 393 | ||
406 | 394 | ||
407 | /** | 395 | /** |
@@ -413,9 +401,7 @@ GNUNET_CRYPTO_crc8_n (const void *buf, | |||
413 | * @return updated crc sum (must be subjected to #GNUNET_CRYPTO_crc16_finish to get actual crc16) | 401 | * @return updated crc sum (must be subjected to #GNUNET_CRYPTO_crc16_finish to get actual crc16) |
414 | */ | 402 | */ |
415 | uint32_t | 403 | uint32_t |
416 | GNUNET_CRYPTO_crc16_step (uint32_t sum, | 404 | GNUNET_CRYPTO_crc16_step (uint32_t sum, const void *buf, size_t len); |
417 | const void *buf, | ||
418 | size_t len); | ||
419 | 405 | ||
420 | 406 | ||
421 | /** | 407 | /** |
@@ -437,10 +423,7 @@ GNUNET_CRYPTO_crc16_finish (uint32_t sum); | |||
437 | * @return crc16 value | 423 | * @return crc16 value |
438 | */ | 424 | */ |
439 | uint16_t | 425 | uint16_t |
440 | GNUNET_CRYPTO_crc16_n (const void *buf, | 426 | GNUNET_CRYPTO_crc16_n (const void *buf, size_t len); |
441 | size_t len); | ||
442 | |||
443 | |||
444 | 427 | ||
445 | 428 | ||
446 | /** | 429 | /** |
@@ -453,8 +436,7 @@ GNUNET_CRYPTO_crc16_n (const void *buf, | |||
453 | * @return the resulting CRC32 checksum | 436 | * @return the resulting CRC32 checksum |
454 | */ | 437 | */ |
455 | int32_t | 438 | int32_t |
456 | GNUNET_CRYPTO_crc32_n (const void *buf, | 439 | GNUNET_CRYPTO_crc32_n (const void *buf, size_t len); |
457 | size_t len); | ||
458 | 440 | ||
459 | /** | 441 | /** |
460 | * @ingroup crypto | 442 | * @ingroup crypto |
@@ -465,8 +447,7 @@ GNUNET_CRYPTO_crc32_n (const void *buf, | |||
465 | * @param length buffer length | 447 | * @param length buffer length |
466 | */ | 448 | */ |
467 | void | 449 | void |
468 | GNUNET_CRYPTO_zero_keys (void *buffer, | 450 | GNUNET_CRYPTO_zero_keys (void *buffer, size_t length); |
469 | size_t length); | ||
470 | 451 | ||
471 | 452 | ||
472 | /** | 453 | /** |
@@ -491,8 +472,7 @@ GNUNET_CRYPTO_random_block (enum GNUNET_CRYPTO_Quality mode, | |||
491 | * @return a random value in the interval [0,@a i) (exclusive). | 472 | * @return a random value in the interval [0,@a i) (exclusive). |
492 | */ | 473 | */ |
493 | uint32_t | 474 | uint32_t |
494 | GNUNET_CRYPTO_random_u32 (enum GNUNET_CRYPTO_Quality mode, | 475 | GNUNET_CRYPTO_random_u32 (enum GNUNET_CRYPTO_Quality mode, uint32_t i); |
495 | uint32_t i); | ||
496 | 476 | ||
497 | 477 | ||
498 | /** | 478 | /** |
@@ -504,8 +484,7 @@ GNUNET_CRYPTO_random_u32 (enum GNUNET_CRYPTO_Quality mode, | |||
504 | * @return random 64-bit number | 484 | * @return random 64-bit number |
505 | */ | 485 | */ |
506 | uint64_t | 486 | uint64_t |
507 | GNUNET_CRYPTO_random_u64 (enum GNUNET_CRYPTO_Quality mode, | 487 | GNUNET_CRYPTO_random_u64 (enum GNUNET_CRYPTO_Quality mode, uint64_t max); |
508 | uint64_t max); | ||
509 | 488 | ||
510 | 489 | ||
511 | /** | 490 | /** |
@@ -518,8 +497,7 @@ GNUNET_CRYPTO_random_u64 (enum GNUNET_CRYPTO_Quality mode, | |||
518 | * @return the permutation array (allocated from heap) | 497 | * @return the permutation array (allocated from heap) |
519 | */ | 498 | */ |
520 | unsigned int * | 499 | unsigned int * |
521 | GNUNET_CRYPTO_random_permute (enum GNUNET_CRYPTO_Quality mode, | 500 | GNUNET_CRYPTO_random_permute (enum GNUNET_CRYPTO_Quality mode, unsigned int n); |
522 | unsigned int n); | ||
523 | 501 | ||
524 | 502 | ||
525 | /** | 503 | /** |
@@ -529,7 +507,8 @@ GNUNET_CRYPTO_random_permute (enum GNUNET_CRYPTO_Quality mode, | |||
529 | * @param key key to initialize | 507 | * @param key key to initialize |
530 | */ | 508 | */ |
531 | void | 509 | void |
532 | GNUNET_CRYPTO_symmetric_create_session_key (struct GNUNET_CRYPTO_SymmetricSessionKey *key); | 510 | GNUNET_CRYPTO_symmetric_create_session_key ( |
511 | struct GNUNET_CRYPTO_SymmetricSessionKey *key); | ||
533 | 512 | ||
534 | 513 | ||
535 | /** | 514 | /** |
@@ -544,11 +523,12 @@ GNUNET_CRYPTO_symmetric_create_session_key (struct GNUNET_CRYPTO_SymmetricSessio | |||
544 | * @return the size of the encrypted block, -1 for errors | 523 | * @return the size of the encrypted block, -1 for errors |
545 | */ | 524 | */ |
546 | ssize_t | 525 | ssize_t |
547 | GNUNET_CRYPTO_symmetric_encrypt (const void *block, | 526 | GNUNET_CRYPTO_symmetric_encrypt ( |
548 | size_t size, | 527 | const void *block, |
549 | const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey, | 528 | size_t size, |
550 | const struct GNUNET_CRYPTO_SymmetricInitializationVector *iv, | 529 | const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey, |
551 | void *result); | 530 | const struct GNUNET_CRYPTO_SymmetricInitializationVector *iv, |
531 | void *result); | ||
552 | 532 | ||
553 | 533 | ||
554 | /** | 534 | /** |
@@ -563,11 +543,12 @@ GNUNET_CRYPTO_symmetric_encrypt (const void *block, | |||
563 | * @return -1 on failure, size of decrypted block on success | 543 | * @return -1 on failure, size of decrypted block on success |
564 | */ | 544 | */ |
565 | ssize_t | 545 | ssize_t |
566 | GNUNET_CRYPTO_symmetric_decrypt (const void *block, | 546 | GNUNET_CRYPTO_symmetric_decrypt ( |
567 | size_t size, | 547 | const void *block, |
568 | const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey, | 548 | size_t size, |
569 | const struct GNUNET_CRYPTO_SymmetricInitializationVector *iv, | 549 | const struct GNUNET_CRYPTO_SymmetricSessionKey *sessionkey, |
570 | void *result); | 550 | const struct GNUNET_CRYPTO_SymmetricInitializationVector *iv, |
551 | void *result); | ||
571 | 552 | ||
572 | 553 | ||
573 | /** | 554 | /** |
@@ -580,10 +561,12 @@ GNUNET_CRYPTO_symmetric_decrypt (const void *block, | |||
580 | * @param ... pairs of void * & size_t for context chunks, terminated by NULL | 561 | * @param ... pairs of void * & size_t for context chunks, terminated by NULL |
581 | */ | 562 | */ |
582 | void | 563 | void |
583 | GNUNET_CRYPTO_symmetric_derive_iv (struct GNUNET_CRYPTO_SymmetricInitializationVector *iv, | 564 | GNUNET_CRYPTO_symmetric_derive_iv ( |
584 | const struct GNUNET_CRYPTO_SymmetricSessionKey *skey, | 565 | struct GNUNET_CRYPTO_SymmetricInitializationVector *iv, |
585 | const void *salt, | 566 | const struct GNUNET_CRYPTO_SymmetricSessionKey *skey, |
586 | size_t salt_len, ...); | 567 | const void *salt, |
568 | size_t salt_len, | ||
569 | ...); | ||
587 | 570 | ||
588 | 571 | ||
589 | /** | 572 | /** |
@@ -595,11 +578,12 @@ GNUNET_CRYPTO_symmetric_derive_iv (struct GNUNET_CRYPTO_SymmetricInitializationV | |||
595 | * @param argp pairs of void * & size_t for context chunks, terminated by NULL | 578 | * @param argp pairs of void * & size_t for context chunks, terminated by NULL |
596 | */ | 579 | */ |
597 | void | 580 | void |
598 | GNUNET_CRYPTO_symmetric_derive_iv_v (struct GNUNET_CRYPTO_SymmetricInitializationVector *iv, | 581 | GNUNET_CRYPTO_symmetric_derive_iv_v ( |
599 | const struct GNUNET_CRYPTO_SymmetricSessionKey *skey, | 582 | struct GNUNET_CRYPTO_SymmetricInitializationVector *iv, |
600 | const void *salt, | 583 | const struct GNUNET_CRYPTO_SymmetricSessionKey *skey, |
601 | size_t salt_len, | 584 | const void *salt, |
602 | va_list argp); | 585 | size_t salt_len, |
586 | va_list argp); | ||
603 | 587 | ||
604 | 588 | ||
605 | /** | 589 | /** |
@@ -638,7 +622,7 @@ GNUNET_CRYPTO_hash_from_string2 (const char *enc, | |||
638 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if result has the wrong encoding | 622 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if result has the wrong encoding |
639 | */ | 623 | */ |
640 | #define GNUNET_CRYPTO_hash_from_string(enc, result) \ | 624 | #define GNUNET_CRYPTO_hash_from_string(enc, result) \ |
641 | GNUNET_CRYPTO_hash_from_string2 (enc, strlen(enc), result) | 625 | GNUNET_CRYPTO_hash_from_string2 (enc, strlen (enc), result) |
642 | 626 | ||
643 | 627 | ||
644 | /** | 628 | /** |
@@ -732,8 +716,10 @@ GNUNET_CRYPTO_hash_context_abort (struct GNUNET_HashContext *hc); | |||
732 | * @param hmac where to store the hmac | 716 | * @param hmac where to store the hmac |
733 | */ | 717 | */ |
734 | void | 718 | void |
735 | GNUNET_CRYPTO_hmac_raw (const void *key, size_t key_len, | 719 | GNUNET_CRYPTO_hmac_raw (const void *key, |
736 | const void *plaintext, size_t plaintext_len, | 720 | size_t key_len, |
721 | const void *plaintext, | ||
722 | size_t plaintext_len, | ||
737 | struct GNUNET_HashCode *hmac); | 723 | struct GNUNET_HashCode *hmac); |
738 | 724 | ||
739 | 725 | ||
@@ -760,9 +746,9 @@ GNUNET_CRYPTO_hmac (const struct GNUNET_CRYPTO_AuthKey *key, | |||
760 | * @param cls closure | 746 | * @param cls closure |
761 | * @param res resulting hash, NULL on error | 747 | * @param res resulting hash, NULL on error |
762 | */ | 748 | */ |
763 | typedef void | 749 | typedef void (*GNUNET_CRYPTO_HashCompletedCallback) ( |
764 | (*GNUNET_CRYPTO_HashCompletedCallback) (void *cls, | 750 | void *cls, |
765 | const struct GNUNET_HashCode *res); | 751 | const struct GNUNET_HashCode *res); |
766 | 752 | ||
767 | 753 | ||
768 | /** | 754 | /** |
@@ -862,9 +848,10 @@ GNUNET_CRYPTO_hash_xor (const struct GNUNET_HashCode *a, | |||
862 | * @param iv set to a valid initialization vector | 848 | * @param iv set to a valid initialization vector |
863 | */ | 849 | */ |
864 | void | 850 | void |
865 | GNUNET_CRYPTO_hash_to_aes_key (const struct GNUNET_HashCode * hc, | 851 | GNUNET_CRYPTO_hash_to_aes_key ( |
866 | struct GNUNET_CRYPTO_SymmetricSessionKey *skey, | 852 | const struct GNUNET_HashCode *hc, |
867 | struct GNUNET_CRYPTO_SymmetricInitializationVector *iv); | 853 | struct GNUNET_CRYPTO_SymmetricSessionKey *skey, |
854 | struct GNUNET_CRYPTO_SymmetricInitializationVector *iv); | ||
868 | 855 | ||
869 | 856 | ||
870 | /** | 857 | /** |
@@ -877,7 +864,7 @@ GNUNET_CRYPTO_hash_to_aes_key (const struct GNUNET_HashCode * hc, | |||
877 | */ | 864 | */ |
878 | int | 865 | int |
879 | GNUNET_CRYPTO_hash_get_bit (const struct GNUNET_HashCode *code, | 866 | GNUNET_CRYPTO_hash_get_bit (const struct GNUNET_HashCode *code, |
880 | unsigned int bit); | 867 | unsigned int bit); |
881 | 868 | ||
882 | 869 | ||
883 | /** | 870 | /** |
@@ -937,10 +924,12 @@ GNUNET_CRYPTO_hash_xorcmp (const struct GNUNET_HashCode *h1, | |||
937 | * @param argp pair of void * & size_t for context chunks, terminated by NULL | 924 | * @param argp pair of void * & size_t for context chunks, terminated by NULL |
938 | */ | 925 | */ |
939 | void | 926 | void |
940 | GNUNET_CRYPTO_hmac_derive_key_v (struct GNUNET_CRYPTO_AuthKey *key, | 927 | GNUNET_CRYPTO_hmac_derive_key_v ( |
941 | const struct GNUNET_CRYPTO_SymmetricSessionKey *rkey, | 928 | struct GNUNET_CRYPTO_AuthKey *key, |
942 | const void *salt, size_t salt_len, | 929 | const struct GNUNET_CRYPTO_SymmetricSessionKey *rkey, |
943 | va_list argp); | 930 | const void *salt, |
931 | size_t salt_len, | ||
932 | va_list argp); | ||
944 | 933 | ||
945 | 934 | ||
946 | /** | 935 | /** |
@@ -953,10 +942,12 @@ GNUNET_CRYPTO_hmac_derive_key_v (struct GNUNET_CRYPTO_AuthKey *key, | |||
953 | * @param ... pair of void * & size_t for context chunks, terminated by NULL | 942 | * @param ... pair of void * & size_t for context chunks, terminated by NULL |
954 | */ | 943 | */ |
955 | void | 944 | void |
956 | GNUNET_CRYPTO_hmac_derive_key (struct GNUNET_CRYPTO_AuthKey *key, | 945 | GNUNET_CRYPTO_hmac_derive_key ( |
957 | const struct GNUNET_CRYPTO_SymmetricSessionKey *rkey, | 946 | struct GNUNET_CRYPTO_AuthKey *key, |
958 | const void *salt, size_t salt_len, | 947 | const struct GNUNET_CRYPTO_SymmetricSessionKey *rkey, |
959 | ...); | 948 | const void *salt, |
949 | size_t salt_len, | ||
950 | ...); | ||
960 | 951 | ||
961 | 952 | ||
962 | /** | 953 | /** |
@@ -1047,8 +1038,10 @@ GNUNET_CRYPTO_kdf_v (void *result, | |||
1047 | void | 1038 | void |
1048 | GNUNET_CRYPTO_kdf_mod_mpi (gcry_mpi_t *r, | 1039 | GNUNET_CRYPTO_kdf_mod_mpi (gcry_mpi_t *r, |
1049 | gcry_mpi_t n, | 1040 | gcry_mpi_t n, |
1050 | const void *xts, size_t xts_len, | 1041 | const void *xts, |
1051 | const void *skm, size_t skm_len, | 1042 | size_t xts_len, |
1043 | const void *skm, | ||
1044 | size_t skm_len, | ||
1052 | const char *ctx); | 1045 | const char *ctx); |
1053 | 1046 | ||
1054 | 1047 | ||
@@ -1082,8 +1075,9 @@ GNUNET_CRYPTO_kdf (void *result, | |||
1082 | * @param pub where to write the public key | 1075 | * @param pub where to write the public key |
1083 | */ | 1076 | */ |
1084 | void | 1077 | void |
1085 | GNUNET_CRYPTO_ecdsa_key_get_public (const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, | 1078 | GNUNET_CRYPTO_ecdsa_key_get_public ( |
1086 | struct GNUNET_CRYPTO_EcdsaPublicKey *pub); | 1079 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, |
1080 | struct GNUNET_CRYPTO_EcdsaPublicKey *pub); | ||
1087 | 1081 | ||
1088 | /** | 1082 | /** |
1089 | * @ingroup crypto | 1083 | * @ingroup crypto |
@@ -1093,9 +1087,9 @@ GNUNET_CRYPTO_ecdsa_key_get_public (const struct GNUNET_CRYPTO_EcdsaPrivateKey * | |||
1093 | * @param pub where to write the public key | 1087 | * @param pub where to write the public key |
1094 | */ | 1088 | */ |
1095 | void | 1089 | void |
1096 | GNUNET_CRYPTO_eddsa_key_get_public (const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, | 1090 | GNUNET_CRYPTO_eddsa_key_get_public ( |
1097 | struct GNUNET_CRYPTO_EddsaPublicKey *pub); | 1091 | const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, |
1098 | 1092 | struct GNUNET_CRYPTO_EddsaPublicKey *pub); | |
1099 | 1093 | ||
1100 | 1094 | ||
1101 | /** | 1095 | /** |
@@ -1106,8 +1100,9 @@ GNUNET_CRYPTO_eddsa_key_get_public (const struct GNUNET_CRYPTO_EddsaPrivateKey * | |||
1106 | * @param pub where to write the public key | 1100 | * @param pub where to write the public key |
1107 | */ | 1101 | */ |
1108 | void | 1102 | void |
1109 | GNUNET_CRYPTO_ecdhe_key_get_public (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, | 1103 | GNUNET_CRYPTO_ecdhe_key_get_public ( |
1110 | struct GNUNET_CRYPTO_EcdhePublicKey *pub); | 1104 | const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, |
1105 | struct GNUNET_CRYPTO_EcdhePublicKey *pub); | ||
1111 | 1106 | ||
1112 | 1107 | ||
1113 | /** | 1108 | /** |
@@ -1117,7 +1112,18 @@ GNUNET_CRYPTO_ecdhe_key_get_public (const struct GNUNET_CRYPTO_EcdhePrivateKey * | |||
1117 | * @return string representing @a pub | 1112 | * @return string representing @a pub |
1118 | */ | 1113 | */ |
1119 | char * | 1114 | char * |
1120 | GNUNET_CRYPTO_ecdsa_public_key_to_string (const struct GNUNET_CRYPTO_EcdsaPublicKey *pub); | 1115 | GNUNET_CRYPTO_ecdsa_public_key_to_string ( |
1116 | const struct GNUNET_CRYPTO_EcdsaPublicKey *pub); | ||
1117 | |||
1118 | /** | ||
1119 | * Convert a private key to a string. | ||
1120 | * | ||
1121 | * @param priv key to convert | ||
1122 | * @return string representing @a priv | ||
1123 | */ | ||
1124 | char * | ||
1125 | GNUNET_CRYPTO_ecdsa_private_key_to_string ( | ||
1126 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv); | ||
1121 | 1127 | ||
1122 | 1128 | ||
1123 | /** | 1129 | /** |
@@ -1127,7 +1133,8 @@ GNUNET_CRYPTO_ecdsa_public_key_to_string (const struct GNUNET_CRYPTO_EcdsaPublic | |||
1127 | * @return string representing @a pub | 1133 | * @return string representing @a pub |
1128 | */ | 1134 | */ |
1129 | char * | 1135 | char * |
1130 | GNUNET_CRYPTO_eddsa_private_key_to_string (const struct GNUNET_CRYPTO_EddsaPrivateKey *priv); | 1136 | GNUNET_CRYPTO_eddsa_private_key_to_string ( |
1137 | const struct GNUNET_CRYPTO_EddsaPrivateKey *priv); | ||
1131 | 1138 | ||
1132 | 1139 | ||
1133 | /** | 1140 | /** |
@@ -1137,7 +1144,8 @@ GNUNET_CRYPTO_eddsa_private_key_to_string (const struct GNUNET_CRYPTO_EddsaPriva | |||
1137 | * @return string representing @a pub | 1144 | * @return string representing @a pub |
1138 | */ | 1145 | */ |
1139 | char * | 1146 | char * |
1140 | GNUNET_CRYPTO_eddsa_public_key_to_string (const struct GNUNET_CRYPTO_EddsaPublicKey *pub); | 1147 | GNUNET_CRYPTO_eddsa_public_key_to_string ( |
1148 | const struct GNUNET_CRYPTO_EddsaPublicKey *pub); | ||
1141 | 1149 | ||
1142 | 1150 | ||
1143 | /** | 1151 | /** |
@@ -1149,9 +1157,10 @@ GNUNET_CRYPTO_eddsa_public_key_to_string (const struct GNUNET_CRYPTO_EddsaPublic | |||
1149 | * @return #GNUNET_OK on success | 1157 | * @return #GNUNET_OK on success |
1150 | */ | 1158 | */ |
1151 | int | 1159 | int |
1152 | GNUNET_CRYPTO_ecdsa_public_key_from_string (const char *enc, | 1160 | GNUNET_CRYPTO_ecdsa_public_key_from_string ( |
1153 | size_t enclen, | 1161 | const char *enc, |
1154 | struct GNUNET_CRYPTO_EcdsaPublicKey *pub); | 1162 | size_t enclen, |
1163 | struct GNUNET_CRYPTO_EcdsaPublicKey *pub); | ||
1155 | 1164 | ||
1156 | 1165 | ||
1157 | /** | 1166 | /** |
@@ -1163,9 +1172,10 @@ GNUNET_CRYPTO_ecdsa_public_key_from_string (const char *enc, | |||
1163 | * @return #GNUNET_OK on success | 1172 | * @return #GNUNET_OK on success |
1164 | */ | 1173 | */ |
1165 | int | 1174 | int |
1166 | GNUNET_CRYPTO_eddsa_private_key_from_string (const char *enc, | 1175 | GNUNET_CRYPTO_eddsa_private_key_from_string ( |
1167 | size_t enclen, | 1176 | const char *enc, |
1168 | struct GNUNET_CRYPTO_EddsaPrivateKey *pub); | 1177 | size_t enclen, |
1178 | struct GNUNET_CRYPTO_EddsaPrivateKey *pub); | ||
1169 | 1179 | ||
1170 | 1180 | ||
1171 | /** | 1181 | /** |
@@ -1177,9 +1187,10 @@ GNUNET_CRYPTO_eddsa_private_key_from_string (const char *enc, | |||
1177 | * @return #GNUNET_OK on success | 1187 | * @return #GNUNET_OK on success |
1178 | */ | 1188 | */ |
1179 | int | 1189 | int |
1180 | GNUNET_CRYPTO_eddsa_public_key_from_string (const char *enc, | 1190 | GNUNET_CRYPTO_eddsa_public_key_from_string ( |
1181 | size_t enclen, | 1191 | const char *enc, |
1182 | struct GNUNET_CRYPTO_EddsaPublicKey *pub); | 1192 | size_t enclen, |
1193 | struct GNUNET_CRYPTO_EddsaPublicKey *pub); | ||
1183 | 1194 | ||
1184 | 1195 | ||
1185 | /** | 1196 | /** |
@@ -1236,7 +1247,8 @@ struct GNUNET_CONFIGURATION_Handle; | |||
1236 | * permission denied); free using #GNUNET_free | 1247 | * permission denied); free using #GNUNET_free |
1237 | */ | 1248 | */ |
1238 | struct GNUNET_CRYPTO_EddsaPrivateKey * | 1249 | struct GNUNET_CRYPTO_EddsaPrivateKey * |
1239 | GNUNET_CRYPTO_eddsa_key_create_from_configuration (const struct GNUNET_CONFIGURATION_Handle *cfg); | 1250 | GNUNET_CRYPTO_eddsa_key_create_from_configuration ( |
1251 | const struct GNUNET_CONFIGURATION_Handle *cfg); | ||
1240 | 1252 | ||
1241 | 1253 | ||
1242 | /** | 1254 | /** |
@@ -1375,8 +1387,7 @@ struct GNUNET_CRYPTO_EccPoint | |||
1375 | * @return NULL on error | 1387 | * @return NULL on error |
1376 | */ | 1388 | */ |
1377 | struct GNUNET_CRYPTO_EccDlogContext * | 1389 | struct GNUNET_CRYPTO_EccDlogContext * |
1378 | GNUNET_CRYPTO_ecc_dlog_prepare (unsigned int max, | 1390 | GNUNET_CRYPTO_ecc_dlog_prepare (unsigned int max, unsigned int mem); |
1379 | unsigned int mem); | ||
1380 | 1391 | ||
1381 | 1392 | ||
1382 | /** | 1393 | /** |
@@ -1389,7 +1400,7 @@ GNUNET_CRYPTO_ecc_dlog_prepare (unsigned int max, | |||
1389 | */ | 1400 | */ |
1390 | int | 1401 | int |
1391 | GNUNET_CRYPTO_ecc_dlog (struct GNUNET_CRYPTO_EccDlogContext *edc, | 1402 | GNUNET_CRYPTO_ecc_dlog (struct GNUNET_CRYPTO_EccDlogContext *edc, |
1392 | gcry_mpi_point_t input); | 1403 | gcry_mpi_point_t input); |
1393 | 1404 | ||
1394 | 1405 | ||
1395 | /** | 1406 | /** |
@@ -1406,8 +1417,7 @@ GNUNET_CRYPTO_ecc_dlog (struct GNUNET_CRYPTO_EccDlogContext *edc, | |||
1406 | * must be freed using #GNUNET_CRYPTO_ecc_free() | 1417 | * must be freed using #GNUNET_CRYPTO_ecc_free() |
1407 | */ | 1418 | */ |
1408 | gcry_mpi_point_t | 1419 | gcry_mpi_point_t |
1409 | GNUNET_CRYPTO_ecc_dexp (struct GNUNET_CRYPTO_EccDlogContext *edc, | 1420 | GNUNET_CRYPTO_ecc_dexp (struct GNUNET_CRYPTO_EccDlogContext *edc, int val); |
1410 | int val); | ||
1411 | 1421 | ||
1412 | 1422 | ||
1413 | /** | 1423 | /** |
@@ -1421,7 +1431,7 @@ GNUNET_CRYPTO_ecc_dexp (struct GNUNET_CRYPTO_EccDlogContext *edc, | |||
1421 | */ | 1431 | */ |
1422 | gcry_mpi_point_t | 1432 | gcry_mpi_point_t |
1423 | GNUNET_CRYPTO_ecc_dexp_mpi (struct GNUNET_CRYPTO_EccDlogContext *edc, | 1433 | GNUNET_CRYPTO_ecc_dexp_mpi (struct GNUNET_CRYPTO_EccDlogContext *edc, |
1424 | gcry_mpi_t val); | 1434 | gcry_mpi_t val); |
1425 | 1435 | ||
1426 | 1436 | ||
1427 | /** | 1437 | /** |
@@ -1436,7 +1446,7 @@ GNUNET_CRYPTO_ecc_dexp_mpi (struct GNUNET_CRYPTO_EccDlogContext *edc, | |||
1436 | gcry_mpi_point_t | 1446 | gcry_mpi_point_t |
1437 | GNUNET_CRYPTO_ecc_pmul_mpi (struct GNUNET_CRYPTO_EccDlogContext *edc, | 1447 | GNUNET_CRYPTO_ecc_pmul_mpi (struct GNUNET_CRYPTO_EccDlogContext *edc, |
1438 | gcry_mpi_point_t p, | 1448 | gcry_mpi_point_t p, |
1439 | gcry_mpi_t val); | 1449 | gcry_mpi_t val); |
1440 | 1450 | ||
1441 | 1451 | ||
1442 | /** | 1452 | /** |
@@ -1474,8 +1484,8 @@ GNUNET_CRYPTO_ecc_bin_to_point (struct GNUNET_CRYPTO_EccDlogContext *edc, | |||
1474 | */ | 1484 | */ |
1475 | gcry_mpi_point_t | 1485 | gcry_mpi_point_t |
1476 | GNUNET_CRYPTO_ecc_add (struct GNUNET_CRYPTO_EccDlogContext *edc, | 1486 | GNUNET_CRYPTO_ecc_add (struct GNUNET_CRYPTO_EccDlogContext *edc, |
1477 | gcry_mpi_point_t a, | 1487 | gcry_mpi_point_t a, |
1478 | gcry_mpi_point_t b); | 1488 | gcry_mpi_point_t b); |
1479 | 1489 | ||
1480 | 1490 | ||
1481 | /** | 1491 | /** |
@@ -1489,8 +1499,8 @@ GNUNET_CRYPTO_ecc_add (struct GNUNET_CRYPTO_EccDlogContext *edc, | |||
1489 | */ | 1499 | */ |
1490 | void | 1500 | void |
1491 | GNUNET_CRYPTO_ecc_rnd (struct GNUNET_CRYPTO_EccDlogContext *edc, | 1501 | GNUNET_CRYPTO_ecc_rnd (struct GNUNET_CRYPTO_EccDlogContext *edc, |
1492 | gcry_mpi_point_t *r, | 1502 | gcry_mpi_point_t *r, |
1493 | gcry_mpi_point_t *r_inv); | 1503 | gcry_mpi_point_t *r_inv); |
1494 | 1504 | ||
1495 | 1505 | ||
1496 | /** | 1506 | /** |
@@ -1622,9 +1632,10 @@ GNUNET_CRYPTO_ecdh_ecdsa (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, | |||
1622 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | 1632 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success |
1623 | */ | 1633 | */ |
1624 | int | 1634 | int |
1625 | GNUNET_CRYPTO_eddsa_sign (const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, | 1635 | GNUNET_CRYPTO_eddsa_sign ( |
1626 | const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, | 1636 | const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, |
1627 | struct GNUNET_CRYPTO_EddsaSignature *sig); | 1637 | const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, |
1638 | struct GNUNET_CRYPTO_EddsaSignature *sig); | ||
1628 | 1639 | ||
1629 | 1640 | ||
1630 | /** | 1641 | /** |
@@ -1637,9 +1648,10 @@ GNUNET_CRYPTO_eddsa_sign (const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, | |||
1637 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | 1648 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success |
1638 | */ | 1649 | */ |
1639 | int | 1650 | int |
1640 | GNUNET_CRYPTO_ecdsa_sign (const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, | 1651 | GNUNET_CRYPTO_ecdsa_sign ( |
1641 | const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, | 1652 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, |
1642 | struct GNUNET_CRYPTO_EcdsaSignature *sig); | 1653 | const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, |
1654 | struct GNUNET_CRYPTO_EcdsaSignature *sig); | ||
1643 | 1655 | ||
1644 | /** | 1656 | /** |
1645 | * @ingroup crypto | 1657 | * @ingroup crypto |
@@ -1652,11 +1664,11 @@ GNUNET_CRYPTO_ecdsa_sign (const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, | |||
1652 | * @returns #GNUNET_OK if ok, #GNUNET_SYSERR if invalid | 1664 | * @returns #GNUNET_OK if ok, #GNUNET_SYSERR if invalid |
1653 | */ | 1665 | */ |
1654 | int | 1666 | int |
1655 | GNUNET_CRYPTO_eddsa_verify (uint32_t purpose, | 1667 | GNUNET_CRYPTO_eddsa_verify ( |
1656 | const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, | 1668 | uint32_t purpose, |
1657 | const struct GNUNET_CRYPTO_EddsaSignature *sig, | 1669 | const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, |
1658 | const struct GNUNET_CRYPTO_EddsaPublicKey *pub); | 1670 | const struct GNUNET_CRYPTO_EddsaSignature *sig, |
1659 | 1671 | const struct GNUNET_CRYPTO_EddsaPublicKey *pub); | |
1660 | 1672 | ||
1661 | 1673 | ||
1662 | /** | 1674 | /** |
@@ -1670,10 +1682,11 @@ GNUNET_CRYPTO_eddsa_verify (uint32_t purpose, | |||
1670 | * @returns #GNUNET_OK if ok, #GNUNET_SYSERR if invalid | 1682 | * @returns #GNUNET_OK if ok, #GNUNET_SYSERR if invalid |
1671 | */ | 1683 | */ |
1672 | int | 1684 | int |
1673 | GNUNET_CRYPTO_ecdsa_verify (uint32_t purpose, | 1685 | GNUNET_CRYPTO_ecdsa_verify ( |
1674 | const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, | 1686 | uint32_t purpose, |
1675 | const struct GNUNET_CRYPTO_EcdsaSignature *sig, | 1687 | const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, |
1676 | const struct GNUNET_CRYPTO_EcdsaPublicKey *pub); | 1688 | const struct GNUNET_CRYPTO_EcdsaSignature *sig, |
1689 | const struct GNUNET_CRYPTO_EcdsaPublicKey *pub); | ||
1677 | 1690 | ||
1678 | 1691 | ||
1679 | /** | 1692 | /** |
@@ -1690,9 +1703,10 @@ GNUNET_CRYPTO_ecdsa_verify (uint32_t purpose, | |||
1690 | * @return derived private key | 1703 | * @return derived private key |
1691 | */ | 1704 | */ |
1692 | struct GNUNET_CRYPTO_EcdsaPrivateKey * | 1705 | struct GNUNET_CRYPTO_EcdsaPrivateKey * |
1693 | GNUNET_CRYPTO_ecdsa_private_key_derive (const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, | 1706 | GNUNET_CRYPTO_ecdsa_private_key_derive ( |
1694 | const char *label, | 1707 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, |
1695 | const char *context); | 1708 | const char *label, |
1709 | const char *context); | ||
1696 | 1710 | ||
1697 | 1711 | ||
1698 | /** | 1712 | /** |
@@ -1707,10 +1721,11 @@ GNUNET_CRYPTO_ecdsa_private_key_derive (const struct GNUNET_CRYPTO_EcdsaPrivateK | |||
1707 | * @param result where to write the derived public key | 1721 | * @param result where to write the derived public key |
1708 | */ | 1722 | */ |
1709 | void | 1723 | void |
1710 | GNUNET_CRYPTO_ecdsa_public_key_derive (const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, | 1724 | GNUNET_CRYPTO_ecdsa_public_key_derive ( |
1711 | const char *label, | 1725 | const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, |
1712 | const char *context, | 1726 | const char *label, |
1713 | struct GNUNET_CRYPTO_EcdsaPublicKey *result); | 1727 | const char *context, |
1728 | struct GNUNET_CRYPTO_EcdsaPublicKey *result); | ||
1714 | 1729 | ||
1715 | 1730 | ||
1716 | /** | 1731 | /** |
@@ -1722,9 +1737,7 @@ GNUNET_CRYPTO_ecdsa_public_key_derive (const struct GNUNET_CRYPTO_EcdsaPublicKey | |||
1722 | * @param val value to write to @a buf | 1737 | * @param val value to write to @a buf |
1723 | */ | 1738 | */ |
1724 | void | 1739 | void |
1725 | GNUNET_CRYPTO_mpi_print_unsigned (void *buf, | 1740 | GNUNET_CRYPTO_mpi_print_unsigned (void *buf, size_t size, gcry_mpi_t val); |
1726 | size_t size, | ||
1727 | gcry_mpi_t val); | ||
1728 | 1741 | ||
1729 | 1742 | ||
1730 | /** | 1743 | /** |
@@ -1749,8 +1762,9 @@ GNUNET_CRYPTO_mpi_scan_unsigned (gcry_mpi_t *result, | |||
1749 | * @param[out] private_key Where to store the private key? | 1762 | * @param[out] private_key Where to store the private key? |
1750 | */ | 1763 | */ |
1751 | void | 1764 | void |
1752 | GNUNET_CRYPTO_paillier_create (struct GNUNET_CRYPTO_PaillierPublicKey *public_key, | 1765 | GNUNET_CRYPTO_paillier_create ( |
1753 | struct GNUNET_CRYPTO_PaillierPrivateKey *private_key); | 1766 | struct GNUNET_CRYPTO_PaillierPublicKey *public_key, |
1767 | struct GNUNET_CRYPTO_PaillierPrivateKey *private_key); | ||
1754 | 1768 | ||
1755 | 1769 | ||
1756 | /** | 1770 | /** |
@@ -1765,10 +1779,11 @@ GNUNET_CRYPTO_paillier_create (struct GNUNET_CRYPTO_PaillierPublicKey *public_ke | |||
1765 | * or -1 if less than one homomorphic operation is possible | 1779 | * or -1 if less than one homomorphic operation is possible |
1766 | */ | 1780 | */ |
1767 | int | 1781 | int |
1768 | GNUNET_CRYPTO_paillier_encrypt (const struct GNUNET_CRYPTO_PaillierPublicKey *public_key, | 1782 | GNUNET_CRYPTO_paillier_encrypt ( |
1769 | const gcry_mpi_t m, | 1783 | const struct GNUNET_CRYPTO_PaillierPublicKey *public_key, |
1770 | int desired_ops, | 1784 | const gcry_mpi_t m, |
1771 | struct GNUNET_CRYPTO_PaillierCiphertext *ciphertext); | 1785 | int desired_ops, |
1786 | struct GNUNET_CRYPTO_PaillierCiphertext *ciphertext); | ||
1772 | 1787 | ||
1773 | 1788 | ||
1774 | /** | 1789 | /** |
@@ -1780,10 +1795,11 @@ GNUNET_CRYPTO_paillier_encrypt (const struct GNUNET_CRYPTO_PaillierPublicKey *pu | |||
1780 | * @param[out] m Decryption of @a ciphertext with @private_key. | 1795 | * @param[out] m Decryption of @a ciphertext with @private_key. |
1781 | */ | 1796 | */ |
1782 | void | 1797 | void |
1783 | GNUNET_CRYPTO_paillier_decrypt (const struct GNUNET_CRYPTO_PaillierPrivateKey *private_key, | 1798 | GNUNET_CRYPTO_paillier_decrypt ( |
1784 | const struct GNUNET_CRYPTO_PaillierPublicKey *public_key, | 1799 | const struct GNUNET_CRYPTO_PaillierPrivateKey *private_key, |
1785 | const struct GNUNET_CRYPTO_PaillierCiphertext *ciphertext, | 1800 | const struct GNUNET_CRYPTO_PaillierPublicKey *public_key, |
1786 | gcry_mpi_t m); | 1801 | const struct GNUNET_CRYPTO_PaillierCiphertext *ciphertext, |
1802 | gcry_mpi_t m); | ||
1787 | 1803 | ||
1788 | 1804 | ||
1789 | /** | 1805 | /** |
@@ -1800,10 +1816,11 @@ GNUNET_CRYPTO_paillier_decrypt (const struct GNUNET_CRYPTO_PaillierPrivateKey *p | |||
1800 | * #GNUNET_SYSERR if no more homomorphic operations are remaining. | 1816 | * #GNUNET_SYSERR if no more homomorphic operations are remaining. |
1801 | */ | 1817 | */ |
1802 | int | 1818 | int |
1803 | GNUNET_CRYPTO_paillier_hom_add (const struct GNUNET_CRYPTO_PaillierPublicKey *public_key, | 1819 | GNUNET_CRYPTO_paillier_hom_add ( |
1804 | const struct GNUNET_CRYPTO_PaillierCiphertext *c1, | 1820 | const struct GNUNET_CRYPTO_PaillierPublicKey *public_key, |
1805 | const struct GNUNET_CRYPTO_PaillierCiphertext *c2, | 1821 | const struct GNUNET_CRYPTO_PaillierCiphertext *c1, |
1806 | struct GNUNET_CRYPTO_PaillierCiphertext *result); | 1822 | const struct GNUNET_CRYPTO_PaillierCiphertext *c2, |
1823 | struct GNUNET_CRYPTO_PaillierCiphertext *result); | ||
1807 | 1824 | ||
1808 | 1825 | ||
1809 | /** | 1826 | /** |
@@ -1813,14 +1830,13 @@ GNUNET_CRYPTO_paillier_hom_add (const struct GNUNET_CRYPTO_PaillierPublicKey *pu | |||
1813 | * @return the number of remaining homomorphic operations | 1830 | * @return the number of remaining homomorphic operations |
1814 | */ | 1831 | */ |
1815 | int | 1832 | int |
1816 | GNUNET_CRYPTO_paillier_hom_get_remaining (const struct GNUNET_CRYPTO_PaillierCiphertext *c); | 1833 | GNUNET_CRYPTO_paillier_hom_get_remaining ( |
1834 | const struct GNUNET_CRYPTO_PaillierCiphertext *c); | ||
1817 | 1835 | ||
1818 | 1836 | ||
1819 | /* ********* Chaum-style RSA-based blind signatures ******************* */ | 1837 | /* ********* Chaum-style RSA-based blind signatures ******************* */ |
1820 | 1838 | ||
1821 | 1839 | ||
1822 | |||
1823 | |||
1824 | /** | 1840 | /** |
1825 | * The private information of an RSA key pair. | 1841 | * The private information of an RSA key pair. |
1826 | */ | 1842 | */ |
@@ -1877,8 +1893,9 @@ GNUNET_CRYPTO_rsa_private_key_free (struct GNUNET_CRYPTO_RsaPrivateKey *key); | |||
1877 | * @return size of memory allocatedin @a buffer | 1893 | * @return size of memory allocatedin @a buffer |
1878 | */ | 1894 | */ |
1879 | size_t | 1895 | size_t |
1880 | GNUNET_CRYPTO_rsa_private_key_encode (const struct GNUNET_CRYPTO_RsaPrivateKey *key, | 1896 | GNUNET_CRYPTO_rsa_private_key_encode ( |
1881 | char **buffer); | 1897 | const struct GNUNET_CRYPTO_RsaPrivateKey *key, |
1898 | char **buffer); | ||
1882 | 1899 | ||
1883 | 1900 | ||
1884 | /** | 1901 | /** |
@@ -1890,8 +1907,7 @@ GNUNET_CRYPTO_rsa_private_key_encode (const struct GNUNET_CRYPTO_RsaPrivateKey * | |||
1890 | * @return NULL on error | 1907 | * @return NULL on error |
1891 | */ | 1908 | */ |
1892 | struct GNUNET_CRYPTO_RsaPrivateKey * | 1909 | struct GNUNET_CRYPTO_RsaPrivateKey * |
1893 | GNUNET_CRYPTO_rsa_private_key_decode (const char *buf, | 1910 | GNUNET_CRYPTO_rsa_private_key_decode (const char *buf, size_t len); |
1894 | size_t len); | ||
1895 | 1911 | ||
1896 | 1912 | ||
1897 | /** | 1913 | /** |
@@ -1901,7 +1917,8 @@ GNUNET_CRYPTO_rsa_private_key_decode (const char *buf, | |||
1901 | * @return the duplicate key; NULL upon error | 1917 | * @return the duplicate key; NULL upon error |
1902 | */ | 1918 | */ |
1903 | struct GNUNET_CRYPTO_RsaPrivateKey * | 1919 | struct GNUNET_CRYPTO_RsaPrivateKey * |
1904 | GNUNET_CRYPTO_rsa_private_key_dup (const struct GNUNET_CRYPTO_RsaPrivateKey *key); | 1920 | GNUNET_CRYPTO_rsa_private_key_dup ( |
1921 | const struct GNUNET_CRYPTO_RsaPrivateKey *key); | ||
1905 | 1922 | ||
1906 | 1923 | ||
1907 | /** | 1924 | /** |
@@ -1911,7 +1928,8 @@ GNUNET_CRYPTO_rsa_private_key_dup (const struct GNUNET_CRYPTO_RsaPrivateKey *key | |||
1911 | * @retur NULL on error, otherwise the public key | 1928 | * @retur NULL on error, otherwise the public key |
1912 | */ | 1929 | */ |
1913 | struct GNUNET_CRYPTO_RsaPublicKey * | 1930 | struct GNUNET_CRYPTO_RsaPublicKey * |
1914 | GNUNET_CRYPTO_rsa_private_key_get_public (const struct GNUNET_CRYPTO_RsaPrivateKey *priv); | 1931 | GNUNET_CRYPTO_rsa_private_key_get_public ( |
1932 | const struct GNUNET_CRYPTO_RsaPrivateKey *priv); | ||
1915 | 1933 | ||
1916 | 1934 | ||
1917 | /** | 1935 | /** |
@@ -1953,8 +1971,9 @@ GNUNET_CRYPTO_rsa_public_key_free (struct GNUNET_CRYPTO_RsaPublicKey *key); | |||
1953 | * @return size of memory allocated in @a buffer | 1971 | * @return size of memory allocated in @a buffer |
1954 | */ | 1972 | */ |
1955 | size_t | 1973 | size_t |
1956 | GNUNET_CRYPTO_rsa_public_key_encode (const struct GNUNET_CRYPTO_RsaPublicKey *key, | 1974 | GNUNET_CRYPTO_rsa_public_key_encode ( |
1957 | char **buffer); | 1975 | const struct GNUNET_CRYPTO_RsaPublicKey *key, |
1976 | char **buffer); | ||
1958 | 1977 | ||
1959 | 1978 | ||
1960 | /** | 1979 | /** |
@@ -1966,8 +1985,7 @@ GNUNET_CRYPTO_rsa_public_key_encode (const struct GNUNET_CRYPTO_RsaPublicKey *ke | |||
1966 | * @return NULL on error | 1985 | * @return NULL on error |
1967 | */ | 1986 | */ |
1968 | struct GNUNET_CRYPTO_RsaPublicKey * | 1987 | struct GNUNET_CRYPTO_RsaPublicKey * |
1969 | GNUNET_CRYPTO_rsa_public_key_decode (const char *buf, | 1988 | GNUNET_CRYPTO_rsa_public_key_decode (const char *buf, size_t len); |
1970 | size_t len); | ||
1971 | 1989 | ||
1972 | 1990 | ||
1973 | /** | 1991 | /** |
@@ -2056,7 +2074,7 @@ GNUNET_CRYPTO_rsa_sign_blinded (const struct GNUNET_CRYPTO_RsaPrivateKey *key, | |||
2056 | */ | 2074 | */ |
2057 | struct GNUNET_CRYPTO_RsaSignature * | 2075 | struct GNUNET_CRYPTO_RsaSignature * |
2058 | GNUNET_CRYPTO_rsa_sign_fdh (const struct GNUNET_CRYPTO_RsaPrivateKey *key, | 2076 | GNUNET_CRYPTO_rsa_sign_fdh (const struct GNUNET_CRYPTO_RsaPrivateKey *key, |
2059 | const struct GNUNET_HashCode *hash); | 2077 | const struct GNUNET_HashCode *hash); |
2060 | 2078 | ||
2061 | 2079 | ||
2062 | /** | 2080 | /** |
@@ -2076,8 +2094,9 @@ GNUNET_CRYPTO_rsa_signature_free (struct GNUNET_CRYPTO_RsaSignature *sig); | |||
2076 | * @return size of memory allocated in @a buffer | 2094 | * @return size of memory allocated in @a buffer |
2077 | */ | 2095 | */ |
2078 | size_t | 2096 | size_t |
2079 | GNUNET_CRYPTO_rsa_signature_encode (const struct GNUNET_CRYPTO_RsaSignature *sig, | 2097 | GNUNET_CRYPTO_rsa_signature_encode ( |
2080 | char **buffer); | 2098 | const struct GNUNET_CRYPTO_RsaSignature *sig, |
2099 | char **buffer); | ||
2081 | 2100 | ||
2082 | 2101 | ||
2083 | /** | 2102 | /** |
@@ -2089,8 +2108,7 @@ GNUNET_CRYPTO_rsa_signature_encode (const struct GNUNET_CRYPTO_RsaSignature *sig | |||
2089 | * @return NULL on error | 2108 | * @return NULL on error |
2090 | */ | 2109 | */ |
2091 | struct GNUNET_CRYPTO_RsaSignature * | 2110 | struct GNUNET_CRYPTO_RsaSignature * |
2092 | GNUNET_CRYPTO_rsa_signature_decode (const char *buf, | 2111 | GNUNET_CRYPTO_rsa_signature_decode (const char *buf, size_t len); |
2093 | size_t len); | ||
2094 | 2112 | ||
2095 | 2113 | ||
2096 | /** | 2114 | /** |
@@ -2115,8 +2133,8 @@ GNUNET_CRYPTO_rsa_signature_dup (const struct GNUNET_CRYPTO_RsaSignature *sig); | |||
2115 | */ | 2133 | */ |
2116 | struct GNUNET_CRYPTO_RsaSignature * | 2134 | struct GNUNET_CRYPTO_RsaSignature * |
2117 | GNUNET_CRYPTO_rsa_unblind (const struct GNUNET_CRYPTO_RsaSignature *sig, | 2135 | GNUNET_CRYPTO_rsa_unblind (const struct GNUNET_CRYPTO_RsaSignature *sig, |
2118 | const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks, | 2136 | const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks, |
2119 | struct GNUNET_CRYPTO_RsaPublicKey *pkey); | 2137 | struct GNUNET_CRYPTO_RsaPublicKey *pkey); |
2120 | 2138 | ||
2121 | 2139 | ||
2122 | /** | 2140 | /** |
@@ -2130,11 +2148,11 @@ GNUNET_CRYPTO_rsa_unblind (const struct GNUNET_CRYPTO_RsaSignature *sig, | |||
2130 | */ | 2148 | */ |
2131 | int | 2149 | int |
2132 | GNUNET_CRYPTO_rsa_verify (const struct GNUNET_HashCode *hash, | 2150 | GNUNET_CRYPTO_rsa_verify (const struct GNUNET_HashCode *hash, |
2133 | const struct GNUNET_CRYPTO_RsaSignature *sig, | 2151 | const struct GNUNET_CRYPTO_RsaSignature *sig, |
2134 | const struct GNUNET_CRYPTO_RsaPublicKey *public_key); | 2152 | const struct GNUNET_CRYPTO_RsaPublicKey *public_key); |
2135 | 2153 | ||
2136 | 2154 | ||
2137 | #if 0 /* keep Emacsens' auto-indent happy */ | 2155 | #if 0 /* keep Emacsens' auto-indent happy */ |
2138 | { | 2156 | { |
2139 | #endif | 2157 | #endif |
2140 | #ifdef __cplusplus | 2158 | #ifdef __cplusplus |