summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authortb <>2019-01-21 10:28:52 +0000
committertb <>2019-01-21 10:28:52 +0000
commitad9a15eedae120d64169a9bdeea62c66b99f0344 (patch)
tree23ba27fdd74b7e2b1a43f24cdf6a5eb8a32ec393 /src/lib
parentb43d2fde51a9d32e752d57173e0ef4b806d6bfbe (diff)
downloadopenbsd-ad9a15eedae120d64169a9bdeea62c66b99f0344.tar.gz
openbsd-ad9a15eedae120d64169a9bdeea62c66b99f0344.tar.bz2
openbsd-ad9a15eedae120d64169a9bdeea62c66b99f0344.zip
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 'src/lib')
-rw-r--r--src/lib/libssl/Makefile3
-rw-r--r--src/lib/libssl/ssl_ciphers.c44
-rw-r--r--src/lib/libssl/ssl_locl.h4
3 files changed, 49 insertions, 2 deletions
diff --git a/src/lib/libssl/Makefile b/src/lib/libssl/Makefile
index 1bb3a0e78d..b51d7168c0 100644
--- a/src/lib/libssl/Makefile
+++ b/src/lib/libssl/Makefile
@@ -1,4 +1,4 @@
1# $OpenBSD: Makefile,v 1.51 2019/01/21 09:10:58 jsing Exp $ 1# $OpenBSD: Makefile,v 1.52 2019/01/21 10:28:52 tb Exp $
2 2
3.include <bsd.own.mk> 3.include <bsd.own.mk>
4.ifndef NOMAN 4.ifndef NOMAN
@@ -43,6 +43,7 @@ SRCS= \
43 ssl_both.c \ 43 ssl_both.c \
44 ssl_cert.c \ 44 ssl_cert.c \
45 ssl_ciph.c \ 45 ssl_ciph.c \
46 ssl_ciphers.c \
46 ssl_clnt.c \ 47 ssl_clnt.c \
47 ssl_err.c \ 48 ssl_err.c \
48 ssl_init.c \ 49 ssl_init.c \
diff --git a/src/lib/libssl/ssl_ciphers.c b/src/lib/libssl/ssl_ciphers.c
new file mode 100644
index 0000000000..081a35ddb2
--- /dev/null
+++ b/src/lib/libssl/ssl_ciphers.c
@@ -0,0 +1,44 @@
1/* $OpenBSD: ssl_ciphers.c,v 1.1 2019/01/21 10:28:52 tb Exp $ */
2/*
3 * Copyright (c) 2019 Theo Buehler <tb@openbsd.org>
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18#include "ssl_locl.h"
19
20int
21ssl_cipher_is_permitted(const SSL_CIPHER *cipher, uint16_t min_ver,
22 uint16_t max_ver)
23{
24 /* XXX: We only support DTLSv1 which is effectively TLSv1.1 */
25 if (min_ver == DTLS1_VERSION || max_ver == DTLS1_VERSION)
26 min_ver = max_ver = TLS1_1_VERSION;
27
28 switch(cipher->algorithm_ssl) {
29 case SSL_SSLV3:
30 if (min_ver <= TLS1_2_VERSION)
31 return 1;
32 break;
33 case SSL_TLSV1_2:
34 if (min_ver <= TLS1_2_VERSION && TLS1_2_VERSION <= max_ver)
35 return 1;
36 break;
37 case SSL_TLSV1_3:
38 if (min_ver <= TLS1_3_VERSION && TLS1_3_VERSION <= max_ver)
39 return 1;
40 break;
41 }
42
43 return 0;
44}
diff --git a/src/lib/libssl/ssl_locl.h b/src/lib/libssl/ssl_locl.h
index 30c1afd22d..7903d84890 100644
--- a/src/lib/libssl/ssl_locl.h
+++ b/src/lib/libssl/ssl_locl.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl_locl.h,v 1.227 2019/01/21 06:58:44 jsing Exp $ */ 1/* $OpenBSD: ssl_locl.h,v 1.228 2019/01/21 10:28:52 tb 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 *
@@ -1052,6 +1052,8 @@ int ssl_version_set_min(const SSL_METHOD *meth, uint16_t ver, uint16_t max_ver,
1052int ssl_version_set_max(const SSL_METHOD *meth, uint16_t ver, uint16_t min_ver, 1052int ssl_version_set_max(const SSL_METHOD *meth, uint16_t ver, uint16_t min_ver,
1053 uint16_t *out_ver); 1053 uint16_t *out_ver);
1054uint16_t ssl_max_server_version(SSL *s); 1054uint16_t ssl_max_server_version(SSL *s);
1055int ssl_cipher_is_permitted(const SSL_CIPHER *cipher, uint16_t min_ver,
1056 uint16_t max_ver);
1055 1057
1056const SSL_METHOD *dtls1_get_client_method(int ver); 1058const SSL_METHOD *dtls1_get_client_method(int ver);
1057const SSL_METHOD *dtls1_get_server_method(int ver); 1059const SSL_METHOD *dtls1_get_server_method(int ver);