Documentation ¶
Index ¶
- Constants
- Variables
- type Body
- type Direction
- type Handler
- type Meta
- type Msg
- type MsgArgs
- type MsgList
- type MsgName
- type Receiver
- type Secret
- type SecretKey
- type Sender
- func (s *Sender) APIArgs() (token, csrf string)
- func (s *Sender) Cancel(m *Meta) error
- func (s *Sender) CorruptStartKexSession(m *Meta, id StrongID) error
- func (s *Sender) Done(m *Meta) error
- func (s *Sender) Hello(m *Meta, devID keybase1.DeviceID, devKeyID keybase1.KID) error
- func (s *Sender) PleaseSign(m *Meta, eddsa libkb.NaclSigningKeyPublic, sig, devType, devDesc string) error
- func (s *Sender) StartKexSession(m *Meta, id StrongID) error
- func (s *Sender) StartReverseKexSession(m *Meta) error
- type StrongID
- type WeakID
Constants ¶
const ( StartKexMsg MsgName = "startkex" StartRevKexMsg = "startrevkex" HelloMsg = "hello" PleaseSignMsg = "pleasesign" DoneMsg = "done" CancelMsg = "cancel" )
These are the valid message names for kex.
Variables ¶
var ErrMACMismatch = errors.New("Computed HMAC doesn't match message HMAC")
ErrMACMismatch is returned when a MAC fails.
var ErrProtocolEOF = errors.New("EOF")
ErrProtocolEOF is returned by Receive when the message body has the EOF flag set.
var ErrStrongIDMismatch = errors.New("Strong session ID (I) mismatch between message and receiver")
ErrStrongIDMismatch is returned when the strong session ID (I) in a message fails to match the receiver's strong session ID.
var ErrWeakIDMismatch = errors.New("Weak session ID (w) mismatch between message and receiver")
ErrWeakIDMismatch is returned when the weak session ID (w) in a message fails to match the receiver's weak session ID.
var HelloTimeout = 5 * time.Minute
HelloTimeout is the time the kex protocol will wait for the hello message from the existing sibling device. It is long because it might take the user a while to access the existing device.
var IntraTimeout = 1 * time.Minute
IntraTimeout is the time the kex protocol will wait for messages once the key exchange has begun.
var PollDuration = 20 * time.Second
PollDuration is the long poll duration for a kex/receive api call.
var StartTimeout = 1 * time.Second
StartTimeout is the duration the existing sibling device will wait for a start message. It is very short because the message should be on the server already. If there are no messages waiting, then the secret phrase is likely incorrect.
Functions ¶
This section is empty.
Types ¶
type Body ¶
Body is the message body.
func BodyDecode ¶
BodyDecode takes a base64-encoded msgpack and turns it into a message body.
func (*Body) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
type Direction ¶
type Direction int
Direction of the message. From device X to device Y, or from device Y to device X.
const ( // DirectionYtoX is for messages intended for device X from device Y DirectionYtoX Direction = 1 // DirectionXtoY is for messages intended for device Y from device X DirectionXtoY = 2 )
type Handler ¶
type Handler interface { StartKexSession(m *Meta, id StrongID) error StartReverseKexSession(m *Meta) error Hello(m *Meta, devID keybase1.DeviceID, devKeyID keybase1.KID) error PleaseSign(m *Meta, eddsa libkb.NaclSigningKeyPublic, sig, devType, devDesc string) error Done(m *Meta) error Cancel(m *Meta) error }
Handler is the key exchange protocol interface. Anything receiving kex messages will implement this, as well as anything sending kex messages.
type Meta ¶
type Meta struct { UID keybase1.UID WeakID WeakID `json:"w"` // `w` in doc StrongID StrongID `json:"I"` // `I` in doc Sender keybase1.DeviceID Receiver keybase1.DeviceID Seqno int Direction Direction `json:"dir"` }
Meta is the metadata that is sent with every kex message.
type Msg ¶
Msg is a kex message.
type MsgArgs ¶
type MsgArgs struct { StrongID StrongID DeviceID keybase1.DeviceID DevKeyID keybase1.KID SigningKey libkb.NaclSigningKeyPublic Sig string DevType string DevDesc string }
MsgArgs contains the union of all the args for the kex message protocol interface. Many of the fields are optional depending on the message.
type Receiver ¶
type Receiver struct { Msgs chan *Msg libkb.Contextified // contains filtered or unexported fields }
Receiver gets kex messages from the server and routes them to a kex Handler.
func NewReceiver ¶
func NewReceiver(dir Direction, secret *Secret, sessToken, sessCsrf string, g *libkb.GlobalContext) *Receiver
NewReceiver creates a Receiver that will route messages to the provided handler. It will receive messages for the specified direction.
func (*Receiver) Next ¶
Next gets messages from the message channel, looking for one that matches name. If none are received for the duration of timeout, it will return libkb.ErrTimeout. If the channel is closed, it will return ErrProtocolEOF.
type Secret ¶
type Secret struct {
// contains filtered or unexported fields
}
Secret generates kex shared secrets.
func SecretFromPhrase ¶
SecretFromPhrase creates a secret for a user give a secret phrase.
func (*Secret) StrongIDSlice ¶
StrongIDSlice returns StrongID as a byte slice for convenience.
func (*Secret) WeakIDSlice ¶
WeakIDSlice returns WeakID as a byte slice for convenience.
type Sender ¶
type Sender struct { libkb.Contextified // contains filtered or unexported fields }
Sender is an implementation of the kex Handler interface that sends messages to the api server.
func NewSender ¶
func NewSender(dir Direction, secret SecretKey, sessToken, sessCsrf string, gc *libkb.GlobalContext) *Sender
NewSender creates a Sender for the given message direction.
func (*Sender) CorruptStartKexSession ¶
CorruptStartKexSession sends a startkex message with a corrupted MAC. This is for testing, clearly. It's an exposed function since only an engine test can test this.
func (*Sender) PleaseSign ¶
func (s *Sender) PleaseSign(m *Meta, eddsa libkb.NaclSigningKeyPublic, sig, devType, devDesc string) error
PleaseSign sends the PleaseSign message to the server.
func (*Sender) StartKexSession ¶
StartKexSession sends the StartKexSession message to the server.
func (*Sender) StartReverseKexSession ¶
StartReverseKexSession sends the StartReverseKexSession message to the server.
type StrongID ¶
type StrongID [32]byte
StrongID is the strong session id type.
func (*StrongID) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
type WeakID ¶
type WeakID [16]byte
WeakID is the weak session id type.
func (*WeakID) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.