Documentation ¶
Overview ¶
Package boxstream implements the Secret Handshake and the box stream protocol.
See https://ssbc.github.io/scuttlebutt-protocol-guide/#handshake as well as https://ssbc.github.io/scuttlebutt-protocol-guide/#box-stream.
Index ¶
Constants ¶
const NetworkKeyLength = 32
NetworkKeyLength is implied to be constant due to an assumption that this key is used as an HMAC key when calling libsodium's crypto_auth during handshakes.
See https://ssbc.github.io/scuttlebutt-protocol-guide/#handshake. See https://doc.libsodium.org/secret-key_cryptography/secret-key_authentication.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CurrentTimeProvider ¶
type HandshakeResult ¶
type HandshakeResult struct { Remote identity.Public WriteSecret Key WriteNonce Nonce ReadSecret Key ReadNonce Nonce }
HandshakeResult is created internally by the Handshaker and passed to NewStream.
type Handshaker ¶
type Handshaker struct {
// contains filtered or unexported fields
}
Handshaker performs the Secret Handshake using the provided ReadWriteCloser.
func NewHandshaker ¶
func NewHandshaker( local identity.Private, networkKey NetworkKey, currentTimeProvider CurrentTimeProvider, ) (Handshaker, error)
NewHandshaker creates a new handshaker which uses the provided local private identity when performing secret handshakes.
func (Handshaker) OpenClientStream ¶
func (h Handshaker) OpenClientStream(rw io.ReadWriteCloser, remote identity.Public) (*Stream, error)
OpenClientStream opens a client stream using the provided identity of the remote peer and the provided ReadWriteCloser. This should be used when initiating a connection with a remote peer.
func (Handshaker) OpenServerStream ¶
func (h Handshaker) OpenServerStream(rw io.ReadWriteCloser) (*Stream, error)
OpenServerStream opens a server stream using the provided ReadWriteCloser. This should be used when handling incoming connections which were initiated by the other party.
type NetworkKey ¶
type NetworkKey struct {
// contains filtered or unexported fields
}
NetworkKey is used for verifying that two peers are a part of the same Secure Scuttlebutt network in the initial stages of the handshake. Peers using two different network keys will not be able to establish a connection with each other. If you want to use the main Secure Scuttlebutt network then use NewDefaultNetworkKey. Setting a different network key using NewNetworkKey is mainly useful for test networks.
See https://ssbc.github.io/scuttlebutt-protocol-guide/#handshake.
func MustNewNetworkKey ¶
func MustNewNetworkKey(b []byte) NetworkKey
func NewDefaultNetworkKey ¶
func NewDefaultNetworkKey() NetworkKey
NewDefaultNetworkKey creates a key initialized with an arbitrarily chosen value used in the default Secure Scuttlebutt network.
func NewNetworkKey ¶
func NewNetworkKey(b []byte) (NetworkKey, error)
NewNetworkKey creates a network key from the provided slice of bytes. The slice must have a length of NetworkKeyLength.
func (NetworkKey) Bytes ¶
func (k NetworkKey) Bytes() []byte
func (NetworkKey) IsZero ¶
func (k NetworkKey) IsZero() bool
type SetDeadliner ¶
type Stream ¶
type Stream struct {
// contains filtered or unexported fields
}
Stream implements the box stream protocol.
func NewStream ¶
func NewStream(rw io.ReadWriteCloser, handshakeResult HandshakeResult) (*Stream, error)
func (Stream) Close ¶
Close writes the goodbye box stream message to the reader and then closes the underlying ReadWriteCloser.
func (*Stream) Read ¶
Read reads the data arriving in the box stream format from the underlying ReadWriteCloser.