Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 
 

89 wiersze
3.5 KiB

  1. /* Copyright (c) 2015, Google Inc.
  2. *
  3. * Permission to use, copy, modify, and/or distribute this software for any
  4. * purpose with or without fee is hereby granted, provided that the above
  5. * copyright notice and this permission notice appear in all copies.
  6. *
  7. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  8. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  9. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
  10. * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  11. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  12. * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  13. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
  14. #ifndef OPENSSL_HEADER_CURVE25519_H
  15. #define OPENSSL_HEADER_CURVE25519_H
  16. #include <openssl/base.h>
  17. #if defined(__cplusplus)
  18. extern "C" {
  19. #endif
  20. /* Curve25519.
  21. *
  22. * Curve25519 is an elliptic curve. See
  23. * https://tools.ietf.org/html/draft-irtf-cfrg-curves-11. */
  24. /* X25519.
  25. *
  26. * Curve25519 is an elliptic curve. The same name is also sometimes used for
  27. * the Diffie-Hellman primitive built from it but “X25519” is a more precise
  28. * name for that, which is the one used here. See http://cr.yp.to/ecdh.html and
  29. * https://tools.ietf.org/html/draft-irtf-cfrg-curves-11. */
  30. /* X25519_keypair sets |out_public_value| and |out_private_key| to a freshly
  31. * generated, public–private key pair. */
  32. OPENSSL_EXPORT void X25519_keypair(uint8_t out_public_value[32],
  33. uint8_t out_private_key[32]);
  34. /* X25519 writes a shared key to |out_shared_key| that is calculated from the
  35. * given private key and the peer's public value. It returns one on success and
  36. * zero on error.
  37. *
  38. * Don't use the shared key directly, rather use a KDF and also include the two
  39. * public values as inputs. */
  40. OPENSSL_EXPORT int X25519(uint8_t out_shared_key[32],
  41. const uint8_t private_key[32],
  42. const uint8_t peers_public_value[32]);
  43. /* X25519_public_from_private calculates a Diffie-Hellman public value from the
  44. * given private key and writes it to |out_public_value|. */
  45. OPENSSL_EXPORT void X25519_public_from_private(uint8_t out_public_value[32],
  46. const uint8_t private_key[32]);
  47. /* Ed25519.
  48. *
  49. * Ed25519 is a signature scheme using a twisted-Edwards curve that is
  50. * birationally equivalent to curve25519. */
  51. /* ED25519_keypair sets |out_public_key| and |out_private_key| to a freshly
  52. * generated, public–private key pair. */
  53. OPENSSL_EXPORT void ED25519_keypair(uint8_t out_public_key[32],
  54. uint8_t out_private_key[64]);
  55. /* ED25519_sign sets |out_sig| to be a signature of |message_len| bytes from
  56. * |message| using |private_key|. It returns one on success or zero on
  57. * error. */
  58. OPENSSL_EXPORT int ED25519_sign(uint8_t out_sig[64], const uint8_t *message,
  59. size_t message_len,
  60. const uint8_t private_key[64]);
  61. /* ED25519_verify returns one iff |signature| is a valid signature, by
  62. * |public_key| of |message_len| bytes from |message|. It returns zero
  63. * otherwise. */
  64. OPENSSL_EXPORT int ED25519_verify(const uint8_t *message, size_t message_len,
  65. const uint8_t signature[64],
  66. const uint8_t public_key[32]);
  67. #if defined(__cplusplus)
  68. } /* extern C */
  69. #endif
  70. #endif /* OPENSSL_HEADER_CURVE25519_H */