crypto_sign_ed25519.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. #ifndef crypto_sign_ed25519_H
  2. #define crypto_sign_ed25519_H
  3. #include <stddef.h>
  4. #include "crypto_hash_sha512.h"
  5. #include "export.h"
  6. #ifdef __cplusplus
  7. # ifdef __GNUC__
  8. # pragma GCC diagnostic ignored "-Wlong-long"
  9. # endif
  10. extern "C" {
  11. #endif
  12. typedef struct crypto_sign_ed25519ph_state {
  13. crypto_hash_sha512_state hs;
  14. } crypto_sign_ed25519ph_state;
  15. SODIUM_EXPORT
  16. size_t crypto_sign_ed25519ph_statebytes(void);
  17. #define crypto_sign_ed25519_BYTES 64U
  18. SODIUM_EXPORT
  19. size_t crypto_sign_ed25519_bytes(void);
  20. #define crypto_sign_ed25519_SEEDBYTES 32U
  21. SODIUM_EXPORT
  22. size_t crypto_sign_ed25519_seedbytes(void);
  23. #define crypto_sign_ed25519_PUBLICKEYBYTES 32U
  24. SODIUM_EXPORT
  25. size_t crypto_sign_ed25519_publickeybytes(void);
  26. #define crypto_sign_ed25519_SECRETKEYBYTES (32U + 32U)
  27. SODIUM_EXPORT
  28. size_t crypto_sign_ed25519_secretkeybytes(void);
  29. #define crypto_sign_ed25519_MESSAGEBYTES_MAX (SODIUM_SIZE_MAX - crypto_sign_ed25519_BYTES)
  30. SODIUM_EXPORT
  31. size_t crypto_sign_ed25519_messagebytes_max(void);
  32. SODIUM_EXPORT
  33. int crypto_sign_ed25519(unsigned char *sm, unsigned long long *smlen_p,
  34. const unsigned char *m, unsigned long long mlen,
  35. const unsigned char *sk)
  36. __attribute__ ((nonnull(1, 5)));
  37. SODIUM_EXPORT
  38. int crypto_sign_ed25519_open(unsigned char *m, unsigned long long *mlen_p,
  39. const unsigned char *sm, unsigned long long smlen,
  40. const unsigned char *pk)
  41. __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(3, 5)));
  42. SODIUM_EXPORT
  43. int crypto_sign_ed25519_detached(unsigned char *sig,
  44. unsigned long long *siglen_p,
  45. const unsigned char *m,
  46. unsigned long long mlen,
  47. const unsigned char *sk)
  48. __attribute__ ((nonnull(1, 5)));
  49. SODIUM_EXPORT
  50. int crypto_sign_ed25519_verify_detached(const unsigned char *sig,
  51. const unsigned char *m,
  52. unsigned long long mlen,
  53. const unsigned char *pk)
  54. __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4)));
  55. SODIUM_EXPORT
  56. int crypto_sign_ed25519_keypair(unsigned char *pk, unsigned char *sk)
  57. __attribute__ ((nonnull));
  58. SODIUM_EXPORT
  59. int crypto_sign_ed25519_seed_keypair(unsigned char *pk, unsigned char *sk,
  60. const unsigned char *seed)
  61. __attribute__ ((nonnull));
  62. SODIUM_EXPORT
  63. int crypto_sign_ed25519_pk_to_curve25519(unsigned char *curve25519_pk,
  64. const unsigned char *ed25519_pk)
  65. __attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
  66. SODIUM_EXPORT
  67. int crypto_sign_ed25519_sk_to_curve25519(unsigned char *curve25519_sk,
  68. const unsigned char *ed25519_sk)
  69. __attribute__ ((nonnull));
  70. SODIUM_EXPORT
  71. int crypto_sign_ed25519_sk_to_seed(unsigned char *seed,
  72. const unsigned char *sk)
  73. __attribute__ ((nonnull));
  74. SODIUM_EXPORT
  75. int crypto_sign_ed25519_sk_to_pk(unsigned char *pk, const unsigned char *sk)
  76. __attribute__ ((nonnull));
  77. SODIUM_EXPORT
  78. int crypto_sign_ed25519ph_init(crypto_sign_ed25519ph_state *state)
  79. __attribute__ ((nonnull));
  80. SODIUM_EXPORT
  81. int crypto_sign_ed25519ph_update(crypto_sign_ed25519ph_state *state,
  82. const unsigned char *m,
  83. unsigned long long mlen)
  84. __attribute__ ((nonnull(1)));
  85. SODIUM_EXPORT
  86. int crypto_sign_ed25519ph_final_create(crypto_sign_ed25519ph_state *state,
  87. unsigned char *sig,
  88. unsigned long long *siglen_p,
  89. const unsigned char *sk)
  90. __attribute__ ((nonnull(1, 2, 4)));
  91. SODIUM_EXPORT
  92. int crypto_sign_ed25519ph_final_verify(crypto_sign_ed25519ph_state *state,
  93. const unsigned char *sig,
  94. const unsigned char *pk)
  95. __attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
  96. #ifdef __cplusplus
  97. }
  98. #endif
  99. #endif