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