rtciv0.5.0

rtci-dtls

Sans-I/O DTLS 1.2 and 1.3 (RFC 6347, RFC 9147) with DTLS-SRTP key export, for WebRTC. 59 public modules, 162 items at 0.5.0.

README

DTLS for WebRTC: DTLS 1.2 and DTLS 1.3, with the extensions WebRTC needs, chiefly the use_srtp extension and the export of SRTP keying material from the handshake. SCTP data channels run over the DTLS association.

Specifications

  • RFC 6347, DTLS 1.2, and RFC 5246, TLS 1.2, as DTLS 1.2 uses it
  • RFC 9147, DTLS 1.3, and RFC 8446, TLS 1.3, as DTLS 1.3 uses it (no 0-RTT, no resumption across processes)
  • RFC 5764, DTLS extension to establish keys for SRTP (use_srtp)
  • RFC 7627, extended master secret; RFC 5746, renegotiation indication
  • RFC 9146, connection identifiers for DTLS 1.2; RFC 5077, session tickets
  • RFC 8122 and RFC 8827, certificate fingerprints and the WebRTC security architecture's DTLS rules

Clause-by-clause status, with the test that proves each clause: rfc6347, rfc9147, rfc5246, rfc8446, rfc5764, rfc7627, rfc5746, rfc9146, rfc5077.

Use

Applications normally get DTLS from the root crate (rtci), which configures it from the peer connection's certificates and fingerprints. Used on its own, config::ConfigBuilder sets certificates, cipher suites, curves, the role and the SRTP protection profiles, and endpoint is the entry point that takes datagrams in and gives datagrams and events out. The crate documentation has an example.

Sans-I/O

The handshake and the record layer are state machines: feed them datagrams and Instants, poll them for the datagrams to send, the next retransmission deadline and the events (handshake complete, exported keys, alerts). The crate does no I/O and reads no clock: every call that depends on time takes an Instant from the caller. All cryptography goes through rtci-crypto's provider (crypto-ring by default, or crypto-aws-lc-rs).

Licence

Licensed under either of the MIT licence or the Apache License, Version 2.0, at your option.

This crate is part of the rtci workspace, which descends from webrtc-rs/rtc and is developed independently; FORK.md lists what it carries over upstream. Upstream's licence and copyright notices are retained.

rtci_dtls

DTLS 1.2 for the Sans-I/O WebRTC stack.

  • modalertAlert records: fatal errors and the orderly close_notify.
  • modapplication_dataApplication data records — the payload DTLS carries once the handshake completes.
  • modchange_cipher_specThe ChangeCipherSpec record, which switches a side over to the negotiated keys.
  • modcipher_suiteThe negotiable cipher suites and the CipherSuite trait they implement.
  • modclient_certificate_typeCertificate types a server may request from a client.
  • modcompression_methodsThe compression-methods field. DTLS in WebRTC always negotiates null compression.
  • modconfigHandshake configuration.
  • modconnConnection state shared across the handshake and record layers.
  • modcontentRecord content types: handshake, alert, change-cipher-spec and application data.
  • modcryptoCryptographic primitives for DTLS.
  • modcurveElliptic curves and the key-exchange values exchanged over them.
  • modendpointThe Sans-I/O entry point: feed it datagrams, poll it for output and events.
  • modextensionClientHello and ServerHello extensions, including use_srtp and SNI.
  • modflightThe flight state machine, which drives the handshake and its retransmissions.
  • modfragment_bufferReassembly of handshake messages fragmented across datagrams.
  • modhandshakeDTLS handshake messages.
  • modhandshakerHandshake orchestration: state, roles and the verification callbacks.
  • modprfThe pseudo-random function that expands the master secret into keys.
  • modrecord_layerThe record layer: framing, sequence numbers and epochs.
  • modsessionPre-shared keys for DTLS 1.3 (RFC 8446 sections 2.2, 4.2.9 to 4.2.11 and 4.6.1, as RFC 9147 carries them): session resumption with tickets, and external PSKs.
  • modsignature_hash_algorithmSignature and hash algorithm pairs, as negotiated for certificate verification.
  • modstateThe negotiated connection state: keys, sequence numbers and peer identity.
  • usecrypto_providerfrom cryptoCryptographic primitives for DTLS.

rtci_dtls::alert

Alert records: fatal errors and the orderly close_notify.

  • structAlert
    • [RFC 5246 §7.2]

