ddn.net.tls.tls13client
TLS 1.3 client handshake (RFC 8446).
Implements the full TLS 1.3 client handshake as a resumable state machine. Each call to handshake() progresses through one or more phases until I/O is needed or the handshake completes.
Phases:
- Send ClientHello (key_share + supported_versions + supported_groups + signature_algorithms)
- Receive ServerHello (select cipher suite, key share group, compute shared secret)
- Receive EncryptedExtensions, Certificate, CertificateVerify, Finished
- Send client Finished
- Switch to application data keys
Types 2
TLS 1.3 client handshake phases.
Each phase represents a discrete step in the handshake state machine. The handshake progresses forward through these phases.
TLS 1.3 client handshake engine.
Drives the client side of a TLS 1.3 handshake over a record layer using a resumable state machine. After successful handshake, provides the AEAD cipher and negotiated parameters for application data exchange.
Call handshake() repeatedly until it returns TlsProgress.DONE. On NEED_READ, wait for the transport to become readable before calling again. On NEED_WRITE, wait for writability.
private RecordLayer recordLayer_private Tls13KeySchedule keySchedule_private TranscriptHash transcript_private string serverName_private TlsVerifyMode verifyMode_private TlsVerifyCallback verifyCallback_private string[] alpnProtocols_private NativeTlsTrustStore trustStore_private string negotiatedAlpn_private CipherSuiteId negotiatedCipher_private ProtocolVersion negotiatedVersion_private TlsCertificateChain peerCerts_private TlsSession tlsSession_private X25519PrivateKey ecdhePrivate_private ubyte[] sharedSecret_private ubyte[32] clientRandom_private ubyte[32] legacySessionId_private bool firstHelloDone_private EcdhP256Store * ecdhP256Store_private TlsAead clientWriteAead_private TlsAead serverReadAead_private TlsAead clientAppAead_private TlsAead serverAppAead_private Tls13HandshakePhase phase_private SecureRandom rng_private NamedGroup hrrSelectedGroup_private ubyte[] hrrCookie_private ubyte[] pendingPlaintext_private ubyte[] pendingHandshakeData_TlsProgress handshake()Performs or continues the TLS 1.3 client handshake.TlsProgress skipCCSAndRead(ref TlsRecord record)TlsProgress ensureHandshakeData()Ensures we have at least 4 bytes of handshake data to read the message header. If we need more data for a complete message, reads and decrypts more records. Returns TlsProgress.DONE when enough dat...ubyte[] consumeHandshakeMessage()Consumes a handshake message from the pending buffer. Updates the transcript and returns the message data.ubyte[] buildClientHello(SecureRandom rng,
NamedGroup forcedGroup = NamedGroup.init,
const(ubyte)[] cookie = null)void processServerHello(TlsRecord rec)void parseServerKeyShare(const(ubyte)[] extData)void verifyNegotiatedCipher(CipherSuiteId cs)Verifies that the server-negotiated cipher suite was offered.void deriveSharedSecret()bool isHelloRetryRequest(TlsRecord rec)void processHelloRetryRequest(const(ubyte)[] data, size_t off,
size_t msgEnd)void switchToHandshakeKeys()void processEncryptedExtensions()void processCertificate()void verifyPeerCertificates()void processCertificateVerify()void verifyCertificateVerify(SignatureScheme sigScheme,
const(ubyte)[] signature, const(ubyte)[] message)void processServerFinished()ubyte[] buildClientFinished()void switchToApplicationKeys()ubyte[] decryptRecord(TlsRecord rec, TlsAead aead)ubyte[] encryptRecord(ubyte[] handshakeMsg, TlsAead aead)this(RecordLayer recordLayer, string serverName,
TlsVerifyMode verifyMode, TlsVerifyCallback verifyCallback,
string[] alpnProtocols, NativeTlsTrustStore trustStore = null)Constructs a TLS 1.3 client handshake engine.EcdhP256StoreHeap storage for EcdhP256 since it's a struct.