SSL_CTX_set_record_padding_callback.pod 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. =pod
  2. =head1 NAME
  3. SSL_CTX_set_record_padding_callback,
  4. SSL_set_record_padding_callback,
  5. SSL_CTX_set_record_padding_callback_arg,
  6. SSL_set_record_padding_callback_arg,
  7. SSL_CTX_get_record_padding_callback_arg,
  8. SSL_get_record_padding_callback_arg,
  9. SSL_CTX_set_block_padding,
  10. SSL_set_block_padding - install callback to specify TLS 1.3 record padding
  11. =head1 SYNOPSIS
  12. #include <openssl/ssl.h>
  13. void SSL_CTX_set_record_padding_callback(SSL_CTX *ctx, size_t (*cb)(SSL *s, int type, size_t len, void *arg));
  14. void SSL_set_record_padding_callback(SSL *ssl, size_t (*cb)(SSL *s, int type, size_t len, void *arg));
  15. void SSL_CTX_set_record_padding_callback_arg(SSL_CTX *ctx, void *arg);
  16. void *SSL_CTX_get_record_padding_callback_arg(SSL_CTX *ctx);
  17. void SSL_set_record_padding_callback_arg(SSL *ssl, void *arg);
  18. void *SSL_get_record_padding_callback_arg(SSL *ssl);
  19. int SSL_CTX_set_block_padding(SSL_CTX *ctx, size_t block_size);
  20. int SSL_set_block_padding(SSL *ssl, size_t block_size);
  21. =head1 DESCRIPTION
  22. SSL_CTX_set_record_padding_callback() or SSL_set_record_padding_callback()
  23. can be used to assign a callback function I<cb> to specify the padding
  24. for TLS 1.3 records. The value set in B<ctx> is copied to a new SSL by SSL_new().
  25. SSL_CTX_set_record_padding_callback_arg() and SSL_set_record_padding_callback_arg()
  26. assign a value B<arg> that is passed to the callback when it is invoked. The value
  27. set in B<ctx> is copied to a new SSL by SSL_new().
  28. SSL_CTX_get_record_padding_callback_arg() and SSL_get_record_padding_callback_arg()
  29. retrieve the B<arg> value that is passed to the callback.
  30. SSL_CTX_set_block_padding() and SSL_set_block_padding() pads the record to a multiple
  31. of the B<block_size>. A B<block_size> of 0 or 1 disables block padding. The limit of
  32. B<block_size> is SSL3_RT_MAX_PLAIN_LENGTH.
  33. The callback is invoked for every record before encryption.
  34. The B<type> parameter is the TLS record type that is being processed; may be
  35. one of SSL3_RT_APPLICATION_DATA, SSL3_RT_HANDSHAKE, or SSL3_RT_ALERT.
  36. The B<len> parameter is the current plaintext length of the record before encryption.
  37. The B<arg> parameter is the value set via SSL_CTX_set_record_padding_callback_arg()
  38. or SSL_set_record_padding_callback_arg().
  39. =head1 RETURN VALUES
  40. The SSL_CTX_get_record_padding_callback_arg() and SSL_get_record_padding_callback_arg()
  41. functions return the B<arg> value assigned in the corresponding set functions.
  42. The SSL_CTX_set_block_padding() and SSL_set_block_padding() functions return 1 on success
  43. or 0 if B<block_size> is too large.
  44. The B<cb> returns the number of padding bytes to add to the record. A return of 0
  45. indicates no padding will be added. A return value that causes the record to
  46. exceed the maximum record size (SSL3_RT_MAX_PLAIN_LENGTH) will pad out to the
  47. maximum record size.
  48. =head1 NOTES
  49. The default behavior is to add no padding to the record.
  50. A user-supplied padding callback function will override the behavior set by
  51. SSL_set_block_padding() or SSL_CTX_set_block_padding(). Setting the user-supplied
  52. callback to NULL will restore the configured block padding behavior.
  53. These functions only apply to TLS 1.3 records being written.
  54. Padding bytes are not added in constant-time.
  55. =head1 SEE ALSO
  56. L<ssl(7)>, L<SSL_new(3)>
  57. =head1 HISTORY
  58. The record padding API was added for TLS 1.3 support in OpenSSL 1.1.1.
  59. =head1 COPYRIGHT
  60. Copyright 2017 The OpenSSL Project Authors. All Rights Reserved.
  61. Licensed under the OpenSSL license (the "License"). You may not use
  62. this file except in compliance with the License. You can obtain a copy
  63. in the file LICENSE in the source distribution or at
  64. L<https://www.openssl.org/source/license.html>.
  65. =cut