SSL_CTX_SET_...DING_CALLBACK(3ossl)
π SSL_CTX_set_record_padding_callback + friends: the TLS 1.3 record padding crew (3ossl, OpenSSL) π
okay so bestie, this is the OpenSSL manual page for the whole little friend group of functions that install a callback to specify TLS 1.3 record padding π
β yes, the header calls it SSL_CTX_SET_...DING_CALLBACK(3ossl) because that name is literally too long to exist, and it lives in the 3ossl OpenSSL section. Buckle up, we're going record by record β¨
πΈ NAME πΈ
SSL_CTX_set_record_padding_callback, SSL_set_record_padding_callback, SSL_CTX_set_record_padding_callback_arg, SSL_set_record_padding_callback_arg, SSL_CTX_get_record_padding_callback_arg, SSL_get_record_padding_callback_arg, SSL_CTX_set_block_padding, SSL_CTX_set_block_padding_ex, SSL_set_block_padding, SSL_set_block_padding_ex β install callback to specify TLS 1.3 record padding π
that's the whole squad, they all show up in this one page, no cap π«Ά
β¨ SYNOPSIS β¨
#include <openssl/ssl.h>
void SSL_CTX_set_record_padding_callback(SSL_CTX *ctx, size_t (*cb)(SSL *s, int type, size_t len, void *arg));
int SSL_set_record_padding_callback(SSL *ssl, size_t (*cb)(SSL *s, int type, size_t len, void *arg));
void SSL_CTX_set_record_padding_callback_arg(SSL_CTX *ctx, void *arg);
void *SSL_CTX_get_record_padding_callback_arg(const SSL_CTX *ctx);
void SSL_set_record_padding_callback_arg(SSL *ssl, void *arg);
void *SSL_get_record_padding_callback_arg(const SSL *ssl);
int SSL_CTX_set_block_padding(SSL_CTX *ctx, size_t block_size);
int SSL_set_block_padding(SSL *ssl, size_t block_size);
int SSL_CTX_set_block_padding_ex(SSL_CTX *ctx, size_t app_block_size, size_t hs_block_size);
int SSL_set_block_padding_ex(SSL *ssl, size_t app_block_size, size_t hs_block_size);
look at all those size_ts, we love a type that ate π
π¦ DESCRIPTION π¦
the callback installers π₯
SSL_CTX_set_record_padding_callback() or SSL_set_record_padding_callback() can be used to assign a callback function cb to specify the padding for TLS 1.3 records. The value set in ctx is copied to a new SSL by SSL_new(). Kernel TLS is not possible if the record padding callback is set, and the callback function cannot be set if Kernel TLS is already configured for the current SSL object. it's giving "you can't sit with us" energy, but like, in both directions π
the arg setters and getters π
SSL_CTX_set_record_padding_callback_arg() and SSL_set_record_padding_callback_arg() assign a value arg that is passed to the callback when it is invoked. The value set in ctx is copied to a new SSL by SSL_new(). so the ctx version is literally the main character and the SSL version is the nepo baby that inherits everything β¨
SSL_CTX_get_record_padding_callback_arg() and SSL_get_record_padding_callback_arg() retrieve the arg value that is passed to the callback. reading it back, we love a round trip π
the block padding squad π§
SSL_CTX_set_block_padding() and SSL_set_block_padding() pads the record to a multiple of the block_size. A block_size of 0 or 1 disables block padding. The limit of block_size is SSL3_RT_MAX_PLAIN_LENGTH. don't get too big for your boots bestie, that's the ceiling π
SSL_CTX_set_block_padding_ex() and SSL_set_block_padding_ex() do similarly but allow the caller to separately specify the padding block size to be applied to handshake and application data messages. two sizes, two vibes, one function π
how the callback actually gets called β
The callback is invoked for every record before encryption. The type parameter is the TLS record type that is being processed; may be one of SSL3_RT_APPLICATION_DATA, SSL3_RT_HANDSHAKE, or SSL3_RT_ALERT. The len parameter is the current plaintext length of the record before encryption. The arg parameter is the value set via SSL_CTX_set_record_padding_callback_arg() or SSL_set_record_padding_callback_arg(). iykyk β that's the whole callback contract, right there π«Ά
the QUIC situation π
These functions cannot be used with QUIC SSL objects. SSL_set_record_padding_callback() and SSL_set_block_padding() fail if called on a QUIC SSL object. sorry QUIC girlies, this party is TLS 1.3 only π«
π RETURN VALUES π
SSL_CTX_get_record_padding_callback_arg()andSSL_get_record_padding_callback_arg()return the arg value assigned in the corresponding set functions. yes, they hand you back your own stuff πSSL_CTX_set_block_padding()andSSL_set_block_padding()return1on success or0if block_size is too large. simple, iconic, no notes π- The cb returns the number of padding bytes to add to the record. A return of
0indicates no padding will be added. A return value that causes the record to exceed the maximum record size (SSL3_RT_MAX_PLAIN_LENGTH) will pad out to the maximum record size. ok so basically if you overshoot, it just caps at the max, it does NOT explode, we love a graceful limit β¨ SSL_CTX_get_record_padding_callback_arg()returns1on success or0if the callback function is not set because Kernel TLS is configured for theSSLobject. (yes, this one is listed as returning1/0even though the synopsis saysvoid *β we just report what the page says, no editing the lore π)
π NOTES π
- The default behavior is to add no padding to the record. clean, minimal, no extra baggage π
- A user-supplied padding callback function will override the behavior set by
SSL_set_block_padding()orSSL_CTX_set_block_padding(). Setting the user-supplied callback toNULLwill restore the configured block padding behavior. so the callback is the main character and the block padding is the backup dancer, but the backup dancer gets their spot back when the star leaves π«Ά - These functions only apply to TLS 1.3 records being written. reading is not invited to this party πΈ
- Padding bytes are not added in constant-time. β οΈ fr fr, keep that in mind if you're being all timing-attack-paranoid
π SEE ALSO π
go read those next bestie, they're the prequels π¦
π HISTORY π
- The record padding API was added for TLS 1.3 support in OpenSSL
1.1.1. a classic, truly vintage β¨ - The return type of
SSL_CTX_set_record_padding_callback()function was changed tointin OpenSSL3.0. glow-up era π - The functions
SSL_set_block_padding_ex()andSSL_CTX_set_block_padding_ex()were added in OpenSSL3.4. the new girls on the block π
π COPYRIGHT π
Copyright 2017-2024 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.
and that's the page!! π written for OpenSSL3.5.0, dated2026-09-2,SSL_CTX_SET_...DING_CALLBACK(3ossl)β mwah, go pad some records responsibly bestie ππ₯
π¦ where this page comes from
- opensuse-leap 16.0: openssl-3-doc 3.5.0-160000.11.1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms