diff options
author | Christian Grothoff <christian@grothoff.org> | 2020-12-19 18:43:38 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2020-12-19 18:43:38 +0100 |
commit | 3636ea628d051cf2ba7a9038c50528c561d0aeaa (patch) | |
tree | 87664b904950052e8b6997a371ed5ecb1ea4b310 /src/util/crypto_ecc.c | |
parent | 74d7528e6bd53cf5acc939c63a5be74a001e5ce1 (diff) | |
download | gnunet-3636ea628d051cf2ba7a9038c50528c561d0aeaa.tar.gz gnunet-3636ea628d051cf2ba7a9038c50528c561d0aeaa.zip |
change GNUNET_DISK_fn_write() to always do atomic writes and to NOT overwrite existing files; also change the return value to not return the size of the written file but GNUNET_OK on success, and integrate creating the directory if needed; breaks API, hence bumping libgnunetutil version
Diffstat (limited to 'src/util/crypto_ecc.c')
-rw-r--r-- | src/util/crypto_ecc.c | 251 |
1 files changed, 12 insertions, 239 deletions
diff --git a/src/util/crypto_ecc.c b/src/util/crypto_ecc.c index 019dbe94e..bc58142c2 100644 --- a/src/util/crypto_ecc.c +++ b/src/util/crypto_ecc.c | |||
@@ -166,12 +166,6 @@ decode_private_ecdsa_key (const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv) | |||
166 | } | 166 | } |
167 | 167 | ||
168 | 168 | ||
169 | /** | ||
170 | * Extract the public key for the given private key. | ||
171 | * | ||
172 | * @param priv the private key | ||
173 | * @param pub where to write the public key | ||
174 | */ | ||
175 | void | 169 | void |
176 | GNUNET_CRYPTO_ecdsa_key_get_public ( | 170 | GNUNET_CRYPTO_ecdsa_key_get_public ( |
177 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, | 171 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, |
@@ -183,12 +177,6 @@ GNUNET_CRYPTO_ecdsa_key_get_public ( | |||
183 | } | 177 | } |
184 | 178 | ||
185 | 179 | ||
186 | /** | ||
187 | * Extract the public key for the given private key. | ||
188 | * | ||
189 | * @param priv the private key | ||
190 | * @param pub where to write the public key | ||
191 | */ | ||
192 | void | 180 | void |
193 | GNUNET_CRYPTO_eddsa_key_get_public ( | 181 | GNUNET_CRYPTO_eddsa_key_get_public ( |
194 | const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, | 182 | const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, |
@@ -205,12 +193,6 @@ GNUNET_CRYPTO_eddsa_key_get_public ( | |||
205 | } | 193 | } |
206 | 194 | ||
207 | 195 | ||
208 | /** | ||
209 | * Extract the public key for the given private key. | ||
210 | * | ||
211 | * @param priv the private key | ||
212 | * @param pub where to write the public key | ||
213 | */ | ||
214 | void | 196 | void |
215 | GNUNET_CRYPTO_ecdhe_key_get_public ( | 197 | GNUNET_CRYPTO_ecdhe_key_get_public ( |
216 | const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, | 198 | const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, |
@@ -222,12 +204,6 @@ GNUNET_CRYPTO_ecdhe_key_get_public ( | |||
222 | } | 204 | } |
223 | 205 | ||
224 | 206 | ||
225 | /** | ||
226 | * Convert a public key to a string. | ||
227 | * | ||
228 | * @param pub key to convert | ||
229 | * @return string representing @a pub | ||
230 | */ | ||
231 | char * | 207 | char * |
232 | GNUNET_CRYPTO_ecdsa_public_key_to_string ( | 208 | GNUNET_CRYPTO_ecdsa_public_key_to_string ( |
233 | const struct GNUNET_CRYPTO_EcdsaPublicKey *pub) | 209 | const struct GNUNET_CRYPTO_EcdsaPublicKey *pub) |
@@ -255,12 +231,6 @@ GNUNET_CRYPTO_ecdsa_public_key_to_string ( | |||
255 | } | 231 | } |
256 | 232 | ||
257 | 233 | ||
258 | /** | ||
259 | * Convert a public key to a string. | ||
260 | * | ||
261 | * @param pub key to convert | ||
262 | * @return string representing @a pub | ||
263 | */ | ||
264 | char * | 234 | char * |
265 | GNUNET_CRYPTO_eddsa_public_key_to_string ( | 235 | GNUNET_CRYPTO_eddsa_public_key_to_string ( |
266 | const struct GNUNET_CRYPTO_EddsaPublicKey *pub) | 236 | const struct GNUNET_CRYPTO_EddsaPublicKey *pub) |
@@ -288,12 +258,6 @@ GNUNET_CRYPTO_eddsa_public_key_to_string ( | |||
288 | } | 258 | } |
289 | 259 | ||
290 | 260 | ||
291 | /** | ||
292 | * Convert a private key to a string. | ||
293 | * | ||
294 | * @param priv key to convert | ||
295 | * @return string representing @a pub | ||
296 | */ | ||
297 | char * | 261 | char * |
298 | GNUNET_CRYPTO_eddsa_private_key_to_string ( | 262 | GNUNET_CRYPTO_eddsa_private_key_to_string ( |
299 | const struct GNUNET_CRYPTO_EddsaPrivateKey *priv) | 263 | const struct GNUNET_CRYPTO_EddsaPrivateKey *priv) |
@@ -321,12 +285,6 @@ GNUNET_CRYPTO_eddsa_private_key_to_string ( | |||
321 | } | 285 | } |
322 | 286 | ||
323 | 287 | ||
324 | /** | ||
325 | * Convert a private key to a string. | ||
326 | * | ||
327 | * @param priv key to convert | ||
328 | * @return string representing @a priv | ||
329 | */ | ||
330 | char * | 288 | char * |
331 | GNUNET_CRYPTO_ecdsa_private_key_to_string ( | 289 | GNUNET_CRYPTO_ecdsa_private_key_to_string ( |
332 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv) | 290 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv) |
@@ -354,15 +312,7 @@ GNUNET_CRYPTO_ecdsa_private_key_to_string ( | |||
354 | } | 312 | } |
355 | 313 | ||
356 | 314 | ||
357 | /** | 315 | enum GNUNET_GenericReturnValue |
358 | * Convert a string representing a public key to a public key. | ||
359 | * | ||
360 | * @param enc encoded public key | ||
361 | * @param enclen number of bytes in @a enc (without 0-terminator) | ||
362 | * @param pub where to store the public key | ||
363 | * @return #GNUNET_OK on success | ||
364 | */ | ||
365 | int | ||
366 | GNUNET_CRYPTO_ecdsa_public_key_from_string ( | 316 | GNUNET_CRYPTO_ecdsa_public_key_from_string ( |
367 | const char *enc, | 317 | const char *enc, |
368 | size_t enclen, | 318 | size_t enclen, |
@@ -387,15 +337,7 @@ GNUNET_CRYPTO_ecdsa_public_key_from_string ( | |||
387 | } | 337 | } |
388 | 338 | ||
389 | 339 | ||
390 | /** | 340 | enum GNUNET_GenericReturnValue |
391 | * Convert a string representing a public key to a public key. | ||
392 | * | ||
393 | * @param enc encoded public key | ||
394 | * @param enclen number of bytes in @a enc (without 0-terminator) | ||
395 | * @param pub where to store the public key | ||
396 | * @return #GNUNET_OK on success | ||
397 | */ | ||
398 | int | ||
399 | GNUNET_CRYPTO_eddsa_public_key_from_string ( | 341 | GNUNET_CRYPTO_eddsa_public_key_from_string ( |
400 | const char *enc, | 342 | const char *enc, |
401 | size_t enclen, | 343 | size_t enclen, |
@@ -420,15 +362,7 @@ GNUNET_CRYPTO_eddsa_public_key_from_string ( | |||
420 | } | 362 | } |
421 | 363 | ||
422 | 364 | ||
423 | /** | 365 | enum GNUNET_GenericReturnValue |
424 | * Convert a string representing a private key to a private key. | ||
425 | * | ||
426 | * @param enc encoded public key | ||
427 | * @param enclen number of bytes in @a enc (without 0-terminator) | ||
428 | * @param priv where to store the private key | ||
429 | * @return #GNUNET_OK on success | ||
430 | */ | ||
431 | int | ||
432 | GNUNET_CRYPTO_eddsa_private_key_from_string ( | 366 | GNUNET_CRYPTO_eddsa_private_key_from_string ( |
433 | const char *enc, | 367 | const char *enc, |
434 | size_t enclen, | 368 | size_t enclen, |
@@ -460,12 +394,6 @@ GNUNET_CRYPTO_eddsa_private_key_from_string ( | |||
460 | } | 394 | } |
461 | 395 | ||
462 | 396 | ||
463 | /** | ||
464 | * @ingroup crypto | ||
465 | * Clear memory that was used to store a private key. | ||
466 | * | ||
467 | * @param pk location of the key | ||
468 | */ | ||
469 | void | 397 | void |
470 | GNUNET_CRYPTO_ecdhe_key_clear (struct GNUNET_CRYPTO_EcdhePrivateKey *pk) | 398 | GNUNET_CRYPTO_ecdhe_key_clear (struct GNUNET_CRYPTO_EcdhePrivateKey *pk) |
471 | { | 399 | { |
@@ -473,12 +401,6 @@ GNUNET_CRYPTO_ecdhe_key_clear (struct GNUNET_CRYPTO_EcdhePrivateKey *pk) | |||
473 | } | 401 | } |
474 | 402 | ||
475 | 403 | ||
476 | /** | ||
477 | * @ingroup crypto | ||
478 | * Clear memory that was used to store a private key. | ||
479 | * | ||
480 | * @param pk location of the key | ||
481 | */ | ||
482 | void | 404 | void |
483 | GNUNET_CRYPTO_ecdsa_key_clear (struct GNUNET_CRYPTO_EcdsaPrivateKey *pk) | 405 | GNUNET_CRYPTO_ecdsa_key_clear (struct GNUNET_CRYPTO_EcdsaPrivateKey *pk) |
484 | { | 406 | { |
@@ -486,12 +408,6 @@ GNUNET_CRYPTO_ecdsa_key_clear (struct GNUNET_CRYPTO_EcdsaPrivateKey *pk) | |||
486 | } | 408 | } |
487 | 409 | ||
488 | 410 | ||
489 | /** | ||
490 | * @ingroup crypto | ||
491 | * Clear memory that was used to store a private key. | ||
492 | * | ||
493 | * @param pk location of the key | ||
494 | */ | ||
495 | void | 411 | void |
496 | GNUNET_CRYPTO_eddsa_key_clear (struct GNUNET_CRYPTO_EddsaPrivateKey *pk) | 412 | GNUNET_CRYPTO_eddsa_key_clear (struct GNUNET_CRYPTO_EddsaPrivateKey *pk) |
497 | { | 413 | { |
@@ -499,11 +415,6 @@ GNUNET_CRYPTO_eddsa_key_clear (struct GNUNET_CRYPTO_EddsaPrivateKey *pk) | |||
499 | } | 415 | } |
500 | 416 | ||
501 | 417 | ||
502 | /** | ||
503 | * Create a new private key. | ||
504 | * | ||
505 | * @param[out] pk fresh private key | ||
506 | */ | ||
507 | void | 418 | void |
508 | GNUNET_CRYPTO_ecdhe_key_create (struct GNUNET_CRYPTO_EcdhePrivateKey *pk) | 419 | GNUNET_CRYPTO_ecdhe_key_create (struct GNUNET_CRYPTO_EcdhePrivateKey *pk) |
509 | { | 420 | { |
@@ -515,11 +426,6 @@ GNUNET_CRYPTO_ecdhe_key_create (struct GNUNET_CRYPTO_EcdhePrivateKey *pk) | |||
515 | } | 426 | } |
516 | 427 | ||
517 | 428 | ||
518 | /** | ||
519 | * Create a new private key. | ||
520 | * | ||
521 | * @param[out] pk private key to initialize | ||
522 | */ | ||
523 | void | 429 | void |
524 | GNUNET_CRYPTO_ecdsa_key_create (struct GNUNET_CRYPTO_EcdsaPrivateKey *pk) | 430 | GNUNET_CRYPTO_ecdsa_key_create (struct GNUNET_CRYPTO_EcdsaPrivateKey *pk) |
525 | { | 431 | { |
@@ -535,11 +441,6 @@ GNUNET_CRYPTO_ecdsa_key_create (struct GNUNET_CRYPTO_EcdsaPrivateKey *pk) | |||
535 | } | 441 | } |
536 | 442 | ||
537 | 443 | ||
538 | /** | ||
539 | * Create a new private key. | ||
540 | * | ||
541 | * @param[out] pk set to fresh private key | ||
542 | */ | ||
543 | void | 444 | void |
544 | GNUNET_CRYPTO_eddsa_key_create (struct GNUNET_CRYPTO_EddsaPrivateKey *pk) | 445 | GNUNET_CRYPTO_eddsa_key_create (struct GNUNET_CRYPTO_EddsaPrivateKey *pk) |
545 | { | 446 | { |
@@ -560,11 +461,6 @@ GNUNET_CRYPTO_eddsa_key_create (struct GNUNET_CRYPTO_EddsaPrivateKey *pk) | |||
560 | } | 461 | } |
561 | 462 | ||
562 | 463 | ||
563 | /** | ||
564 | * Get the shared private key we use for anonymous users. | ||
565 | * | ||
566 | * @return "anonymous" private key | ||
567 | */ | ||
568 | const struct GNUNET_CRYPTO_EcdsaPrivateKey * | 464 | const struct GNUNET_CRYPTO_EcdsaPrivateKey * |
569 | GNUNET_CRYPTO_ecdsa_key_get_anonymous () | 465 | GNUNET_CRYPTO_ecdsa_key_get_anonymous () |
570 | { | 466 | { |
@@ -629,19 +525,7 @@ data_to_ecdsa_value (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose) | |||
629 | } | 525 | } |
630 | 526 | ||
631 | 527 | ||
632 | /** | 528 | enum GNUNET_GenericReturnValue |
633 | * Sign a given block. The @a purpose data is the | ||
634 | * beginning of the data of which the signature is to be | ||
635 | * created. The `size` field in @a purpose must correctly | ||
636 | * indicate the number of bytes of the data structure, including | ||
637 | * its header. | ||
638 | * | ||
639 | * @param priv private key to use for the signing | ||
640 | * @param purpose what to sign (size, purpose) | ||
641 | * @param sig where to write the signature | ||
642 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | ||
643 | */ | ||
644 | int | ||
645 | GNUNET_CRYPTO_ecdsa_sign_ ( | 529 | GNUNET_CRYPTO_ecdsa_sign_ ( |
646 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, | 530 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, |
647 | const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, | 531 | const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, |
@@ -691,19 +575,7 @@ GNUNET_CRYPTO_ecdsa_sign_ ( | |||
691 | } | 575 | } |
692 | 576 | ||
693 | 577 | ||
694 | /** | 578 | enum GNUNET_GenericReturnValue |
695 | * Sign a given block. The @a purpose data is the | ||
696 | * beginning of the data of which the signature is to be | ||
697 | * created. The `size` field in @a purpose must correctly | ||
698 | * indicate the number of bytes of the data structure, including | ||
699 | * its header. | ||
700 | * | ||
701 | * @param priv private key to use for the signing | ||
702 | * @param purpose what to sign (size, purpose) | ||
703 | * @param sig where to write the signature | ||
704 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | ||
705 | */ | ||
706 | int | ||
707 | GNUNET_CRYPTO_eddsa_sign_ ( | 579 | GNUNET_CRYPTO_eddsa_sign_ ( |
708 | const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, | 580 | const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, |
709 | const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, | 581 | const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, |
@@ -727,21 +599,7 @@ GNUNET_CRYPTO_eddsa_sign_ ( | |||
727 | } | 599 | } |
728 | 600 | ||
729 | 601 | ||
730 | /** | 602 | enum GNUNET_GenericReturnValue |
731 | * Verify signature. The @a validate data is the | ||
732 | * beginning of the data of which the signature is to be | ||
733 | * verified. The `size` field in @a validate must correctly | ||
734 | * indicate the number of bytes of the data structure, including | ||
735 | * its header. If @a purpose does not match the purpose given | ||
736 | * in @a validate (the latter | ||
737 | * | ||
738 | * @param purpose what is the purpose that the signature should have? | ||
739 | * @param validate block to validate (size, purpose, data) | ||
740 | * @param sig signature that is being validated | ||
741 | * @param pub public key of the signer | ||
742 | * @returns #GNUNET_OK if ok, #GNUNET_SYSERR if invalid | ||
743 | */ | ||
744 | int | ||
745 | GNUNET_CRYPTO_ecdsa_verify_ ( | 603 | GNUNET_CRYPTO_ecdsa_verify_ ( |
746 | uint32_t purpose, | 604 | uint32_t purpose, |
747 | const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, | 605 | const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, |
@@ -800,22 +658,7 @@ GNUNET_CRYPTO_ecdsa_verify_ ( | |||
800 | } | 658 | } |
801 | 659 | ||
802 | 660 | ||
803 | /** | 661 | enum GNUNET_GenericReturnValue |
804 | * Verify signature. The @a validate data is the | ||
805 | * beginning of the data of which the signature is to be | ||
806 | * verified. The `size` field in @a validate must correctly | ||
807 | * indicate the number of bytes of the data structure, including | ||
808 | * its header. If @a purpose does not match the purpose given | ||
809 | * in @a validate (the latter must be in big endian), signature | ||
810 | * verification fails. | ||
811 | * | ||
812 | * @param purpose what is the purpose that the signature should have? | ||
813 | * @param validate block to validate (size, purpose, data) | ||
814 | * @param sig signature that is being validated | ||
815 | * @param pub public key of the signer | ||
816 | * @returns #GNUNET_OK if ok, #GNUNET_SYSERR if invalid | ||
817 | */ | ||
818 | int | ||
819 | GNUNET_CRYPTO_eddsa_verify_ ( | 662 | GNUNET_CRYPTO_eddsa_verify_ ( |
820 | uint32_t purpose, | 663 | uint32_t purpose, |
821 | const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, | 664 | const struct GNUNET_CRYPTO_EccSignaturePurpose *validate, |
@@ -838,15 +681,7 @@ GNUNET_CRYPTO_eddsa_verify_ ( | |||
838 | } | 681 | } |
839 | 682 | ||
840 | 683 | ||
841 | /** | 684 | enum GNUNET_GenericReturnValue |
842 | * Derive key material from a public and a private ECDHE key. | ||
843 | * | ||
844 | * @param priv private key to use for the ECDH (x) | ||
845 | * @param pub public key to use for the ECDH (yG) | ||
846 | * @param key_material where to write the key material (xyG) | ||
847 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | ||
848 | */ | ||
849 | int | ||
850 | GNUNET_CRYPTO_ecc_ecdh (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, | 685 | GNUNET_CRYPTO_ecc_ecdh (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, |
851 | const struct GNUNET_CRYPTO_EcdhePublicKey *pub, | 686 | const struct GNUNET_CRYPTO_EcdhePublicKey *pub, |
852 | struct GNUNET_HashCode *key_material) | 687 | struct GNUNET_HashCode *key_material) |
@@ -895,18 +730,6 @@ derive_h (const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, | |||
895 | } | 730 | } |
896 | 731 | ||
897 | 732 | ||
898 | /** | ||
899 | * Derive a private key from a given private key and a label. | ||
900 | * Essentially calculates a private key 'd = H(l,P) * x mod n' | ||
901 | * where n is the size of the ECC group and P is the public | ||
902 | * key associated with the private key 'd'. | ||
903 | * | ||
904 | * @param priv original private key | ||
905 | * @param label label to use for key deriviation | ||
906 | * @param context additional context to use for HKDF of 'h'; | ||
907 | * typically the name of the subsystem/application | ||
908 | * @return derived private key | ||
909 | */ | ||
910 | struct GNUNET_CRYPTO_EcdsaPrivateKey * | 733 | struct GNUNET_CRYPTO_EcdsaPrivateKey * |
911 | GNUNET_CRYPTO_ecdsa_private_key_derive ( | 734 | GNUNET_CRYPTO_ecdsa_private_key_derive ( |
912 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, | 735 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, |
@@ -949,16 +772,6 @@ GNUNET_CRYPTO_ecdsa_private_key_derive ( | |||
949 | } | 772 | } |
950 | 773 | ||
951 | 774 | ||
952 | /** | ||
953 | * Derive a public key from a given public key and a label. | ||
954 | * Essentially calculates a public key 'V = H(l,P) * P'. | ||
955 | * | ||
956 | * @param pub original public key | ||
957 | * @param label label to use for key derivation | ||
958 | * @param context additional context to use for HKDF of 'h'; | ||
959 | * typically the name of the subsystem/application | ||
960 | * @param result where to write the derived public key | ||
961 | */ | ||
962 | void | 775 | void |
963 | GNUNET_CRYPTO_ecdsa_public_key_derive ( | 776 | GNUNET_CRYPTO_ecdsa_public_key_derive ( |
964 | const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, | 777 | const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, |
@@ -1010,17 +823,7 @@ GNUNET_CRYPTO_ecdsa_public_key_derive ( | |||
1010 | } | 823 | } |
1011 | 824 | ||
1012 | 825 | ||
1013 | /** | 826 | enum GNUNET_GenericReturnValue |
1014 | * @ingroup crypto | ||
1015 | * Derive key material from a ECDH public key and a private EdDSA key. | ||
1016 | * Dual to #GNUNET_CRRYPTO_ecdh_eddsa. | ||
1017 | * | ||
1018 | * @param priv private key from EdDSA to use for the ECDH (x) | ||
1019 | * @param pub public key to use for the ECDH (yG) | ||
1020 | * @param key_material where to write the key material H(h(x)yG) | ||
1021 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | ||
1022 | */ | ||
1023 | int | ||
1024 | GNUNET_CRYPTO_eddsa_ecdh (const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, | 827 | GNUNET_CRYPTO_eddsa_ecdh (const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, |
1025 | const struct GNUNET_CRYPTO_EcdhePublicKey *pub, | 828 | const struct GNUNET_CRYPTO_EcdhePublicKey *pub, |
1026 | struct GNUNET_HashCode *key_material) | 829 | struct GNUNET_HashCode *key_material) |
@@ -1042,17 +845,7 @@ GNUNET_CRYPTO_eddsa_ecdh (const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, | |||
1042 | } | 845 | } |
1043 | 846 | ||
1044 | 847 | ||
1045 | /** | 848 | enum GNUNET_GenericReturnValue |
1046 | * @ingroup crypto | ||
1047 | * Derive key material from a ECDH public key and a private ECDSA key. | ||
1048 | * Dual to #GNUNET_CRRYPTO_ecdh_eddsa. | ||
1049 | * | ||
1050 | * @param priv private key from ECDSA to use for the ECDH (x) | ||
1051 | * @param pub public key to use for the ECDH (yG) | ||
1052 | * @param key_material where to write the key material H(h(x)yG) | ||
1053 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | ||
1054 | */ | ||
1055 | int | ||
1056 | GNUNET_CRYPTO_ecdsa_ecdh (const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, | 849 | GNUNET_CRYPTO_ecdsa_ecdh (const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, |
1057 | const struct GNUNET_CRYPTO_EcdhePublicKey *pub, | 850 | const struct GNUNET_CRYPTO_EcdhePublicKey *pub, |
1058 | struct GNUNET_HashCode *key_material) | 851 | struct GNUNET_HashCode *key_material) |
@@ -1070,17 +863,7 @@ GNUNET_CRYPTO_ecdsa_ecdh (const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv, | |||
1070 | } | 863 | } |
1071 | 864 | ||
1072 | 865 | ||
1073 | /** | 866 | enum GNUNET_GenericReturnValue |
1074 | * @ingroup crypto | ||
1075 | * Derive key material from a EdDSA public key and a private ECDH key. | ||
1076 | * Dual to #GNUNET_CRRYPTO_eddsa_ecdh. | ||
1077 | * | ||
1078 | * @param priv private key to use for the ECDH (y) | ||
1079 | * @param pub public key from EdDSA to use for the ECDH (X=h(x)G) | ||
1080 | * @param key_material where to write the key material H(yX)=H(h(x)yG) | ||
1081 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | ||
1082 | */ | ||
1083 | int | ||
1084 | GNUNET_CRYPTO_ecdh_eddsa (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, | 867 | GNUNET_CRYPTO_ecdh_eddsa (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, |
1085 | const struct GNUNET_CRYPTO_EddsaPublicKey *pub, | 868 | const struct GNUNET_CRYPTO_EddsaPublicKey *pub, |
1086 | struct GNUNET_HashCode *key_material) | 869 | struct GNUNET_HashCode *key_material) |
@@ -1097,17 +880,7 @@ GNUNET_CRYPTO_ecdh_eddsa (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, | |||
1097 | } | 880 | } |
1098 | 881 | ||
1099 | 882 | ||
1100 | /** | 883 | enum GNUNET_GenericReturnValue |
1101 | * @ingroup crypto | ||
1102 | * Derive key material from a ECDSA public key and a private ECDH key. | ||
1103 | * Dual to #GNUNET_CRYPTO_ecdsa_ecdh. | ||
1104 | * | ||
1105 | * @param priv private key to use for the ECDH (y) | ||
1106 | * @param pub public key from ECDSA to use for the ECDH (X=h(x)G) | ||
1107 | * @param key_material where to write the key material H(yX)=H(h(x)yG) | ||
1108 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | ||
1109 | */ | ||
1110 | int | ||
1111 | GNUNET_CRYPTO_ecdh_ecdsa (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, | 884 | GNUNET_CRYPTO_ecdh_ecdsa (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, |
1112 | const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, | 885 | const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, |
1113 | struct GNUNET_HashCode *key_material) | 886 | struct GNUNET_HashCode *key_material) |