Documentation ¶
Index ¶
- Constants
- func AcceptRequest(serverURL string, fingerprint string) error
- func BytesToPrivateKey(priv []byte) (*rsa.PrivateKey, error)
- func BytesToPublicKey(pub []byte) (*rsa.PublicKey, error)
- func DeclineRequest(serverURL string, fingerprint string) error
- func DecryptWithPrivateKey(ciphertext []byte, priv *rsa.PrivateKey) ([]byte, error)
- func EncryptWithPublicKey(msg []byte, pub *rsa.PublicKey) ([]byte, error)
- func Fingerprint(cert *rsa.PublicKey) string
- func GenerateKeyPair(bits int) (*rsa.PrivateKey, *rsa.PublicKey)
- func ListPairingRequests(serverURL string) ([]string, error)
- func NewRSAAuthorizedTransport(child peers.Transport, keyProvider KeypairProvider) (peers.Transport, error)
- func NewRSAAuthorizedTransportFactory(child peers.TransportFactory, acceptor Acceptor) peers.TransportFactory
- func PrivateKeyToBytes(priv *rsa.PrivateKey) []byte
- func PublicKeyToBytes(pub *rsa.PublicKey) ([]byte, error)
- type Acceptor
- type DummyAcceptor
- type KeypairProvider
Constants ¶
const CiphertextTag = "AesCiphertext::"
CiphertextTag prefixes all messages that have body encrypted
Variables ¶
This section is empty.
Functions ¶
func AcceptRequest ¶
AcceptRequest accepts pairing request fingerprint
func BytesToPrivateKey ¶
func BytesToPrivateKey(priv []byte) (*rsa.PrivateKey, error)
BytesToPrivateKey bytes to private key
func BytesToPublicKey ¶
BytesToPublicKey bytes to public key
func DeclineRequest ¶
DeclineRequest accepts pairing request fingerprint
func DecryptWithPrivateKey ¶
func DecryptWithPrivateKey(ciphertext []byte, priv *rsa.PrivateKey) ([]byte, error)
DecryptWithPrivateKey decrypts data with private key
func EncryptWithPublicKey ¶
EncryptWithPublicKey encrypts data with public key
func Fingerprint ¶
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 ¶
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
Types ¶
type Acceptor ¶
Acceptor lets rsaAuthorizedTransportFactory decide if the key is trusted or not
func NewInFileCachingAcceptor ¶
NewInFileCachingAcceptor returns acceptor, that caches trusted fingerprints in file
func NewInMemoryCachingAcceptor ¶
NewInMemoryCachingAcceptor returns acceptor, that caches trusted fingerprints in memory
type DummyAcceptor ¶
type DummyAcceptor struct { }
DummyAcceptor implements Acceptor by blindly trusting all keys
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.