21#include "hitls_build.h"
22#include "hitls_crypt_type.h"
29#define DTLS_MIN_MTU 256
30#define REC_MAX_PLAIN_LENGTH 16384
32#define REC_MAX_TLS13_ENCRYPTED_OVERHEAD 256u
34#define REC_MAX_TLS13_ENCRYPTED_LEN (REC_MAX_PLAIN_LENGTH + REC_MAX_TLS13_ENCRYPTED_OVERHEAD)
36#define REC_MASTER_SECRET_LEN 48
37#define REC_RANDOM_LEN 32
39#define RECORD_HEADER 0x100
40#define RECORD_INNER_CONTENT_TYPE 0x101
45 REC_TYPE_CHANGE_CIPHER_SPEC = 20,
47 REC_TYPE_HANDSHAKE = 22,
49 REC_TYPE_UNKNOWN = 255
57 bool isClientTrafficSecret;
58 HITLS_HashAlgo prfAlg;
60 HITLS_CipherAlgo cipherAlg;
61 HITLS_CipherType cipherType;
64 uint8_t fixedIvLength;
69 uint8_t recordIvLength;
72 uint8_t masterSecret[MAX_DIGEST_SIZE];
73 uint8_t clientRandom[REC_RANDOM_LEN];
74 uint8_t serverRandom[REC_RANDOM_LEN];
88int32_t REC_Init(TLS_Ctx *ctx);
96void REC_DeInit(TLS_Ctx *ctx);
105bool REC_ReadHasPending(
const TLS_Ctx *ctx);
128int32_t REC_Read(TLS_Ctx *ctx, REC_Type recordType, uint8_t *data, uint32_t *readLen, uint32_t num);
153int32_t REC_Write(TLS_Ctx *ctx, REC_Type recordType,
const uint8_t *data, uint32_t num);
163void REC_ActiveOutdatedWriteState(TLS_Ctx *ctx);
173void REC_DeActiveOutdatedWriteState(TLS_Ctx *ctx);
201int32_t REC_ActivePendingState(TLS_Ctx *ctx,
bool isOut);
211int32_t REC_QueryMtu(TLS_Ctx *ctx);
223int32_t REC_GetMaxWriteSize(
const TLS_Ctx *ctx, uint32_t *len);
235int32_t REC_GetMaxDataMtu(
const TLS_Ctx *ctx, uint32_t *len);
250int32_t REC_TLS13InitPendingState(
const TLS_Ctx *ctx,
const REC_SecParameters *param,
bool isOut);
263int32_t REC_RetransmitListAppend(REC_Ctx *recCtx, REC_Type type,
const uint8_t *msg, uint32_t len);
270void REC_RetransmitListClean(REC_Ctx *recCtx);
280int32_t REC_RetransmitListFlush(TLS_Ctx *ctx);
282REC_Type REC_GetUnexpectedMsgType(TLS_Ctx *ctx);
284bool REC_HaveReadSuiteInfo(
const TLS_Ctx *ctx);
293uint32_t APP_GetReadPendingBytes(
const TLS_Ctx *ctx);
295int32_t REC_RecOutBufReSet(TLS_Ctx *ctx);
306int32_t REC_FlightTransmit(TLS_Ctx *ctx);
315uint32_t REC_GetOutBufPendingSize(
const TLS_Ctx *ctx);
325int32_t REC_OutBufFlush(TLS_Ctx *ctx);