1SSL_CTX_USE_PSK_IDENTITY_HINT(3ossl)OpenSSLSSL_CTX_USE_PSK_IDENTITY_HINT(3ossl)
2
3
4
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
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
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
89 A connection established via a TLSv1.3 PSK will appear as if session
90 resumption has occurred so that SSL_session_reused(3) will return true.
91
93 SSL_CTX_use_psk_identity_hint() and SSL_use_psk_identity_hint() return
94 1 on success, 0 otherwise.
95
96 Return values from the TLSv1.2 and below server callback are
97 interpreted as follows:
98
99 0 PSK identity was not found. An "unknown_psk_identity" alert message
100 will be sent and the connection setup fails.
101
102 >0 PSK identity was found and the server callback has provided the PSK
103 successfully in parameter psk. Return value is the length of psk in
104 bytes. It is an error to return a value greater than max_psk_len.
105
106 If the PSK identity was not found but the callback instructs the
107 protocol to continue anyway, the callback must provide some random
108 data to psk and return the length of the random data, so the
109 connection will fail with decryption_error before it will be
110 finished completely.
111
112 The SSL_psk_find_session_cb_func callback should return 1 on success or
113 0 on failure. In the event of failure the connection setup fails.
114
116 There are no known security issues with sharing the same PSK between
117 TLSv1.2 (or below) and TLSv1.3. However, the RFC has this note of
118 caution:
119
120 "While there is no known way in which the same PSK might produce
121 related output in both versions, only limited analysis has been done.
122 Implementations can ensure safety from cross-protocol related output by
123 not reusing PSKs between TLS 1.3 and TLS 1.2."
124
126 ssl(7), SSL_CTX_set_psk_use_session_callback(3),
127 SSL_set_psk_use_session_callback(3)
128
130 SSL_CTX_set_psk_find_session_callback() and
131 SSL_set_psk_find_session_callback() were added in OpenSSL 1.1.1.
132
134 Copyright 2006-2020 The OpenSSL Project Authors. All Rights Reserved.
135
136 Licensed under the Apache License 2.0 (the "License"). You may not use
137 this file except in compliance with the License. You can obtain a copy
138 in the file LICENSE in the source distribution or at
139 <https://www.openssl.org/source/license.html>.
140
141
142
1433.0.5 2022-07-0S5SL_CTX_USE_PSK_IDENTITY_HINT(3ossl)