1SSL_CTX_USE_PSK_IDENTITY_HINT(3)    OpenSSL   SSL_CTX_USE_PSK_IDENTITY_HINT(3)
2
3
4

NAME

6       SSL_psk_server_cb_func, SSL_psk_find_session_cb_func,
7       SSL_CTX_use_psk_identity_hint, SSL_use_psk_identity_hint,
8       SSL_CTX_set_psk_server_callback, SSL_set_psk_server_callback,
9       SSL_CTX_set_psk_find_session_callback,
10       SSL_set_psk_find_session_callback - set PSK identity hint to use
11

SYNOPSIS

13        #include <openssl/ssl.h>
14
15        typedef int (*SSL_psk_find_session_cb_func)(SSL *ssl,
16                                                    const unsigned char *identity,
17                                                    size_t identity_len,
18                                                    SSL_SESSION **sess);
19
20
21        void SSL_CTX_set_psk_find_session_callback(SSL_CTX *ctx,
22                                                   SSL_psk_find_session_cb_func cb);
23        void SSL_set_psk_find_session_callback(SSL *s, SSL_psk_find_session_cb_func cb);
24
25        typedef unsigned int (*SSL_psk_server_cb_func)(SSL *ssl,
26                                                       const char *identity,
27                                                       unsigned char *psk,
28                                                       unsigned int max_psk_len);
29
30        int SSL_CTX_use_psk_identity_hint(SSL_CTX *ctx, const char *hint);
31        int SSL_use_psk_identity_hint(SSL *ssl, const char *hint);
32
33        void SSL_CTX_set_psk_server_callback(SSL_CTX *ctx, SSL_psk_server_cb_func cb);
34        void SSL_set_psk_server_callback(SSL *ssl, SSL_psk_server_cb_func cb);
35

DESCRIPTION

37       A server application wishing to use TLSv1.3 PSKs should set a callback
38       using either SSL_CTX_set_psk_find_session_callback() or
39       SSL_set_psk_find_session_callback() as appropriate.
40
41       The callback function is given a pointer to the SSL connection in ssl
42       and an identity in identity of length identity_len. The callback
43       function should identify an SSL_SESSION object that provides the PSK
44       details and store it in *sess. The SSL_SESSION object should, as a
45       minimum, set the master key, the ciphersuite and the protocol version.
46       See SSL_CTX_set_psk_use_session_callback(3) for details.
47
48       It is also possible for the callback to succeed but not supply a PSK.
49       In this case no PSK will be used but the handshake will continue. To do
50       this the callback should return successfully and ensure that *sess is
51       NULL.
52
53       Identity hints are not relevant for TLSv1.3. A server application
54       wishing to use PSK ciphersuites for TLSv1.2 and below may call
55       SSL_CTX_use_psk_identity_hint() to set the given NUL-terminated PSK
56       identity hint hint for SSL context object ctx.
57       SSL_use_psk_identity_hint() sets the given NUL-terminated PSK identity
58       hint hint for the SSL connection object ssl. If hint is NULL the
59       current hint from ctx or ssl is deleted.
60
61       In the case where PSK identity hint is NULL, the server does not send
62       the ServerKeyExchange message to the client.
63
64       A server application wishing to use PSKs for TLSv1.2 and below must
65       provide a callback function which is called when the server receives
66       the ClientKeyExchange message from the client. The purpose of the
67       callback function is to validate the received PSK identity and to fetch
68       the pre-shared key used during the connection setup phase. The callback
69       is set using the functions SSL_CTX_set_psk_server_callback() or
70       SSL_set_psk_server_callback(). The callback function is given the
71       connection in parameter ssl, NUL-terminated PSK identity sent by the
72       client in parameter identity, and a buffer psk of length max_psk_len
73       bytes where the pre-shared key is to be stored.
74
75       The callback for use in TLSv1.2 will also work in TLSv1.3 although it
76       is recommended to use SSL_CTX_set_psk_find_session_callback() or
77       SSL_set_psk_find_session_callback() for this purpose instead. If
78       TLSv1.3 has been negotiated then OpenSSL will first check to see if a
79       callback has been set via SSL_CTX_set_psk_find_session_callback() or
80       SSL_set_psk_find_session_callback() and it will use that in preference.
81       If no such callback is present then it will check to see if a callback
82       has been set via SSL_CTX_set_psk_server_callback() or
83       SSL_set_psk_server_callback() and use that. In this case the handshake
84       digest will default to SHA-256 for any returned PSK. TLSv1.3 early data
85       exchanges are possible in PSK connections only with the
86       SSL_psk_find_session_cb_func callback, and are not possible with the
87       SSL_psk_server_cb_func callback.
88

NOTES

90       A connection established via a TLSv1.3 PSK will appear as if session
91       resumption has occurred so that SSL_session_reused(3) will return true.
92

RETURN VALUES

94       SSL_CTX_use_psk_identity_hint() and SSL_use_psk_identity_hint() return
95       1 on success, 0 otherwise.
96
97       Return values from the TLSv1.2 and below server callback are
98       interpreted as follows:
99
100       0   PSK identity was not found. An "unknown_psk_identity" alert message
101           will be sent and the connection setup fails.
102
103       >0  PSK identity was found and the server callback has provided the PSK
104           successfully in parameter psk. Return value is the length of psk in
105           bytes. It is an error to return a value greater than max_psk_len.
106
107           If the PSK identity was not found but the callback instructs the
108           protocol to continue anyway, the callback must provide some random
109           data to psk and return the length of the random data, so the
110           connection will fail with decryption_error before it will be
111           finished completely.
112
113       The SSL_psk_find_session_cb_func callback should return 1 on success or
114       0 on failure. In the event of failure the connection setup fails.
115

NOTES

117       There are no known security issues with sharing the same PSK between
118       TLSv1.2 (or below) and TLSv1.3. However, the RFC has this note of
119       caution:
120
121       "While there is no known way in which the same PSK might produce
122       related output in both versions, only limited analysis has been done.
123       Implementations can ensure safety from cross-protocol related output by
124       not reusing PSKs between TLS 1.3 and TLS 1.2."
125

SEE ALSO

127       SSL_CTX_set_psk_use_session_callback(3),
128       SSL_set_psk_use_session_callback(3)
129

HISTORY

131       SSL_CTX_set_psk_find_session_callback() and
132       SSL_set_psk_find_session_callback() were added in OpenSSL 1.1.1.
133
135       Copyright 2006-2020 The OpenSSL Project Authors. All Rights Reserved.
136
137       Licensed under the OpenSSL license (the "License").  You may not use
138       this file except in compliance with the License.  You can obtain a copy
139       in the file LICENSE in the source distribution or at
140       <https://www.openssl.org/source/license.html>.
141
142
143
1441.1.1q                            2022-07-07  SSL_CTX_USE_PSK_IDENTITY_HINT(3)
Impressum