CovenantSQL: github.com/CovenantSQL/CovenantSQL/crypto/etls Index | Files

package etls

import "github.com/CovenantSQL/CovenantSQL/crypto/etls"

Package etls implements "Enhanced Transport Layer Security", but more efficient than TLS used in https. example can be found in test case.

Index

Package Files

conn.go encrypt.go listener.go

Constants

const (
    // MagicSize is the ETLS magic header size.
    MagicSize = 2
)

Variables

var (
    // MagicBytes is the ETLS connection magic header.
    MagicBytes = [MagicSize]byte{0xC0, 0x4E}
)

func KeyDerivation Uses

func KeyDerivation(rawKey []byte, keyLen int, hSuite *hash.HashSuite) (key []byte)

KeyDerivation .according to ANSI X9.63 we should do a key derivation before using it as a symmetric key, there is not really a common standard KDF(Key Derivation Func). But as SSL/TLS/DTLS did it described in "RFC 4492 TLS ECC", we prefer a Double SHA-256 with it.

type Cipher Uses

type Cipher struct {
    // contains filtered or unexported fields
}

Cipher struct keeps cipher mode, key, iv.

func NewCipher Uses

func NewCipher(rawKey []byte) (c *Cipher)

NewCipher creates a cipher that can be used in Dial(), Listen() etc.

type CipherHandler Uses

type CipherHandler func(conn net.Conn) (cryptoConn *CryptoConn, err error)

CipherHandler is the func type for converting net.Conn to CryptoConn.

type CryptoConn Uses

type CryptoConn struct {
    net.Conn
    *Cipher
}

CryptoConn implements net.Conn and Cipher interface.

func Dial Uses

func Dial(network, address string, cipher *Cipher) (c *CryptoConn, err error)

Dial connects to a address with a Cipher address should be in the form of host:port.

func NewConn Uses

func NewConn(c net.Conn, cipher *Cipher) *CryptoConn

NewConn returns a new CryptoConn.

func (*CryptoConn) Close Uses

func (c *CryptoConn) Close() error

Close closes the connection. Any blocked Read or Write operations will be unblocked and return errors.

func (*CryptoConn) LocalAddr Uses

func (c *CryptoConn) LocalAddr() net.Addr

LocalAddr returns the local network address.

func (*CryptoConn) Read Uses

func (c *CryptoConn) Read(b []byte) (n int, err error)

Read iv and Encrypted data.

func (*CryptoConn) RemoteAddr Uses

func (c *CryptoConn) RemoteAddr() net.Addr

RemoteAddr returns the remote network address.

func (*CryptoConn) SetDeadline Uses

func (c *CryptoConn) SetDeadline(t time.Time) error

SetDeadline sets the read and write deadlines associated with the connection. A zero value for t means Read and Write will not time out. After a Write has timed out, the TLS state is corrupt and all future writes will return the same error.

func (*CryptoConn) SetReadDeadline Uses

func (c *CryptoConn) SetReadDeadline(t time.Time) error

SetReadDeadline sets the read deadline on the underlying connection. A zero value for t means Read will not time out.

func (*CryptoConn) SetWriteDeadline Uses

func (c *CryptoConn) SetWriteDeadline(t time.Time) error

SetWriteDeadline sets the write deadline on the underlying connection. A zero value for t means Write will not time out. After a Write has timed out, the TLS state is corrupt and all future writes will return the same error.

func (*CryptoConn) Write Uses

func (c *CryptoConn) Write(b []byte) (n int, err error)

Write iv and Encrypted data.

type CryptoListener Uses

type CryptoListener struct {
    net.Listener
    CHandler CipherHandler
}

CryptoListener implements net.Listener.

func NewCryptoListener Uses

func NewCryptoListener(network, addr string, handler CipherHandler) (*CryptoListener, error)

NewCryptoListener returns a new CryptoListener.

func (*CryptoListener) Accept Uses

func (l *CryptoListener) Accept() (net.Conn, error)

Accept waits for and returns the next connection to the listener.

func (*CryptoListener) Addr Uses

func (l *CryptoListener) Addr() net.Addr

Addr returns the listener's network address.

func (*CryptoListener) Close Uses

func (l *CryptoListener) Close() error

Close closes the listener. Any blocked Accept operations will be unblocked and return errors.

Package etls imports 11 packages (graph) and is imported by 4 packages. Updated 2019-06-07. Refresh now. Tools for package owners.