/* ****************************************************************************** * INTERPEAK INTERNAL API HEADER FILE * * Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipeap_common_tls.h,v $ $Revision: 1.4.12.1 $ * $Source: /home/interpeak/CVSRoot/ipeap/src/ipeap_common_tls.h,v $ * $Author: jli7 $ $Date: 2015-01-30 03:27:26 $ * $State: Exp $ $Locker: $ * * INTERPEAK_COPYRIGHT_STRING * Design and implementation by Roger Boden ****************************************************************************** */ #ifndef IPEAP_COMMON_TLS_H #define IPEAP_COMMON_TLS_H /* **************************************************************************** * 1 DESCRIPTION **************************************************************************** */ /* **************************************************************************** * 2 CONFIGURATION **************************************************************************** */ #include "ipeap_config.h" /* **************************************************************************** * 3 INCLUDE FILES **************************************************************************** */ #ifdef IPCRYPTO #define IPCOM_USE_CLIB_PROTO #endif #include #include #include #include #include #ifdef IPSSL #include #endif #include #include "ipeap.h" #include "ipeap_h.h" #ifdef __cplusplus extern "C" { #endif /* **************************************************************************** * 4 DEFINES **************************************************************************** */ #define IPEAP_TLS_FLAG_LEN_INCL 0x80 #define IPEAP_TLS_FLAG_MORE_FRAG 0x40 #define IPEAP_TLS_FLAG_START 0x20 #define IPEAP_TLS_HANDSHAKE_COMPLETE 100 #define IPEAP_TLS_DATA_AVAILABLE 101 #define IPEAP_PKT2TLSMSG(pkt) ((Ipeap_tls_msg*)(&((pkt)->data[(pkt)->start]))) #define IPEAP_TLS_SESSION_ID_LEN (1 + 2*SSL3_RANDOM_SIZE) /* copied from openssl/ssl_locl.h */ #define SSL_HANDSHAKE_MAC_MD5 0x10 #define SSL_HANDSHAKE_MAC_SHA 0x20 #define TLS1_PRF_DGST_SHIFT 10 #define TLS1_PRF_MD5 (SSL_HANDSHAKE_MAC_MD5 << TLS1_PRF_DGST_SHIFT) #define TLS1_PRF_SHA1 (SSL_HANDSHAKE_MAC_SHA << TLS1_PRF_DGST_SHIFT) #define TLS1_PRF (TLS1_PRF_MD5 | TLS1_PRF_SHA1) /* **************************************************************************** * 5 TYPES **************************************************************************** */ typedef struct Ipeap_tls_suppl_ctx_st { SSL_CTX *ssl_ctx; SSL *ssl; BIO *in_bio; BIO *out_bio; int frag_tot_len; } Ipeap_tls_suppl_ctx; typedef struct Ipeap_tls_msg_st { Ip_u8 code; Ip_u8 id; Ip_u16 length; Ip_u8 type; Ip_u8 flags; union { struct { Ip_u8 len[4]; Ip_u8 data[1]; } len_present; Ip_u8 data[1]; } u; Ip_u8 pad; } Ipeap_tls_msg; /* **************************************************************************** * 6 FUNCTIONS **************************************************************************** */ IP_GLOBAL Ipeap_tls_suppl_ctx* ipeap_common_tls_ctx_new(void); IP_GLOBAL void ipeap_common_tls_ctx_free(Ipeap_tls_suppl_ctx *ctx); IP_GLOBAL Ip_err ipeap_common_tls_handle_frag_and_handshake(Ipeap_ctx *ctx, Ipeap_tls_suppl_ctx *tls_suppl_ctx, Ipeap_pkt *in_pkt, Ipeap_pkt *out_pkt); IP_GLOBAL Ip_err ipeap_common_tls_make_out_frag_pkt(Ipeap_tls_suppl_ctx *ctx, Ipeap_pkt *pkt, Ip_u8 code, Ip_u8 id, Ip_u8 meth_id); IP_GLOBAL Ip_err ipeap_tls_pkt_set_header(Ipeap_pkt *pkt, Ip_u8 code, Ip_u8 id, Ip_u16 len, Ip_u8 type, Ip_u8 flags); IP_GLOBAL Ip_err ipeap_tls_common_generate_key(Ipeap_tls_suppl_ctx *tls_suppl_ctx, const char* label, Ip_u8* key, int key_len); IP_GLOBAL Ip_err ipeap_tls_common_generate_session_id(Ipeap_tls_suppl_ctx *tls_suppl_ctx,Ip_u8 eap_type,Ip_u8 *session_id,Ip_u32 *session_id_len); #ifdef __cplusplus } #endif #endif /* **************************************************************************** * END OF FILE **************************************************************************** */