gmessages/libgm/payload/registerPhoneRelay.go

41 lines
929 B
Go
Raw Normal View History

2023-06-30 09:54:08 +00:00
package payload
import (
2023-07-15 17:43:28 +00:00
"google.golang.org/protobuf/proto"
2023-06-30 09:54:08 +00:00
"go.mau.fi/mautrix-gmessages/libgm/binary"
"go.mau.fi/mautrix-gmessages/libgm/crypto"
"go.mau.fi/mautrix-gmessages/libgm/util"
)
func RegisterPhoneRelay(jwk *crypto.JWK) ([]byte, *binary.AuthenticationContainer, error) {
2023-06-30 09:54:08 +00:00
id := util.RandomUUIDv4()
key, err := jwk.MarshalX509PublicKey()
if err != nil {
return nil, nil, err
}
payloadData := &binary.AuthenticationContainer{
2023-07-15 22:56:11 +00:00
AuthMessage: &binary.AuthMessage{
RequestID: id,
2023-07-15 22:56:11 +00:00
Network: &Network,
ConfigVersion: ConfigMessage,
},
BrowserDetails: BrowserDetailsMessage,
Data: &binary.AuthenticationContainer_KeyData{
KeyData: &binary.KeyData{
EcdsaKeys: &binary.ECDSAKeys{
Field1: 2,
EncryptedKeys: key,
},
},
},
}
2023-07-15 17:43:28 +00:00
encoded, err4 := proto.Marshal(payloadData)
if err4 != nil {
return nil, payloadData, err4
}
return encoded, payloadData, nil
}