From 7cc0ff236ba2392f4e38f24b0ff89771d4a18a2b Mon Sep 17 00:00:00 2001 From: jsing <> Date: Fri, 11 Sep 2015 15:59:21 +0000 Subject: Convert dtls1_send_finished() and ssl3_send_finished() to ssl3_handshake_msg_start()/ssl3_handshake_msg_finish(). ok beck@ --- src/lib/libssl/d1_both.c | 17 +++++------------ src/lib/libssl/s3_both.c | 15 +++++---------- src/lib/libssl/src/ssl/d1_both.c | 17 +++++------------ src/lib/libssl/src/ssl/s3_both.c | 15 +++++---------- 4 files changed, 20 insertions(+), 44 deletions(-) (limited to 'src/lib') diff --git a/src/lib/libssl/d1_both.c b/src/lib/libssl/d1_both.c index 567a074535..4d2827a2c0 100644 --- a/src/lib/libssl/d1_both.c +++ b/src/lib/libssl/d1_both.c @@ -1,4 +1,4 @@ -/* $OpenBSD: d1_both.c,v 1.35 2015/09/10 17:57:50 jsing Exp $ */ +/* $OpenBSD: d1_both.c,v 1.36 2015/09/11 15:59:21 jsing Exp $ */ /* * DTLS implementation written by Nagendra Modadugu * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. @@ -905,13 +905,12 @@ f_err: int dtls1_send_finished(SSL *s, int a, int b, const char *sender, int slen) { - unsigned char *p, *d; + unsigned char *p; int i; unsigned long l; if (s->state == a) { - d = (unsigned char *)s->init_buf->data; - p = &(d[DTLS1_HM_HEADER_LENGTH]); + p = ssl3_handshake_msg_start(s, SSL3_MT_FINISHED); i = s->method->ssl3_enc->final_finish_mac(s, sender, slen, s->s3->tmp.finish_md); @@ -936,18 +935,12 @@ dtls1_send_finished(SSL *s, int a, int b, const char *sender, int slen) s->s3->previous_server_finished_len = i; } - d = dtls1_set_message_header(s, d, SSL3_MT_FINISHED, l, 0, l); - s->init_num = (int)l + DTLS1_HM_HEADER_LENGTH; - s->init_off = 0; - - /* buffer the message to handle re-xmits */ - dtls1_buffer_message(s, 0); + ssl3_handshake_msg_finish(s, l); s->state = b; } - /* SSL3_ST_SEND_xxxxxx_HELLO_B */ - return (dtls1_do_write(s, SSL3_RT_HANDSHAKE)); + return (ssl3_handshake_write(s)); } /* diff --git a/src/lib/libssl/s3_both.c b/src/lib/libssl/s3_both.c index 5a1d1e7443..6448f27a03 100644 --- a/src/lib/libssl/s3_both.c +++ b/src/lib/libssl/s3_both.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s3_both.c,v 1.43 2015/07/18 19:41:54 doug Exp $ */ +/* $OpenBSD: s3_both.c,v 1.44 2015/09/11 15:59:21 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -155,13 +155,12 @@ ssl3_do_write(SSL *s, int type) int ssl3_send_finished(SSL *s, int a, int b, const char *sender, int slen) { - unsigned char *p, *d; + unsigned char *p; unsigned long l; int md_len; if (s->state == a) { - d = (unsigned char *)s->init_buf->data; - p = &(d[4]); + p = ssl3_handshake_msg_start(s, SSL3_MT_FINISHED); md_len = s->method->ssl3_enc->finish_mac_length; if (s->method->ssl3_enc->final_finish_mac(s, sender, slen, @@ -184,16 +183,12 @@ ssl3_send_finished(SSL *s, int a, int b, const char *sender, int slen) s->s3->previous_server_finished_len = md_len; } - *(d++) = SSL3_MT_FINISHED; - l2n3(l, d); - s->init_num = (int)l + 4; - s->init_off = 0; + ssl3_handshake_msg_finish(s, l); s->state = b; } - /* SSL3_ST_SEND_xxxxxx_HELLO_B */ - return (ssl3_do_write(s, SSL3_RT_HANDSHAKE)); + return (ssl3_handshake_write(s)); } /* ssl3_take_mac calculates the Finished MAC for the handshakes messages seen to far. */ diff --git a/src/lib/libssl/src/ssl/d1_both.c b/src/lib/libssl/src/ssl/d1_both.c index 567a074535..4d2827a2c0 100644 --- a/src/lib/libssl/src/ssl/d1_both.c +++ b/src/lib/libssl/src/ssl/d1_both.c @@ -1,4 +1,4 @@ -/* $OpenBSD: d1_both.c,v 1.35 2015/09/10 17:57:50 jsing Exp $ */ +/* $OpenBSD: d1_both.c,v 1.36 2015/09/11 15:59:21 jsing Exp $ */ /* * DTLS implementation written by Nagendra Modadugu * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. @@ -905,13 +905,12 @@ f_err: int dtls1_send_finished(SSL *s, int a, int b, const char *sender, int slen) { - unsigned char *p, *d; + unsigned char *p; int i; unsigned long l; if (s->state == a) { - d = (unsigned char *)s->init_buf->data; - p = &(d[DTLS1_HM_HEADER_LENGTH]); + p = ssl3_handshake_msg_start(s, SSL3_MT_FINISHED); i = s->method->ssl3_enc->final_finish_mac(s, sender, slen, s->s3->tmp.finish_md); @@ -936,18 +935,12 @@ dtls1_send_finished(SSL *s, int a, int b, const char *sender, int slen) s->s3->previous_server_finished_len = i; } - d = dtls1_set_message_header(s, d, SSL3_MT_FINISHED, l, 0, l); - s->init_num = (int)l + DTLS1_HM_HEADER_LENGTH; - s->init_off = 0; - - /* buffer the message to handle re-xmits */ - dtls1_buffer_message(s, 0); + ssl3_handshake_msg_finish(s, l); s->state = b; } - /* SSL3_ST_SEND_xxxxxx_HELLO_B */ - return (dtls1_do_write(s, SSL3_RT_HANDSHAKE)); + return (ssl3_handshake_write(s)); } /* diff --git a/src/lib/libssl/src/ssl/s3_both.c b/src/lib/libssl/src/ssl/s3_both.c index 5a1d1e7443..6448f27a03 100644 --- a/src/lib/libssl/src/ssl/s3_both.c +++ b/src/lib/libssl/src/ssl/s3_both.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s3_both.c,v 1.43 2015/07/18 19:41:54 doug Exp $ */ +/* $OpenBSD: s3_both.c,v 1.44 2015/09/11 15:59:21 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -155,13 +155,12 @@ ssl3_do_write(SSL *s, int type) int ssl3_send_finished(SSL *s, int a, int b, const char *sender, int slen) { - unsigned char *p, *d; + unsigned char *p; unsigned long l; int md_len; if (s->state == a) { - d = (unsigned char *)s->init_buf->data; - p = &(d[4]); + p = ssl3_handshake_msg_start(s, SSL3_MT_FINISHED); md_len = s->method->ssl3_enc->finish_mac_length; if (s->method->ssl3_enc->final_finish_mac(s, sender, slen, @@ -184,16 +183,12 @@ ssl3_send_finished(SSL *s, int a, int b, const char *sender, int slen) s->s3->previous_server_finished_len = md_len; } - *(d++) = SSL3_MT_FINISHED; - l2n3(l, d); - s->init_num = (int)l + 4; - s->init_off = 0; + ssl3_handshake_msg_finish(s, l); s->state = b; } - /* SSL3_ST_SEND_xxxxxx_HELLO_B */ - return (ssl3_do_write(s, SSL3_RT_HANDSHAKE)); + return (ssl3_handshake_write(s)); } /* ssl3_take_mac calculates the Finished MAC for the handshakes messages seen to far. */ -- cgit v1.2.3-55-g6feb