webrtc_dtls13_msg (webrtc v0.1.0)

View Source

DTLS 1.3 handshake message and extension codec (RFC 8446 §4, RFC 9147 §5). ClientHello and ServerHello share the DTLS 1.2 layout and are handled by webrtc_dtls_msg; this module covers the messages and extensions that only exist in (D)TLS 1.3.

decode/2 and ext/3 never raise: malformed input gives {error, decode_error}.

Summary

Functions

The ClientHello pre_shared_key extension with one identity and a binder of BinderLen zero octets, filled by the caller (it must be the last extension, RFC 8446 §4.2.11).

The connection ID we want to receive (RFC 9146 §3).

early_data, empty in ClientHello and EncryptedExtensions (RFC 8446 §4.2.10).

Decode a 1.3 extension carried as {Type, Data} by the hello codec, in the context of the message that carried it.

True for the message types decode/2 handles.

The synthetic message_hash message replacing ClientHello1 in the transcript after a HelloRetryRequest (RFC 8446 §4.4.1).

psk_key_exchange_modes with psk_dhe_ke only: resumption keeps (EC)DHE and forward secrecy (RFC 8446 §4.2.9).

The ServerHello pre_shared_key extension.

A handshake message as it enters the DTLS 1.3 transcript: the TLS 1.3 header without message_seq and fragment fields (RFC 9147 §5.2).

Functions

client_psk_ext(Ticket, ObfuscatedAge, BinderLen)

-spec client_psk_ext(binary(), 0..4294967295, pos_integer()) -> {41, binary()}.

The ClientHello pre_shared_key extension with one identity and a binder of BinderLen zero octets, filled by the caller (it must be the last extension, RFC 8446 §4.2.11).

connection_id_ext(Cid)

-spec connection_id_ext(binary()) -> {54, binary()}.

The connection ID we want to receive (RFC 9146 §3).

decode(Type, Bin)

-spec decode(atom() | 0..255, binary()) -> {ok, term()} | {error, decode_error}.

early_data_ext()

-spec early_data_ext() -> {42, binary()}.

early_data, empty in ClientHello and EncryptedExtensions (RFC 8446 §4.2.10).

encode(_, Exts)

-spec encode(atom(), term()) -> binary().

ext(Ctx, Name, Exts)

-spec ext(client_hello | server_hello | hello_retry_request, atom(), [{term(), term()}]) ->
             undefined | {ok, term()} | {error, decode_error}.

Decode a 1.3 extension carried as {Type, Data} by the hello codec, in the context of the message that carried it.

hrr_group_ext(Group)

-spec hrr_group_ext(0..65535) -> {51, binary()}.

key_share_ext(Shares)

-spec key_share_ext([{0..65535, binary()}]) -> {51, binary()}.

known(Type)

-spec known(term()) -> boolean().

True for the message types decode/2 handles.

message_hash(Hash)

-spec message_hash(binary()) -> binary().

The synthetic message_hash message replacing ClientHello1 in the transcript after a HelloRetryRequest (RFC 8446 §4.4.1).

psk_modes_ext()

-spec psk_modes_ext() -> {45, binary()}.

psk_key_exchange_modes with psk_dhe_ke only: resumption keeps (EC)DHE and forward secrecy (RFC 8446 §4.2.9).

selected_version_ext()

-spec selected_version_ext() -> {43, binary()}.

server_psk_ext(Index)

-spec server_psk_ext(0..65535) -> {41, binary()}.

The ServerHello pre_shared_key extension.

server_share_ext(Group, Key)

-spec server_share_ext(0..65535, binary()) -> {51, binary()}.

supported_versions_ext(Versions)

-spec supported_versions_ext([0..65535]) -> {43, binary()}.

transcript_msg(Type, Body)

-spec transcript_msg(webrtc_dtls_msg:msg_type(), binary()) -> binary().

A handshake message as it enters the DTLS 1.3 transcript: the TLS 1.3 header without message_seq and fragment fields (RFC 9147 §5.2).