Documentation ¶
Overview ¶
Package exchange contains Telegram key exchange algorithm flows. See https://core.telegram.org/mtproto/auth_key.
Index ¶
- Constants
- type ClientExchange
- type ClientExchangeResult
- type Exchanger
- func (e Exchanger) Client(keys []*rsa.PublicKey) ClientExchange
- func (e Exchanger) Server(key *rsa.PrivateKey) ServerExchange
- func (e Exchanger) WithClock(c clock.Clock) Exchanger
- func (e Exchanger) WithLogger(log *zap.Logger) Exchanger
- func (e Exchanger) WithRand(reader io.Reader) Exchanger
- func (e Exchanger) WithTimeout(timeout time.Duration) Exchanger
- type ServerExchange
- type ServerExchangeResult
- type ServerRNG
- type TestServerRNG
Constants ¶
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 ¶
func (c ClientExchange) Run(ctx context.Context) (ClientExchangeResult, error)
Run runs client-side flow.
type ClientExchangeResult ¶
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 ¶
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) WithLogger ¶
WithLogger sets exchange flow logger.
type ServerExchange ¶
type ServerExchange struct {
// contains filtered or unexported fields
}
ServerExchange is a server-side key exchange flow.
func (ServerExchange) Run ¶
func (s ServerExchange) Run(ctx context.Context) (ServerExchangeResult, error)
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 ¶
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.