noisemanager

package
v0.0.0-...-e5c7075 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package noisemanager gives some useful functions to interact with the noise encryption and decryption, provides verification of the noise channel hash and writes the noise keys to a file

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

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

File models a config file in the application's directory. Callers can use MiddlewareDir function to obtain the default app config dir.

func NewFile

func NewFile(dir, name string) *File

NewFile creates a new config file with the given name in a directory dir.

func (*File) Exists

func (file *File) Exists() bool

Exists checks whether the file exists with suitable permissions as a file and not as a directory.

func (*File) Path

func (file *File) Path() string

Path returns the absolute path to the config file.

func (*File) ReadJSON

func (file *File) ReadJSON(object interface{}) error

ReadJSON reads the config file as JSON to the given object. Make sure the config file exists!

func (*File) Remove

func (file *File) Remove() error

Remove removes the file.

func (*File) WriteJSON

func (file *File) WriteJSON(object interface{}) error

WriteJSON writes the given object as JSON to the config file.

type NoiseConfig

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

NoiseConfig holds the configuration options required to successfully pair through a noise handshake and subsequently encrypt traffic.

func NewNoiseConfig

func NewNoiseConfig(dataDir string, verifyPairing func([]byte) (bool, error)) *NoiseConfig

NewNoiseConfig takes a directory path string as an argument and returns a NoiseConfig struct.

func (*NoiseConfig) CheckVerification

func (noiseConfig *NoiseConfig) CheckVerification() ([]byte, error)

CheckVerification displays the channel hash and returns the success or fail response byte array.

func (*NoiseConfig) Decrypt

func (noiseConfig *NoiseConfig) Decrypt(message []byte) ([]byte, error)

Decrypt takes a (encrypted) byte array message as arguments and returns a noise decrypted byte array per the configuration in NoiseConfig. If the decryption fails the function returns an empty byte array and an error.

func (*NoiseConfig) Encrypt

func (noiseConfig *NoiseConfig) Encrypt(message []byte) []byte

Encrypt takes a (plaintext) byte array message as arguments and returns a noise encrypted byte array per the configuration in NoiseConfig If the encryption fails the function returns an empty byte array and an error.

func (*NoiseConfig) InitializeNoise

func (noiseConfig *NoiseConfig) InitializeNoise(ws *websocket.Conn) error

InitializeNoise sets up a new noise connection. First a fresh keypair is generated if none is locally found. Afterwards a XX handshake is performed. This is a three part handshake required to authenticate both parties. The resulting pairing code is then displayed to the user to check if it matches what is displayed on the other party's device.

Jump to

Keyboard shortcuts

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