mirror of https://github.com/wolfSSL/wolfssl.git
fixed the dtls handshake header handling
parent
93c89ccc35
commit
11df1d25d4
|
@ -394,6 +394,8 @@ enum Misc {
|
||||||
DTLS_RECORD_HEADER_SZ = 13, /* normal + epoch(2) + seq_num(6) */
|
DTLS_RECORD_HEADER_SZ = 13, /* normal + epoch(2) + seq_num(6) */
|
||||||
DTLS_HANDSHAKE_EXTRA = 8, /* diff from normal */
|
DTLS_HANDSHAKE_EXTRA = 8, /* diff from normal */
|
||||||
DTLS_RECORD_EXTRA = 8, /* diff from normal */
|
DTLS_RECORD_EXTRA = 8, /* diff from normal */
|
||||||
|
DTLS_HANDSHAKE_SEQ_SZ = 2, /* handshake header sequence number */
|
||||||
|
DTLS_HANDSHAKE_FRAG_SZ = 3, /* fragment offset and length are 24 bit */
|
||||||
|
|
||||||
FINISHED_LABEL_SZ = 15, /* TLS finished label size */
|
FINISHED_LABEL_SZ = 15, /* TLS finished label size */
|
||||||
TLS_FINISHED_SZ = 12, /* TLS has a shorter size */
|
TLS_FINISHED_SZ = 12, /* TLS has a shorter size */
|
||||||
|
|
|
@ -1562,6 +1562,7 @@ static int GetHandShakeHeader(CYASSL* ssl, const byte* input, word32* inOutIdx,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef CYASSL_DTLS
|
#ifdef CYASSL_DTLS
|
||||||
static int GetDtlsHandShakeHeader(CYASSL* ssl, const byte* input,
|
static int GetDtlsHandShakeHeader(CYASSL* ssl, const byte* input,
|
||||||
word32* inOutIdx, byte *type, word32 *size,
|
word32* inOutIdx, byte *type, word32 *size,
|
||||||
|
@ -1574,13 +1575,16 @@ static int GetDtlsHandShakeHeader(CYASSL* ssl, const byte* input,
|
||||||
*inOutIdx += HANDSHAKE_HEADER_SZ + DTLS_HANDSHAKE_EXTRA;
|
*inOutIdx += HANDSHAKE_HEADER_SZ + DTLS_HANDSHAKE_EXTRA;
|
||||||
|
|
||||||
*type = input[idx++];
|
*type = input[idx++];
|
||||||
c24to32(input, size);
|
c24to32(input + idx, size);
|
||||||
idx += BYTE3_LEN;
|
idx += BYTE3_LEN;
|
||||||
|
|
||||||
c24to32(input, fragOffset);
|
/* skip the sequence number */
|
||||||
idx += BYTE3_LEN;
|
idx += DTLS_HANDSHAKE_SEQ_SZ;
|
||||||
c24to32(input, fragSz);
|
|
||||||
idx += BYTE3_LEN;
|
c24to32(input + idx, fragOffset);
|
||||||
|
idx += DTLS_HANDSHAKE_FRAG_SZ;
|
||||||
|
c24to32(input + idx, fragSz);
|
||||||
|
idx += DTLS_HANDSHAKE_FRAG_SZ;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -2205,6 +2209,28 @@ static int DoHandShakeMsgType(CYASSL* ssl, byte* input, word32* inOutIdx,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int DoHandShakeMsg(CYASSL* ssl, byte* input, word32* inOutIdx,
|
||||||
|
word32 totalSz)
|
||||||
|
{
|
||||||
|
byte type;
|
||||||
|
word32 size;
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
|
CYASSL_ENTER("DoHandShakeMsg()");
|
||||||
|
|
||||||
|
if (GetHandShakeHeader(ssl, input, inOutIdx, &type, &size) != 0)
|
||||||
|
return PARSE_ERROR;
|
||||||
|
|
||||||
|
if (*inOutIdx + size > totalSz)
|
||||||
|
return INCOMPLETE_DATA;
|
||||||
|
|
||||||
|
ret = DoHandShakeMsgType(ssl, input, inOutIdx, type, size, totalSz);
|
||||||
|
|
||||||
|
CYASSL_LEAVE("DoHandShakeMsg()", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef CYASSL_DTLS
|
#ifdef CYASSL_DTLS
|
||||||
static int DoDtlsHandShakeMsg(CYASSL* ssl, byte* input, word32* inOutIdx,
|
static int DoDtlsHandShakeMsg(CYASSL* ssl, byte* input, word32* inOutIdx,
|
||||||
word32 totalSz)
|
word32 totalSz)
|
||||||
|
@ -2231,29 +2257,6 @@ static int DoDtlsHandShakeMsg(CYASSL* ssl, byte* input, word32* inOutIdx,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static int DoHandShakeMsg(CYASSL* ssl, byte* input, word32* inOutIdx,
|
|
||||||
word32 totalSz)
|
|
||||||
{
|
|
||||||
byte type;
|
|
||||||
word32 size;
|
|
||||||
word32 fragOffset, fragSz;
|
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
CYASSL_ENTER("DoHandShakeMsg()");
|
|
||||||
|
|
||||||
if (GetHandShakeHeader(ssl, input, inOutIdx, &type, &size) != 0)
|
|
||||||
return PARSE_ERROR;
|
|
||||||
|
|
||||||
if (*inOutIdx + size > totalSz)
|
|
||||||
return INCOMPLETE_DATA;
|
|
||||||
|
|
||||||
ret = DoHandShakeMsgType(ssl, input, inOutIdx, type, size, totalSz);
|
|
||||||
|
|
||||||
CYASSL_LEAVE("DoHandShakeMsg()", ret);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static INLINE word32 GetSEQIncrement(CYASSL* ssl, int verify)
|
static INLINE word32 GetSEQIncrement(CYASSL* ssl, int verify)
|
||||||
{
|
{
|
||||||
if (verify)
|
if (verify)
|
||||||
|
|
Loading…
Reference in New Issue