mirror of https://github.com/wolfSSL/wolfssl.git
Merge pull request #8787 from julek-wolfssl/refactor-GetHandshakeHeader
Refactor GetHandshakeHeader/GetHandShakeHeader into onepull/8543/merge
commit
6de7bb74ed
|
@ -11578,6 +11578,33 @@ static int MsgCheckBoundary(const WOLFSSL* ssl, byte type,
|
|||
|
||||
#endif /* WOLFSSL_DISABLE_EARLY_SANITY_CHECKS */
|
||||
|
||||
/* Extract the handshake header information.
|
||||
*
|
||||
* ssl The SSL/TLS object.
|
||||
* input The buffer holding the message data.
|
||||
* inOutIdx On entry, the index into the buffer of the handshake data.
|
||||
* On exit, the start of the handshake data.
|
||||
* type Type of handshake message.
|
||||
* size The length of the handshake message data.
|
||||
* totalSz The total size of data in the buffer.
|
||||
* returns BUFFER_E if there is not enough input data and 0 on success.
|
||||
*/
|
||||
int GetHandshakeHeader(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
|
||||
byte* type, word32* size, word32 totalSz)
|
||||
{
|
||||
const byte* ptr = input + *inOutIdx;
|
||||
(void)ssl;
|
||||
|
||||
*inOutIdx += HANDSHAKE_HEADER_SZ;
|
||||
if (*inOutIdx > totalSz)
|
||||
return BUFFER_E;
|
||||
|
||||
*type = ptr[0];
|
||||
c24to32(&ptr[1], size);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* This check is performed as soon as the handshake message type becomes known.
|
||||
* These checks can not be delayed and need to be performed when the msg is
|
||||
|
@ -12043,24 +12070,6 @@ static int GetRecordHeader(WOLFSSL* ssl, word32* inOutIdx,
|
|||
return 0;
|
||||
}
|
||||
|
||||
#ifndef WOLFSSL_NO_TLS12
|
||||
static int GetHandShakeHeader(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
|
||||
byte *type, word32 *size, word32 totalSz)
|
||||
{
|
||||
const byte *ptr = input + *inOutIdx;
|
||||
(void)ssl;
|
||||
|
||||
*inOutIdx += HANDSHAKE_HEADER_SZ;
|
||||
if (*inOutIdx > totalSz)
|
||||
return BUFFER_E;
|
||||
|
||||
*type = ptr[0];
|
||||
c24to32(&ptr[1], size);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_DTLS
|
||||
int GetDtlsHandShakeHeader(WOLFSSL* ssl, const byte* input,
|
||||
word32* inOutIdx, byte *type, word32 *size,
|
||||
|
@ -18122,7 +18131,7 @@ static int DoHandShakeMsg(WOLFSSL* ssl, byte* input, word32* inOutIdx,
|
|||
byte type;
|
||||
word32 size;
|
||||
|
||||
if (GetHandShakeHeader(ssl,input,inOutIdx,&type, &size, totalSz) != 0) {
|
||||
if (GetHandshakeHeader(ssl,input,inOutIdx,&type, &size, totalSz) != 0) {
|
||||
WOLFSSL_ERROR_VERBOSE(PARSE_ERROR);
|
||||
return PARSE_ERROR;
|
||||
}
|
||||
|
@ -18150,7 +18159,7 @@ static int DoHandShakeMsg(WOLFSSL* ssl, byte* input, word32* inOutIdx,
|
|||
byte type;
|
||||
word32 size;
|
||||
|
||||
if (GetHandShakeHeader(ssl, input, inOutIdx, &type, &size,
|
||||
if (GetHandshakeHeader(ssl, input, inOutIdx, &type, &size,
|
||||
totalSz) != 0) {
|
||||
WOLFSSL_ERROR_VERBOSE(PARSE_ERROR);
|
||||
return PARSE_ERROR;
|
||||
|
|
28
src/tls13.c
28
src/tls13.c
|
@ -2236,34 +2236,6 @@ end:
|
|||
#endif /* WOLFSSL_32BIT_MILLI_TIME */
|
||||
#endif /* HAVE_SESSION_TICKET || !NO_PSK */
|
||||
|
||||
|
||||
/* Extract the handshake header information.
|
||||
*
|
||||
* ssl The SSL/TLS object.
|
||||
* input The buffer holding the message data.
|
||||
* inOutIdx On entry, the index into the buffer of the handshake data.
|
||||
* On exit, the start of the handshake data.
|
||||
* type Type of handshake message.
|
||||
* size The length of the handshake message data.
|
||||
* totalSz The total size of data in the buffer.
|
||||
* returns BUFFER_E if there is not enough input data and 0 on success.
|
||||
*/
|
||||
static int GetHandshakeHeader(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
|
||||
byte* type, word32* size, word32 totalSz)
|
||||
{
|
||||
const byte* ptr = input + *inOutIdx;
|
||||
(void)ssl;
|
||||
|
||||
*inOutIdx += HANDSHAKE_HEADER_SZ;
|
||||
if (*inOutIdx > totalSz)
|
||||
return BUFFER_E;
|
||||
|
||||
*type = ptr[0];
|
||||
c24to32(&ptr[1], size);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Add record layer header to message.
|
||||
*
|
||||
* output The buffer to write the record layer header into.
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
#ifndef TESTS_API_TEST_TLS_EMS_H
|
||||
#define TESTS_API_TEST_TLS_EMS_H
|
||||
#ifndef TESTS_API_TEST_TLS_EXT_H
|
||||
#define TESTS_API_TEST_TLS_EXT_H
|
||||
|
||||
int test_tls_ems_downgrade(void);
|
||||
int test_wolfSSL_DisableExtendedMasterSecret(void);
|
||||
|
|
|
@ -6709,6 +6709,8 @@ WOLFSSL_LOCAL int GrowInputBuffer(WOLFSSL* ssl, int size, int usedLength);
|
|||
WOLFSSL_LOCAL int MsgCheckEncryption(WOLFSSL* ssl, byte type, byte encrypted);
|
||||
WOLFSSL_LOCAL int EarlySanityCheckMsgReceived(WOLFSSL* ssl, byte type,
|
||||
word32 msgSz);
|
||||
WOLFSSL_LOCAL int GetHandshakeHeader(WOLFSSL* ssl, const byte* input,
|
||||
word32* inOutIdx, byte* type, word32* size, word32 totalSz);
|
||||
#if !defined(NO_WOLFSSL_CLIENT) || !defined(WOLFSSL_NO_CLIENT_AUTH)
|
||||
WOLFSSL_LOCAL void DoCertFatalAlert(WOLFSSL* ssl, int ret);
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue