crypto_sign.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #ifndef crypto_sign_H
  2. #define crypto_sign_H
  3. /*
  4. * THREAD SAFETY: crypto_sign_keypair() is thread-safe,
  5. * provided that sodium_init() was called before.
  6. *
  7. * Other functions, including crypto_sign_seed_keypair() are always thread-safe.
  8. */
  9. #include <stddef.h>
  10. #include "crypto_sign_ed25519.h"
  11. #include "export.h"
  12. #ifdef __cplusplus
  13. # ifdef __GNUC__
  14. # pragma GCC diagnostic ignored "-Wlong-long"
  15. # endif
  16. extern "C" {
  17. #endif
  18. typedef crypto_sign_ed25519ph_state crypto_sign_state;
  19. SODIUM_EXPORT
  20. size_t crypto_sign_statebytes(void);
  21. #define crypto_sign_BYTES crypto_sign_ed25519_BYTES
  22. SODIUM_EXPORT
  23. size_t crypto_sign_bytes(void);
  24. #define crypto_sign_SEEDBYTES crypto_sign_ed25519_SEEDBYTES
  25. SODIUM_EXPORT
  26. size_t crypto_sign_seedbytes(void);
  27. #define crypto_sign_PUBLICKEYBYTES crypto_sign_ed25519_PUBLICKEYBYTES
  28. SODIUM_EXPORT
  29. size_t crypto_sign_publickeybytes(void);
  30. #define crypto_sign_SECRETKEYBYTES crypto_sign_ed25519_SECRETKEYBYTES
  31. SODIUM_EXPORT
  32. size_t crypto_sign_secretkeybytes(void);
  33. #define crypto_sign_MESSAGEBYTES_MAX crypto_sign_ed25519_MESSAGEBYTES_MAX
  34. SODIUM_EXPORT
  35. size_t crypto_sign_messagebytes_max(void);
  36. #define crypto_sign_PRIMITIVE "ed25519"
  37. SODIUM_EXPORT
  38. const char *crypto_sign_primitive(void);
  39. SODIUM_EXPORT
  40. int crypto_sign_seed_keypair(unsigned char *pk, unsigned char *sk,
  41. const unsigned char *seed)
  42. __attribute__ ((nonnull));
  43. SODIUM_EXPORT
  44. int crypto_sign_keypair(unsigned char *pk, unsigned char *sk)
  45. __attribute__ ((nonnull));
  46. SODIUM_EXPORT
  47. int crypto_sign(unsigned char *sm, unsigned long long *smlen_p,
  48. const unsigned char *m, unsigned long long mlen,
  49. const unsigned char *sk) __attribute__ ((nonnull(1, 5)));
  50. SODIUM_EXPORT
  51. int crypto_sign_open(unsigned char *m, unsigned long long *mlen_p,
  52. const unsigned char *sm, unsigned long long smlen,
  53. const unsigned char *pk)
  54. __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(3, 5)));
  55. SODIUM_EXPORT
  56. int crypto_sign_detached(unsigned char *sig, unsigned long long *siglen_p,
  57. const unsigned char *m, unsigned long long mlen,
  58. const unsigned char *sk) __attribute__ ((nonnull(1, 5)));
  59. SODIUM_EXPORT
  60. int crypto_sign_verify_detached(const unsigned char *sig,
  61. const unsigned char *m,
  62. unsigned long long mlen,
  63. const unsigned char *pk)
  64. __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4)));
  65. SODIUM_EXPORT
  66. int crypto_sign_init(crypto_sign_state *state);
  67. SODIUM_EXPORT
  68. int crypto_sign_update(crypto_sign_state *state,
  69. const unsigned char *m, unsigned long long mlen)
  70. __attribute__ ((nonnull(1)));
  71. SODIUM_EXPORT
  72. int crypto_sign_final_create(crypto_sign_state *state, unsigned char *sig,
  73. unsigned long long *siglen_p,
  74. const unsigned char *sk)
  75. __attribute__ ((nonnull(1, 2, 4)));
  76. SODIUM_EXPORT
  77. int crypto_sign_final_verify(crypto_sign_state *state, const unsigned char *sig,
  78. const unsigned char *pk)
  79. __attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
  80. #ifdef __cplusplus
  81. }
  82. #endif
  83. #endif