package exchange
Import Path
github.com/gotd/td/internal/exchange (on go.dev)
Dependency Relation
imports 16 packages, and imported by 2 packages
Involved Source Files
client.go
client_flow.go
errors.go
Package exchange contains Telegram key exchange algorithm flows.
See https://core.telegram.org/mtproto/auth_key.
generator.go
key.go
proto.go
server.go
server_flow.go
Package-Level Type Names (total 13, in which 10 are exported)
ClientExchange is a client-side key exchange flow.
dc int
keys []PublicKey
log *zap.Logger
rand io.Reader
unencryptedWriter unencryptedWriter
unencryptedWriter.clock clock.Clock
unencryptedWriter.conn transport.Conn
unencryptedWriter.input proto.MessageType
unencryptedWriter.output proto.MessageType
unencryptedWriter.timeout time.Duration
Run runs client-side flow.
( ClientExchange) checkMsgID(id int64) error
( ClientExchange) isClient() bool
( ClientExchange) readUnencrypted(ctx context.Context, b *bin.Buffer, data bin.Decoder) error
( ClientExchange) tryRead(ctx context.Context, b *bin.Buffer) error
( ClientExchange) writeUnencrypted(ctx context.Context, b *bin.Buffer, data bin.Encoder) error
func Exchanger.Client(keys []PublicKey) ClientExchange
ClientExchangeResult contains client part of key exchange result.
AuthKey crypto.AuthKey
ServerSalt int64
SessionID int64
func ClientExchange.Run(ctx context.Context) (ClientExchangeResult, error)
Exchanger is builder for key exchangers.
clock clock.Clock
conn transport.Conn
dc int
log *zap.Logger
rand io.Reader
timeout time.Duration
Client creates new ClientExchange using parameters from Exchanger.
Server creates new ServerExchange using parameters from Exchanger.
WithClock sets exchange flow clock.
WithLogger sets exchange flow logger.
WithRand sets exchange flow random source.
WithTimeout sets write/read deadline of every exchange request.
( Exchanger) unencryptedWriter(input, output proto.MessageType) unencryptedWriter
func NewExchanger(conn transport.Conn, dc int) Exchanger
func Exchanger.WithClock(c clock.Clock) Exchanger
func Exchanger.WithLogger(log *zap.Logger) Exchanger
func Exchanger.WithRand(reader io.Reader) Exchanger
func Exchanger.WithTimeout(timeout time.Duration) Exchanger
PrivateKey is a private Telegram server key.
RSA private key.
Fingerprint computes key fingerprint.
Public returns PublicKey of this PrivateKey pair.
Zero denotes that current PublicKey is zero value.
func Exchanger.Server(key PrivateKey) ServerExchange
PublicKey is a public Telegram server key.
RSA public key.
Fingerprint computes key fingerprint.
Zero denotes that current PublicKey is zero value.
func PrivateKey.Public() PublicKey
func github.com/gotd/td/internal/mtproto.vendoredKeys() []PublicKey
func Exchanger.Client(keys []PublicKey) ClientExchange
ServerExchange is a server-side key exchange flow.
dc int
key PrivateKey
log *zap.Logger
rand io.Reader
rng ServerRNG
unencryptedWriter unencryptedWriter
unencryptedWriter.clock clock.Clock
unencryptedWriter.conn transport.Conn
unencryptedWriter.input proto.MessageType
unencryptedWriter.output proto.MessageType
unencryptedWriter.timeout time.Duration
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.
( ServerExchange) checkMsgID(id int64) error
( ServerExchange) isClient() bool
( ServerExchange) readUnencrypted(ctx context.Context, b *bin.Buffer, data bin.Decoder) error
( ServerExchange) tryRead(ctx context.Context, b *bin.Buffer) error
( ServerExchange) writeUnencrypted(ctx context.Context, b *bin.Buffer, data bin.Encoder) error
func Exchanger.Server(key PrivateKey) ServerExchange
ServerExchangeError is returned when exchange fails due to
some security or validation checks.
Code int32
Err error
Error implements error.
Unwrap implements error wrapper interface.
*ServerExchangeError : github.com/go-faster/errors.Wrapper
*ServerExchangeError : error
ServerExchangeResult contains server part of key exchange result.
Key crypto.AuthKey
ServerSalt int64
func ServerExchange.Run(ctx context.Context) (ServerExchangeResult, error)
Package-Level Functions (total 2, in which 1 is exported)
NewExchanger creates new Exchanger.
Package-Level Variables (only one, which is exported)
ErrKeyFingerprintNotFound is returned when client can't find keys by fingerprints
provided by server during key exchange.
Package-Level Constants (only one, which is exported)
DefaultTimeout is default WithTimeout parameter value.
The pages are generated with Golds v0.6.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |