handshake

package
Version: v2.300.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2021 License: Apache-2.0, MIT Imports: 17 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 RequestUsingReaderWriter

func RequestUsingReaderWriter(ctx context.Context, logger *zap.Logger, 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 ResponseUsingReaderWriter

func ResponseUsingReaderWriter(ctx context.Context, logger *zap.Logger, 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

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

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

func (*BoxEnvelope) GetBox

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

func (*BoxEnvelope) Marshal

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

func (*BoxEnvelope) MarshalTo

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

func (*BoxEnvelope) MarshalToSizedBuffer

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

func (*BoxEnvelope) ProtoMessage

func (*BoxEnvelope) ProtoMessage()

func (*BoxEnvelope) Reset

func (m *BoxEnvelope) Reset()

func (*BoxEnvelope) Size

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

func (*BoxEnvelope) String

func (m *BoxEnvelope) String() string

func (*BoxEnvelope) Unmarshal

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

func (*BoxEnvelope) XXX_DiscardUnknown

func (m *BoxEnvelope) XXX_DiscardUnknown()

func (*BoxEnvelope) XXX_Marshal

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

func (*BoxEnvelope) XXX_Merge

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

func (*BoxEnvelope) XXX_Size

func (m *BoxEnvelope) XXX_Size() int

func (*BoxEnvelope) XXX_Unmarshal

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

type HelloPayload

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

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

func (*HelloPayload) GetEphemeralPubKey

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

func (*HelloPayload) Marshal

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

func (*HelloPayload) MarshalTo

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

func (*HelloPayload) MarshalToSizedBuffer

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

func (*HelloPayload) ProtoMessage

func (*HelloPayload) ProtoMessage()

func (*HelloPayload) Reset

func (m *HelloPayload) Reset()

func (*HelloPayload) Size

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

func (*HelloPayload) String

func (m *HelloPayload) String() string

func (*HelloPayload) Unmarshal

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

func (*HelloPayload) XXX_DiscardUnknown

func (m *HelloPayload) XXX_DiscardUnknown()

func (*HelloPayload) XXX_Marshal

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

func (*HelloPayload) XXX_Merge

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

func (*HelloPayload) XXX_Size

func (m *HelloPayload) XXX_Size() int

func (*HelloPayload) XXX_Unmarshal

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

type RequesterAcknowledgePayload

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

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

func (*RequesterAcknowledgePayload) GetSuccess

func (m *RequesterAcknowledgePayload) GetSuccess() bool

func (*RequesterAcknowledgePayload) Marshal

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

func (*RequesterAcknowledgePayload) MarshalTo

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

func (*RequesterAcknowledgePayload) MarshalToSizedBuffer

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

func (*RequesterAcknowledgePayload) ProtoMessage

func (*RequesterAcknowledgePayload) ProtoMessage()

func (*RequesterAcknowledgePayload) Reset

func (m *RequesterAcknowledgePayload) Reset()

func (*RequesterAcknowledgePayload) Size

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

func (*RequesterAcknowledgePayload) String

func (m *RequesterAcknowledgePayload) String() string

func (*RequesterAcknowledgePayload) Unmarshal

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

func (*RequesterAcknowledgePayload) XXX_DiscardUnknown

func (m *RequesterAcknowledgePayload) XXX_DiscardUnknown()

func (*RequesterAcknowledgePayload) XXX_Marshal

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

func (*RequesterAcknowledgePayload) XXX_Merge

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

func (*RequesterAcknowledgePayload) XXX_Size

func (m *RequesterAcknowledgePayload) XXX_Size() int

func (*RequesterAcknowledgePayload) XXX_Unmarshal

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

type RequesterAuthenticatePayload

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

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

func (*RequesterAuthenticatePayload) GetRequesterAccountId

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

func (*RequesterAuthenticatePayload) GetRequesterAccountSig

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

func (*RequesterAuthenticatePayload) Marshal

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

func (*RequesterAuthenticatePayload) MarshalTo

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

func (*RequesterAuthenticatePayload) MarshalToSizedBuffer

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

func (*RequesterAuthenticatePayload) ProtoMessage

func (*RequesterAuthenticatePayload) ProtoMessage()

func (*RequesterAuthenticatePayload) Reset

func (m *RequesterAuthenticatePayload) Reset()

func (*RequesterAuthenticatePayload) Size

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

func (*RequesterAuthenticatePayload) String

func (*RequesterAuthenticatePayload) Unmarshal

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

func (*RequesterAuthenticatePayload) XXX_DiscardUnknown

func (m *RequesterAuthenticatePayload) XXX_DiscardUnknown()

func (*RequesterAuthenticatePayload) XXX_Marshal

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

func (*RequesterAuthenticatePayload) XXX_Merge

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

func (*RequesterAuthenticatePayload) XXX_Size

func (m *RequesterAuthenticatePayload) XXX_Size() int

func (*RequesterAuthenticatePayload) XXX_Unmarshal

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

type ResponderAcceptPayload

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

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

func (*ResponderAcceptPayload) GetResponderAccountSig

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

func (*ResponderAcceptPayload) Marshal

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

func (*ResponderAcceptPayload) MarshalTo

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

func (*ResponderAcceptPayload) MarshalToSizedBuffer

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

func (*ResponderAcceptPayload) ProtoMessage

func (*ResponderAcceptPayload) ProtoMessage()

func (*ResponderAcceptPayload) Reset

func (m *ResponderAcceptPayload) Reset()

func (*ResponderAcceptPayload) Size

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

func (*ResponderAcceptPayload) String

func (m *ResponderAcceptPayload) String() string

func (*ResponderAcceptPayload) Unmarshal

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

func (*ResponderAcceptPayload) XXX_DiscardUnknown

func (m *ResponderAcceptPayload) XXX_DiscardUnknown()

func (*ResponderAcceptPayload) XXX_Marshal

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

func (*ResponderAcceptPayload) XXX_Merge

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

func (*ResponderAcceptPayload) XXX_Size

func (m *ResponderAcceptPayload) XXX_Size() int

func (*ResponderAcceptPayload) XXX_Unmarshal

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to