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 (*File) Exists ¶
Exists checks whether the file exists with suitable permissions as a file and not as a directory.
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.