Add documentation for SSL_CTX_set_psk_use_session_callback()
[openssl.git] / doc / man3 / SSL_CTX_set_psk_client_callback.pod
1 =pod
2
3 =head1 NAME
4
5 SSL_CTX_set_psk_client_callback, SSL_set_psk_client_callback - set PSK client callback
6
7 =head1 SYNOPSIS
8
9  #include <openssl/ssl.h>
10
11  typedef int (*SSL_psk_use_session_cb_func)(SSL *ssl, const EVP_MD *md,
12                                             const unsigned char **id,
13                                             size_t *idlen,
14                                             SSL_SESSION **sess);
15
16  void SSL_CTX_set_psk_client_callback(SSL_CTX *ctx,
17      unsigned int (*callback)(SSL *ssl, const char *hint,
18                               char *identity, unsigned int max_identity_len,
19                               unsigned char *psk, unsigned int max_psk_len));
20  void SSL_set_psk_client_callback(SSL *ssl,
21      unsigned int (*callback)(SSL *ssl, const char *hint,
22                               char *identity, unsigned int max_identity_len,
23                               unsigned char *psk, unsigned int max_psk_len));
24
25  void SSL_CTX_set_psk_use_session_callback(SSL_CTX *ctx,
26                                            SSL_psk_use_session_cb_func cb);
27
28 =head1 DESCRIPTION
29
30 A client application must provide a callback function which is called
31 when the client is sending the ClientKeyExchange message to the server.
32
33 The purpose of the callback function is to select the PSK identity and
34 the pre-shared key to use during the connection setup phase.
35
36 The callback is set using functions SSL_CTX_set_psk_client_callback()
37 or SSL_set_psk_client_callback(). The callback function is given the
38 connection in parameter B<ssl>, a B<NULL>-terminated PSK identity hint
39 sent by the server in parameter B<hint>, a buffer B<identity> of
40 length B<max_identity_len> bytes where the resulting
41 B<NULL>-terminated identity is to be stored, and a buffer B<psk> of
42 length B<max_psk_len> bytes where the resulting pre-shared key is to
43 be stored.
44
45 =head1 NOTES
46
47 Note that parameter B<hint> given to the callback may be B<NULL>.
48
49 =head1 RETURN VALUES
50
51 Return values from the client callback are interpreted as follows:
52
53 On success (callback found a PSK identity and a pre-shared key to use)
54 the length (> 0) of B<psk> in bytes is returned.
55
56 Otherwise or on errors callback should return 0. In this case
57 the connection setup fails.
58
59 =head1 COPYRIGHT
60
61 Copyright 2006-2016 The OpenSSL Project Authors. All Rights Reserved.
62
63 Licensed under the OpenSSL license (the "License").  You may not use
64 this file except in compliance with the License.  You can obtain a copy
65 in the file LICENSE in the source distribution or at
66 L<https://www.openssl.org/source/license.html>.
67
68 =cut