session

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: Apache-2.0 Imports: 6 Imported by: 6

Documentation

Index

Constants

View Source
const (
	StateIdle = iota
	StateNegotiating
	StateEstablished
)

Secure Session states.

View Source
const (
	STATE_IDLE        = StateIdle
	STATE_NEGOTIATING = StateNegotiating
	STATE_ESTABLISHED = StateEstablished
)

Secure Session states.

Deprecated: Since 0.11. Use "session.State..." constants instead.

Variables

View Source
var (
	ErrCreateSession     = errors.New("failed to create secure session object")
	ErrDestroySession    = errors.New("failed to destroy secure session object")
	ErrMessageSize       = errors.New("failed to get message size")
	ErrMessageData       = errors.New("failed to process message data")
	ErrNoPublicKey       = errors.NewCallbackError("failed to get public key (get_public_key_by_id callback error)")
	ErrBadRemoteIDLength = errors.NewCallbackError("incorrect remote id length (0)")
	ErrGetRemoteID       = errors.NewCallbackError("failed to get session remote id")
	ErrMissingClientID   = errors.NewWithCode(errors.InvalidParameter, "empty client ID for Secure Session")
	ErrMissingPrivateKey = errors.NewWithCode(errors.InvalidParameter, "empty client private key for Secure Session")
	ErrMissingMessage    = errors.NewWithCode(errors.InvalidParameter, "empty message for Secure Session")
	ErrOutOfMemory       = errors.NewWithCode(errors.NoMemory, "Secure Session cannot allocate enough memory")
	// Deprecated: Since 0.14. Use ErrOutOfMemory instead.
	ErrOverflow = ErrOutOfMemory
)

Errors returned by Secure Session.

Functions

This section is empty.

Types

type SecureSession

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

SecureSession is a lightweight mechanism for securing any kind of network communication (both private and public networks, including the Internet). It is protocol-agnostic and operates on the 5th layer of the network OSI model (the session layer).

func New

func New(id []byte, signKey *keys.PrivateKey, callbacks SessionCallbacks) (*SecureSession, error)

New makes a new Secure Session with provided peer ID, private key, and callbacks.

func (*SecureSession) Close

func (ss *SecureSession) Close() error

Close destroys a Secure Session.

func (*SecureSession) ConnectRequest

func (ss *SecureSession) ConnectRequest() ([]byte, error)

ConnectRequest generates a connection request that must be sent to the remote peer.

func (*SecureSession) GetRemoteID

func (ss *SecureSession) GetRemoteID() ([]byte, error)

GetRemoteID returns ID of the remote peer.

func (*SecureSession) GetRemoteId deprecated

func (ss *SecureSession) GetRemoteId() ([]byte, error)

GetRemoteId returns ID of the remote peer.

Deprecated: Since 0.11. Use GetRemoteID() instead.

func (*SecureSession) GetState

func (ss *SecureSession) GetState() int

GetState returns current state of Secure Session.

func (*SecureSession) Unwrap

func (ss *SecureSession) Unwrap(data []byte) ([]byte, bool, error)

Unwrap decrypts the encrypted data from the peer. It is also used for connection negotiation.

func (*SecureSession) Wrap

func (ss *SecureSession) Wrap(data []byte) ([]byte, error)

Wrap encrypts the provided data for the peer.

type SessionCallbacks

type SessionCallbacks interface {
	GetPublicKeyForId(ss *SecureSession, id []byte) *keys.PublicKey
	StateChanged(ss *SecureSession, state int)
}

SessionCallbacks implements a delegate for SecureSession.

Jump to

Keyboard shortcuts

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