diff options
author | Theo Buehler <tb@cvs.openbsd.org> | 2019-01-21 10:28:53 +0000 |
---|---|---|
committer | Theo Buehler <tb@cvs.openbsd.org> | 2019-01-21 10:28:53 +0000 |
commit | da7ab3402b7ec35421ab82825b9e2d479ec44887 (patch) | |
tree | ce96f436baa2904a4c8273b34cba2c20a9577b92 /lib/libssl | |
parent | cb48bf977a475468637078c2e9ac1f91bf4826f3 (diff) |
Add ssl_cipher_is_permitted(), an internal helper function that
will be used in a few places shortly, e.g. in
ssl_cipher_list_to_bytes().
ok jsing
Diffstat (limited to 'lib/libssl')
-rw-r--r-- | lib/libssl/Makefile | 3 | ||||
-rw-r--r-- | lib/libssl/ssl_ciphers.c | 44 | ||||
-rw-r--r-- | lib/libssl/ssl_locl.h | 4 |
3 files changed, 49 insertions, 2 deletions
diff --git a/lib/libssl/Makefile b/lib/libssl/Makefile index 1bb3a0e78d8..b51d7168c03 100644 --- a/lib/libssl/Makefile +++ b/lib/libssl/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.51 2019/01/21 09:10:58 jsing Exp $ +# $OpenBSD: Makefile,v 1.52 2019/01/21 10:28:52 tb Exp $ .include <bsd.own.mk> .ifndef NOMAN @@ -43,6 +43,7 @@ SRCS= \ ssl_both.c \ ssl_cert.c \ ssl_ciph.c \ + ssl_ciphers.c \ ssl_clnt.c \ ssl_err.c \ ssl_init.c \ diff --git a/lib/libssl/ssl_ciphers.c b/lib/libssl/ssl_ciphers.c new file mode 100644 index 00000000000..081a35ddb2b --- /dev/null +++ b/lib/libssl/ssl_ciphers.c @@ -0,0 +1,44 @@ +/* $OpenBSD: ssl_ciphers.c,v 1.1 2019/01/21 10:28:52 tb Exp $ */ +/* + * Copyright (c) 2019 Theo Buehler <tb@openbsd.org> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include "ssl_locl.h" + +int +ssl_cipher_is_permitted(const SSL_CIPHER *cipher, uint16_t min_ver, + uint16_t max_ver) +{ + /* XXX: We only support DTLSv1 which is effectively TLSv1.1 */ + if (min_ver == DTLS1_VERSION || max_ver == DTLS1_VERSION) + min_ver = max_ver = TLS1_1_VERSION; + + switch(cipher->algorithm_ssl) { + case SSL_SSLV3: + if (min_ver <= TLS1_2_VERSION) + return 1; + break; + case SSL_TLSV1_2: + if (min_ver <= TLS1_2_VERSION && TLS1_2_VERSION <= max_ver) + return 1; + break; + case SSL_TLSV1_3: + if (min_ver <= TLS1_3_VERSION && TLS1_3_VERSION <= max_ver) + return 1; + break; + } + + return 0; +} diff --git a/lib/libssl/ssl_locl.h b/lib/libssl/ssl_locl.h index 30c1afd22d7..7903d848901 100644 --- a/lib/libssl/ssl_locl.h +++ b/lib/libssl/ssl_locl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_locl.h,v 1.227 2019/01/21 06:58:44 jsing Exp $ */ +/* $OpenBSD: ssl_locl.h,v 1.228 2019/01/21 10:28:52 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -1052,6 +1052,8 @@ int ssl_version_set_min(const SSL_METHOD *meth, uint16_t ver, uint16_t max_ver, int ssl_version_set_max(const SSL_METHOD *meth, uint16_t ver, uint16_t min_ver, uint16_t *out_ver); uint16_t ssl_max_server_version(SSL *s); +int ssl_cipher_is_permitted(const SSL_CIPHER *cipher, uint16_t min_ver, + uint16_t max_ver); const SSL_METHOD *dtls1_get_client_method(int ver); const SSL_METHOD *dtls1_get_server_method(int ver); |