rtci_dtls::application_data

Application data records — the payload DTLS carries once the handshake completes.

rtci_dtls::change_cipher_spec

The ChangeCipherSpec record, which switches a side over to the negotiated keys.

rtci_dtls::cipher_suite

The negotiable cipher suites and the CipherSuite trait they implement.

rtci_dtls::cipher_suite::cipher_suite_aes_128_ccm

Shared implementation for the AES-128-CCM suites.

  • structCipherSuiteAes128CcmThe shared AES-128-CCM implementation, parameterized over the key exchange and signature.

rtci_dtls::cipher_suite::cipher_suite_aes_128_gcm_sha256

Shared implementation for the AES-128-GCM-SHA256 suites.

  • structCipherSuiteAes128GcmSha256The shared AES-128-GCM with SHA-256 implementation, parameterized over the key exchange and signature.

rtci_dtls::cipher_suite::cipher_suite_aes_256_cbc_sha

Shared implementation for the AES-256-CBC-SHA suites.

  • structCipherSuiteAes256CbcShaThe shared AES-256-CBC with SHA-1 implementation, parameterized over the key exchange and signature.

rtci_dtls::cipher_suite::cipher_suite_chacha20_poly1305_sha256

Shared implementation for the ChaCha20-Poly1305-SHA256 suites.

rtci_dtls::cipher_suite::cipher_suite_tls_ecdhe_ecdsa_with_aes_128_ccm

An ECDHE-ECDSA suite with AES-128, the pairing WebRTC normally negotiates. An ECDHE-ECDSA suite with AES-128-CCM and a truncated 8-byte tag.

rtci_dtls::cipher_suite::cipher_suite_tls_ecdhe_ecdsa_with_aes_128_ccm8

An ECDHE-ECDSA suite with AES-128-CCM and a full 16-byte tag.

rtci_dtls::cipher_suite::cipher_suite_tls_psk_with_aes_128_ccm

TLS_PSK_WITH_AES_128_CCM, for pre-shared-key handshakes.

rtci_dtls::cipher_suite::cipher_suite_tls_psk_with_aes_128_ccm8

TLS_PSK_WITH_AES_128_CCM_8, with a truncated 8-byte tag.

rtci_dtls::cipher_suite::cipher_suite_tls_psk_with_aes_128_gcm_sha256

TLS_PSK_WITH_AES_128_GCM_SHA256, for pre-shared-key handshakes.

rtci_dtls::client_certificate_type

Certificate types a server may request from a client.

rtci_dtls::compression_methods

The compression-methods field. DTLS in WebRTC always negotiates null compression.

rtci_dtls::config

Handshake configuration.

  • structConfigBuilderConfig is used to configure a DTLS client or server. After a Config is passed to a DTLS function it must not be modified.
  • structHandshakeConfigThe resolved configuration a handshake runs with, produced by ConfigBuilder::build.
  • structRustlsVerifierAdapterExplicit rustls/webpki backend used only for CA-chain and hostname verification.
  • enumClientAuthTypeClientAuthType declares the policy the server will follow for TLS Client Authentication.
  • enumDtlsVersionA version of DTLS this crate negotiates.
  • enumExtendedMasterSecretTypeHow strictly to require the extended master secret extension ([RFC 7627]).
  • fngen_self_signed_root_certGenerates a self-signed certificate, as WebRTC endpoints use.
  • typeVerifyPeerCertificateFnA callback that decides whether a peer's certificate chain is acceptable.

rtci_dtls::conn

Connection state shared across the handshake and record layers.

  • structDTLSConnOne DTLS association: the handshake state machine plus the record layer around it.
  • constMAX_RECORD_PAYLOADThe most bytes a record carries before protection (RFC 5246 6.2.1).

rtci_dtls::content

Record content types: handshake, alert, change-cipher-spec and application data.

rtci_dtls::crypto

Cryptographic primitives for DTLS.

  • modcrypto_cbcAES-CBC with a separate HMAC, for the older CBC suites.
  • modcrypto_ccmAES-CCM authenticated encryption.
  • modcrypto_chacha20ChaCha20-Poly1305 authenticated encryption.
  • modcrypto_gcmAES-GCM authenticated encryption.
  • structCertificateA X.509 certificate(s) used to authenticate a DTLS connection.
  • structCryptoPrivateKeyProvider-neutral DTLS signing key.
  • constOID_ECDSAThe X.509 algorithm OID for ECDSA with a named curve.
  • constOID_ED25519The X.509 algorithm OID for Ed25519.

