move ProtocolVersion struct members directly into RecordLayerHeader
This commit is contained in:
parent
6280aa9c91
commit
6e4d33eb00
@ -1279,7 +1279,8 @@ struct CYASSL_X509 {
|
||||
/* record layer header for PlainText, Compressed, and CipherText */
|
||||
typedef struct RecordLayerHeader {
|
||||
byte type;
|
||||
ProtocolVersion version;
|
||||
byte pvMajor;
|
||||
byte pvMinor;
|
||||
byte length[2];
|
||||
} RecordLayerHeader;
|
||||
|
||||
@ -1287,7 +1288,8 @@ typedef struct RecordLayerHeader {
|
||||
/* record layer header for DTLS PlainText, Compressed, and CipherText */
|
||||
typedef struct DtlsRecordLayerHeader {
|
||||
byte type;
|
||||
ProtocolVersion version;
|
||||
byte pvMajor;
|
||||
byte pvMinor;
|
||||
byte epoch[2]; /* increment on cipher state change */
|
||||
byte sequence_number[6]; /* per record */
|
||||
byte length[2];
|
||||
|
@ -1642,7 +1642,8 @@ static void AddRecordHeader(byte* output, word32 length, byte type, CYASSL* ssl)
|
||||
/* record layer header */
|
||||
rl = (RecordLayerHeader*)output;
|
||||
rl->type = type;
|
||||
rl->version = ssl->version; /* type and version same in each */
|
||||
rl->pvMajor = ssl->version.major; /* type and version same in each */
|
||||
rl->pvMinor = ssl->version.minor;
|
||||
|
||||
if (!ssl->options.dtls)
|
||||
c16toa((word16)length, rl->length);
|
||||
@ -1944,9 +1945,7 @@ static int GetRecordHeader(CYASSL* ssl, const byte* input, word32* inOutIdx,
|
||||
}
|
||||
|
||||
/* catch version mismatch */
|
||||
if (rh->version.major != ssl->version.major ||
|
||||
rh->version.minor != ssl->version.minor) {
|
||||
|
||||
if (rh->pvMajor != ssl->version.major || rh->pvMinor != ssl->version.minor){
|
||||
if (ssl->options.side == SERVER_END &&
|
||||
ssl->options.acceptState == ACCEPT_BEGIN)
|
||||
CYASSL_MSG("Client attempting to connect with different version");
|
||||
@ -2975,8 +2974,8 @@ static INLINE int Decrypt(CYASSL* ssl, byte* plain, const byte* input,
|
||||
c32toa(GetSEQIncrement(ssl, 1), additional + AEAD_SEQ_OFFSET);
|
||||
|
||||
additional[AEAD_TYPE_OFFSET] = ssl->curRL.type;
|
||||
additional[AEAD_VMAJ_OFFSET] = ssl->curRL.version.major;
|
||||
additional[AEAD_VMIN_OFFSET] = ssl->curRL.version.minor;
|
||||
additional[AEAD_VMAJ_OFFSET] = ssl->curRL.pvMajor;
|
||||
additional[AEAD_VMIN_OFFSET] = ssl->curRL.pvMinor;
|
||||
|
||||
c16toa(sz - AES_GCM_EXP_IV_SZ - AEAD_AUTH_TAG_SZ,
|
||||
additional + AEAD_LEN_OFFSET);
|
||||
@ -4190,7 +4189,8 @@ int SendAlert(CYASSL* ssl, int severity, int type)
|
||||
else {
|
||||
RecordLayerHeader *const rl = (RecordLayerHeader*)output;
|
||||
rl->type = alert;
|
||||
rl->version = ssl->version;
|
||||
rl->pvMajor = ssl->version.major;
|
||||
rl->pvMinor = ssl->version.minor;
|
||||
c16toa(ALERT_SIZE, rl->length);
|
||||
|
||||
XMEMCPY(output + RECORD_HEADER_SZ, input, ALERT_SIZE);
|
||||
@ -5208,7 +5208,7 @@ int SetCipherList(Suites* s, const char* list)
|
||||
return SUITES_ERROR;
|
||||
}
|
||||
|
||||
length = (word32)sizeof(ProtocolVersion) + RAN_LEN
|
||||
length = VERSION_SZ + RAN_LEN
|
||||
+ idSz + ENUM_LEN
|
||||
+ ssl->suites->suiteSz + SUITE_LEN
|
||||
+ COMP_LEN + ENUM_LEN;
|
||||
@ -5238,8 +5238,8 @@ int SetCipherList(Suites* s, const char* list)
|
||||
AddHeaders(output, length, client_hello, ssl);
|
||||
|
||||
/* client hello, first version */
|
||||
XMEMCPY(output + idx, &ssl->version, sizeof(ProtocolVersion));
|
||||
idx += (int)sizeof(ProtocolVersion);
|
||||
output[idx++] = ssl->version.major;
|
||||
output[idx++] = ssl->version.minor;
|
||||
ssl->chVersion = ssl->version; /* store in case changed */
|
||||
|
||||
/* then random */
|
||||
@ -6133,7 +6133,7 @@ int SetCipherList(Suites* s, const char* list)
|
||||
int sendSz;
|
||||
int ret;
|
||||
|
||||
length = sizeof(ProtocolVersion) + RAN_LEN
|
||||
length = VERSION_SZ + RAN_LEN
|
||||
+ ID_LEN + ENUM_LEN
|
||||
+ SUITE_LEN
|
||||
+ ENUM_LEN;
|
||||
@ -6157,8 +6157,8 @@ int SetCipherList(Suites* s, const char* list)
|
||||
#endif
|
||||
/* now write to output */
|
||||
/* first version */
|
||||
XMEMCPY(output + idx, &ssl->version, sizeof(ProtocolVersion));
|
||||
idx += (word32)sizeof(ProtocolVersion);
|
||||
output[idx++] = ssl->version.major;
|
||||
output[idx++] = ssl->version.minor;
|
||||
|
||||
/* then random */
|
||||
if (!ssl->options.resuming)
|
||||
@ -7603,8 +7603,8 @@ int SetCipherList(Suites* s, const char* list)
|
||||
|
||||
AddHeaders(output, length, hello_verify_request, ssl);
|
||||
|
||||
XMEMCPY(output + idx, &ssl->chVersion, VERSION_SZ);
|
||||
idx += VERSION_SZ;
|
||||
output[idx++] = ssl->chVersion.major;
|
||||
output[idx++] = ssl->chVersion.minor;
|
||||
|
||||
output[idx++] = cookieSz;
|
||||
if ((ret = EmbedGenerateCookie(output + idx, cookieSz, ssl)) < 0)
|
||||
|
@ -1148,7 +1148,7 @@ static int ProcessServerHello(const byte* input, int* sslBytes,
|
||||
{
|
||||
ProtocolVersion pv;
|
||||
byte b;
|
||||
int toRead = sizeof(ProtocolVersion) + RAN_LEN + ENUM_LEN;
|
||||
int toRead = VERSION_SZ + RAN_LEN + ENUM_LEN;
|
||||
int doResume = 0;
|
||||
|
||||
/* make sure we didn't miss ClientHello */
|
||||
@ -1163,9 +1163,9 @@ static int ProcessServerHello(const byte* input, int* sslBytes,
|
||||
return -1;
|
||||
}
|
||||
|
||||
XMEMCPY(&pv, input, sizeof(ProtocolVersion));
|
||||
input += sizeof(ProtocolVersion);
|
||||
*sslBytes -= (int)sizeof(ProtocolVersion);
|
||||
XMEMCPY(&pv, input, VERSION_SZ);
|
||||
input += VERSION_SZ;
|
||||
*sslBytes -= VERSION_SZ;
|
||||
|
||||
session->sslServer->version = pv;
|
||||
session->sslClient->version = pv;
|
||||
@ -1278,7 +1278,7 @@ static int ProcessClientHello(const byte* input, int* sslBytes,
|
||||
{
|
||||
byte bLen;
|
||||
word16 len;
|
||||
int toRead = sizeof(ProtocolVersion) + RAN_LEN + ENUM_LEN;
|
||||
int toRead = VERSION_SZ + RAN_LEN + ENUM_LEN;
|
||||
|
||||
session->flags.clientHello = 1; /* don't process again */
|
||||
|
||||
@ -1289,8 +1289,8 @@ static int ProcessClientHello(const byte* input, int* sslBytes,
|
||||
}
|
||||
|
||||
/* skip, get negotiated one from server hello */
|
||||
input += sizeof(ProtocolVersion);
|
||||
*sslBytes -= (int)sizeof(ProtocolVersion);
|
||||
input += VERSION_SZ;
|
||||
*sslBytes -= VERSION_SZ;
|
||||
|
||||
XMEMCPY(session->sslServer->arrays->clientRandom, input, RAN_LEN);
|
||||
XMEMCPY(session->sslClient->arrays->clientRandom, input, RAN_LEN);
|
||||
|
Loading…
Reference in New Issue
Block a user