secio

package module
v1.1.8 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2017 License: MIT Imports: 26 Imported by: 0

README

go-libp2p-secio

standard-readme compliant GoDoc Coverage Status Build Status

go-libp2p's secio encrypted transport

Package secio is used to encrypt go-libp2p-conn connections. Connections wrapped by secio use secure sessions provided by this package to encrypt all traffic. A TLS-like handshake is used to setup the communication channel.

Install

go-libp2p-secio is a standard Go module which can be installed with:

go get github.com/libp2p/go-libp2p-secio

Note that go-libp2p-secio is packaged with Gx, so it is recommended to use Gx to install and use it (see the Usage section).

Usage

This module is packaged with Gx. In order to use it in your own project it is recommended that you:

go get -u github.com/whyrusleeping/gx
go get -u github.com/whyrusleeping/gx-go
cd <your-project-repository>
gx init
gx import github.com/multiformats/go-libp2p-secio
gx install --global
gx-go --rewrite

Please check Gx and Gx-go documentation for more information.

For more information about how go-libp2p-secio is used in the libp2p context, you can see the go-libp2p-conn module.

Contribute

Feel free to join in. All welcome. Open an issue!

This repository falls under the IPFS Code of Conduct.

Want to hack on IPFS?

License

MIT

Documentation

Overview

Package secio is used to encrypt `go-libp2p-conn` connections. Connections wrapped by secio use secure sessions provided by this package to encrypt all traffic. A TLS-like handshake is used to setup the communication channel.

Index

Constants

This section is empty.

Variables

View Source
var ErrClosed = errors.New("connection closed")

ErrClosed signals the closing of a connection.

View Source
var ErrEcho = errors.New("same keys and nonces. one side talking to self")

ErrEcho is returned when we're attempting to handshake with the same keys and nonces.

View Source
var ErrMACInvalid = errors.New("MAC verification failed")

ErrMACInvalid signals that a MAC verification failed

View Source
var ErrUnsupportedKeyType = errors.New("unsupported key type")

ErrUnsupportedKeyType is returned when a private key cast/type switch fails.

View Source
var HandshakeTimeout = time.Second * 30

HandshakeTimeout governs how long the handshake will be allowed to take place for. Making this number large means there could be many bogus connections waiting to timeout in flight. Typical handshakes take ~3RTTs, so it should be completed within seconds across a typical planet in the solar system.

View Source
var SupportedCiphers = "AES-256,AES-128,Blowfish"

SupportedCiphers is the list of supported Ciphers

View Source
var SupportedExchanges = "P-256,P-384,P-521"

SupportedExchanges is the list of supported ECDH curves

View Source
var SupportedHashes = "SHA256,SHA512"

SupportedHashes is the list of supported Hashes

Functions

func NewETMReader

func NewETMReader(r io.Reader, s cipher.Stream, mac HMAC) msgio.ReadCloser

NewETMReader Encrypt-Then-MAC

func NewETMWriter

func NewETMWriter(w io.Writer, s cipher.Stream, mac HMAC) msgio.WriteCloser

NewETMWriter Encrypt-Then-MAC

Types

type HMAC

type HMAC struct {
	hash.Hash
	// contains filtered or unexported fields
}

HMAC carries a hash and its size

type Session

type Session interface {
	// ReadWriter returns the encrypted communication channel
	ReadWriter() msgio.ReadWriteCloser

	// LocalPeer retrieves the local peer.
	LocalPeer() peer.ID

	// LocalPrivateKey retrieves the local private key
	LocalPrivateKey() ci.PrivKey

	// RemotePeer retrieves the remote peer.
	RemotePeer() peer.ID

	// RemotePublicKey retrieves the remote's public key
	// which was received during the handshake.
	RemotePublicKey() ci.PubKey

	// Close closes the secure session
	Close() error
}

Session provides the necessary functionality to wrap a connection and tunnel it through a secure channel via the provided ReadWriter.

type SessionGenerator

type SessionGenerator struct {
	LocalID    peer.ID
	PrivateKey ci.PrivKey
}

SessionGenerator constructs secure communication sessions for a peer.

func (*SessionGenerator) NewSession

func (sg *SessionGenerator) NewSession(ctx context.Context, insecure io.ReadWriteCloser) (Session, error)

NewSession takes an insecure io.ReadWriter, sets up a TLS-like handshake with the other side, and returns a secure session. The handshake isn't run until the connection is read or written to. See the source for the protocol details and security implementation. The provided Context is only needed for the duration of this function.

Directories

Path Synopsis
Package spipe_pb is a generated protocol buffer package.
Package spipe_pb is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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