diff options
| author | jsing <> | 2021-02-22 15:59:10 +0000 |
|---|---|---|
| committer | jsing <> | 2021-02-22 15:59:10 +0000 |
| commit | 31c2675f96aa093b3ad5ba68f18a9459299bb76f (patch) | |
| tree | a7f7865a8d1bcc0bfa905831a41b2d44f8183e83 /src/lib/libssl/ssl_versions.c | |
| parent | b38b3c4cdaca2fdaf70efbdf79aa68508345e85b (diff) | |
| download | openbsd-31c2675f96aa093b3ad5ba68f18a9459299bb76f.tar.gz openbsd-31c2675f96aa093b3ad5ba68f18a9459299bb76f.tar.bz2 openbsd-31c2675f96aa093b3ad5ba68f18a9459299bb76f.zip | |
Factor out/change some of the legacy client version handling code.
This consolidates the version handling code and will make upcoming changes
easier.
ok tb@
Diffstat (limited to 'src/lib/libssl/ssl_versions.c')
| -rw-r--r-- | src/lib/libssl/ssl_versions.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/lib/libssl/ssl_versions.c b/src/lib/libssl/ssl_versions.c index 1ee5ed312c..3c4801971e 100644 --- a/src/lib/libssl/ssl_versions.c +++ b/src/lib/libssl/ssl_versions.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: ssl_versions.c,v 1.11 2021/02/20 09:43:29 jsing Exp $ */ | 1 | /* $OpenBSD: ssl_versions.c,v 1.12 2021/02/22 15:59:10 jsing Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2016, 2017 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2016, 2017 Joel Sing <jsing@openbsd.org> |
| 4 | * | 4 | * |
| @@ -163,6 +163,17 @@ ssl_supported_version_range(SSL *s, uint16_t *min_ver, uint16_t *max_ver) | |||
| 163 | } | 163 | } |
| 164 | 164 | ||
| 165 | int | 165 | int |
| 166 | ssl_max_supported_version(SSL *s, uint16_t *max_ver) | ||
| 167 | { | ||
| 168 | *max_ver = 0; | ||
| 169 | |||
| 170 | if (!ssl_supported_version_range(s, NULL, max_ver)) | ||
| 171 | return 0; | ||
| 172 | |||
| 173 | return 1; | ||
| 174 | } | ||
| 175 | |||
| 176 | int | ||
| 166 | ssl_max_shared_version(SSL *s, uint16_t peer_ver, uint16_t *max_ver) | 177 | ssl_max_shared_version(SSL *s, uint16_t peer_ver, uint16_t *max_ver) |
| 167 | { | 178 | { |
| 168 | uint16_t min_version, max_version, shared_version; | 179 | uint16_t min_version, max_version, shared_version; |
| @@ -235,6 +246,22 @@ ssl_downgrade_max_version(SSL *s, uint16_t *max_ver) | |||
| 235 | } | 246 | } |
| 236 | 247 | ||
| 237 | int | 248 | int |
| 249 | ssl_check_version_from_server(SSL *s, uint16_t server_version) | ||
| 250 | { | ||
| 251 | uint16_t min_version, max_version; | ||
| 252 | |||
| 253 | /* Ensure that the version selected by the server is valid. */ | ||
| 254 | |||
| 255 | if (SSL_is_dtls(s)) | ||
| 256 | return (server_version == DTLS1_VERSION); | ||
| 257 | |||
| 258 | if (!ssl_supported_version_range(s, &min_version, &max_version)) | ||
| 259 | return 0; | ||
| 260 | |||
| 261 | return (server_version >= min_version && server_version <= max_version); | ||
| 262 | } | ||
| 263 | |||
| 264 | int | ||
| 238 | ssl_legacy_stack_version(SSL *s, uint16_t version) | 265 | ssl_legacy_stack_version(SSL *s, uint16_t version) |
| 239 | { | 266 | { |
| 240 | if (SSL_is_dtls(s)) | 267 | if (SSL_is_dtls(s)) |
