move gotd fork into repo. (#111)
- update to latest telegram layer - remove some references to fields in tg.Entities that don't exist in the schema - originally added here: https://github.com/beeper/td/commit/820929062a2ba0104397bc01235ab58a9cff780e - referenced here - https://github.com/mautrix/telegramgo/commit/124f0967ed195b5a380c9bd02e170ada9710dde3 - https://github.com/mautrix/telegramgo/commit/4205047aab2e0639217148b5d125bfaab668bd8e
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
package mtproto
|
||||
|
||||
import (
|
||||
// For embedding public keys.
|
||||
_ "embed"
|
||||
"sync"
|
||||
|
||||
"go.mau.fi/mautrix-telegram/pkg/gotd/crypto"
|
||||
"go.mau.fi/mautrix-telegram/pkg/gotd/exchange"
|
||||
)
|
||||
|
||||
var (
|
||||
// publicKeys is byte blob of new keys added for PQInnerData encryption (key exchange).
|
||||
//
|
||||
// See https://github.com/telegramdesktop/tdesktop/commit/95a7ce4622dc24717dc5b95fc99599dddfd4ff6c.
|
||||
//
|
||||
// See https://github.com/tdlib/td/commit/e9e24282378fcdb3a3ce020bee4253b65ac98213.
|
||||
//go:embed _data/public_keys.pem
|
||||
publicKeys []byte
|
||||
|
||||
parsedKeys struct {
|
||||
Keys []exchange.PublicKey
|
||||
Once sync.Once
|
||||
}
|
||||
)
|
||||
|
||||
//nolint:gochecknoinits
|
||||
func init() {
|
||||
makePublicKeys := func(data []byte) ([]exchange.PublicKey, error) {
|
||||
rsaKeys, err := crypto.ParseRSAPublicKeys(data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
keys := make([]exchange.PublicKey, 0, len(rsaKeys))
|
||||
for _, key := range rsaKeys {
|
||||
keys = append(keys, exchange.PublicKey{
|
||||
RSA: key,
|
||||
})
|
||||
}
|
||||
return keys, nil
|
||||
}
|
||||
parsedKeys.Once.Do(func() {
|
||||
keys, err := makePublicKeys(publicKeys)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
parsedKeys.Keys = append(parsedKeys.Keys, keys...)
|
||||
})
|
||||
}
|
||||
|
||||
// vendoredKeys parses vendored file _data/public_keys.pem as list of
|
||||
// PEM-encoded public RSA keys.
|
||||
//
|
||||
// Most recent key list can be found on https://my.telegram.org/apps.
|
||||
func vendoredKeys() []exchange.PublicKey {
|
||||
return parsedKeys.Keys
|
||||
}
|
||||
Reference in New Issue
Block a user