auth

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2026 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AutoGenKeyLength = 16
	Base62Chars      = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
	PBKDF2Iterations = 100000
	PBKDF2Salt       = "VIIPER-Key-v1"
)
View Source
const (
	HandshakeMagic = "eVI1\x00"
	NonceSize      = 32
)

Variables

This section is empty.

Functions

func DeriveKey

func DeriveKey(password string) ([]byte, error)

DeriveKey uses PBKDF2 to stretch any password to 32 bytes

func DeriveSessionKey

func DeriveSessionKey(key, serverNonce, clientNonce []byte) []byte

DeriveSessionKey creates unique session key from key and nonces SHA mixing is used for easier client implementations

func GenerateKey

func GenerateKey() (string, error)

GenerateKey creates a random 16-char base62 key

func HandleAuthHandshake

func HandleAuthHandshake(r *bufio.Reader, w io.Writer, key []byte, isClient bool) (clientNonce, serverNonce []byte, err error)

HandleAuthHandshake performs the authentication handshake

func IsAuthHandshake

func IsAuthHandshake(r *bufio.Reader) (bool, error)

IsAuthHandshake checks if the next bytes in reader match the handshake magic

func ReadClientNonce

func ReadClientNonce(r io.Reader) (clientNonce []byte, err error)

ReadClientNonce reads client nonce from handshake Expects handshake magic already consumed, reads only the 32-byte nonce

func WrapConn

func WrapConn(conn net.Conn, sessionKey []byte) (net.Conn, error)

func WriteServerHandshake

func WriteServerHandshake(w io.Writer) (serverNonce []byte, err error)

WriteServerHandshake generates server nonce and sends response Sends: "OK\0" + server_nonce[32]

Types

type Conn

type Conn struct {
	net.Conn
	// contains filtered or unexported fields
}

func (*Conn) Read

func (s *Conn) Read(p []byte) (int, error)

func (*Conn) Write

func (s *Conn) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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