sanity check on ticket encrypt callback

This commit is contained in:
Jacob Barthelmeh
2019-08-27 11:41:27 -06:00
parent 0f60ee8a85
commit 10431738c7

View File

@ -25235,9 +25235,14 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
/* encrypt */
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),
&encLen, ssl->ctx->ticketEncCtx);
}
if (ret == WOLFSSL_TICKET_RET_OK) {
if (encLen < (int)sizeof(InternalTicket) ||
encLen > WOLFSSL_TICKET_ENC_SZ) {
@ -25312,10 +25317,16 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
return BAD_TICKET_MSG_SZ;
}
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, &outLen,
ssl->ctx->ticketEncCtx);
}
if (ret == WOLFSSL_TICKET_RET_FATAL || ret < 0) return ret;
if (outLen > (int)inLen || outLen < (int)sizeof(InternalTicket)) {
WOLFSSL_MSG("Bad user ticket decrypt len");