rtci_dtls::crypto::crypto_cbc

AES-CBC with a separate HMAC, for the older CBC suites.

  • structCryptoCbcAES-CBC encryption with a separate HMAC for DTLS records, holding the per-direction keys.

rtci_dtls::crypto::crypto_ccm

AES-CCM authenticated encryption.

  • structCryptoCcmAES-CCM authenticated encryption for DTLS records, holding the per-direction keys.
  • enumCryptoCcmTagLenThe authentication tag length a CCM suite uses.

rtci_dtls::crypto::crypto_chacha20

ChaCha20-Poly1305 authenticated encryption.

  • structCryptoChaCha20ChaCha20-Poly1305 authenticated encryption for DTLS records, holding the per-direction keys.

rtci_dtls::crypto::crypto_gcm

AES-GCM authenticated encryption.

  • structCryptoGcmAES-GCM authenticated encryption for DTLS records, holding the per-direction keys.

rtci_dtls::curve

Elliptic curves and the key-exchange values exchanged over them.

  • modnamed_curveThe named elliptic curves and key generation over them.
  • enumEllipticCurveTypeHow an elliptic curve is identified in a key exchange — by name, or explicitly.

rtci_dtls::curve::named_curve

The named elliptic curves and key generation over them.

  • structNamedCurveKeypairAn ephemeral ECDHE key pair, with the curve it belongs to.
  • enumNamedCurveThe named elliptic curves this crate can perform ECDHE over.

rtci_dtls::endpoint

The Sans-I/O entry point: feed it datagrams, poll it for output and events.

  • structDatagramTooBigWhat Endpoint::datagram_too_big made of a report that a datagram was too big for the path.
  • structEndpointThe main entry point to the library
  • enumEndpointEventWhat the endpoint reports to its caller.

rtci_dtls::extension

ClientHello and ServerHello extensions, including use_srtp and SNI.

rtci_dtls::extension::extension_server_name

Server Name Indication (SNI).

  • structExtensionServerNameThe Server Name Indication extension, naming the host the client meant to reach.

rtci_dtls::extension::extension_supported_elliptic_curves

The curves a client will accept for ECDHE.

rtci_dtls::extension::extension_supported_point_formats

The EC point formats a client will accept; WebRTC uses uncompressed.

rtci_dtls::extension::extension_supported_signature_algorithms

The signature and hash algorithm pairs a client will accept.

rtci_dtls::extension::extension_use_extended_master_secret

The extended master secret extension ([RFC 7627]), which binds the master secret to the whole handshake.

rtci_dtls::extension::extension_use_srtp

The use_srtp extension, which negotiates SRTP protection profiles during the DTLS handshake ([RFC 5764]).

rtci_dtls::extension::renegotiation_info

The renegotiation info extension, sent empty to signal renegotiation is not supported.

rtci_dtls::flight

The flight state machine, which drives the handshake and its retransmissions.

No public items at its top level.

rtci_dtls::fragment_buffer

Reassembly of handshake messages fragmented across datagrams.

No public items at its top level.

rtci_dtls::handshake

DTLS handshake messages.

rtci_dtls::handshake::handshake_cache

Buffers handshake messages so their hash can be computed for Finished verification.

No public items at its top level.

rtci_dtls::handshake::handshake_header

The header prefixing every handshake message, including fragment offsets.

  • structHandshakeHeaderThe header on every handshake message: type, length, message sequence, and the fragment offset and length that let one message span datagrams.

rtci_dtls::handshake::handshake_message_certificate

Certificate: the sender's certificate chain.

rtci_dtls::handshake::handshake_message_certificate_request

CertificateRequest: the server asks the client to authenticate.

rtci_dtls::handshake::handshake_message_certificate_verify

CertificateVerify: proves possession of the certificate's private key.

rtci_dtls::handshake::handshake_message_client_hello

ClientHello: opens the handshake with the client's offers.

rtci_dtls::handshake::handshake_message_client_key_exchange

ClientKeyExchange: the client's half of the key agreement.

rtci_dtls::handshake::handshake_message_finished

Finished: a hash over the handshake, proving both sides saw the same messages.

  • structHandshakeMessageFinishedA hash over every preceding handshake message, which both sides compare to detect tampering.

rtci_dtls::handshake::handshake_message_hello_verify_request

HelloVerifyRequest: DTLS's cookie exchange, which resists amplification attacks.

rtci_dtls::handshake::handshake_message_new_session_ticket

NewSessionTicket (RFC 5077): a ticket the client may resume the session with.

  • structHandshakeMessageNewSessionTicketNewSessionTicket (RFC 5077 section 3.3), DTLS 1.2: a ticket the server gives the client in its last flight, for the client to resume the session with later. The ticket is opaque to the client; an empty one says the server issues none after all.

rtci_dtls::handshake::handshake_message_server_hello

ServerHello: the server's chosen parameters.

rtci_dtls::handshake::handshake_message_server_hello_done

ServerHelloDone: the server has finished its first flight.

rtci_dtls::handshake::handshake_message_server_key_exchange

ServerKeyExchange: the server's half of the key agreement.

rtci_dtls::handshake::handshake_random

The 32-byte random each side contributes to key derivation.

rtci_dtls::handshaker

Handshake orchestration: state, roles and the verification callbacks.

No public items at its top level.

rtci_dtls::prf

The pseudo-random function that expands the master secret into keys.

No public items at its top level.

rtci_dtls::record_layer

The record layer: framing, sequence numbers and epochs.

rtci_dtls::record_layer::record_layer_header

The DTLS record header.

rtci_dtls::session

Pre-shared keys for DTLS 1.3 (RFC 8446 sections 2.2, 4.2.9 to 4.2.11 and 4.6.1, as RFC 9147 carries them): session resumption with tickets, and external PSKs.

  • structDtls12SessionA DTLS 1.2 session (RFC 5246 section 7.3) that a handshake may resume: what the full handshake that made it agreed on. A server keeps it in its SessionCache under its session id, or seals it into a ticket (RFC 5077); a client keeps it in its SessionStore, with the ticket if the server gave one. Opaque to applications.
  • structExternalPskAn external pre-shared key for DTLS 1.3 (RFC 8446 section 2.2): an identity both sides know and a secret both hold, provisioned out of band. A client offers each it is configured with; a server accepts the one whose identity it has, in place of certificates.
  • structMemorySessionCacheA SessionCache in memory, of a bounded size: the oldest session goes first.
  • structMemorySessionStoreA SessionStore in memory: a few tickets per server name, most recent first.
  • structSessionTicketIssuerThe keys a DTLS server seals its session tickets under (DTLS 1.3 tickets, RFC 8446 section 4.6.1, and DTLS 1.2 tickets, RFC 5077), with the record of the tickets already accepted, for several configurations to share (ConfigBuilder::with_session_ticket_issuer): a ticket one of them issued is accepted, once, by any of them. A configuration given none makes keys of its own when it is built …
  • structTls13SessionA ticket a client received in a NewSessionTicket, with what it needs to resume: the resumption PSK derived for it, the suite it belongs to, and the certificates of the handshake it came from. Opaque to applications; a SessionStore keeps it.
  • traitSessionCacheWhere a DTLS 1.2 server keeps the sessions it may resume by session id (RFC 5246 sections 7.3, 7.4.1.3). A server without one gives no session id and resumes by ticket only, if it issues tickets.
  • traitSessionStoreWhere a client keeps the tickets servers give it, keyed by server name.
  • constMAX_TICKET_LIFETIMEThe longest a ticket may be used for (RFC 8446 section 4.6.1: seven days).

rtci_dtls::signature_hash_algorithm

Signature and hash algorithm pairs, as negotiated for certificate verification.

  • structSignatureHashAlgorithmA signature and hash pair, as negotiated for certificate verification.
  • enumHashAlgorithmThe hash algorithms that may be paired with a signature algorithm.
  • enumSignatureAlgorithmThe signature algorithms this crate can verify and produce.
  • enumSignatureSchemeA TLS signature scheme, which names a signature and hash together ([RFC 8446] §4.2.3).

rtci_dtls::state

The negotiated connection state: keys, sequence numbers and peer identity.

  • structStateThe negotiated connection state: keys, sequence numbers, peer identity and the active cipher suite.

Generated from the sources of rtci-dtls 0.5.0 at its release tag. Items made by macros and methods are on docs.rs.