relay

package
v4.14.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2019 License: Apache-2.0 Imports: 16 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteAllMessages

func DeleteAllMessages(server Server) error

DeleteAllMessages deletes all messages in all channels which expired on the given server.

func PullOldestMessage

func PullOldestMessage(server Server, channel *Channel) ([]byte, error)

PullOldestMessage pulls the oldest message on the given channel from the given server. If no message is available for ten seconds, then this function returns nil.

func PushMessage

func PushMessage(server Server, channel *Channel, data interface{}) error

PushMessage pushes the encryption of the given data as JSON to the given server.

Types

type Channel

type Channel struct {
	// ChannelID is the identifier which uniquely identifies the channel between the parties.
	ChannelID string `json:"id"`

	// EncryptionKey is used to encrypt the communication between the desktop and the mobile.
	EncryptionKey []byte `json:"key"`

	// AuthenticationKey is used to authenticate messages between the desktop and the mobile.
	AuthenticationKey []byte `json:"mac"`
	// contains filtered or unexported fields
}

Channel implements an encrypted communication channel between the desktop and the paired mobile.

func NewChannel

func NewChannel(channelID string, encryptionKey []byte, authenticationKey []byte, socksProxy socksproxy.SocksProxy) *Channel

NewChannel returns a new channel with the given channel ID, encryption and authentication key.

func NewChannelFromConfigFile

func NewChannelFromConfigFile(configDir string, socksProxy socksproxy.SocksProxy) *Channel

NewChannelFromConfigFile returns a new channel with the channel identifier and encryption key from the config file or nil if the config file does not exist.

func NewChannelWithRandomKey

func NewChannelWithRandomKey(socksProxy socksproxy.SocksProxy) *Channel

NewChannelWithRandomKey returns a new channel with a random encryption key and identifier.

func (*Channel) RemoveConfigFile

func (channel *Channel) RemoveConfigFile(configDir string) error

RemoveConfigFile removes the config file. Callers can use config.AppDir to obtain standard user location config dir.

func (*Channel) SendClear

func (channel *Channel) SendClear() error

SendClear clears the screen of the paired mobile.

func (*Channel) SendHashPubKey

func (channel *Channel) SendHashPubKey(verifyPass interface{}) error

SendHashPubKey sends the hash of the public key from the BitBox to the mobile to finish pairing.

func (*Channel) SendPairingTest

func (channel *Channel) SendPairingTest(tfaTestString string) error

SendPairingTest sends the encrypted test string from the BitBox to the paired mobile.

func (*Channel) SendPing

func (channel *Channel) SendPing() error

SendPing sends a 'ping' to the paired mobile to which it automatically responds with 'pong'.

func (*Channel) SendPubKey

func (channel *Channel) SendPubKey(verifyPass interface{}) error

SendPubKey sends the ECDH public key from the BitBox to the paired mobile to finish pairing.

func (*Channel) SendRandomNumberEcho

func (channel *Channel) SendRandomNumberEcho(randomNumberEcho string) error

SendRandomNumberEcho sends the encrypted random number echo from the BitBox to the paired mobile.

func (*Channel) SendSigningEcho

func (channel *Channel) SendSigningEcho(
	signingEcho string,
	coin string,
	scriptType string,
	transaction string,
) error

SendSigningEcho sends the encrypted signing echo from the BitBox to the paired mobile.

func (*Channel) SendXpubEcho

func (channel *Channel) SendXpubEcho(xpubEcho string, typ string) error

SendXpubEcho sends the encrypted xpub echo from the BitBox to the paired mobile.

func (*Channel) StoreToConfigFile

func (channel *Channel) StoreToConfigFile(configDir string) error

StoreToConfigFile stores the channel to the config file located in the provided configDir. Callers can use config.AppDir to obtain standard user location config dir.

func (*Channel) WaitForCommand

func (channel *Channel) WaitForCommand(duration time.Duration) (string, error)

WaitForCommand waits for the given duration for an ECDH command from mobile. Returns the command or an error if no command has been received in the given duration.

func (*Channel) WaitForMobilePublicKey

func (channel *Channel) WaitForMobilePublicKey(duration time.Duration) (string, error)

WaitForMobilePublicKey waits for the given duration for the ECDH public key from the mobile. Returns an error if no ECDH public key has been received from the server in the given duration.

func (*Channel) WaitForMobilePublicKeyHash

func (channel *Channel) WaitForMobilePublicKeyHash(duration time.Duration) (string, error)

WaitForMobilePublicKeyHash waits for the given duration for the public key hash from the mobile. Returns an error if no public key hash has been received from the server in the given duration.

func (*Channel) WaitForPong

func (channel *Channel) WaitForPong(duration time.Duration) error

WaitForPong waits for the given duration for the 'pong' from the mobile after sending 'ping'. Returns nil if the pong was retrieved from the relay server and an error otherwise.

func (*Channel) WaitForRandomNumberClear

func (channel *Channel) WaitForRandomNumberClear(duration time.Duration) error

WaitForRandomNumberClear waits for the given duration for a random number clear from the mobile. Returns nil if a random number clear was retrieved from the relay server and an error otherwise.

func (*Channel) WaitForScanningSuccess

func (channel *Channel) WaitForScanningSuccess(duration time.Duration) error

WaitForScanningSuccess waits for the given duration for the scanning success from the mobile. Returns nil if the scanning success was retrieved from the relay server and an error otherwise.

func (*Channel) WaitForSigningPin

func (channel *Channel) WaitForSigningPin(duration time.Duration) (string, error)

WaitForSigningPin waits for the given duration for the 2FA signing PIN from the mobile. Returns an error if no 2FA signing PIN was available on the relay server in the given duration. Otherwise, the returned value is either the PIN (on confirmation) or "abort" (on cancel).

type Command

type Command string

Command enumerates the commands that can be sent to the relay server.

const (
	// PushMessageCommand pushes a message for the other communication party on the given channel.
	PushMessageCommand Command = "data"

	// PullOldestMessageCommand pulls the oldest message on the specified channel for the specified
	// communication party. If there are several messages, only the oldest message is returned.
	// The relay server waits up to 10 seconds before returning no message at all.
	PullOldestMessageCommand Command = "gd"

	// DeleteAllMessagesCommand deletes all messages in all channels which expired.
	// In the default script, messages expire 40 seconds after their creation.
	DeleteAllMessagesCommand Command = "dd"
)

type Party

type Party int

Party enumerates the endpoints of the pairing.

const (
	// Desktop is the endpoint that is connected to the BitBox.
	Desktop Party = 0

	// Mobile is the endpoint that acts as a trusted screen.
	Mobile Party = 1
)

func (Party) Encode

func (party Party) Encode() string

Encode encodes the party as a string.

type Server

type Server string

Server models the relay server, which relays messages between the paired parties.

const (
	// DefaultServer stores the default server.
	DefaultServer Server = "https://digitalbitbox.com/smartverification/index.php"
)

Jump to

Keyboard shortcuts

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