xref: /openbsd/lib/libssl/man/SSL_get_ciphers.3 (revision d89ec533)
1.\" $OpenBSD: SSL_get_ciphers.3,v 1.11 2020/09/16 07:25:15 schwarze Exp $
2.\" full merge up to: OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" selective merge up to: OpenSSL 83cf7abf May 29 13:07:08 2018 +0100
4.\"
5.\" This file is a derived work.
6.\" The changes are covered by the following Copyright and license:
7.\"
8.\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org>
9.\"
10.\" Permission to use, copy, modify, and distribute this software for any
11.\" purpose with or without fee is hereby granted, provided that the above
12.\" copyright notice and this permission notice appear in all copies.
13.\"
14.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21.\"
22.\" The original file was written by Lutz Jaenicke <jaenicke@openssl.org>,
23.\" Nick Mathewson <nickm@torproject.org>, Kurt Roeckx <kurt@roeckx.be>,
24.\" Kazuki Yamaguchi <k@rhe.jp>, and Benjamin Kaduk <bkaduk@akamai.com>.
25.\" Copyright (c) 2000, 2005, 2015, 2016, 2017 The OpenSSL Project.
26.\" All rights reserved.
27.\"
28.\" Redistribution and use in source and binary forms, with or without
29.\" modification, are permitted provided that the following conditions
30.\" are met:
31.\"
32.\" 1. Redistributions of source code must retain the above copyright
33.\"    notice, this list of conditions and the following disclaimer.
34.\"
35.\" 2. Redistributions in binary form must reproduce the above copyright
36.\"    notice, this list of conditions and the following disclaimer in
37.\"    the documentation and/or other materials provided with the
38.\"    distribution.
39.\"
40.\" 3. All advertising materials mentioning features or use of this
41.\"    software must display the following acknowledgment:
42.\"    "This product includes software developed by the OpenSSL Project
43.\"    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
44.\"
45.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
46.\"    endorse or promote products derived from this software without
47.\"    prior written permission. For written permission, please contact
48.\"    openssl-core@openssl.org.
49.\"
50.\" 5. Products derived from this software may not be called "OpenSSL"
51.\"    nor may "OpenSSL" appear in their names without prior written
52.\"    permission of the OpenSSL Project.
53.\"
54.\" 6. Redistributions of any form whatsoever must retain the following
55.\"    acknowledgment:
56.\"    "This product includes software developed by the OpenSSL Project
57.\"    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
58.\"
59.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
60.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
61.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
62.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
63.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
64.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
65.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
66.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
67.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
68.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
69.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
70.\" OF THE POSSIBILITY OF SUCH DAMAGE.
71.\"
72.Dd $Mdocdate: September 16 2020 $
73.Dt SSL_GET_CIPHERS 3
74.Os
75.Sh NAME
76.Nm SSL_get_ciphers ,
77.Nm SSL_CTX_get_ciphers ,
78.Nm SSL_get1_supported_ciphers ,
79.Nm SSL_get_client_ciphers ,
80.Nm SSL_get_cipher_list
81.Nd get lists of available SSL_CIPHERs
82.Sh SYNOPSIS
83.In openssl/ssl.h
84.Ft STACK_OF(SSL_CIPHER) *
85.Fn SSL_get_ciphers "const SSL *ssl"
86.Ft STACK_OF(SSL_CIPHER) *
87.Fn SSL_CTX_get_ciphers "const SSL_CTX *ctx"
88.Ft STACK_OF(SSL_CIPHER) *
89.Fn SSL_get1_supported_ciphers "SSL *ssl"
90.Ft STACK_OF(SSL_CIPHER) *
91.Fn SSL_get_client_ciphers "const SSL *ssl"
92.Ft const char *
93.Fn SSL_get_cipher_list "const SSL *ssl" "int priority"
94.Sh DESCRIPTION
95.Fn SSL_get_ciphers
96returns the stack of available
97.Vt SSL_CIPHER Ns s
98for
99.Fa ssl ,
100sorted by preference.
101.Pp
102.Fn SSL_CTX_get_ciphers
103returns the stack of available
104.Vt SSL_CIPHER Ns s
105for
106.Fa ctx .
107.Pp
108.Fn SSL_get1_supported_ciphers
109returns a stack of enabled
110.Vt SSL_CIPHER Ns s
111for
112.Fa ssl
113as it would be sent in a ClientHello, sorted by preference.
114The list depends on settings like the cipher list, the supported
115protocol versions, the security level, and the enabled signature
116algorithms.
117The list of ciphers that would be sent in a ClientHello can differ
118from the list of ciphers that would be acceptable when acting as a
119server.
120For example,
121additional ciphers may be usable by a server if there is a gap in the
122list of supported protocols, and some ciphers may not be usable by a
123server if there is not a suitable certificate configured.
124.Pp
125.Fn SSL_get_client_ciphers
126returns the stack of available
127.Vt SSL_CIPHER Ns s
128matching the list received from the client on
129.Fa ssl .
130.Pp
131The details of the ciphers obtained by
132.Fn SSL_get_ciphers ,
133.Fn SSL_CTX_get_ciphers ,
134.Fn SSL_get1_supported_ciphers ,
135and
136.Fn SSL_get_client_ciphers
137can be obtained using the
138.Xr SSL_CIPHER_get_name 3
139family of functions.
140.Pp
141.Fn SSL_get_cipher_list
142is deprecated \(em use
143.Fn SSL_get_ciphers
144instead \(em and badly misnamed; it does not return a list
145but the name of one element of the return value of
146.Fn SSL_get_ciphers ,
147with the index given by the
148.Fa priority
149argument.
150Passing 0 selects the cipher with the highest priority.
151To iterate over all available ciphers in decreasing priority,
152repeatedly increment the argument by 1 until
153.Dv NULL
154is returned.
155.Sh RETURN VALUES
156.Fn SSL_get_ciphers
157returns an internal pointer to a list of ciphers or
158.Dv NULL
159if
160.Fa ssl
161is
162.Dv NULL
163or if no ciphers are available.
164The returned pointer may not only become invalid when
165.Fa ssl
166is destroyed or when
167.Xr SSL_set_cipher_list 3
168is called on it, but also when the
169.Vt SSL_CTX
170object in use by
171.Fa ssl
172at the time of the call is freed or when
173.Xr SSL_CTX_set_cipher_list 3
174is called on that context object.
175.Pp
176.Fn SSL_CTX_get_ciphers
177returns an internal pointer to a list of ciphers or
178.Dv NULL
179if
180.Fa ctx
181is
182.Dv NULL
183or if no ciphers are available.
184The returned pointer becomes invalid when
185.Fa ctx
186is destroyed or when
187.Xr SSL_CTX_set_cipher_list 3
188is called on it.
189.Pp
190.Fn SSL_get1_supported_ciphers
191returns a newly allocated list of ciphers or
192.Dv NULL
193if
194.Fa ssl
195is
196.Dv NULL ,
197if no ciphers are available, or if an error occurs.
198When the returned pointer is no longer needed, the caller is
199responsible for freeing it using
200.Fn sk_SSL_CIPHER_free .
201.Pp
202.Fn SSL_get_client_ciphers
203returns an internal pointer to a list of ciphers or
204.Dv NULL
205if
206.Fa ssl
207is
208.Dv NULL ,
209has no active session,
210or is not operating in server mode.
211The returned pointer becomes invalid when the
212.Vt SSL_SESSION
213object is destroyed, even if the
214.Fa ssl
215object remains valid.
216It may also become invalid in other circumstances,
217for example when processing a new ClientHello.
218.Pp
219.Fn SSL_get_cipher_list
220returns an internal pointer to a string or
221.Dv NULL
222if
223.Fa ssl
224is
225.Dv NULL ,
226if no ciphers are available, or if
227.Fa priority
228is greater than or equal to the number of available ciphers.
229.Sh SEE ALSO
230.Xr ssl 3 ,
231.Xr SSL_CIPHER_get_name 3 ,
232.Xr SSL_CTX_set_cipher_list 3
233.Sh HISTORY
234.Fn SSL_get_cipher_list
235first appeared in SSLeay 0.5.2.
236.Fn SSL_get_ciphers
237first appeared in SSLeay 0.8.0.
238Both functions have been available since
239.Ox 2.4 .
240.Pp
241.Fn SSL_CTX_get_ciphers
242first appeared in OpenSSL 1.1.0 and has been available since
243.Ox 6.3 .
244.Pp
245.Fn SSL_get1_supported_ciphers
246and
247.Fn SSL_get_client_ciphers
248first appeared in OpenSSL 1.1.0 and has been available since
249.Ox 6.5 .
250