| 1 |  |
| 2 | |
| 3 | mint - A Minimal TLS 1.3 stack |
| 4 | ============================== |
| 5 | |
| 6 | [](https://circleci.com/gh/bifurcation/mint) |
| 7 | |
| 8 | This project is primarily a learning effort for me to understand the [TLS |
| 9 | 1.3](http://tlswg.github.io/tls13-spec/) protocol. The goal is to arrive at a |
| 10 | pretty complete implementation of TLS 1.3, with minimal, elegant code that |
| 11 | demonstrates how things work. Testing is a priority to ensure correctness, but |
| 12 | otherwise, the quality of the software engineering might not be at a level where |
| 13 | it makes sense to integrate this with other libraries. Backward compatibility |
| 14 | is not an objective. |
| 15 | |
| 16 | We borrow liberally from the [Go TLS |
| 17 | library](https://golang.org/pkg/crypto/tls/), especially where TLS 1.3 aligns |
| 18 | with earlier TLS versions. However, unnecessary parts will be ruthlessly cut |
| 19 | off. |
| 20 | |
| 21 | ## DTLS Support |
| 22 | |
| 23 | Mint has partial support for DTLS, but that support is not yet complete |
| 24 | and may still contain serious defects. |
| 25 | |
| 26 | |
| 27 | ## Quickstart |
| 28 | |
| 29 | Installation is the same as for any other Go package: |
| 30 | |
| 31 | ``` |
| 32 | go get github.com/bifurcation/mint |
| 33 | ``` |
| 34 | |
| 35 | The API is pretty much the same as for the TLS module, with `Dial` and `Listen` |
| 36 | methods wrapping the underlying socket APIs. |
| 37 | |
| 38 | ``` |
| 39 | conn, err := mint.Dial("tcp", "localhost:4430", &mint.Config{...}) |
| 40 | ... |
| 41 | listener, err := mint.Listen("tcp", "localhost:4430", &mint.Config{...}) |
| 42 | ``` |
| 43 | |
| 44 | Documentation is available on |
| 45 | [godoc.org](https://godoc.org/github.com/bifurcation/mint) |
| 46 | |
| 47 | |
| 48 | ## Interoperability testing |
| 49 | |
| 50 | The `mint-client` and `mint-server` executables are included to make it easy to |
| 51 | do basic interoperability tests with other TLS 1.3 implementations. The steps |
| 52 | for testing against NSS are as follows. |
| 53 | |
| 54 | ``` |
| 55 | # Install mint |
| 56 | go get github.com/bifurcation/mint |
| 57 | |
| 58 | # Environment for NSS (you'll probably want a new directory) |
| 59 | NSS_ROOT=<whereever you want to put NSS> |
| 60 | mkdir $NSS_ROOT |
| 61 | cd $NSS_ROOT |
| 62 | export USE_64=1 |
| 63 | export ENABLE_TLS_1_3=1 |
| 64 | export HOST=localhost |
| 65 | export DOMSUF=localhost |
| 66 | |
| 67 | # Build NSS |
| 68 | hg clone https://hg.mozilla.org/projects/nss |
| 69 | hg clone https://hg.mozilla.org/projects/nspr |
| 70 | cd nss |
| 71 | make nss_build_all |
| 72 | |
| 73 | export PLATFORM=`cat $NSS_ROOT/dist/latest` |
| 74 | export DYLD_LIBRARY_PATH=$NSS_ROOT/dist/$PLATFORM/lib |
| 75 | export LD_LIBRARY_PATH=$NSS_ROOT/dist/$PLATFORM/lib |
| 76 | |
| 77 | # Run NSS tests (this creates data for the server to use) |
| 78 | cd tests/ssl_gtests |
| 79 | ./ssl_gtests.sh |
| 80 | |
| 81 | # Test with client=mint server=NSS |
| 82 | cd $NSS_ROOT |
| 83 | ./dist/$PLATFORM/bin/selfserv -d tests_results/security/$HOST.1/ssl_gtests/ -n rsa -p 4430 |
| 84 | # if you get `NSS_Init failed.`, check the path above, particularly around $HOST |
| 85 | # ... |
| 86 | go run $GOPATH/src/github.com/bifurcation/mint/bin/mint-client/main.go |
| 87 | |
| 88 | # Test with client=NSS server=mint |
| 89 | go run $GOPATH/src/github.com/bifurcation/mint/bin/mint-server/main.go |
| 90 | # ... |
| 91 | cd $NSS_ROOT |
| 92 | dist/$PLATFORM/bin/tstclnt -d tests_results/security/$HOST/ssl_gtests/ -V tls1.3:tls1.3 -h 127.0.0.1 -p 4430 -o |
| 93 | ``` |
| 94 |