handshake

package
v2.81.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2020 License: Apache-2.0, MIT Imports: 14 Imported by: 0

Documentation

Overview

Package handshake implements a capability-based handshake.

Handshake Sequence Diagram: --------------------------- Handshake vastely inspired by Scuttlebutt's Capability-based Handshake https://scuttlebot.io/more/protocols/shs.pdf

  • a, b are ephemeral key pairs generated by respectively Requester and Responder. Ephemeral keys are used for one handshake only and then discarded. They guarantee the freshness of the messages and avoid replay attacks.

  • A, B are the Account IDs of respectively Requester and Responder.

  • a.b denotes a secret derived from the two keys a and b.

  • | is the concatenation operator.

  • box[a.b](content) denotes the encryption of content using Nacl box with a.b as key.

  • sig[A](content) denotes the signature of content verified by A.

    +-----------+ +-----------+ | Requester | | Responder | +-----------+ +-----------+ | ---------------------\ | |-| 1. Requester Hello | | | |--------------------| | | | | a | |---------------------------------->| | ---------------------\ | | | 2. Responder Hello |-| | |--------------------| | | | | b | |<----------------------------------| | ----------------------------\ | |-| 3. Requester Authenticate | | | |---------------------------| | | | | box[a.b|a.B](A,sig[A](a.b)) | |---------------------------------->| | ----------------------\ | | | 4. Responder Accept |-| | |---------------------| | | | | box[a.b|A.B](sig[B](a.b)) | |<----------------------------------| | ---------------------------\ | |-| 5. Requester Acknowledge | | | |--------------------------| | | | | ok | |---------------------------------->| | |

See the documentation at https://berty.tech/protocol for more information.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLengthHandshake        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowHandshake          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupHandshake = fmt.Errorf("proto: unexpected end of group")
)

Functions

func Request

func Request(stream p2pnetwork.Stream, ownAccountID p2pcrypto.PrivKey, peerAccountID p2pcrypto.PubKey) error

Request init a handshake with the responder

func RequestUsingReaderWriter added in v2.59.0

func RequestUsingReaderWriter(reader ggio.Reader, writer ggio.Writer, ownAccountID p2pcrypto.PrivKey, peerAccountID p2pcrypto.PubKey) error

RequestUsingReaderWriter init a handshake with the responder, using provided ggio reader and writer

func Response

func Response(stream p2pnetwork.Stream, ownAccountID p2pcrypto.PrivKey) (p2pcrypto.PubKey, error)

Response handle the handshake inited by the requester

func ResponseUsingReaderWriter added in v2.59.0

func ResponseUsingReaderWriter(reader ggio.Reader, writer ggio.Writer, ownAccountID p2pcrypto.PrivKey) (p2pcrypto.PubKey, error)

ResponseUsingReaderWriter handle the handshake inited by the requester, using provided ggio reader and writer

Types

type BoxEnvelope added in v2.40.0

type BoxEnvelope struct {
	Box                  []byte   `protobuf:"bytes,1,opt,name=box,proto3" json:"box,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*BoxEnvelope) Descriptor added in v2.40.0

func (*BoxEnvelope) Descriptor() ([]byte, []int)

func (*BoxEnvelope) GetBox added in v2.40.0

func (m *BoxEnvelope) GetBox() []byte

func (*BoxEnvelope) Marshal added in v2.40.0

func (m *BoxEnvelope) Marshal() (dAtA []byte, err error)

func (*BoxEnvelope) MarshalTo added in v2.40.0

func (m *BoxEnvelope) MarshalTo(dAtA []byte) (int, error)

func (*BoxEnvelope) MarshalToSizedBuffer added in v2.40.0

func (m *BoxEnvelope) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*BoxEnvelope) ProtoMessage added in v2.40.0

func (*BoxEnvelope) ProtoMessage()

func (*BoxEnvelope) Reset added in v2.40.0

func (m *BoxEnvelope) Reset()

func (*BoxEnvelope) Size added in v2.40.0

func (m *BoxEnvelope) Size() (n int)

func (*BoxEnvelope) String added in v2.40.0

func (m *BoxEnvelope) String() string

func (*BoxEnvelope) Unmarshal added in v2.40.0

func (m *BoxEnvelope) Unmarshal(dAtA []byte) error

func (*BoxEnvelope) XXX_DiscardUnknown added in v2.40.0

func (m *BoxEnvelope) XXX_DiscardUnknown()

func (*BoxEnvelope) XXX_Marshal added in v2.40.0

func (m *BoxEnvelope) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*BoxEnvelope) XXX_Merge added in v2.40.0

func (m *BoxEnvelope) XXX_Merge(src proto.Message)

func (*BoxEnvelope) XXX_Size added in v2.40.0

func (m *BoxEnvelope) XXX_Size() int

func (*BoxEnvelope) XXX_Unmarshal added in v2.40.0

func (m *BoxEnvelope) XXX_Unmarshal(b []byte) error

type HelloPayload added in v2.40.0

type HelloPayload struct {
	EphemeralPubKey      []byte   `protobuf:"bytes,1,opt,name=ephemeral_pub_key,json=ephemeralPubKey,proto3" json:"ephemeral_pub_key,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*HelloPayload) Descriptor added in v2.40.0

func (*HelloPayload) Descriptor() ([]byte, []int)

func (*HelloPayload) GetEphemeralPubKey added in v2.40.0

func (m *HelloPayload) GetEphemeralPubKey() []byte

func (*HelloPayload) Marshal added in v2.40.0

func (m *HelloPayload) Marshal() (dAtA []byte, err error)

func (*HelloPayload) MarshalTo added in v2.40.0

func (m *HelloPayload) MarshalTo(dAtA []byte) (int, error)

func (*HelloPayload) MarshalToSizedBuffer added in v2.40.0

func (m *HelloPayload) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*HelloPayload) ProtoMessage added in v2.40.0

