gnunet-android

GNUnet for Android
Log | Files | Refs | README

crypto_sign_ed25519.h (4341B)


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