1238384Sjkim=pod
2238384Sjkim
3238384Sjkim=begin comment
4238384Sjkim
5238384SjkimCopyright 2005 Nokia. All rights reserved.
6238384Sjkim
7238384SjkimThe portions of the attached software ("Contribution") is developed by
8238384SjkimNokia Corporation and is licensed pursuant to the OpenSSL open source
9238384Sjkimlicense.
10238384Sjkim
11238384SjkimThe Contribution, originally written by Mika Kousa and Pasi Eronen of
12238384SjkimNokia Corporation, consists of the "PSK" (Pre-Shared Key) ciphersuites
13238384Sjkimsupport (see RFC 4279) to OpenSSL.
14238384Sjkim
15238384SjkimNo patent licenses or other rights except those expressly stated in
16238384Sjkimthe OpenSSL open source license shall be deemed granted or received
17238384Sjkimexpressly, by implication, estoppel, or otherwise.
18238384Sjkim
19238384SjkimNo assurances are provided by Nokia that the Contribution does not
20238384Sjkiminfringe the patent or other intellectual property rights of any third
21238384Sjkimparty or that the license provides you with all the necessary rights
22238384Sjkimto make use of the Contribution.
23238384Sjkim
24238384SjkimTHE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. IN
25238384SjkimADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA
26238384SjkimSPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY
27238384SjkimOTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR
28238384SjkimOTHERWISE.
29238384Sjkim
30238384Sjkim=end comment
31238384Sjkim
32238384Sjkim=head1 NAME
33238384Sjkim
34238384SjkimSSL_CTX_set_psk_client_callback, SSL_set_psk_client_callback - set PSK client callback
35238384Sjkim
36238384Sjkim=head1 SYNOPSIS
37238384Sjkim
38238384Sjkim #include <openssl/ssl.h>
39238384Sjkim
40238384Sjkim void SSL_CTX_set_psk_client_callback(SSL_CTX *ctx,
41238384Sjkim	unsigned int (*callback)(SSL *ssl, const char *hint,
42238384Sjkim	char *identity, unsigned int max_identity_len,
43238384Sjkim	unsigned char *psk, unsigned int max_psk_len));
44238384Sjkim void SSL_set_psk_client_callback(SSL *ssl,
45238384Sjkim	unsigned int (*callback)(SSL *ssl, const char *hint,
46238384Sjkim	char *identity, unsigned int max_identity_len,
47238384Sjkim 	unsigned char *psk, unsigned int max_psk_len));
48238384Sjkim
49238384Sjkim
50238384Sjkim=head1 DESCRIPTION
51238384Sjkim
52238384SjkimA client application must provide a callback function which is called
53238384Sjkimwhen the client is sending the ClientKeyExchange message to the server.
54238384Sjkim
55238384SjkimThe purpose of the callback function is to select the PSK identity and
56238384Sjkimthe pre-shared key to use during the connection setup phase.
57238384Sjkim
58238384SjkimThe callback is set using functions SSL_CTX_set_psk_client_callback()
59238384Sjkimor SSL_set_psk_client_callback(). The callback function is given the
60238384Sjkimconnection in parameter B<ssl>, a B<NULL>-terminated PSK identity hint
61238384Sjkimsent by the server in parameter B<hint>, a buffer B<identity> of
62238405Sjkimlength B<max_identity_len> bytes where the resulting
63238384SjkimB<NULL>-terminated identity is to be stored, and a buffer B<psk> of
64238384Sjkimlength B<max_psk_len> bytes where the resulting pre-shared key is to
65238384Sjkimbe stored.
66238384Sjkim
67238384Sjkim=head1 NOTES
68238384Sjkim
69238384SjkimNote that parameter B<hint> given to the callback may be B<NULL>.
70238384Sjkim
71238384Sjkim=head1 RETURN VALUES
72238384Sjkim
73238384SjkimReturn values from the client callback are interpreted as follows:
74238384Sjkim
75238384SjkimOn success (callback found a PSK identity and a pre-shared key to use)
76238384Sjkimthe length (> 0) of B<psk> in bytes is returned.
77238384Sjkim
78238384SjkimOtherwise or on errors callback should return 0. In this case
79238384Sjkimthe connection setup fails.
80238384Sjkim
81238384Sjkim=cut
82