moontls — the TLS 1.3 protocol state machine for MoonBit (RFC 8446): record layer, handshake and key schedule, bytes in and events out. No sockets, no cryptography of its own: the algorithms are mooncrypt's and certificate reading is mooncred's.
// The key schedule of RFC 8446 §7.1, one step at a time.
let early = @keys.early() // no PSK
let handshake = @keys.handshake(early[:], ecdhe[:]) // salted by ECDHE
let master = @keys.master(handshake[:])
let transcript = @keys.Transcript::new()
transcript.add(client_hello[:])
transcript.add(server_hello[:])
let secret = @keys.client_handshake(handshake[:], transcript.hash()[:])
let ok = @keys.finished_ok(secret[:], transcript.hash()[:], verify_data[:])| Specification | State | |
|---|---|---|
| wire | §3 integer widths and the frozen legacy_version | 0.2.0 |
| alert | §6 the alert protocol | 0.2.0 |
| keys | §7.1 key schedule, §4.4.1 transcript hash, §4.4.4 Finished | 0.1.0 |
| record | §5 record layer, §7.3 traffic keys | 0.2.0 |
| ext | §4.2 extensions: ALPN, SNI, key_share, supported_versions | next |
| hs | §4 handshake state machine, ClientHello to Finished | after that |
@keys.early() // SHA-256, the suite RFC 8446 §9.1 makes mandatory
@keys.early(digest=Sha384) // 48 octets instead of 32, all the way downInstall
Download zipmoontls — the TLS 1.3 protocol state machine for MoonBit (RFC 8446): record layer, handshake and key schedule, bytes in and events out. No sockets, no cryptography of its own: the algorithms are mooncrypt's and certificate reading is mooncred's.