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