SSL_CTX_SET_TLSEXT_USE_SRTP(3ossl)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 15.1

πŸ’… SSL_CTX_set_tlsext_use_srtp β€” the OpenSSL 3ossl glow-up

okay bestie, sit down, because today we're talking about SSL_CTX_set_tlsext_use_srtp, SSL_set_tlsext_use_srtp, SSL_get_srtp_profiles and SSL_get_selected_srtp_profile β€” the four little functions that let you configure and query SRTP support in OpenSSL. this is from the 3ossl manual, and it's giving "niche but iconic" energy fr fr πŸŽ€


✨ NAME ✨

SSL_CTX_set_tlsext_use_srtp, SSL_set_tlsext_use_srtp, SSL_get_srtp_profiles, SSL_get_selected_srtp_profile β€” configure and query SRTP support πŸ’–

🌸 SYNOPSIS 🌸

#include <openssl/srtp.h>

int SSL_CTX_set_tlsext_use_srtp(SSL_CTX *ctx, const char *profiles);
int SSL_set_tlsext_use_srtp(SSL *ssl, const char *profiles);

STACK_OF(SRTP_PROTECTION_PROFILE) *SSL_get_srtp_profiles(SSL *ssl);
SRTP_PROTECTION_PROFILE *SSL_get_selected_srtp_profile(SSL *s);

literally just four signatures, no drama πŸ‘‘


πŸ¦‹ DESCRIPTION πŸ¦‹

so. SRTP is the Secure Real-Time Transport Protocol, and OpenSSL implements support for the "use_srtp" DTLS extension defined in RFC5764. what does that give you? a whole mechanism for establishing SRTP keying material, algorithms and parameters using DTLS 🫢 and this capability may be used as part of an implementation that conforms to RFC5763.

⚠️ but bestie, read this part twice: OpenSSL does not implement SRTP itself or RFC5763. also, OpenSSL does not support the use of SRTP Master Key Identifiers (MKIs). and this extension is only supported in DTLS β€” any SRTP configuration will be ignored if a TLS connection is attempted 😭

an OpenSSL client wishing to send the "use_srtp" extension should call SSL_CTX_set_tlsext_use_srtp() to set its use for all SSL objects subsequently created from an SSL_CTX. alternatively a client may call SSL_set_tlsext_use_srtp() to set its use for an individual SSL object πŸ”₯

the profiles parameter should point to a NUL-terminated, colon delimited list of SRTP protection profile names.

the currently supported protection profile names are:

  • SRTP_AES128_CM_SHA1_80 β€” this corresponds to SRTP_AES128_CM_HMAC_SHA1_80 defined in RFC5764 πŸ’œ
  • SRTP_AES128_CM_SHA1_32 β€” this corresponds to SRTP_AES128_CM_HMAC_SHA1_32 defined in RFC5764 πŸ’œ
  • SRTP_AEAD_AES_128_GCM β€” this corresponds to the profile of the same name defined in RFC7714 ✨
  • SRTP_AEAD_AES_256_GCM β€” this corresponds to the profile of the same name defined in RFC7714 ✨
  • SRTP_DOUBLE_AEAD_AES_128_GCM_AEAD_AES_128_GCM β€” this corresponds to the profile of the same name defined in RFC8723 🌈
  • SRTP_DOUBLE_AEAD_AES_256_GCM_AEAD_AES_256_GCM β€” this corresponds to the profile of the same name defined in RFC8723 🌈
  • SRTP_ARIA_128_CTR_HMAC_SHA1_80 β€” this corresponds to the profile of the same name defined in RFC8269 🧚
  • SRTP_ARIA_128_CTR_HMAC_SHA1_32 β€” this corresponds to the profile of the same name defined in RFC8269 🧚
  • SRTP_ARIA_256_CTR_HMAC_SHA1_80 β€” this corresponds to the profile of the same name defined in RFC8269 🧚
  • SRTP_ARIA_256_CTR_HMAC_SHA1_32 β€” this corresponds to the profile of the same name defined in RFC8269 🧚
  • SRTP_AEAD_ARIA_128_GCM β€” this corresponds to the profile of the same name defined in RFC8269 πŸ“
  • SRTP_AEAD_ARIA_256_GCM β€” this corresponds to the profile of the same name defined in RFC8269 πŸ“
😭 supplying an unrecognised protection profile name will result in an error. no vibes-based guessing allowed.

an OpenSSL server wishing to support the "use_srtp" extension should also call SSL_CTX_set_tlsext_use_srtp() or SSL_set_tlsext_use_srtp() to indicate the protection profiles that it is willing to negotiate 🀝


the currently configured list of protection profiles β€” for either a client or a server β€” can be obtained by calling SSL_get_srtp_profiles(). this returns a stack of SRTP_PROTECTION_PROFILE objects. and listen: the memory pointed to in the return value of this function should not be freed by the caller πŸ™ˆ (yes, that's you. put the free() down.)

after a handshake has been completed, the negotiated SRTP protection profile (if any) can be obtained (on the client or the server) by calling SSL_get_selected_srtp_profile(). this function will return NULL if no SRTP protection profile was negotiated. the memory returned from this function should not be freed by the caller either, periodt πŸ’…

if an SRTP protection profile has been successfully negotiated, then the SRTP keying material (on both the client and server) should be obtained via a call to SSL_export_keying_material(3). that call should provide:

  • a label value of "EXTRACTOR-dtls_srtp"
  • a NULL context value (use_context is 0)

the total length of keying material obtained should be equal to two times the sum of the master key length and the salt length as defined for the protection profile in use. and the order matters, bestie β€” this gives you:

  1. the client write master key
  2. the server write master key
  3. the client write master salt
  4. the server write master salt

...in that order πŸ”₯πŸ‘‘

πŸ’€ one more thing and it's important: these functions cannot be used with QUIC SSL objects. SSL_CTX_set_tlsext_use_srtp() fails if called on a QUIC SSL context. SSL_set_tlsext_use_srtp() fails if called on a QUIC SSL object. no cap.

πŸ’€ RETURN VALUES πŸ’€

  • SSL_CTX_set_tlsext_use_srtp() and SSL_set_tlsext_use_srtp() return 0 on success or 1 on error. yes, that's inverted from what your brain expects β€” that's just how it is, don't @ me πŸ™ˆ
  • SSL_get_srtp_profiles() returns a stack of SRTP_PROTECTION_PROFILE objects on success, or NULL on error or if no protection profiles have been configured.
  • SSL_get_selected_srtp_profile() returns a pointer to an SRTP_PROTECTION_PROFILE object if one has been negotiated, or NULL otherwise.

πŸŽ€ SEE ALSO πŸŽ€


Copyright 2017-2023 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 whole page, bestie 🫢 this was OpenSSL 3.5.6, dated 2026-04-07 β€” go forth and negotiate those protection profiles responsibly, mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from