5 SSL_psk_server_cb_func,
6 SSL_psk_find_session_cb_func,
7 SSL_CTX_use_psk_identity_hint,
8 SSL_use_psk_identity_hint,
9 SSL_CTX_set_psk_server_callback,
10 SSL_set_psk_server_callback,
11 SSL_CTX_set_psk_find_session_callback,
12 SSL_set_psk_find_session_callback
13 - set PSK identity hint to use
17 #include <openssl/ssl.h>
19 typedef unsigned int (*SSL_psk_server_cb_func)(SSL *ssl,
22 unsigned int max_psk_len);
24 typedef int (*SSL_psk_find_session_cb_func)(SSL *ssl,
25 const unsigned char *identity,
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);
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);
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);
41 TLSv1.3 Pre-Shared Keys (PSKs) and PSKs for TLSv1.2 and below are not
44 Identity hints are not relevant for TLSv1.3. A server application wishing to use
45 PSK ciphersuites for TLSv1.2 and below may call SSL_CTX_use_psk_identity_hint()
46 to set the given B<NULL>-terminated PSK identity hint B<hint> for SSL context
47 object B<ctx>. SSL_use_psk_identity_hint() sets the given B<NULL>-terminated PSK
48 identity hint B<hint> for the SSL connection object B<ssl>. If B<hint> is
49 B<NULL> the current hint from B<ctx> or B<ssl> is deleted.
51 In the case where PSK identity hint is B<NULL>, the server does not send the
52 ServerKeyExchange message to the client.
54 A server application for TLSv1.2 and below must provide a callback function
55 which is called when the server receives the ClientKeyExchange message from the
56 client. The purpose of the callback function is to validate the
57 received PSK identity and to fetch the pre-shared key used during the
58 connection setup phase. The callback is set using the functions
59 SSL_CTX_set_psk_server_callback() or SSL_set_psk_server_callback(). The callback
60 function is given the connection in parameter B<ssl>, B<NULL>-terminated PSK
61 identity sent by the client in parameter B<identity>, and a buffer B<psk> of
62 length B<max_psk_len> bytes where the pre-shared key is to be stored.
64 A client application wishing to use TLSv1.3 PSKs must set a different callback
65 using either SSL_CTX_set_psk_use_session_callback() or
66 SSL_set_psk_use_session_callback() as appropriate.
68 The callback function is given a reference to the SSL connection in B<ssl> and
69 an identity in B<identity> of length B<identity_len>. The callback function
70 should identify an SSL_SESSION object that provides the PSK details and store it
71 in B<*sess>. The SSL_SESSION object should, as a minimum, set the master key,
72 the ciphersuite and the protocol version. See
73 L<SSL_CTX_set_psk_use_session_callback(3)> for details.
75 It is also possible for the callback to succeed but not supply a PSK. In this
76 case no PSK will be used but the handshake will continue. To do this the
77 callback should return successfully and ensure that B<*sess> is
82 SSL_CTX_use_psk_identity_hint() and SSL_use_psk_identity_hint() return
83 1 on success, 0 otherwise.
85 Return values from the TLSv1.2 and below server callback are interpreted as
92 PSK identity was not found. An "unknown_psk_identity" alert message
93 will be sent and the connection setup fails.
97 PSK identity was found and the server callback has provided the PSK
98 successfully in parameter B<psk>. Return value is the length of
99 B<psk> in bytes. It is an error to return a value greater than
102 If the PSK identity was not found but the callback instructs the
103 protocol to continue anyway, the callback must provide some random
104 data to B<psk> and return the length of the random data, so the
105 connection will fail with decryption_error before it will be finished
110 The SSL_psk_find_session_cb_func callback should return 1 on success or 0 on
111 failure. In the event of failure the connection setup fails.
115 Copyright 2006-2017 The OpenSSL Project Authors. All Rights Reserved.
117 Licensed under the OpenSSL license (the "License"). You may not use
118 this file except in compliance with the License. You can obtain a copy
119 in the file LICENSE in the source distribution or at
120 L<https://www.openssl.org/source/license.html>.