diff options
author | Matt Caswell <matt@openssl.org> | 2016-08-03 20:57:52 +0100 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2016-09-13 09:41:21 +0100 |
commit | 2c7b4dbc1af9cfae4e4afd7c4a07db95a1133a6a (patch) | |
tree | 01fe05288e91154c01cec450435541330b5dcd78 /ssl/statem/statem_dtls.c | |
parent | b7273855acd7ec2d1e7a4ba626ed538808fc7517 (diff) |
Convert tls_construct_client_hello() to use PACKETW
Reviewed-by: Rich Salz <rsalz@openssl.org>
Diffstat (limited to 'ssl/statem/statem_dtls.c')
-rw-r--r-- | ssl/statem/statem_dtls.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/ssl/statem/statem_dtls.c b/ssl/statem/statem_dtls.c index de2de09796..6d6c5a3aa6 100644 --- a/ssl/statem/statem_dtls.c +++ b/ssl/statem/statem_dtls.c @@ -1190,3 +1190,46 @@ void dtls1_get_message_header(unsigned char *data, struct hm_header_st *msg_hdr) n2l3(data, msg_hdr->frag_off); n2l3(data, msg_hdr->frag_len); } + +/* + * Temporary name. To be renamed dtls1_set_handshake_header() once all PACKETW + * conversion is complete. The old dtls1_set_handshake_heder() can be deleted + * at that point. + * TODO - RENAME ME + */ +int dtls1_set_handshake_header2(SSL *s, PACKETW *pkt, PACKETW *body, int htype) +{ + unsigned char *header; + dtls1_set_message_header(s, htype, 0, 0, 0); + + /* + * We allocate space at the start for the message header. This gets filled + * in later + */ + if (!PACKETW_allocate_bytes(pkt, DTLS1_HM_HEADER_LENGTH, &header) + || !PACKETW_get_sub_packet(pkt, body)) + return 0; + + return 1; +} + +int dtls1_close_construct_packet(SSL *s, PACKETW *pkt) +{ + size_t msglen; + + if (!PACKETW_get_length(pkt, &msglen) + || msglen > INT_MAX + || !PACKETW_close(pkt)) + return 0; + s->d1->w_msg_hdr.msg_len = msglen - DTLS1_HM_HEADER_LENGTH; + s->d1->w_msg_hdr.frag_len = msglen - DTLS1_HM_HEADER_LENGTH; + s->init_num = (int)msglen; + s->init_off = 0; + + /* Buffer the message to handle re-xmits */ + + if (!dtls1_buffer_message(s, 0)) + return 0; + + return 1; +} |