simplify the interaction with mint

This commit is contained in:
Marten Seemann
2017-10-21 19:28:51 +07:00
parent 282b423f7d
commit 9825ddb43a
5 changed files with 64 additions and 70 deletions

View File

@@ -43,15 +43,16 @@ func tlsToMintConfig(tlsConf *tls.Config, pers protocol.Perspective) (*mint.Conf
return mconf, nil
}
type mintTLS interface {
crypto.TLSExporter
Handshake() mint.Alert
}
type mintController struct {
conn *mint.Conn
}
var _ crypto.MintController = &mintController{}
func (mc *mintController) Handshake() mint.Alert {
return mc.conn.Handshake()
}
var _ mintTLS = &mintController{}
func (mc *mintController) GetCipherSuite() mint.CipherSuiteParams {
return mc.conn.State().CipherSuite
@@ -61,6 +62,10 @@ func (mc *mintController) ComputeExporter(label string, context []byte, keyLengt
return mc.conn.ComputeExporter(label, context, keyLength)
}
func (mc *mintController) Handshake() mint.Alert {
return mc.conn.Handshake()
}
// mint expects a net.Conn, but we're doing the handshake on a stream
// so we wrap a stream such that implements a net.Conn
type fakeConn struct {