func (*HelloPayload) ProtoMessage()

func (*HelloPayload) Reset added in v2.40.0

func (m *HelloPayload) Reset()

func (*HelloPayload) Size added in v2.40.0

func (m *HelloPayload) Size() (n int)

func (*HelloPayload) String added in v2.40.0

func (m *HelloPayload) String() string

func (*HelloPayload) Unmarshal added in v2.40.0

func (m *HelloPayload) Unmarshal(dAtA []byte) error

func (*HelloPayload) XXX_DiscardUnknown added in v2.40.0

func (m *HelloPayload) XXX_DiscardUnknown()

func (*HelloPayload) XXX_Marshal added in v2.40.0

func (m *HelloPayload) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*HelloPayload) XXX_Merge added in v2.40.0

func (m *HelloPayload) XXX_Merge(src proto.Message)

func (*HelloPayload) XXX_Size added in v2.40.0

func (m *HelloPayload) XXX_Size() int

func (*HelloPayload) XXX_Unmarshal added in v2.40.0

func (m *HelloPayload) XXX_Unmarshal(b []byte) error

type RequesterAcknowledgePayload added in v2.40.0

type RequesterAcknowledgePayload struct {
	Success              bool     `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*RequesterAcknowledgePayload) Descriptor added in v2.40.0

func (*RequesterAcknowledgePayload) Descriptor() ([]byte, []int)

func (*RequesterAcknowledgePayload) GetSuccess added in v2.40.0

func (m *RequesterAcknowledgePayload) GetSuccess() bool

func (*RequesterAcknowledgePayload) Marshal added in v2.40.0

func (m *RequesterAcknowledgePayload) Marshal() (dAtA []byte, err error)

func (*RequesterAcknowledgePayload) MarshalTo added in v2.40.0

func (m *RequesterAcknowledgePayload) MarshalTo(dAtA []byte) (int, error)

func (*RequesterAcknowledgePayload) MarshalToSizedBuffer added in v2.40.0

func (m *RequesterAcknowledgePayload) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*RequesterAcknowledgePayload) ProtoMessage added in v2.40.0

func (*RequesterAcknowledgePayload) ProtoMessage()

func (*RequesterAcknowledgePayload) Reset added in v2.40.0

func (m *RequesterAcknowledgePayload) Reset()

func (*RequesterAcknowledgePayload) Size added in v2.40.0

func (m *RequesterAcknowledgePayload) Size() (n int)

func (*RequesterAcknowledgePayload) String added in v2.40.0

func (m *RequesterAcknowledgePayload) String() string

func (*RequesterAcknowledgePayload) Unmarshal added in v2.40.0

func (m *RequesterAcknowledgePayload) Unmarshal(dAtA []byte) error

func (*RequesterAcknowledgePayload) XXX_DiscardUnknown added in v2.40.0

func (m *RequesterAcknowledgePayload) XXX_DiscardUnknown()

func (*RequesterAcknowledgePayload) XXX_Marshal added in v2.40.0

func (m *RequesterAcknowledgePayload) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*RequesterAcknowledgePayload) XXX_Merge added in v2.40.0

func (m *RequesterAcknowledgePayload) XXX_Merge(src proto.Message)

func (*RequesterAcknowledgePayload) XXX_Size added in v2.40.0

func (m *RequesterAcknowledgePayload) XXX_Size() int

func (*RequesterAcknowledgePayload) XXX_Unmarshal added in v2.40.0

func (m *RequesterAcknowledgePayload) XXX_Unmarshal(b []byte) error

type RequesterAuthenticatePayload added in v2.40.0

type RequesterAuthenticatePayload struct {
	RequesterAccountId   []byte   `protobuf:"bytes,1,opt,name=requester_account_id,json=requesterAccountId,proto3" json:"requester_account_id,omitempty"`
	RequesterAccountSig  []byte   `protobuf:"bytes,2,opt,name=requester_account_sig,json=requesterAccountSig,proto3" json:"requester_account_sig,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*RequesterAuthenticatePayload) Descriptor added in v2.40.0

func (*RequesterAuthenticatePayload) Descriptor() ([]byte, []int)

func (*RequesterAuthenticatePayload) GetRequesterAccountId added in v2.40.0

func (m *RequesterAuthenticatePayload) GetRequesterAccountId() []byte

func (*RequesterAuthenticatePayload) GetRequesterAccountSig added in v2.40.0

func (m *RequesterAuthenticatePayload) GetRequesterAccountSig() []byte

func (*RequesterAuthenticatePayload) Marshal added in v2.40.0

func (m *RequesterAuthenticatePayload) Marshal() (dAtA []byte, err error)

func (*RequesterAuthenticatePayload) MarshalTo added in v2.40.0

func (m *RequesterAuthenticatePayload) MarshalTo(dAtA []byte) (int, error)

func (*RequesterAuthenticatePayload) MarshalToSizedBuffer added in v2.40.0

func (m *RequesterAuthenticatePayload) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*RequesterAuthenticatePayload) ProtoMessage added in v2.40.0

