
#use wml::openssl-macros area=docs page=SSL_CTX_use_psk_identity_hint

<title>Documents, SSL_CTX_use_psk_identity_hint(3)</title>

<h1>SSL_CTX_use_psk_identity_hint(3)</h1>

#use wml::imp::generic

{:
## What's this? [[s|(<STRONG>[^<].+?)</A>(</STRONG><DD>)|$1$2|sg]]
[[s|<P>\s+<P>|<P>|sg]]
[[s|<P>\s+</|</|sg]]
[[s|<DD>\s*<DT>|<DD>&nbsp;<DT>|sg]]
[[s|<DD>\s*</DL>|<DD>&nbsp;</DL>|sg]]
[[s|\[|&#91;|sg]]
[[s|\]|&#93;|sg]]

<!-- INDEX BEGIN -->

<UL>

	<LI><A HREF="#NAME">NAME</A>
	<LI><A HREF="#SYNOPSIS">SYNOPSIS</A>
	<LI><A HREF="#DESCRIPTION">DESCRIPTION</A>
	<LI><A HREF="#RETURN_VALUES">RETURN VALUES</A>
</UL>
<!-- INDEX END -->

<HR>
<P>
<HR>
<H1><A NAME="NAME">NAME</A></H1>
<P>
SSL_CTX_use_psk_identity_hint, SSL_use_psk_identity_hint,
SSL_CTX_set_psk_server_callback, SSL_set_psk_server_callback - set PSK
identity hint to use

</P>
<P>
<HR>
<H1><A NAME="SYNOPSIS">SYNOPSIS</A></H1>
<PRE> #include &lt;openssl/ssl.h&gt;
</PRE>
<PRE> int SSL_CTX_use_psk_identity_hint(SSL_CTX *ctx, const char *hint);
 int SSL_use_psk_identity_hint(SSL *ssl, const char *hint);
</PRE>
<PRE> void SSL_CTX_set_psk_server_callback(SSL_CTX *ctx,
        unsigned int (*callback)(SSL *ssl, const char *identity,
        unsigned char *psk, int max_psk_len));
 void SSL_set_psk_server_callback(SSL *ssl,
        unsigned int (*callback)(SSL *ssl, const char *identity,
        unsigned char *psk, int max_psk_len));
</PRE>
<P>
<HR>
<H1><A NAME="DESCRIPTION">DESCRIPTION</A></H1>
<P>
<CODE>SSL_CTX_use_psk_identity_hint()</CODE> sets the given <STRONG>NULL</STRONG>-terminated PSK identity hint <STRONG>hint</STRONG> to SSL context object
<STRONG>ctx</STRONG>. <CODE>SSL_use_psk_identity_hint()</CODE> sets the given <STRONG>NULL</STRONG>-terminated PSK identity hint <STRONG>hint</STRONG> to SSL connection object <STRONG>ssl</STRONG>. If <STRONG>hint</STRONG>
is <STRONG>NULL</STRONG> the current hint from <STRONG>ctx</STRONG> or <STRONG>ssl</STRONG> is deleted.

</P>
<P>
In the case where PSK identity hint is <STRONG>NULL</STRONG>, the server does not send the ServerKeyExchange message to the client.

</P>
<P>
A server application must provide a callback function which is called when
the server receives the ClientKeyExchange message from the client. The
purpose of the callback function is to validate the received PSK identity
and to fetch the pre-shared key used during the connection setup phase. The
callback is set using functions
<CODE>SSL_CTX_set_psk_server_callback()</CODE> or
<CODE>SSL_set_psk_server_callback().</CODE> The callback function is given
the connection in parameter <STRONG>ssl</STRONG>, <STRONG>NULL</STRONG>-terminated PSK identity sent by the client in parameter <STRONG>identity</STRONG>, and a buffer <STRONG>psk</STRONG> of length
<STRONG>max_psk_len</STRONG> bytes where the pre-shared key is to be stored.

</P>
<P>
<HR>
<H1><A NAME="RETURN_VALUES">RETURN VALUES</A></H1>
<P>
<CODE>SSL_CTX_use_psk_identity_hint()</CODE> and
<CODE>SSL_use_psk_identity_hint()</CODE> return 1 on success, 0 otherwise.

</P>
<P>
Return values from the server callback are interpreted as follows:

</P>
<DL>
<DT><STRONG><A NAME="item__">> 0</A></STRONG><DD>
<P>
PSK identity was found and the server callback has provided the PSK
successfully in parameter <STRONG>psk</STRONG>. Return value is the length of
<STRONG>psk</STRONG> in bytes. It is an error to return a value greater than
<STRONG>max_psk_len</STRONG>.

</P>
<P>
If the PSK identity was not found but the callback instructs the protocol
to continue anyway, the callback must provide some random data to <STRONG>psk</STRONG> and return the length of the random data, so the connection will fail with
decryption_error before it will be finished completely.

</P>
<DT><STRONG><A NAME="item_0">0</A></STRONG><DD>
<P>
PSK identity was not found. An ``unknown_psk_identity'' alert message will
be sent and the connection setup fails.

</P>
</DL>
:}

