#ifndef _CRYPT_H_ #define _CRYPT_H_ #include #include #include #define CRYPT_PUBKEY_HEXSIZE (crypto_kx_PUBLICKEYBYTES + crypto_sign_PUBLICKEYBYTES) * 2 #define CRYPT_SECKEY_HEXSIZE (crypto_kx_SECRETKEYBYTES + crypto_sign_SECRETKEYBYTES) * 2 typedef struct crypt_key_t { unsigned char kx_pub[crypto_kx_PUBLICKEYBYTES]; unsigned char kx_sec[crypto_kx_SECRETKEYBYTES]; unsigned char sign_pub[crypto_sign_PUBLICKEYBYTES]; unsigned char sign_sec[crypto_sign_SECRETKEYBYTES]; bool hasSecKey; } crypt_key_t; int crypt_key_gen(crypt_key_t *k); int crypt_key_from_hex(crypt_key_t *k, char phex[CRYPT_PUBKEY_HEXSIZE], char shex[CRYPT_SECKEY_HEXSIZE]); int crypt_key_from_hex_public(crypt_key_t *k, char phex[CRYPT_PUBKEY_HEXSIZE]); void crypt_key_export_public(crypt_key_t *k, char hex[CRYPT_PUBKEY_HEXSIZE]); void crypt_key_export_secret(crypt_key_t *k, char hex[CRYPT_SECKEY_HEXSIZE]); void crypt_store_public_key(crypt_key_t *k, FILE *out_file); void crypt_store_secret_key(crypt_key_t *k, FILE *out_file); typedef struct crypt_session_t { unsigned char rx[crypto_kx_SESSIONKEYBYTES]; unsigned char tx[crypto_kx_SESSIONKEYBYTES]; crypt_key_t *remote_key; } crypt_session_t; int crypt_session_init(crypt_session_t *s, crypt_key_t *own, crypt_key_t *remote, bool is_client); #endif /* _CRYPT_H_ */