summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libssl/s3_clnt.c38
-rw-r--r--src/lib/libssl/s3_lib.c6
-rw-r--r--src/lib/libssl/s3_srvr.c14
-rw-r--r--src/lib/libssl/ssl.h13
-rw-r--r--src/lib/libssl/ssl_lib.c6
-rw-r--r--src/lib/libssl/ssl_locl.h10
-rw-r--r--src/lib/libssl/ssl_sess.c10
7 files changed, 50 insertions, 47 deletions
diff --git a/src/lib/libssl/s3_clnt.c b/src/lib/libssl/s3_clnt.c
index 18e34f7b7b..2c272032b5 100644
--- a/src/lib/libssl/s3_clnt.c
+++ b/src/lib/libssl/s3_clnt.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: s3_clnt.c,v 1.163 2017/01/23 00:12:54 jsing Exp $ */ 1/* $OpenBSD: s3_clnt.c,v 1.164 2017/01/23 01:22:08 jsing 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 *
@@ -600,7 +600,7 @@ ssl3_client_hello(SSL *s)
600 if ((sess == NULL) || 600 if ((sess == NULL) ||
601 (sess->ssl_version != s->version) || 601 (sess->ssl_version != s->version) ||
602 (!sess->session_id_length && !sess->tlsext_tick) || 602 (!sess->session_id_length && !sess->tlsext_tick) ||
603 (sess->not_resumable)) { 603 (sess->internal->not_resumable)) {
604 if (!ssl_get_new_session(s, 0)) 604 if (!ssl_get_new_session(s, 0))
605 goto err; 605 goto err;
606 } 606 }
@@ -1037,9 +1037,9 @@ ssl3_get_server_certificate(SSL *s)
1037 sc = ssl_sess_cert_new(); 1037 sc = ssl_sess_cert_new();
1038 if (sc == NULL) 1038 if (sc == NULL)
1039 goto err; 1039 goto err;
1040 if (s->session->sess_cert) 1040 if (SSI(s)->sess_cert)
1041 ssl_sess_cert_free(s->session->sess_cert); 1041 ssl_sess_cert_free(SSI(s)->sess_cert);
1042 s->session->sess_cert = sc; 1042 SSI(s)->sess_cert = sc;
1043 1043
1044 sc->cert_chain = sk; 1044 sc->cert_chain = sk;
1045 /* 1045 /*
@@ -1114,7 +1114,7 @@ ssl3_get_server_kex_dhe(SSL *s, EVP_PKEY **pkey, unsigned char **pp, long *nn)
1114 int al; 1114 int al;
1115 1115
1116 alg_a = S3I(s)->tmp.new_cipher->algorithm_auth; 1116 alg_a = S3I(s)->tmp.new_cipher->algorithm_auth;
1117 sc = s->session->sess_cert; 1117 sc = SSI(s)->sess_cert;
1118 1118
1119 if (*nn < 0) 1119 if (*nn < 0)
1120 goto err; 1120 goto err;
@@ -1281,7 +1281,7 @@ ssl3_get_server_kex_ecdhe(SSL *s, EVP_PKEY **pkey, unsigned char **pp, long *nn)
1281 int al; 1281 int al;
1282 1282
1283 alg_a = S3I(s)->tmp.new_cipher->algorithm_auth; 1283 alg_a = S3I(s)->tmp.new_cipher->algorithm_auth;
1284 sc = s->session->sess_cert; 1284 sc = SSI(s)->sess_cert;
1285 1285
1286 if (*nn < 0) 1286 if (*nn < 0)
1287 goto err; 1287 goto err;
@@ -1397,18 +1397,18 @@ ssl3_get_server_key_exchange(SSL *s)
1397 return (1); 1397 return (1);
1398 } 1398 }
1399 1399
1400 if (s->session->sess_cert != NULL) { 1400 if (SSI(s)->sess_cert != NULL) {
1401 DH_free(s->session->sess_cert->peer_dh_tmp); 1401 DH_free(SSI(s)->sess_cert->peer_dh_tmp);
1402 s->session->sess_cert->peer_dh_tmp = NULL; 1402 SSI(s)->sess_cert->peer_dh_tmp = NULL;
1403 1403
1404 EC_KEY_free(s->session->sess_cert->peer_ecdh_tmp); 1404 EC_KEY_free(SSI(s)->sess_cert->peer_ecdh_tmp);
1405 s->session->sess_cert->peer_ecdh_tmp = NULL; 1405 SSI(s)->sess_cert->peer_ecdh_tmp = NULL;
1406 1406
1407 free(s->session->sess_cert->peer_x25519_tmp); 1407 free(SSI(s)->sess_cert->peer_x25519_tmp);
1408 s->session->sess_cert->peer_x25519_tmp = NULL; 1408 SSI(s)->sess_cert->peer_x25519_tmp = NULL;
1409 } else { 1409 } else {
1410 s->session->sess_cert = ssl_sess_cert_new(); 1410 SSI(s)->sess_cert = ssl_sess_cert_new();
1411 if (s->session->sess_cert == NULL) 1411 if (SSI(s)->sess_cert == NULL)
1412 goto err; 1412 goto err;
1413 } 1413 }
1414 1414
@@ -2341,7 +2341,7 @@ ssl3_send_client_key_exchange(SSL *s)
2341 if (s->state == SSL3_ST_CW_KEY_EXCH_A) { 2341 if (s->state == SSL3_ST_CW_KEY_EXCH_A) {
2342 alg_k = S3I(s)->tmp.new_cipher->algorithm_mkey; 2342 alg_k = S3I(s)->tmp.new_cipher->algorithm_mkey;
2343 2343
2344 if ((sess_cert = s->session->sess_cert) == NULL) { 2344 if ((sess_cert = SSI(s)->sess_cert) == NULL) {
2345 ssl3_send_alert(s, SSL3_AL_FATAL, 2345 ssl3_send_alert(s, SSL3_AL_FATAL,
2346 SSL_AD_UNEXPECTED_MESSAGE); 2346 SSL_AD_UNEXPECTED_MESSAGE);
2347 SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, 2347 SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE,
@@ -2636,13 +2636,13 @@ ssl3_check_cert_and_algorithm(SSL *s)
2636 if (alg_a & SSL_aNULL) 2636 if (alg_a & SSL_aNULL)
2637 return (1); 2637 return (1);
2638 2638
2639 sc = s->session->sess_cert; 2639 sc = SSI(s)->sess_cert;
2640 if (sc == NULL) { 2640 if (sc == NULL) {
2641 SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, 2641 SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,
2642 ERR_R_INTERNAL_ERROR); 2642 ERR_R_INTERNAL_ERROR);
2643 goto err; 2643 goto err;
2644 } 2644 }
2645 dh = s->session->sess_cert->peer_dh_tmp; 2645 dh = SSI(s)->sess_cert->peer_dh_tmp;
2646 2646
2647 /* This is the passed certificate. */ 2647 /* This is the passed certificate. */
2648 2648
diff --git a/src/lib/libssl/s3_lib.c b/src/lib/libssl/s3_lib.c
index 990ce2153d..ae2586912c 100644
--- a/src/lib/libssl/s3_lib.c
+++ b/src/lib/libssl/s3_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: s3_lib.c,v 1.120 2017/01/22 09:02:07 jsing Exp $ */ 1/* $OpenBSD: s3_lib.c,v 1.121 2017/01/23 01:22:08 jsing 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 *
@@ -1928,10 +1928,10 @@ ssl_ctrl_get_server_tmp_key(SSL *s, EVP_PKEY **pkey_tmp)
1928 1928
1929 if (s->server != 0) 1929 if (s->server != 0)
1930 return 0; 1930 return 0;
1931 if (s->session == NULL || s->session->sess_cert == NULL) 1931 if (s->session == NULL || SSI(s)->sess_cert == NULL)
1932 return 0; 1932 return 0;
1933 1933
1934 sc = s->session->sess_cert; 1934 sc = SSI(s)->sess_cert;
1935 1935
1936 if ((pkey = EVP_PKEY_new()) == NULL) 1936 if ((pkey = EVP_PKEY_new()) == NULL)
1937 return 0; 1937 return 0;
diff --git a/src/lib/libssl/s3_srvr.c b/src/lib/libssl/s3_srvr.c
index a18b218207..ebdb10cb91 100644
--- a/src/lib/libssl/s3_srvr.c
+++ b/src/lib/libssl/s3_srvr.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: s3_srvr.c,v 1.142 2017/01/23 00:12:54 jsing Exp $ */ 1/* $OpenBSD: s3_srvr.c,v 1.143 2017/01/23 01:22:08 jsing 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 *
@@ -2593,17 +2593,17 @@ ssl3_get_client_certificate(SSL *s)
2593 * With the current implementation, sess_cert will always be NULL 2593 * With the current implementation, sess_cert will always be NULL
2594 * when we arrive here 2594 * when we arrive here
2595 */ 2595 */
2596 if (s->session->sess_cert == NULL) { 2596 if (SSI(s)->sess_cert == NULL) {
2597 s->session->sess_cert = ssl_sess_cert_new(); 2597 SSI(s)->sess_cert = ssl_sess_cert_new();
2598 if (s->session->sess_cert == NULL) { 2598 if (SSI(s)->sess_cert == NULL) {
2599 SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, 2599 SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE,
2600 ERR_R_MALLOC_FAILURE); 2600 ERR_R_MALLOC_FAILURE);
2601 goto err; 2601 goto err;
2602 } 2602 }
2603 } 2603 }
2604 if (s->session->sess_cert->cert_chain != NULL) 2604 if (SSI(s)->sess_cert->cert_chain != NULL)
2605 sk_X509_pop_free(s->session->sess_cert->cert_chain, X509_free); 2605 sk_X509_pop_free(SSI(s)->sess_cert->cert_chain, X509_free);
2606 s->session->sess_cert->cert_chain = sk; 2606 SSI(s)->sess_cert->cert_chain = sk;
2607 2607
2608 /* 2608 /*
2609 * Inconsistency alert: cert_chain does *not* include the 2609 * Inconsistency alert: cert_chain does *not* include the
diff --git a/src/lib/libssl/ssl.h b/src/lib/libssl/ssl.h
index 5904872c92..dce72d8c25 100644
--- a/src/lib/libssl/ssl.h
+++ b/src/lib/libssl/ssl.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl.h,v 1.108 2017/01/23 01:04:23 jsing Exp $ */ 1/* $OpenBSD: ssl.h,v 1.109 2017/01/23 01:22:08 jsing 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 *
@@ -464,28 +464,23 @@ struct ssl_session_st {
464 464
465 int master_key_length; 465 int master_key_length;
466 unsigned char master_key[SSL_MAX_MASTER_KEY_LENGTH]; 466 unsigned char master_key[SSL_MAX_MASTER_KEY_LENGTH];
467
467 /* session_id - valid? */ 468 /* session_id - valid? */
468 unsigned int session_id_length; 469 unsigned int session_id_length;
469 unsigned char session_id[SSL_MAX_SSL_SESSION_ID_LENGTH]; 470 unsigned char session_id[SSL_MAX_SSL_SESSION_ID_LENGTH];
471
470 /* this is used to determine whether the session is being reused in 472 /* this is used to determine whether the session is being reused in
471 * the appropriate context. It is up to the application to set this, 473 * the appropriate context. It is up to the application to set this,
472 * via SSL_new */ 474 * via SSL_new */
473 unsigned int sid_ctx_length; 475 unsigned int sid_ctx_length;
474 unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH]; 476 unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH];
475 477
476 /* Used to indicate that session resumption is not allowed.
477 * Applications can also set this bit for a new session via
478 * not_resumable_session_cb to disable session caching and tickets. */
479 int not_resumable;
480
481 /* The cert is the certificate used to establish this connection */
482 struct sess_cert_st /* SESS_CERT */ *sess_cert;
483
484 /* This is the cert for the other end. 478 /* This is the cert for the other end.
485 * On clients, it will be the same as sess_cert->peer_key->x509 479 * On clients, it will be the same as sess_cert->peer_key->x509
486 * (the latter is not enough as sess_cert is not retained 480 * (the latter is not enough as sess_cert is not retained
487 * in the external representation of sessions, see ssl_asn1.c). */ 481 * in the external representation of sessions, see ssl_asn1.c). */
488 X509 *peer; 482 X509 *peer;
483
489 /* when app_verify_callback accepts a session where the peer's certificate 484 /* when app_verify_callback accepts a session where the peer's certificate
490 * is not ok, we must remember the error for session reuse: */ 485 * is not ok, we must remember the error for session reuse: */
491 long verify_result; /* only for servers */ 486 long verify_result; /* only for servers */
diff --git a/src/lib/libssl/ssl_lib.c b/src/lib/libssl/ssl_lib.c
index f4bb212865..1e529e85de 100644
--- a/src/lib/libssl/ssl_lib.c
+++ b/src/lib/libssl/ssl_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl_lib.c,v 1.130 2017/01/23 00:12:54 jsing Exp $ */ 1/* $OpenBSD: ssl_lib.c,v 1.131 2017/01/23 01:22:08 jsing 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 *
@@ -826,10 +826,10 @@ SSL_get_peer_cert_chain(const SSL *s)
826 STACK_OF(X509) *r; 826 STACK_OF(X509) *r;
827 827
828 if ((s == NULL) || (s->session == NULL) || 828 if ((s == NULL) || (s->session == NULL) ||
829 (s->session->sess_cert == NULL)) 829 (SSI(s)->sess_cert == NULL))
830 r = NULL; 830 r = NULL;
831 else 831 else
832 r = s->session->sess_cert->cert_chain; 832 r = SSI(s)->sess_cert->cert_chain;
833 833
834 /* 834 /*
835 * If we are a client, cert_chain includes the peer's own 835 * If we are a client, cert_chain includes the peer's own
diff --git a/src/lib/libssl/ssl_locl.h b/src/lib/libssl/ssl_locl.h
index 3f63b1de2f..2eace2567d 100644
--- a/src/lib/libssl/ssl_locl.h
+++ b/src/lib/libssl/ssl_locl.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl_locl.h,v 1.152 2017/01/23 00:12:55 jsing Exp $ */ 1/* $OpenBSD: ssl_locl.h,v 1.153 2017/01/23 01:22:08 jsing 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 *
@@ -373,6 +373,14 @@ __BEGIN_HIDDEN_DECLS
373#define NAMED_CURVE_TYPE 3 373#define NAMED_CURVE_TYPE 3
374 374
375typedef struct ssl_session_internal_st { 375typedef struct ssl_session_internal_st {
376 /* Used to indicate that session resumption is not allowed.
377 * Applications can also set this bit for a new session via
378 * not_resumable_session_cb to disable session caching and tickets. */
379 int not_resumable;
380
381 /* The cert is the certificate used to establish this connection */
382 struct sess_cert_st /* SESS_CERT */ *sess_cert;
383
376 size_t tlsext_ecpointformatlist_length; 384 size_t tlsext_ecpointformatlist_length;
377 uint8_t *tlsext_ecpointformatlist; /* peer's list */ 385 uint8_t *tlsext_ecpointformatlist; /* peer's list */
378 size_t tlsext_ellipticcurvelist_length; 386 size_t tlsext_ellipticcurvelist_length;
diff --git a/src/lib/libssl/ssl_sess.c b/src/lib/libssl/ssl_sess.c
index 7f03d12d35..2520843cc0 100644
--- a/src/lib/libssl/ssl_sess.c
+++ b/src/lib/libssl/ssl_sess.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl_sess.c,v 1.56 2017/01/23 00:12:55 jsing Exp $ */ 1/* $OpenBSD: ssl_sess.c,v 1.57 2017/01/23 01:22:08 jsing 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 *
@@ -673,7 +673,7 @@ remove_session_lock(SSL_CTX *ctx, SSL_SESSION *c, int lck)
673 CRYPTO_w_unlock(CRYPTO_LOCK_SSL_CTX); 673 CRYPTO_w_unlock(CRYPTO_LOCK_SSL_CTX);
674 674
675 if (ret) { 675 if (ret) {
676 r->not_resumable = 1; 676 r->internal->not_resumable = 1;
677 if (ctx->remove_session_cb != NULL) 677 if (ctx->remove_session_cb != NULL)
678 ctx->remove_session_cb(ctx, r); 678 ctx->remove_session_cb(ctx, r);
679 SSL_SESSION_free(r); 679 SSL_SESSION_free(r);
@@ -699,8 +699,8 @@ SSL_SESSION_free(SSL_SESSION *ss)
699 699
700 explicit_bzero(ss->master_key, sizeof ss->master_key); 700 explicit_bzero(ss->master_key, sizeof ss->master_key);
701 explicit_bzero(ss->session_id, sizeof ss->session_id); 701 explicit_bzero(ss->session_id, sizeof ss->session_id);
702 if (ss->sess_cert != NULL) 702 if (ss->internal->sess_cert != NULL)
703 ssl_sess_cert_free(ss->sess_cert); 703 ssl_sess_cert_free(ss->internal->sess_cert);
704 X509_free(ss->peer); 704 X509_free(ss->peer);
705 if (ss->ciphers != NULL) 705 if (ss->ciphers != NULL)
706 sk_SSL_CIPHER_free(ss->ciphers); 706 sk_SSL_CIPHER_free(ss->ciphers);
@@ -910,7 +910,7 @@ timeout_doall_arg(SSL_SESSION *s, TIMEOUT_PARAM *p)
910 * save on locking overhead */ 910 * save on locking overhead */
911 (void)lh_SSL_SESSION_delete(p->cache, s); 911 (void)lh_SSL_SESSION_delete(p->cache, s);
912 SSL_SESSION_list_remove(p->ctx, s); 912 SSL_SESSION_list_remove(p->ctx, s);
913 s->not_resumable = 1; 913 s->internal->not_resumable = 1;
914 if (p->ctx->remove_session_cb != NULL) 914 if (p->ctx->remove_session_cb != NULL)
915 p->ctx->remove_session_cb(p->ctx, s); 915 p->ctx->remove_session_cb(p->ctx, s);
916 SSL_SESSION_free(s); 916 SSL_SESSION_free(s);