auth

package
v0.0.0-...-35b3a18 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2022 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const CiphertextTag = "AesCiphertext::"

CiphertextTag prefixes all messages that have body encrypted

Variables

This section is empty.

Functions

func AcceptRequest

func AcceptRequest(serverURL string, fingerprint string) error

AcceptRequest accepts pairing request fingerprint

func BytesToPrivateKey

func BytesToPrivateKey(priv []byte) (*rsa.PrivateKey, error)

BytesToPrivateKey bytes to private key

func BytesToPublicKey

func BytesToPublicKey(pub []byte) (*rsa.PublicKey, error)

BytesToPublicKey bytes to public key

func DeclineRequest

func DeclineRequest(serverURL string, fingerprint string) error

DeclineRequest accepts pairing request fingerprint

func DecryptWithPrivateKey

func DecryptWithPrivateKey(ciphertext []byte, priv *rsa.PrivateKey) ([]byte, error)

DecryptWithPrivateKey decrypts data with private key

func EncryptWithPublicKey

func EncryptWithPublicKey(msg []byte, pub *rsa.PublicKey) ([]byte, error)

EncryptWithPublicKey encrypts data with public key

func Fingerprint

func Fingerprint(cert *rsa.PublicKey) string

Fingerprint allows presenting public key in a format, that can be interpreted by human

func GenerateKeyPair

func GenerateKeyPair(bits int) (*rsa.PrivateKey, *rsa.PublicKey)

GenerateKeyPair generates a new key pair

func ListPairingRequests

func ListPairingRequests(serverURL string) ([]string, error)

ListPairingRequests displays a list of pairing requests

func NewRSAAuthorizedTransport

func NewRSAAuthorizedTransport(child peers.Transport, keyProvider KeypairProvider) (peers.Transport, error)

NewRSAAuthorizedTransport creates AesTranport instances

func NewRSAAuthorizedTransportFactory

func NewRSAAuthorizedTransportFactory(child peers.TransportFactory, acceptor Acceptor) peers.TransportFactory

NewRSAAuthorizedTransportFactory is a decorator over TransportFactory, that allows encryption in transit with AES

func PrivateKeyToBytes

func PrivateKeyToBytes(priv *rsa.PrivateKey) []byte

PrivateKeyToBytes private key to bytes

func PublicKeyToBytes

func PublicKeyToBytes(pub *rsa.PublicKey) ([]byte, error)

PublicKeyToBytes public key to bytes

Types

type Acceptor

type Acceptor interface {
	IsTrusted(*rsa.PublicKey) (bool, error)
}

Acceptor lets rsaAuthorizedTransportFactory decide if the key is trusted or not

func NewInFileCachingAcceptor

func NewInFileCachingAcceptor(filePath string, child Acceptor) Acceptor

NewInFileCachingAcceptor returns acceptor, that caches trusted fingerprints in file

func NewInMemoryCachingAcceptor

func NewInMemoryCachingAcceptor(child Acceptor) Acceptor

NewInMemoryCachingAcceptor returns acceptor, that caches trusted fingerprints in memory

type DummyAcceptor

type DummyAcceptor struct {
}

DummyAcceptor implements Acceptor by blindly trusting all keys

func (DummyAcceptor) IsTrusted

func (a DummyAcceptor) IsTrusted(*rsa.PublicKey) (bool, error)

IsTrusted implements Acceptor

type KeypairProvider

type KeypairProvider interface {
	Public() (*rsa.PublicKey, error)
	Private() (*rsa.PrivateKey, error)
}

KeypairProvider allows retrieving key pairs for transport messages encryption

func NewStoredInFilesKeypairProvider

func NewStoredInFilesKeypairProvider(directoryPath string) (KeypairProvider, error)

NewStoredInFilesKeypairProvider uses private key from given directory or creates fresh one if none exists, then uses it as KeypairProvider.

Jump to

Keyboard shortcuts

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