Use th5
This commit is contained in:
parent
4837945b4d
commit
2c9c2d0d6d
@ -96,7 +96,7 @@ go get -u github.com/henrydcase/tlshandshake/...
|
|||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
|
|
||||||
We use ``trs`` library, a fork of Cloudflare's ``tls-tris`` library, which supports TLSv1.3 and number of experimental features.
|
We use [``th5``](https://github.com/henrydcase/th5) library.
|
||||||
|
|
||||||
# License
|
# License
|
||||||
|
|
||||||
|
@ -8,8 +8,8 @@ import (
|
|||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/henrydcase/th5"
|
||||||
hs "github.com/henrydcase/tlshandshake"
|
hs "github.com/henrydcase/tlshandshake"
|
||||||
"github.com/henrydcase/trs"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var tls_min, tls_max, named_groups, named_ciphers string
|
var tls_min, tls_max, named_groups, named_ciphers string
|
||||||
@ -56,14 +56,14 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set requested DH groups
|
// Set requested DH groups
|
||||||
client.TLS.CurvePreferences = []trs.CurveID{}
|
client.TLS.CurvePreferences = []th5.CurveID{}
|
||||||
if len(named_groups) != 0 {
|
if len(named_groups) != 0 {
|
||||||
for _, ng := range strings.Split(named_groups, ":") {
|
for _, ng := range strings.Split(named_groups, ":") {
|
||||||
id, err := getIDByName(hs.NamedGroupsToName, ng)
|
id, err := getIDByName(hs.NamedGroupsToName, ng)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("Wrong group name provided")
|
panic("Wrong group name provided")
|
||||||
}
|
}
|
||||||
client.TLS.CurvePreferences = append(client.TLS.CurvePreferences, trs.CurveID(id))
|
client.TLS.CurvePreferences = append(client.TLS.CurvePreferences, th5.CurveID(id))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
76
lib.go
76
lib.go
@ -4,56 +4,56 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/henrydcase/trs"
|
"github.com/henrydcase/th5"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Client struct {
|
type Client struct {
|
||||||
TLS trs.Config
|
TLS th5.Config
|
||||||
Addr string
|
Addr string
|
||||||
}
|
}
|
||||||
|
|
||||||
var TlsVersionToName = map[uint16]string{
|
var TlsVersionToName = map[uint16]string{
|
||||||
trs.VersionTLS10: "1.0",
|
th5.VersionTLS10: "1.0",
|
||||||
trs.VersionTLS11: "1.1",
|
th5.VersionTLS11: "1.1",
|
||||||
trs.VersionTLS12: "1.2",
|
th5.VersionTLS12: "1.2",
|
||||||
trs.VersionTLS13: "1.3",
|
th5.VersionTLS13: "1.3",
|
||||||
}
|
}
|
||||||
|
|
||||||
var CipherSuiteIdToName = map[uint16]string{
|
var CipherSuiteIdToName = map[uint16]string{
|
||||||
trs.TLS_AES_128_GCM_SHA256: "TLS_AES_128_GCM_SHA256",
|
th5.TLS_AES_128_GCM_SHA256: "TLS_AES_128_GCM_SHA256",
|
||||||
trs.TLS_AES_256_GCM_SHA384: "TLS_AES_256_GCM_SHA384",
|
th5.TLS_AES_256_GCM_SHA384: "TLS_AES_256_GCM_SHA384",
|
||||||
trs.TLS_CHACHA20_POLY1305_SHA256: "TLS_CHACHA20_POLY1305_SHA256",
|
th5.TLS_CHACHA20_POLY1305_SHA256: "TLS_CHACHA20_POLY1305_SHA256",
|
||||||
trs.TLS_RSA_WITH_RC4_128_SHA: "TLS_RSA_WITH_RC4_128_SHA",
|
th5.TLS_RSA_WITH_RC4_128_SHA: "TLS_RSA_WITH_RC4_128_SHA",
|
||||||
trs.TLS_RSA_WITH_3DES_EDE_CBC_SHA: "TLS_RSA_WITH_3DES_EDE_CBC_SHA",
|
th5.TLS_RSA_WITH_3DES_EDE_CBC_SHA: "TLS_RSA_WITH_3DES_EDE_CBC_SHA",
|
||||||
trs.TLS_RSA_WITH_AES_128_CBC_SHA: "TLS_RSA_WITH_AES_128_CBC_SHA",
|
th5.TLS_RSA_WITH_AES_128_CBC_SHA: "TLS_RSA_WITH_AES_128_CBC_SHA",
|
||||||
trs.TLS_RSA_WITH_AES_256_CBC_SHA: "TLS_RSA_WITH_AES_256_CBC_SHA",
|
th5.TLS_RSA_WITH_AES_256_CBC_SHA: "TLS_RSA_WITH_AES_256_CBC_SHA",
|
||||||
trs.TLS_RSA_WITH_AES_128_CBC_SHA256: "TLS_RSA_WITH_AES_128_CBC_SHA256",
|
th5.TLS_RSA_WITH_AES_128_CBC_SHA256: "TLS_RSA_WITH_AES_128_CBC_SHA256",
|
||||||
trs.TLS_RSA_WITH_AES_128_GCM_SHA256: "TLS_RSA_WITH_AES_128_GCM_SHA256",
|
th5.TLS_RSA_WITH_AES_128_GCM_SHA256: "TLS_RSA_WITH_AES_128_GCM_SHA256",
|
||||||
trs.TLS_RSA_WITH_AES_256_GCM_SHA384: "TLS_RSA_WITH_AES_256_GCM_SHA384",
|
th5.TLS_RSA_WITH_AES_256_GCM_SHA384: "TLS_RSA_WITH_AES_256_GCM_SHA384",
|
||||||
trs.TLS_ECDHE_ECDSA_WITH_RC4_128_SHA: "TLS_ECDHE_ECDSA_WITH_RC4_128_SHA",
|
th5.TLS_ECDHE_ECDSA_WITH_RC4_128_SHA: "TLS_ECDHE_ECDSA_WITH_RC4_128_SHA",
|
||||||
trs.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA: "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA",
|
th5.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA: "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA",
|
||||||
trs.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA: "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA",
|
th5.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA: "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA",
|
||||||
trs.TLS_ECDHE_RSA_WITH_RC4_128_SHA: "TLS_ECDHE_RSA_WITH_RC4_128_SHA",
|
th5.TLS_ECDHE_RSA_WITH_RC4_128_SHA: "TLS_ECDHE_RSA_WITH_RC4_128_SHA",
|
||||||
trs.TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA: "TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA",
|
th5.TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA: "TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA",
|
||||||
trs.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA: "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA",
|
th5.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA: "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA",
|
||||||
trs.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA: "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA",
|
th5.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA: "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA",
|
||||||
trs.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256: "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256",
|
th5.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256: "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256",
|
||||||
trs.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256: "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256",
|
th5.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256: "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256",
|
||||||
trs.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256: "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
|
th5.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256: "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
|
||||||
trs.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256: "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
|
th5.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256: "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
|
||||||
trs.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384: "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
|
th5.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384: "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
|
||||||
trs.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384: "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
|
th5.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384: "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
|
||||||
trs.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305: "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305",
|
th5.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305: "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305",
|
||||||
trs.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305: "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305",
|
th5.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305: "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305",
|
||||||
}
|
}
|
||||||
|
|
||||||
var NamedGroupsToName = map[uint16]string{
|
var NamedGroupsToName = map[uint16]string{
|
||||||
uint16(trs.HybridSIDHp503Curve25519): "X25519-SIDHp503",
|
uint16(th5.HybridSIDHp503Curve25519): "X25519-SIDHp503",
|
||||||
uint16(trs.HybridSIKEp503Curve25519): "X25519-SIKEp503",
|
uint16(th5.HybridSIKEp503Curve25519): "X25519-SIKEp503",
|
||||||
uint16(trs.X25519): "X25519",
|
uint16(th5.X25519): "X25519",
|
||||||
uint16(trs.CurveP256): "P-256",
|
uint16(th5.CurveP256): "P-256",
|
||||||
uint16(trs.CurveP384): "P-384",
|
uint16(th5.CurveP384): "P-384",
|
||||||
uint16(trs.CurveP521): "P-521",
|
uint16(th5.CurveP521): "P-521",
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewClient() *Client {
|
func NewClient() *Client {
|
||||||
@ -63,7 +63,7 @@ func NewClient() *Client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) Run() {
|
func (c *Client) Run() {
|
||||||
con, err := trs.Dial("tcp", c.Addr, &c.TLS)
|
con, err := th5.Dial("tcp", c.Addr, &c.TLS)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("handshake failed: %v\n\n", err)
|
fmt.Printf("handshake failed: %v\n\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
4
utils.go
4
utils.go
@ -4,7 +4,7 @@ import (
|
|||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/grantae/certinfo"
|
"github.com/grantae/certinfo"
|
||||||
trs "github.com/henrydcase/trs"
|
th5 "github.com/henrydcase/th5"
|
||||||
)
|
)
|
||||||
|
|
||||||
var tf = map[bool]string{
|
var tf = map[bool]string{
|
||||||
@ -18,7 +18,7 @@ func toHex(b []byte) string {
|
|||||||
return string(str)
|
return string(str)
|
||||||
}
|
}
|
||||||
|
|
||||||
func printTlsState(con *trs.Conn) {
|
func printTlsState(con *th5.Conn) {
|
||||||
state := con.ConnectionState()
|
state := con.ConnectionState()
|
||||||
fmt.Println("| TLS-Session:")
|
fmt.Println("| TLS-Session:")
|
||||||
fmt.Println("-----------------------------------------------------------------")
|
fmt.Println("-----------------------------------------------------------------")
|
||||||
|
Loading…
Reference in New Issue
Block a user