diff options
| author | jsing <> | 2024-07-20 04:04:23 +0000 |
|---|---|---|
| committer | jsing <> | 2024-07-20 04:04:23 +0000 |
| commit | 026ea65c83ed46dcfd89ada1f6250daa4fcc01b3 (patch) | |
| tree | b04719de2f91b0f8d7c9c7acb93cef76a89b9948 /src/lib/libssl/ssl_clnt.c | |
| parent | bea193397b98da148fada221ab7ddef17f6749cf (diff) | |
| download | openbsd-026ea65c83ed46dcfd89ada1f6250daa4fcc01b3.tar.gz openbsd-026ea65c83ed46dcfd89ada1f6250daa4fcc01b3.tar.bz2 openbsd-026ea65c83ed46dcfd89ada1f6250daa4fcc01b3.zip | |
Remove cipher from SSL_SESSION.
For a long time SSL_SESSION has had both a cipher ID and a pointer to
an SSL_CIPHER (and not both are guaranteed to be populated). There is also
a pointer to an SSL_CIPHER in the SSL_HANDSHAKE that denotes the cipher
being used for this connection. Some code has been using the cipher from
SSL_SESSION and some code has been using the cipher from SSL_HANDSHAKE.
Remove cipher from SSL_SESSION and use the version in SSL_HANDSHAKE
everywhere. If resuming from a session then we need to use the SSL_SESSION
cipher ID to set the SSL_HANDSHAKE cipher. And we still need to ensure that
we update the cipher ID in the SSL_SESSION whenever the SSL_HANDSHAKE
cipher changes (this only occurs in a few places).
ok tb@
Diffstat (limited to 'src/lib/libssl/ssl_clnt.c')
| -rw-r--r-- | src/lib/libssl/ssl_clnt.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/lib/libssl/ssl_clnt.c b/src/lib/libssl/ssl_clnt.c index 6cf0ee4a4a..7b2e05d23d 100644 --- a/src/lib/libssl/ssl_clnt.c +++ b/src/lib/libssl/ssl_clnt.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: ssl_clnt.c,v 1.166 2024/07/19 08:56:17 jsing Exp $ */ | 1 | /* $OpenBSD: ssl_clnt.c,v 1.167 2024/07/20 04:04:23 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 | * |
| @@ -481,7 +481,7 @@ ssl3_connect(SSL *s) | |||
| 481 | 481 | ||
| 482 | s->s3->hs.state = SSL3_ST_CW_FINISHED_A; | 482 | s->s3->hs.state = SSL3_ST_CW_FINISHED_A; |
| 483 | s->init_num = 0; | 483 | s->init_num = 0; |
| 484 | s->session->cipher = s->s3->hs.cipher; | 484 | s->session->cipher_id = s->s3->hs.cipher->id; |
| 485 | 485 | ||
| 486 | if (!tls1_setup_key_block(s)) { | 486 | if (!tls1_setup_key_block(s)) { |
| 487 | ret = -1; | 487 | ret = -1; |
| @@ -946,8 +946,8 @@ ssl3_get_server_hello(SSL *s) | |||
| 946 | * client cannot change the cipher at this stage, | 946 | * client cannot change the cipher at this stage, |
| 947 | * as the server has already made a selection. | 947 | * as the server has already made a selection. |
| 948 | */ | 948 | */ |
| 949 | if ((s->session->cipher = pref_cipher) == NULL) | 949 | if ((s->s3->hs.cipher = pref_cipher) == NULL) |
| 950 | s->session->cipher = | 950 | s->s3->hs.cipher = |
| 951 | ssl3_get_cipher_by_value(cipher_suite); | 951 | ssl3_get_cipher_by_value(cipher_suite); |
| 952 | s->s3->flags |= SSL3_FLAGS_CCS_OK; | 952 | s->s3->flags |= SSL3_FLAGS_CCS_OK; |
| 953 | } | 953 | } |
| @@ -1016,14 +1016,13 @@ ssl3_get_server_hello(SSL *s) | |||
| 1016 | * and/or cipher_id values may not be set. Make sure that | 1016 | * and/or cipher_id values may not be set. Make sure that |
| 1017 | * cipher_id is set and use it for comparison. | 1017 | * cipher_id is set and use it for comparison. |
| 1018 | */ | 1018 | */ |
| 1019 | if (s->session->cipher) | ||
| 1020 | s->session->cipher_id = s->session->cipher->id; | ||
| 1021 | if (s->hit && (s->session->cipher_id != cipher->id)) { | 1019 | if (s->hit && (s->session->cipher_id != cipher->id)) { |
| 1022 | al = SSL_AD_ILLEGAL_PARAMETER; | 1020 | al = SSL_AD_ILLEGAL_PARAMETER; |
| 1023 | SSLerror(s, SSL_R_OLD_SESSION_CIPHER_NOT_RETURNED); | 1021 | SSLerror(s, SSL_R_OLD_SESSION_CIPHER_NOT_RETURNED); |
| 1024 | goto fatal_err; | 1022 | goto fatal_err; |
| 1025 | } | 1023 | } |
| 1026 | s->s3->hs.cipher = cipher; | 1024 | s->s3->hs.cipher = cipher; |
| 1025 | s->session->cipher_id = cipher->id; | ||
| 1027 | 1026 | ||
| 1028 | if (!tls1_transcript_hash_init(s)) | 1027 | if (!tls1_transcript_hash_init(s)) |
| 1029 | goto err; | 1028 | goto err; |
