summary refs log tree commit diff
path: root/man/tls_config_set_protocols.3
blob: 7c62493e831edc0aa8295374fc0d057dafac831c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
.\" $OpenBSD: tls_config_set_protocols.3,v 1.11 2021/01/02 19:58:44 schwarze Exp $
.\"
.\" Copyright (c) 2014 Ted Unangst <tedu@openbsd.org>
.\" Copyright (c) 2015, 2016 Joel Sing <jsing@openbsd.org>
.\" Copyright (c) 2015 Bob Beck <beck@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.
.\"
.Dd $Mdocdate: January 2 2021 $
.Dt TLS_CONFIG_SET_PROTOCOLS 3
.Os
.Sh NAME
.Nm tls_config_set_protocols ,
.Nm tls_config_parse_protocols ,
.Nm tls_config_set_alpn ,
.Nm tls_config_set_ciphers ,
.Nm tls_config_set_dheparams ,
.Nm tls_config_set_ecdhecurves ,
.Nm tls_config_prefer_ciphers_client ,
.Nm tls_config_prefer_ciphers_server
.Nd TLS protocol and cipher selection
.Sh SYNOPSIS
.In tls.h
.Ft int
.Fo tls_config_set_protocols
.Fa "struct tls_config *config"
.Fa "uint32_t protocols"
.Fc
.Ft int
.Fo tls_config_parse_protocols
.Fa "uint32_t *protocols"
.Fa "const char *protostr"
.Fc
.Ft int
.Fo tls_config_set_alpn
.Fa "struct tls_config *config"
.Fa "const char *alpn"
.Fc
.Ft int
.Fo tls_config_set_ciphers
.Fa "struct tls_config *config"
.Fa "const char *ciphers"
.Fc
.Ft int
.Fo tls_config_set_dheparams
.Fa "struct tls_config *config"
.Fa "const char *params"
.Fc
.Ft int
.Fo tls_config_set_ecdhecurves
.Fa "struct tls_config *config"
.Fa "const char *curves"
.Fc
.Ft void
.Fn tls_config_prefer_ciphers_client "struct tls_config *config"
.Ft void
.Fn tls_config_prefer_ciphers_server "struct tls_config *config"
.Sh DESCRIPTION
These functions modify a configuration by setting parameters.
The configuration options apply to both clients and servers, unless noted
otherwise.
.Pp
.Fn tls_config_set_protocols
specifies which versions of the TLS protocol may be used.
Possible values are the bitwise OR of:
.Pp
.Bl -item -offset indent -compact
.It
.Dv TLS_PROTOCOL_TLSv1_0
.It
.Dv TLS_PROTOCOL_TLSv1_1
.It
.Dv TLS_PROTOCOL_TLSv1_2
.It
.Dv TLS_PROTOCOL_TLSv1_3
.El
.Pp
Additionally, the values
.Dv TLS_PROTOCOL_TLSv1
(TLSv1.0, TLSv1.1, TLSv1.2, TLSv1.3),
.Dv TLS_PROTOCOLS_ALL
(all supported protocols) and
.Dv TLS_PROTOCOLS_DEFAULT
(TLSv1.2 and TLSv1.3) may be used.
.Pp
The
.Fn tls_config_parse_protocols
utility function parses a protocol string and returns the corresponding
value via the
.Ar protocols
argument.
This value can then be passed to the
.Fn tls_config_set_protocols
function.
The protocol string is a comma or colon separated list of keywords.
Valid keywords are:
.Pp
.Bl -tag -width "tlsv1.3" -offset indent -compact
.It Dv tlsv1.0
.It Dv tlsv1.1
.It Dv tlsv1.2
.It Dv tlsv1.3
.It Dv all
.Pq all supported protocols
.It Dv default
.Pq an alias for Dv secure
.It Dv legacy
.Pq an alias for Dv all
.It Dv secure
.Pq currently TLSv1.2 and TLSv1.3
.El
.Pp
If a value has a negative prefix (in the form of a leading exclamation mark)
then it is removed from the list of available protocols, rather than being
added to it.
.Pp
.Fn tls_config_set_alpn
sets the ALPN protocols that are supported.
The alpn string is a comma separated list of protocols, in order of preference.
.Pp
.Fn tls_config_set_ciphers
sets the list of ciphers that may be used.
Lists of ciphers are specified by name, and the
permitted names are:
.Pp
.Bl -item -offset indent -compact
.It
.Dv secure Pq or alias Dv default
.It
.Dv compat
.It
.Dv legacy
.It
.Dv insecure Pq or alias Dv all
.El
.Pp
Alternatively, libssl cipher strings can be specified.
See the CIPHERS section of
.Xr openssl 1
for further information.
.Pp
.Fn tls_config_set_dheparams
specifies the parameters that will be used during Diffie-Hellman Ephemeral
(DHE) key exchange.
Possible values are:
.Pp
.Bl -item -offset indent -compact
.It
.Dv none
.It
.Dv auto
.It
.Dv legacy
.El
.Pp
In
.Dv auto
mode, the key size for the ephemeral key is automatically selected
based on the size of the private key being used for signing.
In
.Dv legacy
mode, 1024 bit ephemeral keys are used.
The default value is
.Dv none ,
which disables DHE key exchange.
.Pp
.Fn tls_config_set_ecdhecurves
specifies the names of the elliptic curves that may be used during Elliptic
Curve Diffie-Hellman Ephemeral (ECDHE) key exchange.
This is a comma separated list, given in order of preference.
The special value of "default" will use the default curves (currently X25519,
P-256 and P-384).
This function replaces
.Fn tls_config_set_ecdhecurve ,
which is deprecated.
.Pp
.Fn tls_config_prefer_ciphers_client
prefers ciphers in the client's cipher list when selecting a cipher suite
(server only).
This is considered to be less secure than preferring the server's list.
.Pp
.Fn tls_config_prefer_ciphers_server
prefers ciphers in the server's cipher list when selecting a cipher suite
(server only).
This is considered to be more secure than preferring the client's list and is
the default.
.Sh RETURN VALUES
These functions return 0 on success or -1 on error.
.Sh SEE ALSO
.Xr tls_config_ocsp_require_stapling 3 ,
.Xr tls_config_set_session_id 3 ,
.Xr tls_config_verify 3 ,
.Xr tls_init 3 ,
.Xr tls_load_file 3
.Sh HISTORY
.Fn tls_config_set_ciphers
appeared in
.Ox 5.6
and got its final name in
.Ox 5.7 .
.Pp
.Fn tls_config_set_protocols ,
.Fn tls_config_parse_protocols ,
.Fn tls_config_set_dheparams ,
and
.Fn tls_config_set_ecdhecurve
appeared in
.Ox 5.7 ,
.Fn tls_config_prefer_ciphers_client
and
.Fn tls_config_prefer_ciphers_server
in
.Ox 5.9 ,
and
.Fn tls_config_set_alpn
in
.Ox 6.1 .
.Sh AUTHORS
.An Joel Sing Aq Mt jsing@openbsd.org
with contributions from
.An Ted Unangst Aq Mt tedu@openbsd.org
.Pq Fn tls_config_set_ciphers
and
.An Reyk Floeter Aq Mt reyk@openbsd.org
.Pq Fn tls_config_set_ecdhecurve