Categorygithub.com/bifurcation/mint
modulepackage
0.0.0-20210616192047-fd18df995463
Repository: https://github.com/bifurcation/mint.git
Documentation: pkg.go.dev

# README

A lock with a mint leaf

mint - A Minimal TLS 1.3 stack

Build Status

This project is primarily a learning effort for me to understand the TLS 1.3 protocol. The goal is to arrive at a pretty complete implementation of TLS 1.3, with minimal, elegant code that demonstrates how things work. Testing is a priority to ensure correctness, but otherwise, the quality of the software engineering might not be at a level where it makes sense to integrate this with other libraries. Backward compatibility is not an objective.

We borrow liberally from the Go TLS library, especially where TLS 1.3 aligns with earlier TLS versions. However, unnecessary parts will be ruthlessly cut off.

DTLS Support

Mint has partial support for DTLS, but that support is not yet complete and may still contain serious defects.

Quickstart

Installation is the same as for any other Go package:

go get github.com/bifurcation/mint

The API is pretty much the same as for the TLS module, with Dial and Listen methods wrapping the underlying socket APIs.

conn, err := mint.Dial("tcp", "localhost:4430", &mint.Config{...})
...
listener, err := mint.Listen("tcp", "localhost:4430", &mint.Config{...})

Documentation is available on godoc.org

Interoperability testing

The mint-client and mint-server executables are included to make it easy to do basic interoperability tests with other TLS 1.3 implementations. The steps for testing against NSS are as follows.

# Install mint
go get github.com/bifurcation/mint

# Environment for NSS (you'll probably want a new directory)
NSS_ROOT=<whereever you want to put NSS>
mkdir $NSS_ROOT
cd $NSS_ROOT
export USE_64=1
export ENABLE_TLS_1_3=1
export HOST=localhost
export DOMSUF=localhost

# Build NSS
hg clone https://hg.mozilla.org/projects/nss
hg clone https://hg.mozilla.org/projects/nspr
cd nss
make nss_build_all

export PLATFORM=`cat $NSS_ROOT/dist/latest`
export DYLD_LIBRARY_PATH=$NSS_ROOT/dist/$PLATFORM/lib
export LD_LIBRARY_PATH=$NSS_ROOT/dist/$PLATFORM/lib

# Run NSS tests (this creates data for the server to use)
cd tests/ssl_gtests
./ssl_gtests.sh

# Test with client=mint server=NSS
cd $NSS_ROOT
./dist/$PLATFORM/bin/selfserv -d tests_results/security/$HOST.1/ssl_gtests/ -n rsa -p 4430
# if you get `NSS_Init failed.`, check the path above, particularly around $HOST
# ...
go run $GOPATH/src/github.com/bifurcation/mint/bin/mint-client/main.go

# Test with client=NSS server=mint
go run $GOPATH/src/github.com/bifurcation/mint/bin/mint-server/main.go
# ...
cd $NSS_ROOT
dist/$PLATFORM/bin/tstclnt -d tests_results/security/$HOST/ssl_gtests/ -V tls1.3:tls1.3 -h 127.0.0.1 -p 4430 -o

# Packages

No description provided by the author
No description provided by the author

# Functions

No description provided by the author
No description provided by the author
No description provided by the author
Client returns a new TLS client side connection using conn as the underlying transport.
No description provided by the author
Dial connects to the given network address using net.Dial and then initiates a TLS handshake, returning the resulting TLS connection.
DialWithDialer connects to the given network address using dialer.Dial and then initiates a TLS handshake, returning the resulting TLS connection.
No description provided by the author
No description provided by the author
No description provided by the author
From RFC 5869 PRK = HMAC-Hash(salt, IKM).
Listen creates a TLS listener accepting connections on the given network address using net.Listen.
No description provided by the author
No description provided by the author
NewDefaultCookieProtector creates a source for source address tokens.
No description provided by the author
No description provided by the author
NewListener creates a Listener which accepts connections from an inner Listener and wraps each connection with Server.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Server returns a new TLS server side connection using conn as the underlying transport.
No description provided by the author

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
alert level.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
XXX: Actually TLS_NULL_WITH_NULL_NULL, but we need a way to label the zero value for this type so that we can detect when a field is set.
No description provided by the author
No description provided by the author
ECDSA algorithms.
No description provided by the author
No description provided by the author
EdDSA algorithms.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Finite field groups.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Omitted: *_RESERVED.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Elliptic Curve Groups.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
RSASSA-PKCS1-v1_5 algorithms.
No description provided by the author
No description provided by the author
No description provided by the author
RSASSA-PSS algorithms.
No description provided by the author
No description provided by the author
No description provided by the author
states valid for the client.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
states valid for the server.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
ECDH functions.
No description provided by the author

# Structs

