mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 10:47:28 +02:00
sanity check on ticket encrypt callback
This commit is contained in:
@ -25235,9 +25235,14 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
|
|||||||
|
|
||||||
/* encrypt */
|
/* encrypt */
|
||||||
encLen = WOLFSSL_TICKET_ENC_SZ; /* max size user can use */
|
encLen = WOLFSSL_TICKET_ENC_SZ; /* max size user can use */
|
||||||
ret = ssl->ctx->ticketEncCb(ssl, et->key_name, et->iv, et->mac, 1,
|
if (ssl->ctx->ticketEncCb == NULL) {
|
||||||
|
ret = WOLFSSL_TICKET_RET_FATAL;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ret = ssl->ctx->ticketEncCb(ssl, et->key_name, et->iv, et->mac, 1,
|
||||||
et->enc_ticket, sizeof(InternalTicket),
|
et->enc_ticket, sizeof(InternalTicket),
|
||||||
&encLen, ssl->ctx->ticketEncCtx);
|
&encLen, ssl->ctx->ticketEncCtx);
|
||||||
|
}
|
||||||
if (ret == WOLFSSL_TICKET_RET_OK) {
|
if (ret == WOLFSSL_TICKET_RET_OK) {
|
||||||
if (encLen < (int)sizeof(InternalTicket) ||
|
if (encLen < (int)sizeof(InternalTicket) ||
|
||||||
encLen > WOLFSSL_TICKET_ENC_SZ) {
|
encLen > WOLFSSL_TICKET_ENC_SZ) {
|
||||||
@ -25312,10 +25317,16 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
|
|||||||
return BAD_TICKET_MSG_SZ;
|
return BAD_TICKET_MSG_SZ;
|
||||||
}
|
}
|
||||||
outLen = inLen; /* may be reduced by user padding */
|
outLen = inLen; /* may be reduced by user padding */
|
||||||
ret = ssl->ctx->ticketEncCb(ssl, et->key_name, et->iv,
|
|
||||||
|
if (ssl->ctx->ticketEncCb == NULL) {
|
||||||
|
ret = WOLFSSL_TICKET_RET_FATAL;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ret = ssl->ctx->ticketEncCb(ssl, et->key_name, et->iv,
|
||||||
et->enc_ticket + inLen, 0,
|
et->enc_ticket + inLen, 0,
|
||||||
et->enc_ticket, inLen, &outLen,
|
et->enc_ticket, inLen, &outLen,
|
||||||
ssl->ctx->ticketEncCtx);
|
ssl->ctx->ticketEncCtx);
|
||||||
|
}
|
||||||
if (ret == WOLFSSL_TICKET_RET_FATAL || ret < 0) return ret;
|
if (ret == WOLFSSL_TICKET_RET_FATAL || ret < 0) return ret;
|
||||||
if (outLen > (int)inLen || outLen < (int)sizeof(InternalTicket)) {
|
if (outLen > (int)inLen || outLen < (int)sizeof(InternalTicket)) {
|
||||||
WOLFSSL_MSG("Bad user ticket decrypt len");
|
WOLFSSL_MSG("Bad user ticket decrypt len");
|
||||||
|
Reference in New Issue
Block a user