#ifndef TRUNNEL_LINK_HANDSHAKE_H
#define TRUNNEL_LINK_HANDSHAKE_H
#include <stdint.h>
#include "trunnel.h"
#define CERTTYPE_RSA1024_ID_LINK 1
#define CERTTYPE_RSA1024_ID_ID 2
#define CERTTYPE_RSA1024_ID_AUTH 3
#define CERTTYPE_ED_ID_SIGN 4
#define CERTTYPE_ED_SIGN_LINK 5
#define CERTTYPE_ED_SIGN_AUTH 6
#define CERTTYPE_RSA1024_ID_EDID 7
#if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_AUTH_CHALLENGE_CELL)
struct auth_challenge_cell_st {
uint8_t challenge[32];
uint16_t n_methods;
TRUNNEL_DYNARRAY_HEAD(, uint16_t) methods;
uint8_t trunnel_error_code_;
};
#endif
typedef struct auth_challenge_cell_st auth_challenge_cell_t;
#if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_AUTH_CTX)
struct auth_ctx_st {
uint8_t is_ed;
uint8_t trunnel_error_code_;
};
#endif
typedef struct auth_ctx_st auth_ctx_t;
#if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_CERTS_CELL_CERT)
struct certs_cell_cert_st {
uint8_t cert_type;
uint16_t cert_len;
TRUNNEL_DYNARRAY_HEAD(, uint8_t) body;
uint8_t trunnel_error_code_;
};
#endif
typedef struct certs_cell_cert_st certs_cell_cert_t;
#if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_RSA_ED_CROSSCERT)
struct rsa_ed_crosscert_st {
uint8_t ed_key[32];
uint32_t expiration;
const uint8_t *end_of_signed;
uint8_t sig_len;
TRUNNEL_DYNARRAY_HEAD(, uint8_t) sig;
uint8_t trunnel_error_code_;
};
#endif
typedef struct rsa_ed_crosscert_st rsa_ed_crosscert_t;
#if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_AUTH1)
struct auth1_st {
uint8_t type[8];
uint8_t cid[32];
uint8_t sid[32];
uint8_t u1_cid_ed[32];
uint8_t u1_sid_ed[32];
uint8_t slog[32];
uint8_t clog[32];
uint8_t scert[32];
uint8_t tlssecrets[32];
const uint8_t *end_of_fixed_part;
uint8_t rand[24];
const uint8_t *end_of_signed;
TRUNNEL_DYNARRAY_HEAD(, uint8_t) sig;
uint8_t trunnel_error_code_;
};
#endif
typedef struct auth1_st auth1_t;
#if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_CERTS_CELL)
struct certs_cell_st {
uint8_t n_certs;
TRUNNEL_DYNARRAY_HEAD(, struct certs_cell_cert_st *) certs;
uint8_t trunnel_error_code_;
};
#endif
typedef struct certs_cell_st certs_cell_t;
auth_challenge_cell_t *auth_challenge_cell_new(void);
void auth_challenge_cell_free(auth_challenge_cell_t *victim);
ssize_t auth_challenge_cell_parse(auth_challenge_cell_t **output, const uint8_t *input, const size_t len_in);
ssize_t auth_challenge_cell_encoded_len(const auth_challenge_cell_t *obj);
ssize_t auth_challenge_cell_encode(uint8_t *output, size_t avail, const auth_challenge_cell_t *input);
const char *auth_challenge_cell_check(const auth_challenge_cell_t *obj);
int auth_challenge_cell_clear_errors(auth_challenge_cell_t *obj);
size_t auth_challenge_cell_getlen_challenge(const auth_challenge_cell_t *inp);
uint8_t auth_challenge_cell_get_challenge(auth_challenge_cell_t *inp, size_t idx);
uint8_t auth_challenge_cell_getconst_challenge(const auth_challenge_cell_t *inp, size_t idx);
int auth_challenge_cell_set_challenge(auth_challenge_cell_t *inp, size_t idx, uint8_t elt);
uint8_t * auth_challenge_cell_getarray_challenge(auth_challenge_cell_t *inp);
const uint8_t * auth_challenge_cell_getconstarray_challenge(const auth_challenge_cell_t *inp);
uint16_t auth_challenge_cell_get_n_methods(const auth_challenge_cell_t *inp);
int auth_challenge_cell_set_n_methods(auth_challenge_cell_t *inp, uint16_t val);
size_t auth_challenge_cell_getlen_methods(const auth_challenge_cell_t *inp);
uint16_t auth_challenge_cell_get_methods(auth_challenge_cell_t *inp, size_t idx);
uint16_t auth_challenge_cell_getconst_methods(const auth_challenge_cell_t *inp, size_t idx);
int auth_challenge_cell_set_methods(auth_challenge_cell_t *inp, size_t idx, uint16_t elt);
int auth_challenge_cell_add_methods(auth_challenge_cell_t *inp, uint16_t elt);
uint16_t * auth_challenge_cell_getarray_methods(auth_challenge_cell_t *inp);
const uint16_t * auth_challenge_cell_getconstarray_methods(const auth_challenge_cell_t *inp);
int auth_challenge_cell_setlen_methods(auth_challenge_cell_t *inp, size_t newlen);
auth_ctx_t *auth_ctx_new(void);
void auth_ctx_free(auth_ctx_t *victim);
uint8_t auth_ctx_get_is_ed(const auth_ctx_t *inp);
int auth_ctx_set_is_ed(auth_ctx_t *inp, uint8_t val);
certs_cell_cert_t *certs_cell_cert_new(void);
void certs_cell_cert_free(certs_cell_cert_t *victim);
ssize_t certs_cell_cert_parse(certs_cell_cert_t **output, const uint8_t *input, const size_t len_in);
ssize_t certs_cell_cert_encoded_len(const certs_cell_cert_t *obj);
ssize_t certs_cell_cert_encode(uint8_t *output, size_t avail, const certs_cell_cert_t *input);
const char *certs_cell_cert_check(const certs_cell_cert_t *obj);
int certs_cell_cert_clear_errors(certs_cell_cert_t *obj);
uint8_t certs_cell_cert_get_cert_type(const certs_cell_cert_t *inp);
int certs_cell_cert_set_cert_type(certs_cell_cert_t *inp, uint8_t val);
uint16_t certs_cell_cert_get_cert_len(const certs_cell_cert_t *inp);
int certs_cell_cert_set_cert_len(certs_cell_cert_t *inp, uint16_t val);
size_t certs_cell_cert_getlen_body(const certs_cell_cert_t *inp);
uint8_t certs_cell_cert_get_body(certs_cell_cert_t *inp, size_t idx);
uint8_t certs_cell_cert_getconst_body(const certs_cell_cert_t *inp, size_t idx);
int certs_cell_cert_set_body(certs_cell_cert_t *inp, size_t idx, uint8_t elt);
int certs_cell_cert_add_body(certs_cell_cert_t *inp, uint8_t elt);
uint8_t * certs_cell_cert_getarray_body(certs_cell_cert_t *inp);
const uint8_t * certs_cell_cert_getconstarray_body(const certs_cell_cert_t *inp);
int certs_cell_cert_setlen_body(certs_cell_cert_t *inp, size_t newlen);
rsa_ed_crosscert_t *rsa_ed_crosscert_new(void);
void rsa_ed_crosscert_free(rsa_ed_crosscert_t *victim);
ssize_t rsa_ed_crosscert_parse(rsa_ed_crosscert_t **output, const uint8_t *input, const size_t len_in);
ssize_t rsa_ed_crosscert_encoded_len(const rsa_ed_crosscert_t *obj);
ssize_t rsa_ed_crosscert_encode(uint8_t *output, size_t avail, const rsa_ed_crosscert_t *input);
const char *rsa_ed_crosscert_check(const rsa_ed_crosscert_t *obj);
int rsa_ed_crosscert_clear_errors(rsa_ed_crosscert_t *obj);
size_t rsa_ed_crosscert_getlen_ed_key(const rsa_ed_crosscert_t *inp);
uint8_t rsa_ed_crosscert_get_ed_key(rsa_ed_crosscert_t *inp, size_t idx);
uint8_t rsa_ed_crosscert_getconst_ed_key(const rsa_ed_crosscert_t *inp, size_t idx);
int rsa_ed_crosscert_set_ed_key(rsa_ed_crosscert_t *inp, size_t idx, uint8_t elt);
uint8_t * rsa_ed_crosscert_getarray_ed_key(rsa_ed_crosscert_t *inp);
const uint8_t * rsa_ed_crosscert_getconstarray_ed_key(const rsa_ed_crosscert_t *inp);
uint32_t rsa_ed_crosscert_get_expiration(const rsa_ed_crosscert_t *inp);
int rsa_ed_crosscert_set_expiration(rsa_ed_crosscert_t *inp, uint32_t val);
const uint8_t * rsa_ed_crosscert_get_end_of_signed(const rsa_ed_crosscert_t *inp);
uint8_t rsa_ed_crosscert_get_sig_len(const rsa_ed_crosscert_t *inp);
int rsa_ed_crosscert_set_sig_len(rsa_ed_crosscert_t *inp, uint8_t val);
size_t rsa_ed_crosscert_getlen_sig(const rsa_ed_crosscert_t *inp);
uint8_t rsa_ed_crosscert_get_sig(rsa_ed_crosscert_t *inp, size_t idx);
uint8_t rsa_ed_crosscert_getconst_sig(const rsa_ed_crosscert_t *inp, size_t idx);
int rsa_ed_crosscert_set_sig(rsa_ed_crosscert_t *inp, size_t idx, uint8_t elt);
int rsa_ed_crosscert_add_sig(rsa_ed_crosscert_t *inp, uint8_t elt);
uint8_t * rsa_ed_crosscert_getarray_sig(rsa_ed_crosscert_t *inp);
const uint8_t * rsa_ed_crosscert_getconstarray_sig(const rsa_ed_crosscert_t *inp);
int rsa_ed_crosscert_setlen_sig(rsa_ed_crosscert_t *inp, size_t newlen);
auth1_t *auth1_new(void);
void auth1_free(auth1_t *victim);
ssize_t auth1_parse(auth1_t **output, const uint8_t *input, const size_t len_in, const auth_ctx_t *auth_ctx_ctx);
ssize_t auth1_encoded_len(const auth1_t *obj, const auth_ctx_t *auth_ctx_ctx);
ssize_t auth1_encode(uint8_t *output, size_t avail, const auth1_t *input, const auth_ctx_t *auth_ctx_ctx);
const char *auth1_check(const auth1_t *obj, const auth_ctx_t *auth_ctx_ctx);
int auth1_clear_errors(auth1_t *obj);
size_t auth1_getlen_type(const auth1_t *inp);
uint8_t auth1_get_type(auth1_t *inp, size_t idx);
uint8_t auth1_getconst_type(const auth1_t *inp, size_t idx);
int auth1_set_type(auth1_t *inp, size_t idx, uint8_t elt);
uint8_t * auth1_getarray_type(auth1_t *inp);
const uint8_t * auth1_getconstarray_type(const auth1_t *inp);
size_t auth1_getlen_cid(const auth1_t *inp);
uint8_t auth1_get_cid(auth1_t *inp, size_t idx);
uint8_t auth1_getconst_cid(const auth1_t *inp, size_t idx);
int auth1_set_cid(auth1_t *inp, size_t idx, uint8_t elt);
uint8_t * auth1_getarray_cid(auth1_t *inp);
const uint8_t * auth1_getconstarray_cid(const auth1_t *inp);
size_t auth1_getlen_sid(const auth1_t *inp);
uint8_t auth1_get_sid(auth1_t *inp, size_t idx);
uint8_t auth1_getconst_sid(const auth1_t *inp, size_t idx);
int auth1_set_sid(auth1_t *inp, size_t idx, uint8_t elt);
uint8_t * auth1_getarray_sid(auth1_t *inp);
const uint8_t * auth1_getconstarray_sid(const auth1_t *inp);
size_t auth1_getlen_u1_cid_ed(const auth1_t *inp);
uint8_t auth1_get_u1_cid_ed(auth1_t *inp, size_t idx);
uint8_t auth1_getconst_u1_cid_ed(const auth1_t *inp, size_t idx);
int auth1_set_u1_cid_ed(auth1_t *inp, size_t idx, uint8_t elt);
uint8_t * auth1_getarray_u1_cid_ed(auth1_t *inp);
const uint8_t * auth1_getconstarray_u1_cid_ed(const auth1_t *inp);
size_t auth1_getlen_u1_sid_ed(const auth1_t *inp);
uint8_t auth1_get_u1_sid_ed(auth1_t *inp, size_t idx);
uint8_t auth1_getconst_u1_sid_ed(const auth1_t *inp, size_t idx);
int auth1_set_u1_sid_ed(auth1_t *inp, size_t idx, uint8_t elt);
uint8_t * auth1_getarray_u1_sid_ed(auth1_t *inp);
const uint8_t * auth1_getconstarray_u1_sid_ed(const auth1_t *inp);
size_t auth1_getlen_slog(const auth1_t *inp);
uint8_t auth1_get_slog(auth1_t *inp, size_t idx);
uint8_t auth1_getconst_slog(const auth1_t *inp, size_t idx);
int auth1_set_slog(auth1_t *inp, size_t idx, uint8_t elt);
uint8_t * auth1_getarray_slog(auth1_t *inp);
const uint8_t * auth1_getconstarray_slog(const auth1_t *inp);
size_t auth1_getlen_clog(const auth1_t *inp);
uint8_t auth1_get_clog(auth1_t *inp, size_t idx);
uint8_t auth1_getconst_clog(const auth1_t *inp, size_t idx);
int auth1_set_clog(auth1_t *inp, size_t idx, uint8_t elt);
uint8_t * auth1_getarray_clog(auth1_t *inp);
const uint8_t * auth1_getconstarray_clog(const auth1_t *inp);
size_t auth1_getlen_scert(const auth1_t *inp);
uint8_t auth1_get_scert(auth1_t *inp, size_t idx);
uint8_t auth1_getconst_scert(const auth1_t *inp, size_t idx);
int auth1_set_scert(auth1_t *inp, size_t idx, uint8_t elt);
uint8_t * auth1_getarray_scert(auth1_t *inp);
const uint8_t * auth1_getconstarray_scert(const auth1_t *inp);
size_t auth1_getlen_tlssecrets(const auth1_t *inp);
uint8_t auth1_get_tlssecrets(auth1_t *inp, size_t idx);
uint8_t auth1_getconst_tlssecrets(const auth1_t *inp, size_t idx);
int auth1_set_tlssecrets(auth1_t *inp, size_t idx, uint8_t elt);
uint8_t * auth1_getarray_tlssecrets(auth1_t *inp);
const uint8_t * auth1_getconstarray_tlssecrets(const auth1_t *inp);
const uint8_t * auth1_get_end_of_fixed_part(const auth1_t *inp);
size_t auth1_getlen_rand(const auth1_t *inp);
uint8_t auth1_get_rand(auth1_t *inp, size_t idx);
uint8_t auth1_getconst_rand(const auth1_t *inp, size_t idx);
int auth1_set_rand(auth1_t *inp, size_t idx, uint8_t elt);
uint8_t * auth1_getarray_rand(auth1_t *inp);
const uint8_t * auth1_getconstarray_rand(const auth1_t *inp);
const uint8_t * auth1_get_end_of_signed(const auth1_t *inp);
size_t auth1_getlen_sig(const auth1_t *inp);
uint8_t auth1_get_sig(auth1_t *inp, size_t idx);
uint8_t auth1_getconst_sig(const auth1_t *inp, size_t idx);
int auth1_set_sig(auth1_t *inp, size_t idx, uint8_t elt);
int auth1_add_sig(auth1_t *inp, uint8_t elt);
uint8_t * auth1_getarray_sig(auth1_t *inp);
const uint8_t * auth1_getconstarray_sig(const auth1_t *inp);
int auth1_setlen_sig(auth1_t *inp, size_t newlen);
certs_cell_t *certs_cell_new(void);
void certs_cell_free(certs_cell_t *victim);
ssize_t certs_cell_parse(certs_cell_t **output, const uint8_t *input, const size_t len_in);
ssize_t certs_cell_encoded_len(const certs_cell_t *obj);
ssize_t certs_cell_encode(uint8_t *output, size_t avail, const certs_cell_t *input);
const char *certs_cell_check(const certs_cell_t *obj);
int certs_cell_clear_errors(certs_cell_t *obj);
uint8_t certs_cell_get_n_certs(const certs_cell_t *inp);
int certs_cell_set_n_certs(certs_cell_t *inp, uint8_t val);
size_t certs_cell_getlen_certs(const certs_cell_t *inp);
struct certs_cell_cert_st * certs_cell_get_certs(certs_cell_t *inp, size_t idx);
const struct certs_cell_cert_st * certs_cell_getconst_certs(const certs_cell_t *inp, size_t idx);
int certs_cell_set_certs(certs_cell_t *inp, size_t idx, struct certs_cell_cert_st * elt);
int certs_cell_set0_certs(certs_cell_t *inp, size_t idx, struct certs_cell_cert_st * elt);
int certs_cell_add_certs(certs_cell_t *inp, struct certs_cell_cert_st * elt);
struct certs_cell_cert_st * * certs_cell_getarray_certs(certs_cell_t *inp);
const struct certs_cell_cert_st * const * certs_cell_getconstarray_certs(const certs_cell_t *inp);
int certs_cell_setlen_certs(certs_cell_t *inp, size_t newlen);
#endif