summaryrefslogtreecommitdiff
path: root/src/lib/libssl/t1_enc.c
diff options
context:
space:
mode:
authorjsing <>2024-07-20 04:04:23 +0000
committerjsing <>2024-07-20 04:04:23 +0000
commitb68193edfb3424eb0f993aec6089c9e057aa5d4d (patch)
treeb04719de2f91b0f8d7c9c7acb93cef76a89b9948 /src/lib/libssl/t1_enc.c
parentcc7dc6e9b7012526aa3797842d226b3a275a7e70 (diff)
downloadopenbsd-b68193edfb3424eb0f993aec6089c9e057aa5d4d.tar.gz
openbsd-b68193edfb3424eb0f993aec6089c9e057aa5d4d.tar.bz2
openbsd-b68193edfb3424eb0f993aec6089c9e057aa5d4d.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/t1_enc.c')
-rw-r--r--src/lib/libssl/t1_enc.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/lib/libssl/t1_enc.c b/src/lib/libssl/t1_enc.c
index c6140e9b34..64e1dd5b63 100644
--- a/src/lib/libssl/t1_enc.c
+++ b/src/lib/libssl/t1_enc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: t1_enc.c,v 1.157 2022/11/26 16:08:56 tb Exp $ */ 1/* $OpenBSD: t1_enc.c,v 1.158 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 *
@@ -357,15 +357,17 @@ tls1_setup_key_block(SSL *s)
357 if (s->s3->hs.tls12.key_block != NULL) 357 if (s->s3->hs.tls12.key_block != NULL)
358 return (1); 358 return (1);
359 359
360 if (s->session->cipher && 360 if (s->s3->hs.cipher == NULL)
361 (s->session->cipher->algorithm_mac & SSL_AEAD)) { 361 return (0);
362 if (!ssl_cipher_get_evp_aead(s->session, &aead)) { 362
363 if ((s->s3->hs.cipher->algorithm_mac & SSL_AEAD) != 0) {
364 if (!ssl_cipher_get_evp_aead(s, &aead)) {
363 SSLerror(s, SSL_R_CIPHER_OR_HASH_UNAVAILABLE); 365 SSLerror(s, SSL_R_CIPHER_OR_HASH_UNAVAILABLE);
364 return (0); 366 return (0);
365 } 367 }
366 } else { 368 } else {
367 /* XXX - mac_type and mac_secret_size are now unused. */ 369 /* XXX - mac_type and mac_secret_size are now unused. */
368 if (!ssl_cipher_get_evp(s->session, &cipher, &mac_hash, 370 if (!ssl_cipher_get_evp(s, &cipher, &mac_hash,
369 &mac_type, &mac_secret_size)) { 371 &mac_type, &mac_secret_size)) {
370 SSLerror(s, SSL_R_CIPHER_OR_HASH_UNAVAILABLE); 372 SSLerror(s, SSL_R_CIPHER_OR_HASH_UNAVAILABLE);
371 return (0); 373 return (0);
@@ -395,12 +397,12 @@ tls1_setup_key_block(SSL *s)
395 */ 397 */
396 s->s3->need_empty_fragments = 1; 398 s->s3->need_empty_fragments = 1;
397 399
398 if (s->session->cipher != NULL) { 400 if (s->s3->hs.cipher != NULL) {
399 if (s->session->cipher->algorithm_enc == SSL_eNULL) 401 if (s->s3->hs.cipher->algorithm_enc == SSL_eNULL)
400 s->s3->need_empty_fragments = 0; 402 s->s3->need_empty_fragments = 0;
401 403
402#ifndef OPENSSL_NO_RC4 404#ifndef OPENSSL_NO_RC4
403 if (s->session->cipher->algorithm_enc == SSL_RC4) 405 if (s->s3->hs.cipher->algorithm_enc == SSL_RC4)
404 s->s3->need_empty_fragments = 0; 406 s->s3->need_empty_fragments = 0;
405#endif 407#endif
406 } 408 }