ddn.net.tls.tls12

TLS 1.2 handshake engine (RFC 5246).

Implements TLS 1.2 client and server handshakes as resumable state machines with ECDHE key exchange and AES-GCM cipher suites.

Types 4

TLS 1.2 client handshake phases.

Each phase represents a discrete step in the client handshake state machine. The handshake progresses forward through these phases.

NOT_STARTEDHandshake has not been initiated
SEND_CLIENT_HELLOBuild and send ClientHello
FLUSH_CLIENT_HELLOFlush pending ClientHello bytes
RECV_SERVER_HELLOWait for ServerHello record
RECV_CERTIFICATEWait for Certificate record
RECV_SERVER_KEY_EXCHANGEWait for ServerKeyExchange record
RECV_SERVER_HELLO_DONEWait for ServerHelloDone record
SEND_CLIENT_KEY_EXCHANGEBuild and send ClientKeyExchange
FLUSH_CLIENT_KEY_EXCHANGEFlush pending ClientKeyExchange bytes
DERIVE_KEYSDerive key material from shared secret
SEND_CHANGE_CIPHER_SPECSend ChangeCipherSpec message
FLUSH_CHANGE_CIPHER_SPECFlush pending ChangeCipherSpec bytes
SEND_FINISHEDBuild and send encrypted Finished
FLUSH_FINISHEDFlush pending Finished bytes
RECV_CHANGE_CIPHER_SPECWait for ChangeCipherSpec record
RECV_SERVER_FINISHEDWait for encrypted server Finished
DONEHandshake complete

TLS 1.2 client handshake engine.

Drives the client side of a TLS 1.2 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.

Methods
TlsProgress handshake()Performs or continues the TLS 1.2 client handshake.
Tls12HandshakePhase phase() @property constReturns: The current handshake phase.
TlsAead clientAead() @propertyReturns: The client application data AEAD cipher.
TlsAead serverAead() @propertyReturns: The server application data AEAD cipher.
CipherSuiteId cipherSuite() @property constReturns: The negotiated cipher suite ID.
string alpn() @property constReturns: The negotiated ALPN protocol.
TlsCertificateChain peerCertificates() @propertyReturns: The peer certificate chain.
TlsSession session() @propertyReturns: The TLS session for resumption.
size_t cipherKeyLength(CipherSuiteId cs) static @safe pure nothrow @nogc
Constructors
this(RecordLayer recordLayer, string serverName, TlsVerifyMode verifyMode, TlsVerifyCallback verifyCallback, string[] alpnProtocols, NativeTlsTrustStore trustStore = null)Constructs a TLS 1.2 client handshake engine.
Nested Templates
EcdhP256StoreHeap storage for EcdhP256 since it's a struct.

TLS 1.2 server handshake phases.

Each phase represents a discrete step in the server handshake state machine. The handshake progresses forward through these phases.

NOT_STARTEDHandshake has not been initiated
RECV_CLIENT_HELLOWait for ClientHello record
SEND_SERVER_HELLOBuild and send ServerHello
FLUSH_SERVER_HELLOFlush pending ServerHello bytes
SEND_CERTIFICATEBuild and send Certificate
FLUSH_CERTIFICATEFlush pending Certificate bytes
SEND_SERVER_KEY_EXCHANGEBuild and send ServerKeyExchange
FLUSH_SERVER_KEY_EXCHANGEFlush pending ServerKeyExchange bytes
SEND_SERVER_HELLO_DONEBuild and send ServerHelloDone
FLUSH_SERVER_HELLO_DONEFlush pending ServerHelloDone bytes
RECV_CLIENT_KEY_EXCHANGEWait for ClientKeyExchange record
DERIVE_KEYSDerive key material from shared secret
RECV_CHANGE_CIPHER_SPECWait for ChangeCipherSpec record
RECV_CLIENT_FINISHEDWait for encrypted client Finished
SEND_CHANGE_CIPHER_SPECSend ChangeCipherSpec message
FLUSH_CHANGE_CIPHER_SPECFlush pending ChangeCipherSpec bytes
SEND_SERVER_FINISHEDBuild and send encrypted server Finished
FLUSH_SERVER_FINISHEDFlush pending server Finished bytes
DONEHandshake complete

TLS 1.2 server handshake engine.

Drives the server side of a TLS 1.2 handshake over a record layer using a resumable state machine. After successful handshake, provides the AEAD ciphers and negotiated parameters for application data exchange.

Call handshake() repeatedly until it returns TlsProgress.DONE.

Methods
TlsProgress handshake()Performs or continues the TLS 1.2 server handshake.
Tls12ServerHandshakePhase phase() @property constReturns: The current handshake phase.
TlsAead serverAead() @propertyReturns: The server application data AEAD cipher.
TlsAead clientAead() @propertyReturns: The client application data AEAD cipher.
CipherSuiteId cipherSuite() @property constReturns: The negotiated cipher suite ID.
string alpn() @property constReturns: The negotiated ALPN protocol.
string serverName() @property constReturns: The server name from ClientHello SNI.
TlsCertificateChain peerCertificates() @propertyReturns: The peer certificate chain.
TlsSession session() @propertyReturns: The TLS session for resumption.
Constructors
this(RecordLayer recordLayer, TlsVerifyMode verifyMode, TlsVerifyCallback verifyCallback, string[] alpnProtocols, ubyte[][] certChainDer, string certChainPem, string privateKeyPem)Constructs a TLS 1.2 server handshake engine.

Functions 1

fnbool verifyRsaPkcs1Signature(RSAPublicKey key, SignatureScheme sigScheme, const(ubyte)[] message, const(ubyte)[] signature)Verifies an RSA PKCS#1 v1.5 signature for TLS 1.2 `ServerKeyExchange`.