darkstar

package
v1.2.8 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2023 License: Apache-2.0 Imports: 20 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrShortPacket = errors.New("short packet")

ErrShortPacket means that the packet is too short for a valid encrypted packet.

Functions

func DarkstarFormatBytesToPublicKey added in v1.2.0

func DarkstarFormatBytesToPublicKey(bytes []byte) crypto.PublicKey

func KeychainFormatBytesToPublicKey added in v1.2.0

func KeychainFormatBytesToPublicKey(bytes []byte) crypto.PublicKey

func NewDarkStarConn

func NewDarkStarConn(c net.Conn, encryptCipher cipher.AEAD, decryptCipher cipher.AEAD) net.Conn

NewConn wraps a stream-oriented net.Conn with cipher.

func NewPacketConn added in v1.0.0

func NewPacketConn(c net.PacketConn, ciph shadowaead.Cipher) net.PacketConn

NewPacketConn wraps a net.PacketConn with cipher

func Pack added in v1.0.0

func Pack(dst, plaintext []byte, ciph shadowaead.Cipher) ([]byte, error)

Pack encrypts plaintext using Cipher with a randomly generated salt and returns a slice of dst containing the encrypted packet and any error occurred. Ensure len(dst) >= ciph.SaltSize() + len(plaintext) + aead.Overhead().

func PublicKeyToDarkstarFormatBytes added in v1.2.0

func PublicKeyToDarkstarFormatBytes(pubKey crypto.PublicKey) ([]byte, error)

use this for handshake

func PublicKeyToKeychainFormatBytes added in v1.2.0

func PublicKeyToKeychainFormatBytes(pubKey crypto.PublicKey) ([]byte, error)

use this where we read the configs

func Unpack added in v1.0.0

func Unpack(dst, pkt []byte, ciph shadowaead.Cipher) ([]byte, error)

Unpack decrypts pkt using Cipher and returns a slice of dst containing the decrypted payload and any error occurred. Ensure len(dst) >= len(pkt) - aead.SaltSize() - aead.Overhead().

Types

type BlackHoleConn added in v1.1.0

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

func NewBlackHoleConn added in v1.1.0

func NewBlackHoleConn() *BlackHoleConn

func (*BlackHoleConn) Close added in v1.1.0

func (b2 *BlackHoleConn) Close() error

func (*BlackHoleConn) LocalAddr added in v1.1.0

func (b2 *BlackHoleConn) LocalAddr() net.Addr

func (*BlackHoleConn) Read added in v1.1.0

func (b2 *BlackHoleConn) Read(b []byte) (n int, err error)

func (*BlackHoleConn) RemoteAddr added in v1.1.0

func (b2 *BlackHoleConn) RemoteAddr() net.Addr

func (*BlackHoleConn) SetDeadline added in v1.1.0

func (b2 *BlackHoleConn) SetDeadline(_ time.Time) error

func (*BlackHoleConn) SetReadDeadline added in v1.1.0

func (b2 *BlackHoleConn) SetReadDeadline(_ time.Time) error

func (*BlackHoleConn) SetWriteDeadline added in v1.1.0

func (b2 *BlackHoleConn) SetWriteDeadline(_ time.Time) error

func (*BlackHoleConn) Write added in v1.1.0

func (b2 *BlackHoleConn) Write(b []byte) (n int, err error)

type DarkStarClient

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

func NewDarkStarClient

func NewDarkStarClient(serverPersistentPublicKey string, host string, port int) *DarkStarClient

func (*DarkStarClient) Decrypter

func (a *DarkStarClient) Decrypter(salt []byte) (cipher.AEAD, error)

func (*DarkStarClient) Encrypter

func (a *DarkStarClient) Encrypter(salt []byte) (cipher.AEAD, error)

func (*DarkStarClient) KeySize

func (a *DarkStarClient) KeySize() int

func (*DarkStarClient) PacketConn

func (a *DarkStarClient) PacketConn(conn net.PacketConn) net.PacketConn

func (*DarkStarClient) SaltSize

func (a *DarkStarClient) SaltSize() int

func (*DarkStarClient) StreamConn

func (a *DarkStarClient) StreamConn(conn net.Conn) (net.Conn, error)

type DarkStarServer

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

func NewDarkStarServer

func NewDarkStarServer(serverPersistentPrivateKey string, host string, port int) *DarkStarServer

func (*DarkStarServer) Decrypter

func (a *DarkStarServer) Decrypter(sharedKey []byte) (cipher.AEAD, error)

func (*DarkStarServer) Encrypter

func (a *DarkStarServer) Encrypter(sharedKey []byte) (cipher.AEAD, error)

func (*DarkStarServer) KeySize

func (a *DarkStarServer) KeySize() int

func (*DarkStarServer) PacketConn

func (a *DarkStarServer) PacketConn(conn net.PacketConn) net.PacketConn

func (*DarkStarServer) SaltSize

func (a *DarkStarServer) SaltSize() int

func (*DarkStarServer) StreamConn

func (a *DarkStarServer) StreamConn(conn net.Conn) (net.Conn, error)

Jump to

Keyboard shortcuts

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