moonbitstack/moontls/srtp does not have a README file

    Keys

    pub(all) struct Keys {
    client_key : Bytes
    server_key : Bytes
    client_salt : Bytes
    server_salt : Bytes
    } derive(Eq,
    Debug
    )

    The four pieces of keying material a DTLS-SRTP handshake produces (RFC 5764 §4.2).

    Which side is "client" is the DTLS side, not the RTP side: the peer that sent the ClientHello uses client_key and client_salt to protect what it sends, whichever end of the media stream it turns out to be.

    Keys::equal

    fn Keys::equal(Keys, Keys) -> Bool
    automatically derived

    Keys::not_equal

    fn Keys::not_equal(x : Keys, y : Keys) -> Bool
    automatically derived

    Keys::to_repr

    automatically derived

    Profile

    pub(all) enum Profile {
    Aes128CmSha1Tag80
    Aes128CmSha1Tag32
    NullSha1Tag80
    NullSha1Tag32
    Aead128Gcm
    Aead256Gcm
    } derive(Eq,
    Debug
    )

    An SRTP protection profile (RFC 5764 §4.1.2, RFC 7714 §14.2): which transform the two ends will protect RTP with, and therefore how much keying material the handshake has to export.

    The Null profiles authenticate without encrypting. They exist for diagnosis, and a peer that offers nothing else is asking for RTP in the clear — this package will negotiate one only if a caller puts it in supported, which the default does not.

    Profile::code

    fn Profile::code(self : Profile) -> Int

    The two octets this profile goes on the wire as (RFC 5764 §4.1.2).

    Profile::equal

    fn Profile::equal(Profile, Profile) -> Bool
    automatically derived

    Profile::key_size

    fn Profile::key_size(self : Profile) -> Int

    The SRTP master key length this profile fixes, in octets.

    Profile::not_equal

    fn Profile::not_equal(x : Profile, y : Profile) -> Bool
    automatically derived

    Profile::of

    fn Profile::of(code : Int) -> Profile?

    The profile a code names, or None for one this package has no lengths for.

    Unlike an extension type, an unknown profile cannot be carried through: the whole point of the negotiation is to fix the key and salt lengths, and a profile whose lengths are unknown fixes nothing.

    Profile::salt_size

    fn Profile::salt_size(self : Profile) -> Int

    The SRTP master salt length this profile fixes, in octets.

    The counter-mode profiles carry a 112-bit salt (RFC 5764 §4.1.2); the GCM ones carry 96 bits, because RFC 7714 §8.1 builds the nonce from the salt and the 96-bit AEAD nonce leaves no room for more.

    Profile::to_repr

    automatically derived

    keys

    fn keys(secret : BytesView, profile : Profile, digest? :
    Digest
    ) -> Keys

    Export this profile's SRTP keying material from the TLS 1.3 exporter master secret (RFC 5764 §4.2).

    secret is [@keys.exporter_master]'s output. §4.2 exports one block and cuts it into four: both master keys first, then both salts — not key, salt, key, salt, which is the mistake that produces a connection where each end decrypts its own traffic and neither decrypts the other's.

    keys12

    fn keys12(master : BytesView, client_random : BytesView, server_random : BytesView, profile : Profile, digest? :
    Digest
    ) -> Keys

    Export this profile's SRTP keying material from a TLS 1.2 master secret (RFC 5764 §4.2 over RFC 5705 §4): PRF(master, "EXTRACTOR-dtls_srtp", client_random + server_random).

    The cut is the same as [keys]'s: both master keys, then both salts.

    label

    let label : Bytes

    The label RFC 5764 §4.2 exports SRTP keying material under.

    select

    fn select(offered : ArrayView[Int], supported? : ArrayView[Profile]) -> Profile?

    The profile to answer an offer with, by the answerer's preference rather than the offerer's (RFC 5764 §4.1.1).

    offered is the wire codes a peer sent. The first entry of supported that appears in the offer wins; None means nothing overlapped, which RFC 5764 §4.1.1 makes a handshake failure rather than a connection without SRTP.

    supported

    let supported : Array[Profile]

    The profiles this package will negotiate, strongest first.

    The order is Chrome's and Firefox's offer order, which is also the order libwebrtc prefers: the AEAD profiles before the counter-mode one, and the truncated-tag and null profiles not at all. A caller wanting a different order or a wider set passes its own list to [select].

    Source Files