lokinet/include/llarp/crypto_async.h

143 lines
3.1 KiB
C
Raw Normal View History

2018-01-31 19:59:26 +00:00
#ifndef LLARP_CRYPTO_ASYNC_H_
#define LLARP_CRYPTO_ASYNC_H_
#include <llarp/crypto.h>
#include <llarp/ev.h>
2018-05-18 20:08:57 +00:00
#include <llarp/logic.h>
#include <llarp/threadpool.h>
2018-01-31 19:59:26 +00:00
#ifdef __cplusplus
extern "C" {
#endif
2018-05-18 20:08:57 +00:00
struct llarp_async_iwp;
struct llarp_async_iwp *
llarp_async_iwp_new(struct llarp_alloc *mem, struct llarp_crypto *crypto,
struct llarp_logic *logic, struct llarp_threadpool *worker);
2018-05-22 19:19:06 +00:00
void
llarp_async_iwp_free(struct llarp_async_iwp *iwp);
2018-05-18 20:08:57 +00:00
struct iwp_async_keygen;
typedef void (*iwp_keygen_hook)(struct iwp_async_keygen *);
struct iwp_async_keygen
{
struct llarp_async_iwp *iwp;
void *user;
uint8_t *keybuf;
2018-05-18 20:08:57 +00:00
iwp_keygen_hook hook;
};
void
iwp_call_async_keygen(struct llarp_async_iwp *iwp,
struct iwp_async_keygen *keygen);
2018-05-18 20:08:57 +00:00
2018-05-19 13:36:42 +00:00
struct iwp_async_intro;
2018-05-19 17:21:56 +00:00
typedef void (*iwp_intro_hook)(struct iwp_async_intro *);
2018-05-19 13:36:42 +00:00
struct iwp_async_intro
2018-05-18 20:08:57 +00:00
{
struct llarp_async_iwp *iwp;
void *user;
uint8_t *buf;
2018-05-18 20:08:57 +00:00
size_t sz;
/** nonce paramter */
uint8_t *nonce;
2018-05-18 20:08:57 +00:00
/** remote public key */
uint8_t *remote_pubkey;
2018-05-18 20:08:57 +00:00
/** local private key */
uint8_t *secretkey;
2018-05-18 20:08:57 +00:00
/** callback */
2018-05-19 17:21:56 +00:00
iwp_intro_hook hook;
2018-05-18 20:08:57 +00:00
};
void
iwp_call_async_gen_intro(struct llarp_async_iwp *iwp,
struct iwp_async_intro *intro);
2018-05-18 20:08:57 +00:00
2018-05-19 13:36:42 +00:00
struct iwp_async_introack;
2018-05-19 17:21:56 +00:00
typedef void (*iwp_introack_hook)(struct iwp_async_introack *);
2018-05-19 13:36:42 +00:00
struct iwp_async_introack
2018-05-18 20:08:57 +00:00
{
struct llarp_async_iwp *iwp;
void *user;
uint8_t *buf;
2018-05-18 20:08:57 +00:00
size_t sz;
/** nonce paramter */
uint8_t *nonce;
2018-05-19 17:21:56 +00:00
/** token paramter */
uint8_t *token;
2018-05-18 20:08:57 +00:00
/** remote public key */
uint8_t *remote_pubkey;
2018-05-18 20:08:57 +00:00
/** local private key */
uint8_t *secretkey;
2018-05-18 20:08:57 +00:00
/** callback */
2018-05-19 17:21:56 +00:00
iwp_introack_hook hook;
2018-05-18 20:08:57 +00:00
};
void
iwp_call_async_gen_introack(struct llarp_async_iwp *iwp,
struct iwp_async_introack *introack);
2018-05-18 20:08:57 +00:00
void
iwp_call_async_verify_introack(struct llarp_async_iwp *iwp,
struct iwp_async_introack *introack);
2018-05-19 17:21:56 +00:00
struct iwp_async_session_start;
2018-05-19 17:21:56 +00:00
typedef void (*iwp_session_start_hook)(struct iwp_async_session_start *);
struct iwp_async_session_start
2018-05-19 13:36:42 +00:00
{
struct llarp_async_iwp *iwp;
void *user;
uint8_t *buf;
2018-05-19 13:36:42 +00:00
size_t sz;
uint8_t *nonce;
uint8_t *token;
uint8_t *sessionkey;
uint8_t *secretkey;
uint8_t *remote_pubkey;
2018-05-19 17:21:56 +00:00
iwp_session_start_hook hook;
2018-05-19 13:36:42 +00:00
};
2018-05-19 17:21:56 +00:00
void
iwp_call_async_gen_session_start(struct llarp_async_iwp *iwp,
struct iwp_async_session_start *start);
2018-05-19 17:21:56 +00:00
void
iwp_call_async_verify_session_start(struct llarp_async_iwp *iwp,
struct iwp_async_session_start *start);
2018-05-19 17:21:56 +00:00
struct iwp_async_frame;
typedef void (*iwp_async_frame_hook)(struct iwp_async_frame *);
2018-05-19 17:21:56 +00:00
struct iwp_async_frame
{
void *user;
2018-05-19 17:21:56 +00:00
bool success;
uint8_t *sessionkey;
2018-05-19 17:21:56 +00:00
size_t sz;
iwp_async_frame_hook hook;
uint8_t buf[1500];
};
void
iwp_call_async_frame_decrypt(struct llarp_async_iwp *iwp,
struct iwp_async_frame *frame);
2018-05-19 17:21:56 +00:00
void
iwp_call_async_frame_encrypt(struct llarp_async_iwp *iwp,
struct iwp_async_frame *frame);
2018-05-19 17:21:56 +00:00
2018-01-31 19:59:26 +00:00
#ifdef __cplusplus
}
#endif
#endif