client

package
v0.0.0-...-1ecb8ac Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2024 License: Unlicense Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const MaxNumberOfCommands int = 16

Variables

This section is empty.

Functions

func CreateSharedKey

func CreateSharedKey(own KeySet, other PublicKeySet) ([sha256.Size]byte, error)

func Decrypt

func Decrypt(sharedKey []byte, initialVector InitialVector, message []byte) ([]byte, error)

Types

type Client

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

func New

func New(user EphemeralUser, conn *Connection) Client

func (*Client) BroadcastKeys

func (client *Client) BroadcastKeys() error

func (*Client) RefreshKeys

func (client *Client) RefreshKeys() error

func (*Client) SendMessage

func (client *Client) SendMessage(msg string) error

type CommandQueue

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

func CreateCommandQueue

func CreateCommandQueue() CommandQueue

func (*CommandQueue) Enqueue

func (queue *CommandQueue) Enqueue(out commands.IOut)

func (*CommandQueue) Free

func (queue *CommandQueue) Free(slot int)

func (*CommandQueue) Pop

func (queue *CommandQueue) Pop() (*commands.IOut, error)

func (*CommandQueue) TakeSlot

func (queue *CommandQueue) TakeSlot() (int, error)

type Config

type Config struct {
	Host string
}

type Connection

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

func Connect

func Connect(address string) (*Connection, error)

func (*Connection) Close

func (cnn *Connection) Close()

func (*Connection) FreeCommandSlot

func (cnn *Connection) FreeCommandSlot(slot int)

func (*Connection) IsOpen

func (cnn *Connection) IsOpen() bool

func (*Connection) Receive

func (cnn *Connection) Receive() (*commands.Command, error)

func (*Connection) Send

func (cnn *Connection) Send(outCommand commands.IOut) error

func (*Connection) SendNext

func (cnn *Connection) SendNext() error

type EphemeralUser

type EphemeralUser struct {
	Name      commands.UserName
	Keys      KeySet
	SharedKey [32]byte
	IsKeySet  bool
}

type InitialVector

type InitialVector = [ivSize]byte

func Encrypt

func Encrypt(sharedKey []byte, message []byte) (InitialVector, []byte, error)

returns the Initial Vector and the encrypted message

type KeySet

type KeySet struct {
	PrivateKey ed25519.PrivateKey //Private component of identity key
	PublicKey  ed25519.PublicKey  // public component of identity key
	PreKey     *ecdh.PrivateKey   // This pre signed key is a temporary identity key
	Ek         *ecdh.PrivateKey   // this ephemeral key should be created for each exchange
	Signature  []byte             // signature, used to authenticate the preKey.
}

func CreateKeys

func CreateKeys() KeySet

type PublicKeySet

type PublicKeySet struct {
	IdentityKey  []byte
	SignedKey    []byte
	Ephemeralkey []byte
	Signature    []byte
}

Jump to

Keyboard shortcuts

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