gnunet-android

GNUnet for Android
Log | Files | Refs | README

crypto_sign.h (3353B)


      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             __attribute__ ((nonnull));
     56 
     57 SODIUM_EXPORT
     58 int crypto_sign_keypair(unsigned char *pk, unsigned char *sk)
     59             __attribute__ ((nonnull));
     60 
     61 SODIUM_EXPORT
     62 int crypto_sign(unsigned char *sm, unsigned long long *smlen_p,
     63                 const unsigned char *m, unsigned long long mlen,
     64                 const unsigned char *sk) __attribute__ ((nonnull(1, 5)));
     65 
     66 SODIUM_EXPORT
     67 int crypto_sign_open(unsigned char *m, unsigned long long *mlen_p,
     68                      const unsigned char *sm, unsigned long long smlen,
     69                      const unsigned char *pk)
     70             __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(3, 5)));
     71 
     72 SODIUM_EXPORT
     73 int crypto_sign_detached(unsigned char *sig, unsigned long long *siglen_p,
     74                          const unsigned char *m, unsigned long long mlen,
     75                          const unsigned char *sk) __attribute__ ((nonnull(1, 5)));
     76 
     77 SODIUM_EXPORT
     78 int crypto_sign_verify_detached(const unsigned char *sig,
     79                                 const unsigned char *m,
     80                                 unsigned long long mlen,
     81                                 const unsigned char *pk)
     82             __attribute__ ((warn_unused_result)) __attribute__ ((nonnull(1, 4)));
     83 
     84 SODIUM_EXPORT
     85 int crypto_sign_init(crypto_sign_state *state);
     86 
     87 SODIUM_EXPORT
     88 int crypto_sign_update(crypto_sign_state *state,
     89                        const unsigned char *m, unsigned long long mlen)
     90             __attribute__ ((nonnull(1)));
     91 
     92 SODIUM_EXPORT
     93 int crypto_sign_final_create(crypto_sign_state *state, unsigned char *sig,
     94                              unsigned long long *siglen_p,
     95                              const unsigned char *sk)
     96             __attribute__ ((nonnull(1, 2, 4)));
     97 
     98 SODIUM_EXPORT
     99 int crypto_sign_final_verify(crypto_sign_state *state, const unsigned char *sig,
    100                              const unsigned char *pk)
    101             __attribute__ ((warn_unused_result)) __attribute__ ((nonnull));
    102 
    103 #ifdef __cplusplus
    104 }
    105 #endif
    106 
    107 #endif