func (*RequesterAuthenticatePayload) ProtoMessage()

func (*RequesterAuthenticatePayload) Reset added in v2.40.0

func (m *RequesterAuthenticatePayload) Reset()

func (*RequesterAuthenticatePayload) Size added in v2.40.0

func (m *RequesterAuthenticatePayload) Size() (n int)

func (*RequesterAuthenticatePayload) String added in v2.40.0

func (*RequesterAuthenticatePayload) Unmarshal added in v2.40.0

func (m *RequesterAuthenticatePayload) Unmarshal(dAtA []byte) error

func (*RequesterAuthenticatePayload) XXX_DiscardUnknown added in v2.40.0

func (m *RequesterAuthenticatePayload) XXX_DiscardUnknown()

func (*RequesterAuthenticatePayload) XXX_Marshal added in v2.40.0

func (m *RequesterAuthenticatePayload) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*RequesterAuthenticatePayload) XXX_Merge added in v2.40.0

func (m *RequesterAuthenticatePayload) XXX_Merge(src proto.Message)

func (*RequesterAuthenticatePayload) XXX_Size added in v2.40.0

func (m *RequesterAuthenticatePayload) XXX_Size() int

func (*RequesterAuthenticatePayload) XXX_Unmarshal added in v2.40.0

func (m *RequesterAuthenticatePayload) XXX_Unmarshal(b []byte) error

type ResponderAcceptPayload added in v2.40.0

type ResponderAcceptPayload struct {
	ResponderAccountSig  []byte   `protobuf:"bytes,1,opt,name=responder_account_sig,json=responderAccountSig,proto3" json:"responder_account_sig,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*ResponderAcceptPayload) Descriptor added in v2.40.0

func (*ResponderAcceptPayload) Descriptor() ([]byte, []int)

func (*ResponderAcceptPayload) GetResponderAccountSig added in v2.40.0

func (m *ResponderAcceptPayload) GetResponderAccountSig() []byte

func (*ResponderAcceptPayload) Marshal added in v2.40.0

func (m *ResponderAcceptPayload) Marshal() (dAtA []byte, err error)

func (*ResponderAcceptPayload) MarshalTo added in v2.40.0

func (m *ResponderAcceptPayload) MarshalTo(dAtA []byte) (int, error)

func (*ResponderAcceptPayload) MarshalToSizedBuffer added in v2.40.0

func (m *ResponderAcceptPayload) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*ResponderAcceptPayload) ProtoMessage added in v2.40.0

func (*ResponderAcceptPayload) ProtoMessage()

func (*ResponderAcceptPayload) Reset added in v2.40.0

func (m *ResponderAcceptPayload) Reset()

func (*ResponderAcceptPayload) Size added in v2.40.0

func (m *ResponderAcceptPayload) Size() (n int)

func (*ResponderAcceptPayload) String added in v2.40.0

func (m *ResponderAcceptPayload) String() string

func (*ResponderAcceptPayload) Unmarshal added in v2.40.0

func (m *ResponderAcceptPayload) Unmarshal(dAtA []byte) error

func (*ResponderAcceptPayload) XXX_DiscardUnknown added in v2.40.0

func (m *ResponderAcceptPayload) XXX_DiscardUnknown()

func (*ResponderAcceptPayload) XXX_Marshal added in v2.40.0

func (m *ResponderAcceptPayload) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ResponderAcceptPayload) XXX_Merge added in v2.40.0

func (m *ResponderAcceptPayload) XXX_Merge(src proto.Message)

func (*ResponderAcceptPayload) XXX_Size added in v2.40.0

func (m *ResponderAcceptPayload) XXX_Size() int

func (*ResponderAcceptPayload) XXX_Unmarshal added in v2.40.0

func (m *ResponderAcceptPayload) XXX_Unmarshal(b []byte) error

Jump to

Keyboard shortcuts

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