summaryrefslogtreecommitdiff
path: root/src/lib/libssl/s23_clnt.c
diff options
context:
space:
mode:
authordoug <>2015-07-19 06:31:32 +0000
committerdoug <>2015-07-19 06:31:32 +0000
commit915e1bd09b87e5d7402cab53ddc89bd039968fd4 (patch)
treee880527a1af6d90c596c3aef10956ea51a3d268e /src/lib/libssl/s23_clnt.c
parentb3d9b986084188c42954e6d52677fe5f9b37f0e7 (diff)
downloadopenbsd-915e1bd09b87e5d7402cab53ddc89bd039968fd4.tar.gz
openbsd-915e1bd09b87e5d7402cab53ddc89bd039968fd4.tar.bz2
openbsd-915e1bd09b87e5d7402cab53ddc89bd039968fd4.zip
Add TLS_method, TLS_client_method and TLS_server_method.
Use these instead of SSLv23_*method when you want to make sure TLS is used. By default, we disable SSLv3 but it's still possible for the user to re-enable it. TLS_*method does not allow SSLv3. Both BoringSSL and (next version of) OpenSSL have these methods. However, they have changed the implementation significantly. We will as well, but not right now. Riding the libssl major bump. ok miod@ bcook@
Diffstat (limited to '')
-rw-r--r--src/lib/libssl/s23_clnt.c66
1 files changed, 65 insertions, 1 deletions
diff --git a/src/lib/libssl/s23_clnt.c b/src/lib/libssl/s23_clnt.c
index 30d97683a7..00954777fc 100644
--- a/src/lib/libssl/s23_clnt.c
+++ b/src/lib/libssl/s23_clnt.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: s23_clnt.c,v 1.38 2015/03/31 13:17:48 jsing Exp $ */ 1/* $OpenBSD: s23_clnt.c,v 1.39 2015/07/19 06:31:32 doug Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -120,6 +120,7 @@
120static const SSL_METHOD *ssl23_get_client_method(int ver); 120static const SSL_METHOD *ssl23_get_client_method(int ver);
121static int ssl23_client_hello(SSL *s); 121static int ssl23_client_hello(SSL *s);
122static int ssl23_get_server_hello(SSL *s); 122static int ssl23_get_server_hello(SSL *s);
123static const SSL_METHOD *tls_get_client_method(int ver);
123 124
124const SSL_METHOD SSLv23_client_method_data = { 125const SSL_METHOD SSLv23_client_method_data = {
125 .version = TLS1_2_VERSION, 126 .version = TLS1_2_VERSION,
@@ -153,6 +154,39 @@ const SSL_METHOD SSLv23_client_method_data = {
153 .ssl_ctx_callback_ctrl = ssl3_ctx_callback_ctrl, 154 .ssl_ctx_callback_ctrl = ssl3_ctx_callback_ctrl,
154}; 155};
155 156
157const SSL_METHOD TLS_client_method_data = {
158 .version = TLS1_2_VERSION,
159 .ssl_new = tls1_new,
160 .ssl_clear = tls1_clear,
161 .ssl_free = tls1_free,
162 .ssl_accept = ssl_undefined_function,
163 .ssl_connect = tls_connect,
164 .ssl_read = ssl23_read,
165 .ssl_peek = ssl23_peek,
166 .ssl_write = ssl23_write,
167 .ssl_shutdown = ssl_undefined_function,
168 .ssl_renegotiate = ssl_undefined_function,
169 .ssl_renegotiate_check = ssl_ok,
170 .ssl_get_message = ssl3_get_message,
171 .ssl_read_bytes = ssl3_read_bytes,
172 .ssl_write_bytes = ssl3_write_bytes,
173 .ssl_dispatch_alert = ssl3_dispatch_alert,
174 .ssl_ctrl = ssl3_ctrl,
175 .ssl_ctx_ctrl = ssl3_ctx_ctrl,
176 .get_cipher_by_char = ssl3_get_cipher_by_char,
177 .put_cipher_by_char = ssl3_put_cipher_by_char,
178 .ssl_pending = ssl_undefined_const_function,
179 .num_ciphers = ssl3_num_ciphers,
180 .get_cipher = ssl3_get_cipher,
181 .get_ssl_method = tls_get_client_method,
182 .get_timeout = ssl23_default_timeout,
183 .ssl3_enc = &ssl3_undef_enc_method,
184 .ssl_version = ssl_undefined_void_function,
185 .ssl_callback_ctrl = ssl3_callback_ctrl,
186 .ssl_ctx_callback_ctrl = ssl3_ctx_callback_ctrl,
187};
188
189
156const SSL_METHOD * 190const SSL_METHOD *
157SSLv23_client_method(void) 191SSLv23_client_method(void)
158{ 192{
@@ -544,3 +578,33 @@ ssl23_get_server_hello(SSL *s)
544err: 578err:
545 return (-1); 579 return (-1);
546} 580}
581
582const SSL_METHOD *
583TLS_client_method(void)
584{
585 return &TLS_client_method_data;
586}
587
588static const SSL_METHOD *
589tls_get_client_method(int ver)
590{
591 if (ver == SSL3_VERSION)
592 return (NULL);
593 else
594 return ssl23_get_client_method(ver);
595}
596
597int
598tls_connect(SSL *s)
599{
600 int ret;
601 unsigned long old_options;
602
603 old_options = s->options;
604
605 s->options |= SSL_OP_NO_SSLv3;
606 ret = ssl23_connect(s);
607 s->options = old_options;
608
609 return ret;
610}