opaque ProtocolName<1..2^8-1>; struct { ProtocolName protocol_name_list<2..2^16-1> } ProtocolNameList;.
No description provided by the author
No description provided by the author
opaque ASN1Cert<1..2^24-1>; struct { ASN1Cert cert_data; Extension extensions<0..2^16-1> } CertificateEntry; struct { opaque certificate_request_context<0..2^8-1>; CertificateEntry certificate_list<0..2^24-1>; } Certificate;.
struct { opaque certificate_request_context<0..2^8-1>; Extension extensions<2..2^16-1>; } CertificateRequest;.
struct { SignatureScheme algorithm; opaque signature<0..2^16-1>; } CertificateVerify;.
No description provided by the author
struct { ProtocolVersion legacy_version = 0x0303; /* TLS v1.2 */ Random random; opaque legacy_session_id<0..32>; CipherSuite cipher_suites<2..2^16-2>; opaque legacy_compression_methods<1..2^8-1>; Extension extensions<0..2^16-1>; } ClientHello;.
Config is the struct used to pass configuration settings to a TLS client or server instance.
Conn implements the net.Conn interface, as with "crypto/tls" * Read, Write, and Close are provided locally * LocalAddr, RemoteAddr, and Set*Deadline are forwarded to the inner Conn.
ConnectionOptions objects represent per-connection settings for a client initiating a connection.
ConnectionParameters objects represent the parameters negotiated for a connection.
No description provided by the author
struct { opaque cookie<1..2^16-1>; } Cookie;.
The DefaultCookieProtector is a simple implementation for the CookieProtector.
No description provided by the author
No description provided by the author
No description provided by the author
struct { Extension extensions<0..2^16-1>; } EncryptedExtensions; Marshal() and Unmarshal() are handled by ExtensionList.
struct {} EndOfEarlyData;.
struct { ExtensionType extension_type; opaque extension_data<0..2^16-1>; } Extension;.
struct { opaque verify_data[verify_data_length]; } Finished; verifyDataLen is not a field in the TLS struct, but we add it here so that calling code can tell us how much data to expect when we marshal / unmarshal.
Working state for the handshake.
No description provided by the author
struct { HandshakeType msg_type; /* handshake type */ uint24 length; /* bytes in message */ select (HandshakeType) { ..
No description provided by the author
No description provided by the author
struct { NamedGroup group; opaque key_exchange<1..2^16-1>; } KeyShareEntry; struct { select (Handshake.msg_type) { case client_hello: KeyShareEntry client_shares<0..2^16-1>; case hello_retry_request: NamedGroup selected_group; case server_hello: KeyShareEntry server_share; }; } KeyShare;.
No description provided by the author
No description provided by the author
No description provided by the author
enum { update_not_requested(0), update_requested(1), (255) } KeyUpdateRequest; struct { KeyUpdateRequest request_update; } KeyUpdate;.
A listener implements a network listener (net.Listener) for TLS connections.
struct { uint32 ticket_lifetime; uint32 ticket_age_add; opaque ticket_nonce<1..255>; opaque ticket<1..2^16-1>; Extension extensions<0..2^16-2>; } NewSessionTicket;.
No description provided by the author
No description provided by the author
No description provided by the author
struct { opaque identity<1..2^16-1>; uint32 obfuscated_ticket_age; } PskIdentity; opaque PskBinderEntry<32..255>; struct { select (Handshake.msg_type) { case client_hello: PskIdentity identities<7..2^16-1>; PskBinderEntry binders<33..2^16-1>; case server_hello: uint16 selected_identity; }; } PreSharedKeyExtension;.
enum { psk_ke(0), psk_dhe_ke(1), (255) } PskKeyExchangeMode; struct { PskKeyExchangeMode ke_modes<1..255>; } PskKeyExchangeModes;.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
struct { ProtocolVersion legacy_version = 0x0303; /* TLS v1.2 */ Random random; opaque legacy_session_id_echo<0..32>; CipherSuite cipher_suite; uint8 legacy_compression_method = 0; Extension extensions<6..2^16-1>; } ServerHello;.
struct { SignatureScheme supported_signature_algorithms<2..2^16-2>; } SignatureSchemeList.
No description provided by the author
struct { NamedGroup named_group_list<2..2^16-1>; } NamedGroupList;.
No description provided by the author
struct { ProtocolVersion versions<2..254>; } SupportedVersions;.
No description provided by the author
No description provided by the author
No description provided by the author
struct { ContentType type; ProtocolVersion record_version [0301 for CH, 0303 for others] uint16 length; opaque fragment[TLSPlaintext.length]; } TLSPlaintext;.

# Interfaces

No description provided by the author
A CookieHandler can be used to give the application more fine-grained control over Cookies.
CookieProtector is used to create and verify a cookie.
No description provided by the author
Marker interface for actions that an implementation should take based on state transitions.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Type aliases

No description provided by the author
No description provided by the author
uint8 CipherSuite[2];.
No description provided by the author
No description provided by the author
Epochs for DTLS (also used for key phase labelling).
No description provided by the author
enum {...} ExtensionType.
enum {...} HandshakeType;.
enum { update_not_requested(0), update_requested(1), (255) } KeyUpdateRequest;.
enum {...} NamedGroup.
enum {...} PskKeyExchangeMode;.
No description provided by the author
enum {...} ContentType;.
struct { NameType name_type; select (name_type) { case host_name: HostName; } name; } ServerName; enum { host_name(0), (255) } NameType; opaque HostName<1..2^16-1>; struct { ServerName server_name_list<1..2^16-1> } ServerNameList; But we only care about the case where there's a single DNS hostname.
enum {...} SignatureScheme.
No description provided by the author