]> git.ipfire.org Git - thirdparty/openssl.git/blame - doc/man3/SSL_CTX_use_psk_identity_hint.pod
Update copyright year
[thirdparty/openssl.git] / doc / man3 / SSL_CTX_use_psk_identity_hint.pod
CommitLineData
ddac1974
NL
1=pod
2
ddac1974
NL
3=head1 NAME
4
93a048a1
MC
5SSL_psk_server_cb_func,
6SSL_psk_find_session_cb_func,
7SSL_CTX_use_psk_identity_hint,
8SSL_use_psk_identity_hint,
9SSL_CTX_set_psk_server_callback,
10SSL_set_psk_server_callback,
11SSL_CTX_set_psk_find_session_callback,
12SSL_set_psk_find_session_callback
13- set PSK identity hint to use
ddac1974 14
ddac1974
NL
15=head1 SYNOPSIS
16
17 #include <openssl/ssl.h>
18
93a048a1
MC
19 typedef int (*SSL_psk_find_session_cb_func)(SSL *ssl,
20 const unsigned char *identity,
21 size_t identity_len,
22 SSL_SESSION **sess);
23
4a192c77
MC
24
25 void SSL_CTX_set_psk_find_session_callback(SSL_CTX *ctx,
26 SSL_psk_find_session_cb_func cb);
27 void SSL_set_psk_find_session_callback(SSL *s, SSL_psk_find_session_cb_func cb);
28
29 typedef unsigned int (*SSL_psk_server_cb_func)(SSL *ssl,
30 const char *identity,
31 unsigned char *psk,
32 unsigned int max_psk_len);
33
ddac1974
NL
34 int SSL_CTX_use_psk_identity_hint(SSL_CTX *ctx, const char *hint);
35 int SSL_use_psk_identity_hint(SSL *ssl, const char *hint);
36
93a048a1
MC
37 void SSL_CTX_set_psk_server_callback(SSL_CTX *ctx, SSL_psk_server_cb_func cb);
38 void SSL_set_psk_server_callback(SSL *ssl, SSL_psk_server_cb_func cb);
ddac1974 39
ddac1974
NL
40=head1 DESCRIPTION
41
4a192c77
MC
42A client application wishing to use TLSv1.3 PSKs should set a callback
43using either SSL_CTX_set_psk_use_session_callback() or
44SSL_set_psk_use_session_callback() as appropriate.
45
46The callback function is given a pointer to the SSL connection in B<ssl> and
47an identity in B<identity> of length B<identity_len>. The callback function
48should identify an SSL_SESSION object that provides the PSK details and store it
49in B<*sess>. The SSL_SESSION object should, as a minimum, set the master key,
50the ciphersuite and the protocol version. See
51L<SSL_CTX_set_psk_use_session_callback(3)> for details.
52
53It is also possible for the callback to succeed but not supply a PSK. In this
54case no PSK will be used but the handshake will continue. To do this the
55callback should return successfully and ensure that B<*sess> is
56NULL.
93a048a1
MC
57
58Identity hints are not relevant for TLSv1.3. A server application wishing to use
59PSK ciphersuites for TLSv1.2 and below may call SSL_CTX_use_psk_identity_hint()
72257204
MC
60to set the given B<NUL>-terminated PSK identity hint B<hint> for SSL context
61object B<ctx>. SSL_use_psk_identity_hint() sets the given B<NUL>-terminated PSK
93a048a1
MC
62identity hint B<hint> for the SSL connection object B<ssl>. If B<hint> is
63B<NULL> the current hint from B<ctx> or B<ssl> is deleted.
ddac1974 64
93a048a1
MC
65In the case where PSK identity hint is B<NULL>, the server does not send the
66ServerKeyExchange message to the client.
ddac1974 67
4a192c77
MC
68A server application wishing to use PSKs for TLSv1.2 and below must provide a
69callback function which is called when the server receives the
70ClientKeyExchange message from the client. The purpose of the callback function
71is to validate the received PSK identity and to fetch the pre-shared key used
72during the connection setup phase. The callback is set using the functions
93a048a1 73SSL_CTX_set_psk_server_callback() or SSL_set_psk_server_callback(). The callback
72257204 74function is given the connection in parameter B<ssl>, B<NUL>-terminated PSK
93a048a1
MC
75identity sent by the client in parameter B<identity>, and a buffer B<psk> of
76length B<max_psk_len> bytes where the pre-shared key is to be stored.
77
4a192c77
MC
78The callback for use in TLSv1.2 will also work in TLSv1.3 although it is
79recommended to use SSL_CTX_set_psk_find_session_callback()
80or SSL_set_psk_find_session_callback() for this purpose instead. If TLSv1.3 has
81been negotiated then OpenSSL will first check to see if a callback has been set
82via SSL_CTX_set_psk_find_session_callback() or SSL_set_psk_find_session_callback()
83and it will use that in preference. If no such callback is present then it will
84check to see if a callback has been set via SSL_CTX_set_psk_server_callback() or
85SSL_set_psk_server_callback() and use that. In this case the handshake digest
86will default to SHA-256 for any returned PSK.
ddac1974 87
8ead6158
MC
88=head1 NOTES
89
90A connection established via a TLSv1.3 PSK will appear as if session resumption
91has occurred so that L<SSL_session_reused(3)> will return true.
92
ddac1974
NL
93=head1 RETURN VALUES
94
72257204 95B<SSL_CTX_use_psk_identity_hint()> and B<SSL_use_psk_identity_hint()> return
ddac1974
NL
961 on success, 0 otherwise.
97
93a048a1
MC
98Return values from the TLSv1.2 and below server callback are interpreted as
99follows:
ddac1974 100
5cc27077
NA
101=over 4
102
fe757304
SS
103=item Z<>0
104
105PSK identity was not found. An "unknown_psk_identity" alert message
106will be sent and the connection setup fails.
107
108=item E<gt>0
ddac1974
NL
109
110PSK identity was found and the server callback has provided the PSK
111successfully in parameter B<psk>. Return value is the length of
112B<psk> in bytes. It is an error to return a value greater than
113B<max_psk_len>.
114
115If the PSK identity was not found but the callback instructs the
116protocol to continue anyway, the callback must provide some random
117data to B<psk> and return the length of the random data, so the
118connection will fail with decryption_error before it will be finished
119completely.
120
5cc27077
NA
121=back
122
72257204 123The B<SSL_psk_find_session_cb_func> callback should return 1 on success or 0 on
93a048a1
MC
124failure. In the event of failure the connection setup fails.
125
e105ae84
MC
126=head1 SEE ALSO
127
128L<SSL_CTX_set_psk_use_session_callback(3)>,
129L<SSL_set_psk_use_session_callback(3)>
130
131=head1 HISTORY
132
133SSL_CTX_set_psk_find_session_callback() and SSL_set_psk_find_session_callback()
134were added in OpenSSL 1.1.1.
135
e2f92610
RS
136=head1 COPYRIGHT
137
b0edda11 138Copyright 2006-2018 The OpenSSL Project Authors. All Rights Reserved.
e2f92610
RS
139
140Licensed under the OpenSSL license (the "License"). You may not use
141this file except in compliance with the License. You can obtain a copy
142in the file LICENSE in the source distribution or at
143L<https://www.openssl.org/source/license.html>.
144
e2f92610 145=cut