core

package
v0.0.0-...-4728dbd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 25, 2018 License: BSD-2-Clause Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const ClientHelloDataLength = 7
View Source
const (
	EthernetMACHeaderLength = 14 //2 * 6 for MAC-addresses + 2 for ethertype
)
View Source
const ServerHelloDataLength = 8
View Source
const VPNPacketLength = 9

Variables

View Source
var (
	ErrInvalidClientHello = errors.New("core: invalid ClientHello packet")
	ErrInvalidServerHello = errors.New("core: invalid ServerHello packet")
	ErrInvalidCertificate = errors.New("core: unsupported certificate")
	ErrInvalidSignature   = errors.New("core: invalid signature")
	ErrInvalidVPNPacket   = errors.New("core: invalid vpn packet")
	ErrInvalidAEAD        = errors.New("core: invalid aead specified")
)
View Source
var (
	ErrInvalidCurve = errors.New("core: invalid curve type")
)
View Source
var (
	GoVPNAEADData = []byte("govpn-aead-data")
)
View Source
var (
	MACBroadcastAddr = MacAddr{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}
)

Functions

func CalculateSecret

func CalculateSecret(private, theirPublic []byte, t CurveType) ([]byte, error)

func Curve25519CalculateSecret

func Curve25519CalculateSecret(private, theirPublic []byte) ([]byte, error)

func Curve25519GenerateKey

func Curve25519GenerateKey() ([]byte, []byte, error)

func GenerateKeyPair

func GenerateKeyPair(t CurveType) ([]byte, []byte, error)

Types

type AEADType

type AEADType byte
const (
	Aes128Gcm AEADType = iota
	Aes256Gcm
	Chacha20Poly1305
)

type Client

type Client struct {
	sync.Mutex

	ServerAddress string
	SendQueue     chan<- []byte
	ReceiveQueue  <-chan []byte
	// contains filtered or unexported fields
}

func NewClient

func NewClient(ServerAddr, ClientCertFile, ClientKeyFile, ServerCertFile string) (*Client, error)

func (*Client) Close

func (c *Client) Close() error

func (*Client) PerformHandshake

func (c *Client) PerformHandshake(cipherType AEADType, curveType CurveType) error

func (*Client) Run

func (c *Client) Run()

func (*Client) RunBackground

func (c *Client) RunBackground()

type ClientHelloData

type ClientHelloData struct {
	Type                    PacketType
	CurveSelection          CurveType
	AEADSelection           AEADType
	ClientSessionKeyLength  int //sent as LittleEndian uint16
	ClientCertificateLength int //sent as LittleEndian uint16
	ClientSessionKey        []byte
	ClientCertificate       *x509.Certificate //returned for server
	Signature               []byte            //not used in code
}

type CurveType

type CurveType byte
const (
	Curve25519 CurveType = iota
	P256
	P384
	P521
)

type DHPubKey

type DHPubKey []byte

type Endpoint

type Endpoint struct {
	sync.Mutex

	Name string
	// contains filtered or unexported fields
}

type MacAddr

type MacAddr [6]byte

type PacketType

type PacketType byte
const (
	VpnPacketType PacketType = iota
	ClientHelloPacketType
	ServerHelloPacketType
)

type QueuedPacket

type QueuedPacket struct {
	Addr *net.UDPAddr
	Data []byte
}

type Server

type Server struct {
	ServerMACAddress MacAddr
	ReceiveQueue     <-chan []byte
	SendQueue        chan<- []byte
	// contains filtered or unexported fields
}

func NewServer

func NewServer(serverAddr, caCertFile, serverCertFile, serverKeyFile string, ServerQueueSize int, ServerMACAddr *MacAddr) (*Server, error)

func (*Server) Close

func (s *Server) Close() error

func (*Server) Run

func (s *Server) Run()

type ServerHelloData

type ServerHelloData struct {
	Type                   PacketType
	SessionNonce           [5]byte
	ServerSessionKeyLength int
	ServerSessionKey       DHPubKey
	Signature              []byte
}

type SharedKey

type SharedKey []byte

type SymmetricCryptoContext

type SymmetricCryptoContext struct {
	SymmetricCipher AEADType
	SessionNonce    [5]byte
	SharedSecret    []byte
	NonceCounter    uint64
}

type VpnPacket

type VpnPacket struct {
	Type          PacketType
	Nonce         [6]byte
	PayloadLength uint16
	Payload       []byte
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL