exchange

package
v0.44.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package exchange contains Telegram key exchange algorithm flows. See https://core.telegram.org/mtproto/auth_key.

Index

Constants

View Source
const DefaultTimeout = 1 * time.Minute

DefaultTimeout is default WithTimeout parameter value.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientExchange

type ClientExchange struct {
	// contains filtered or unexported fields
}

ClientExchange is a client-side key exchange flow.

func (ClientExchange) Run

Run runs client-side flow.

type ClientExchangeResult

type ClientExchangeResult struct {
	AuthKey    crypto.AuthKey
	SessionID  int64
	ServerSalt int64
}

ClientExchangeResult contains client part of key exchange result.

type Exchanger

type Exchanger struct {
	// contains filtered or unexported fields
}

Exchanger is builder for key exchangers.

func NewExchanger

func NewExchanger(conn transport.Conn) Exchanger

NewExchanger creates new Exchanger.

func (Exchanger) Client

func (e Exchanger) Client(keys []*rsa.PublicKey) ClientExchange

Client creates new ClientExchange using parameters from Exchanger.

func (Exchanger) Server

func (e Exchanger) Server(key *rsa.PrivateKey) ServerExchange

Server creates new ServerExchange using parameters from Exchanger.

func (Exchanger) WithClock

func (e Exchanger) WithClock(c clock.Clock) Exchanger

WithClock sets exchange flow clock.

func (Exchanger) WithLogger

func (e Exchanger) WithLogger(log *zap.Logger) Exchanger

WithLogger sets exchange flow logger.

func (Exchanger) WithRand

func (e Exchanger) WithRand(reader io.Reader) Exchanger

WithRand sets exchange flow random source.

func (Exchanger) WithTimeout added in v0.24.0

func (e Exchanger) WithTimeout(timeout time.Duration) Exchanger

WithTimeout sets write/read deadline of every exchange request.

type ServerExchange

type ServerExchange struct {
	// contains filtered or unexported fields
}

ServerExchange is a server-side key exchange flow.

func (ServerExchange) Run

Run runs server-side flow. If b parameter is not nil, it will be used as first read message. Otherwise, it will be read from connection.

type ServerExchangeResult

type ServerExchangeResult struct {
	Key        crypto.AuthKey
	ServerSalt int64
}

ServerExchangeResult contains server part of key exchange result.

type ServerRNG

type ServerRNG interface {
	PQ() (pq *big.Int, err error)
	GA(g int, dhPrime *big.Int) (a, ga *big.Int, err error)
	DhPrime() (p *big.Int, err error)
}

ServerRNG is server-side random number generator.

type TestServerRNG

type TestServerRNG struct {
	// contains filtered or unexported fields
}

TestServerRNG implements testing-only ServerRNG.

func (TestServerRNG) DhPrime

func (s TestServerRNG) DhPrime() (p *big.Int, err error)

DhPrime always returns testing dh_prime.

func (TestServerRNG) GA

func (s TestServerRNG) GA(g int, dhPrime *big.Int) (a, ga *big.Int, err error)

GA returns testing a and g_a params.

func (TestServerRNG) PQ

func (s TestServerRNG) PQ() (pq *big.Int, err error)

PQ always returns testing pq value.

nolint:unparam

Jump to

Keyboard shortcuts

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