#ifndef _CRYPT_H_ #define _CRYPT_H_ #include #include #define CRYPT_PUBKEY_HEXSIZE (crypto_kx_PUBLICKEYBYTES + crypto_sign_PUBLICKEYBYTES) * 2 + 1 #define CRYPT_SECKEY_HEXSIZE (crypto_kx_SECRETKEYBYTES + crypto_sign_SECRETKEYBYTES) * 2 + 1 typedef struct crypt_key_t { unsigned char kxPub[crypto_kx_PUBLICKEYBYTES]; unsigned char kxSec[crypto_kx_SECRETKEYBYTES]; unsigned char signPub[crypto_sign_PUBLICKEYBYTES]; unsigned char signSec[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]); typedef struct crypt_session_t { unsigned char rx[crypto_kx_SESSIONKEYBYTES]; unsigned char tx[crypto_kx_SESSIONKEYBYTES]; crypt_key_t *remoteKey; } crypt_session_t; int crypt_session_init(crypt_session_t *s, crypt_key_t *own, crypt_key_t *remote, bool dirClient); #endif /* _CRYPT_H_ */