Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions src/internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -33900,7 +33900,8 @@ int SendClientKeyExchange(WOLFSSL* ssl)
/* Ensure the buffer is null-terminated. */
ssl->arrays->client_identity[MAX_PSK_ID_LEN] = '\0';
args->encSz = (word32)XSTRLEN(ssl->arrays->client_identity);
if (args->encSz > MAX_PSK_ID_LEN) {
if (args->encSz > MAX_PSK_ID_LEN ||
args->encSz > MAX_ENCRYPT_SZ) {
ERROR_OUT(CLIENT_ID_ERROR, exit_scke);
}
XMEMCPY(args->encSecret, ssl->arrays->client_identity,
Expand Down Expand Up @@ -33931,6 +33932,9 @@ int SendClientKeyExchange(WOLFSSL* ssl)
if (esSz > MAX_PSK_ID_LEN) {
ERROR_OUT(CLIENT_ID_ERROR, exit_scke);
}
if (esSz > MAX_ENCRYPT_SZ - (2 * OPAQUE16_LEN)) {
ERROR_OUT(CLIENT_ID_ERROR, exit_scke);
}
Comment thread
kareem-wolfssl marked this conversation as resolved.
/* CLIENT: Pre-shared Key for peer authentication. */
ssl->options.peerAuthGood = 1;

Expand All @@ -33945,7 +33949,7 @@ int SendClientKeyExchange(WOLFSSL* ssl)
args->output += OPAQUE16_LEN;
XMEMCPY(args->output, ssl->arrays->client_identity, esSz);
args->output += esSz;
args->length = args->encSz - esSz - OPAQUE16_LEN;
args->length = args->encSz - esSz - (2 * OPAQUE16_LEN);
args->encSz = esSz + OPAQUE16_LEN;

CHECK_RET(ret, AllocKey(ssl, DYNAMIC_TYPE_DH,
Expand Down Expand Up @@ -33982,6 +33986,9 @@ int SendClientKeyExchange(WOLFSSL* ssl)
if (esSz > MAX_PSK_ID_LEN) {
ERROR_OUT(CLIENT_ID_ERROR, exit_scke);
}
if (esSz > MAX_ENCRYPT_SZ - OPAQUE16_LEN - OPAQUE8_LEN) {
ERROR_OUT(CLIENT_ID_ERROR, exit_scke);
}
Comment thread
kareem-wolfssl marked this conversation as resolved.
/* CLIENT: Pre-shared Key for peer authentication. */
ssl->options.peerAuthGood = 1;

Expand All @@ -33990,10 +33997,10 @@ int SendClientKeyExchange(WOLFSSL* ssl)
args->output += OPAQUE16_LEN;
XMEMCPY(args->output, ssl->arrays->client_identity, esSz);
args->output += esSz;
args->encSz = esSz + OPAQUE16_LEN;

/* length is used for public key size */
args->length = MAX_ENCRYPT_SZ;
args->length =
args->encSz - esSz - OPAQUE16_LEN - OPAQUE8_LEN;
args->encSz = esSz + OPAQUE16_LEN;

/* Create shared ECC key leaving room at the beginning
* of buffer for size of shared key. */
Expand Down
3 changes: 2 additions & 1 deletion src/tls13.c
Original file line number Diff line number Diff line change
Expand Up @@ -5371,7 +5371,8 @@ int DoTls13ServerHello(WOLFSSL* ssl, const byte* input, word32* inOutIdx,

/* Session id */
args->sessIdSz = input[args->idx++];
if ((args->idx - args->begin) + args->sessIdSz > helloSz)
if (args->sessIdSz > ID_LEN || args->sessIdSz > RAN_LEN ||
((args->idx - args->begin) + args->sessIdSz > helloSz))
return BUFFER_ERROR;
args->sessId = input + args->idx;
args->idx += args->sessIdSz;
Expand Down
Loading