moonbitstack/moontls/ext does not have a README file

    Ext

    pub(all) struct Ext {
    kind : Kind
    data : Bytes
    } derive(Eq,
    Debug
    )

    One extension: its type and its still-unparsed payload (RFC 8446 §4.2).

    Ext::equal

    fn Ext::equal(Ext, Ext) -> Bool

    Ext::not_equal

    fn Ext::not_equal(x : Ext, y : Ext) -> Bool

    Ext::to_repr

    Kind

    pub(all) enum Kind {
    ServerName
    SupportedGroups
    SignatureAlgorithms
    Alpn
    SupportedVersions
    KeyShare
    QuicTransportParameters
    UseSrtp
    Cookie
    Other(Int)
    } derive(Eq,
    Debug
    )

    Which extension this is (RFC 8446 §4.2, and IANA's TLS ExtensionType registry).

    Other keeps a type this package has no codec for. An extension is self-describing — a type and a length — so one it does not understand can be carried, forwarded and counted without being parsed, which is what RFC 8446 §4.2 asks a receiver to do with an extension it does not recognise.

    Kind::code

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

    The two octets this extension type goes on the wire as.

    Kind::equal

    fn Kind::equal(Kind, Kind) -> Bool

    Kind::not_equal

    fn Kind::not_equal(x : Kind, y : Kind) -> Bool

    Kind::of

    fn Kind::of(code : Int) -> Kind

    The extension type a code names. Never fails: one without a codec here becomes Other.

    Kind::to_repr

    fn cookie(value : BytesView) -> Bytes

    A cookie payload (RFC 8446 §4.2.2): opaque octets, length-prefixed.

    The server puts whatever it needs into it and the client hands it back untouched. Over datagrams that round trip is the whole defence (RFC 9147 §5.1): a server that answers a ClientHello with a cookie has committed no memory, and an address that cannot receive never comes back.

    decode

    fn decode(view : BytesView) -> Array[Ext]?

    Decode an extension block, or None if a length overruns what is there.

    A length that does not fit is a refusal rather than a truncated answer: an extension block is framed, so an overrun means the message is malformed and not that more octets are coming.

    ecdsa_secp256r1_sha256

    let ecdsa_secp256r1_sha256 : Int

    ecdsa_secp256r1_sha256, the other scheme §9.1 requires.

    encode

    fn encode(exts : ArrayView[Ext]) -> Bytes

    Encode an extension block: a two-octet total length, then each extension as a two-octet type, a two-octet length, and its payload.

    find

    fn find(exts : ArrayView[Ext], kind : Kind) -> Ext?

    The first extension of a given type, or None.

    groups

    fn groups(offered : ArrayView[Int]) -> Bytes

    A supported_groups payload (RFC 8446 §4.2.7).
    let h2 : String

    HTTP/2 over TLS's ALPN identifier (RFC 7540 §3.3).
    let h3 : String

    HTTP/3's ALPN identifier (RFC 9114 §3.1).

    http11

    let http11 : String

    HTTP/1.1's ALPN identifier (RFC 7301 §6).

    protocols

    fn protocols(names : ArrayView[String]) -> Bytes

    An ALPN ProtocolNameList payload (RFC 7301 §3.1): a two-octet length of the name list, then each protocol as a one-octet length and its octets.
    fn read_cookie(view : BytesView) -> Bytes?

    The octets such a payload carries, or None if it is truncated.

    An empty cookie is refused rather than read as an empty one: §4.2.2 gives the field a minimum of one octet, and a cookie proving nothing is worse than no cookie, because it looks like proof.

    read_groups

    fn read_groups(view : BytesView) -> Array[Int]

    The groups such a payload offers.

    read_protocols

    fn read_protocols(view : BytesView) -> Array[String]

    The protocol names such a payload carries, stopping at the declared list length or a truncated entry.

    read_schemes

    fn read_schemes(view : BytesView) -> Array[Int]

    The schemes such a payload offers.

    read_selected_share

    fn read_selected_share(view : BytesView) -> (Int, Bytes)?

    The group and key such a payload selected.

    read_selected_version

    fn read_selected_version(view : BytesView) -> Int?

    The version such a payload selected, or None if it is not two octets.

    read_share

    fn read_share(view : BytesView) -> (Int, Bytes, Int)?

    One KeyShareEntry off the front of view, with how many octets it took, or None on a partial read.

    read_shares

    fn read_shares(view : BytesView) -> Array[(Int, Bytes)]

    The shares such a payload offers, in order.

    read_use_srtp

    fn read_use_srtp(view : BytesView) -> (Array[Int], Bytes)?

    The profiles and MKI such a payload carries, or None if it is truncated or its declared lengths do not fit.

    A profile list of odd length is a decode failure rather than a list with the last octet dropped: RFC 5764 §4.1.2 makes each profile two octets, so an odd length means the sender and the receiver disagree about the structure.

    read_versions

    fn read_versions(view : BytesView) -> Array[Int]

    The versions such a payload offers, in order.

    rsa_pss_rsae_sha256

    let rsa_pss_rsae_sha256 : Int

    rsa_pss_rsae_sha256, the signature scheme RFC 8446 §9.1 requires.

    schemes

    fn schemes(offered : ArrayView[Int]) -> Bytes

    A signature_algorithms payload (RFC 8446 §4.2.3).

    secp256r1

    let secp256r1 : Int

    secp256r1 (NIST P-256).

    secp384r1

    let secp384r1 : Int

    secp384r1 (NIST P-384).

    selected_share

    fn selected_share(group : Int, key : BytesView) -> Bytes

    A ServerHello's key_share payload: one KeyShareEntry.

    selected_version

    fn selected_version(version : Int) -> Bytes

    A ServerHello's supported_versions payload: the selected version alone, with no list prefix (RFC 8446 §4.2.1).

    share

    fn share(group : Int, key : BytesView) -> Bytes

    One KeyShareEntry: the named group, the key's length, then the key (RFC 8446 §4.2.8).

    shares

    fn shares(entries : ArrayView[(Int, Bytes)]) -> Bytes

    A ClientHello's key_share payload: the client_shares length, then the KeyShareEntry list.

    use_srtp

    fn use_srtp(profiles : ArrayView[Int], mki : BytesView) -> Bytes

    A use_srtp payload (RFC 5764 §4.1.2): the protection profiles offered, then the master key identifier.

    A client sends every profile it will accept; a server answers with exactly one, which is why the same codec serves both ends and the count is left to the caller. The MKI is empty in every profile this family implements — RFC 5764 §4.1.2 allows one, and nothing here needs it.

    version_13

    let version_13 : Int

    The TLS 1.3 version code supported_versions selects (RFC 8446 §4.2.1).

    versions

    fn versions(offered : ArrayView[Int]) -> Bytes

    A ClientHello's supported_versions payload (RFC 8446 §4.2.1): a one-octet length, then each version as two octets, most preferred first.

    x25519

    let x25519 : Int

    x25519, the group RFC 8446 §4.2.7 lists first and TLS 1.3 offers first.

    Source Files