提交 f046afb0 编写于 作者: M Matt Caswell

Ensure the CertStatus message adds a DTLS message header where needed

The function tls_construct_cert_status() is called by both TLS and DTLS
code. However it only ever constructed a TLS message header for the message
which obviously failed in DTLS.
Reviewed-by: NRich Salz <rsalz@openssl.org>
上级 ee4cdb7f
...@@ -3150,34 +3150,35 @@ int tls_construct_new_session_ticket(SSL *s) ...@@ -3150,34 +3150,35 @@ int tls_construct_new_session_ticket(SSL *s)
int tls_construct_cert_status(SSL *s) int tls_construct_cert_status(SSL *s)
{ {
unsigned char *p; unsigned char *p;
size_t msglen;
/*- /*-
* Grow buffer if need be: the length calculation is as * Grow buffer if need be: the length calculation is as
* follows 1 (message type) + 3 (message length) + * follows handshake_header_length +
* 1 (ocsp response type) + 3 (ocsp response length) * 1 (ocsp response type) + 3 (ocsp response length)
* + (ocsp response) * + (ocsp response)
*/ */
if (!BUF_MEM_grow(s->init_buf, 8 + s->tlsext_ocsp_resplen)) { msglen = 4 + s->tlsext_ocsp_resplen;
ossl_statem_set_error(s); if (!BUF_MEM_grow(s->init_buf, SSL_HM_HEADER_LENGTH(s) + msglen))
return 0; goto err;
}
p = (unsigned char *)s->init_buf->data; p = ssl_handshake_start(s);
/* do the header */
*(p++) = SSL3_MT_CERTIFICATE_STATUS;
/* message length */
l2n3(s->tlsext_ocsp_resplen + 4, p);
/* status type */ /* status type */
*(p++) = s->tlsext_status_type; *(p++) = s->tlsext_status_type;
/* length of OCSP response */ /* length of OCSP response */
l2n3(s->tlsext_ocsp_resplen, p); l2n3(s->tlsext_ocsp_resplen, p);
/* actual response */ /* actual response */
memcpy(p, s->tlsext_ocsp_resp, s->tlsext_ocsp_resplen); memcpy(p, s->tlsext_ocsp_resp, s->tlsext_ocsp_resplen);
/* number of bytes to write */
s->init_num = 8 + s->tlsext_ocsp_resplen; if (!ssl_set_handshake_header(s, SSL3_MT_CERTIFICATE_STATUS, msglen))
s->init_off = 0; goto err;
return 1; return 1;
err:
ossl_statem_set_error(s);
return 0;
} }
#ifndef OPENSSL_NO_NEXTPROTONEG #ifndef OPENSSL_NO_NEXTPROTONEG
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册