SSL_CTX_use_psk_identity_hint.pod 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. =pod
  2. =head1 NAME
  3. SSL_psk_server_cb_func,
  4. SSL_psk_find_session_cb_func,
  5. SSL_CTX_use_psk_identity_hint,
  6. SSL_use_psk_identity_hint,
  7. SSL_CTX_set_psk_server_callback,
  8. SSL_set_psk_server_callback,
  9. SSL_CTX_set_psk_find_session_callback,
  10. SSL_set_psk_find_session_callback
  11. - set PSK identity hint to use
  12. =head1 SYNOPSIS
  13. #include <openssl/ssl.h>
  14. typedef int (*SSL_psk_find_session_cb_func)(SSL *ssl,
  15. const unsigned char *identity,
  16. size_t identity_len,
  17. SSL_SESSION **sess);
  18. void SSL_CTX_set_psk_find_session_callback(SSL_CTX *ctx,
  19. SSL_psk_find_session_cb_func cb);
  20. void SSL_set_psk_find_session_callback(SSL *s, SSL_psk_find_session_cb_func cb);
  21. typedef unsigned int (*SSL_psk_server_cb_func)(SSL *ssl,
  22. const char *identity,
  23. unsigned char *psk,
  24. unsigned int max_psk_len);
  25. int SSL_CTX_use_psk_identity_hint(SSL_CTX *ctx, const char *hint);
  26. int SSL_use_psk_identity_hint(SSL *ssl, const char *hint);
  27. void SSL_CTX_set_psk_server_callback(SSL_CTX *ctx, SSL_psk_server_cb_func cb);
  28. void SSL_set_psk_server_callback(SSL *ssl, SSL_psk_server_cb_func cb);
  29. =head1 DESCRIPTION
  30. A client application wishing to use TLSv1.3 PSKs should set a callback
  31. using either SSL_CTX_set_psk_use_session_callback() or
  32. SSL_set_psk_use_session_callback() as appropriate.
  33. The callback function is given a pointer to the SSL connection in B<ssl> and
  34. an identity in B<identity> of length B<identity_len>. The callback function
  35. should identify an SSL_SESSION object that provides the PSK details and store it
  36. in B<*sess>. The SSL_SESSION object should, as a minimum, set the master key,
  37. the ciphersuite and the protocol version. See
  38. L<SSL_CTX_set_psk_use_session_callback(3)> for details.
  39. It is also possible for the callback to succeed but not supply a PSK. In this
  40. case no PSK will be used but the handshake will continue. To do this the
  41. callback should return successfully and ensure that B<*sess> is
  42. NULL.
  43. Identity hints are not relevant for TLSv1.3. A server application wishing to use
  44. PSK ciphersuites for TLSv1.2 and below may call SSL_CTX_use_psk_identity_hint()
  45. to set the given B<NUL>-terminated PSK identity hint B<hint> for SSL context
  46. object B<ctx>. SSL_use_psk_identity_hint() sets the given B<NUL>-terminated PSK
  47. identity hint B<hint> for the SSL connection object B<ssl>. If B<hint> is
  48. B<NULL> the current hint from B<ctx> or B<ssl> is deleted.
  49. In the case where PSK identity hint is B<NULL>, the server does not send the
  50. ServerKeyExchange message to the client.
  51. A server application wishing to use PSKs for TLSv1.2 and below must provide a
  52. callback function which is called when the server receives the
  53. ClientKeyExchange message from the client. The purpose of the callback function
  54. is to validate the received PSK identity and to fetch the pre-shared key used
  55. during the connection setup phase. The callback is set using the functions
  56. SSL_CTX_set_psk_server_callback() or SSL_set_psk_server_callback(). The callback
  57. function is given the connection in parameter B<ssl>, B<NUL>-terminated PSK
  58. identity sent by the client in parameter B<identity>, and a buffer B<psk> of
  59. length B<max_psk_len> bytes where the pre-shared key is to be stored.
  60. The callback for use in TLSv1.2 will also work in TLSv1.3 although it is
  61. recommended to use SSL_CTX_set_psk_find_session_callback()
  62. or SSL_set_psk_find_session_callback() for this purpose instead. If TLSv1.3 has
  63. been negotiated then OpenSSL will first check to see if a callback has been set
  64. via SSL_CTX_set_psk_find_session_callback() or SSL_set_psk_find_session_callback()
  65. and it will use that in preference. If no such callback is present then it will
  66. check to see if a callback has been set via SSL_CTX_set_psk_server_callback() or
  67. SSL_set_psk_server_callback() and use that. In this case the handshake digest
  68. will default to SHA-256 for any returned PSK.
  69. =head1 NOTES
  70. A connection established via a TLSv1.3 PSK will appear as if session resumption
  71. has occurred so that L<SSL_session_reused(3)> will return true.
  72. =head1 RETURN VALUES
  73. B<SSL_CTX_use_psk_identity_hint()> and B<SSL_use_psk_identity_hint()> return
  74. 1 on success, 0 otherwise.
  75. Return values from the TLSv1.2 and below server callback are interpreted as
  76. follows:
  77. =over 4
  78. =item Z<>0
  79. PSK identity was not found. An "unknown_psk_identity" alert message
  80. will be sent and the connection setup fails.
  81. =item E<gt>0
  82. PSK identity was found and the server callback has provided the PSK
  83. successfully in parameter B<psk>. Return value is the length of
  84. B<psk> in bytes. It is an error to return a value greater than
  85. B<max_psk_len>.
  86. If the PSK identity was not found but the callback instructs the
  87. protocol to continue anyway, the callback must provide some random
  88. data to B<psk> and return the length of the random data, so the
  89. connection will fail with decryption_error before it will be finished
  90. completely.
  91. =back
  92. The B<SSL_psk_find_session_cb_func> callback should return 1 on success or 0 on
  93. failure. In the event of failure the connection setup fails.
  94. =head1 SEE ALSO
  95. L<SSL_CTX_set_psk_use_session_callback(3)>,
  96. L<SSL_set_psk_use_session_callback(3)>
  97. =head1 HISTORY
  98. SSL_CTX_set_psk_find_session_callback() and SSL_set_psk_find_session_callback()
  99. were added in OpenSSL 1.1.1.
  100. =head1 COPYRIGHT
  101. Copyright 2006-2018 The OpenSSL Project Authors. All Rights Reserved.
  102. Licensed under the OpenSSL license (the "License"). You may not use
  103. this file except in compliance with the License. You can obtain a copy
  104. in the file LICENSE in the source distribution or at
  105. L<https://www.openssl.org/source/license.html>.
  106. =cut