diff options
author | 2017-03-05 14:24:12 +0000 | |
---|---|---|
committer | 2017-03-05 14:24:12 +0000 | |
commit | a9e43a46453719e446ba6c550d97b12d57af555f (patch) | |
tree | 84fdb96b5e57f9b02423df25f5bcb5d80c01d85a /lib/libssl/ssl_both.c | |
parent | Add an initial regress test that covers the server-side of libssl, by (diff) | |
download | wireguard-openbsd-a9e43a46453719e446ba6c550d97b12d57af555f.tar.xz wireguard-openbsd-a9e43a46453719e446ba6c550d97b12d57af555f.zip |
Convert various handshake message generation functions to CBB.
ok beck@ inoguchi@
Diffstat (limited to 'lib/libssl/ssl_both.c')
-rw-r--r-- | lib/libssl/ssl_both.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/lib/libssl/ssl_both.c b/lib/libssl/ssl_both.c index 14fd121d53b..d1a0879b729 100644 --- a/lib/libssl/ssl_both.c +++ b/lib/libssl/ssl_both.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_both.c,v 1.6 2017/02/07 02:08:38 beck Exp $ */ +/* $OpenBSD: ssl_both.c,v 1.7 2017/03/05 14:24:12 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -166,9 +166,11 @@ 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; + CBB cbb, finished; int md_len; + memset(&cbb, 0, sizeof(cbb)); + if (s->internal->state == a) { md_len = TLS1_FINISH_MAC_LENGTH; OPENSSL_assert(md_len <= EVP_MAX_MD_SIZE); @@ -189,14 +191,23 @@ ssl3_send_finished(SSL *s, int a, int b, const char *sender, int slen) S3I(s)->previous_server_finished_len = md_len; } - p = ssl3_handshake_msg_start(s, SSL3_MT_FINISHED); - memcpy(p, S3I(s)->tmp.finish_md, md_len); - ssl3_handshake_msg_finish(s, md_len); + if (!ssl3_handshake_msg_start_cbb(s, &cbb, &finished, + SSL3_MT_FINISHED)) + goto err; + if (!CBB_add_bytes(&finished, S3I(s)->tmp.finish_md, md_len)) + goto err; + if (!ssl3_handshake_msg_finish_cbb(s, &cbb)) + goto err; s->internal->state = b; } return (ssl3_handshake_write(s)); + + err: + CBB_cleanup(&cbb); + + return (-1); } /* |