From 4fbee6b90386fa14be274db8ba947f951bc6de4c Mon Sep 17 00:00:00 2001 From: jsing <> Date: Mon, 22 Jul 2024 14:47:15 +0000 Subject: Use cipher suite values instead of IDs. OpenSSL has had the concept of cipher IDs, which were a way of working around overlapping cipher suite values between SSLv2 and SSLv3. Given that we no longer have to deal with this issue, replace the use of IDs with cipher suite values. In particular, this means that we can stop mapping back and forth between the two, simplifying things considerably. While here, remove the 'valid' member of the SSL_CIPHER. The ssl3_ciphers[] table is no longer mutable, meaning that ciphers cannot be disabled at runtime (and we have `#if 0' if we want to do it at compile time). Clean up the comments and add/update RFC references for cipher suites. ok tb@ --- src/lib/libssl/ssl_srvr.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'src/lib/libssl/ssl_srvr.c') diff --git a/src/lib/libssl/ssl_srvr.c b/src/lib/libssl/ssl_srvr.c index be6bd7402c..302b6bdf0f 100644 --- a/src/lib/libssl/ssl_srvr.c +++ b/src/lib/libssl/ssl_srvr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_srvr.c,v 1.164 2024/07/20 04:04:23 jsing Exp $ */ +/* $OpenBSD: ssl_srvr.c,v 1.165 2024/07/22 14:47:15 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -651,7 +651,7 @@ ssl3_accept(SSL *s) goto end; s->s3->hs.state = SSL3_ST_SW_FINISHED_A; s->init_num = 0; - s->session->cipher_id = s->s3->hs.cipher->id; + s->session->cipher_value = s->s3->hs.cipher->value; if (!tls1_setup_key_block(s)) { ret = -1; @@ -781,7 +781,6 @@ ssl3_get_client_hello(SSL *s) uint8_t comp_method; int comp_null; int i, j, al, ret, cookie_valid = 0; - unsigned long id; SSL_CIPHER *c; STACK_OF(SSL_CIPHER) *ciphers = NULL; const SSL_METHOD *method; @@ -978,11 +977,10 @@ ssl3_get_client_hello(SSL *s) /* XXX - CBS_len(&cipher_suites) will always be zero here... */ if (s->hit && CBS_len(&cipher_suites) > 0) { j = 0; - id = s->session->cipher_id; for (i = 0; i < sk_SSL_CIPHER_num(ciphers); i++) { c = sk_SSL_CIPHER_value(ciphers, i); - if (c->id == id) { + if (c->value == s->session->cipher_value) { j = 1; break; } @@ -1127,9 +1125,9 @@ ssl3_get_client_hello(SSL *s) goto fatal_err; } s->s3->hs.cipher = c; - s->session->cipher_id = s->s3->hs.cipher->id; + s->session->cipher_value = s->s3->hs.cipher->value; } else { - s->s3->hs.cipher = ssl3_get_cipher_by_id(s->session->cipher_id); + s->s3->hs.cipher = ssl3_get_cipher_by_value(s->session->cipher_value); if (s->s3->hs.cipher == NULL) goto fatal_err; } @@ -1269,8 +1267,7 @@ ssl3_send_server_hello(SSL *s) goto err; /* Cipher suite. */ - if (!CBB_add_u16(&server_hello, - ssl3_cipher_get_value(s->s3->hs.cipher))) + if (!CBB_add_u16(&server_hello, s->s3->hs.cipher->value)) goto err; /* Compression method (null). */ -- cgit v1.2.3-55-g6feb