first commit
This commit is contained in:
@@ -0,0 +1,542 @@
|
||||
package android
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/aes"
|
||||
"crypto/cipher"
|
||||
"crypto/ecdsa"
|
||||
"crypto/elliptic"
|
||||
"crypto/hmac"
|
||||
"crypto/md5"
|
||||
"crypto/rand"
|
||||
"crypto/sha1"
|
||||
"crypto/sha256"
|
||||
"encoding/binary"
|
||||
"encoding/hex"
|
||||
"hash"
|
||||
"io"
|
||||
"xiawan/wx/clientsdk/android/mmproto"
|
||||
"xiawan/wx/protobuf/wechat"
|
||||
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"golang.org/x/crypto/hkdf"
|
||||
)
|
||||
|
||||
const (
|
||||
HYBRID_ENC HYBRID_STATUS = 0
|
||||
HYBRID_DEC HYBRID_STATUS = 1
|
||||
)
|
||||
|
||||
type Client struct {
|
||||
PubKey []byte
|
||||
Privkey []byte
|
||||
InitPubKey []byte
|
||||
Externkey []byte
|
||||
|
||||
Version int
|
||||
DeviceType string
|
||||
|
||||
clientHash hash.Hash
|
||||
serverHash hash.Hash
|
||||
|
||||
curve elliptic.Curve
|
||||
|
||||
Status HYBRID_STATUS
|
||||
}
|
||||
|
||||
func (h *Client) Init(Model string, version int, deviceType string) {
|
||||
h.curve = elliptic.P256()
|
||||
h.clientHash = sha256.New()
|
||||
h.serverHash = sha256.New()
|
||||
if Model == "IOS" {
|
||||
h.Privkey, h.PubKey = GetECDH415Key()
|
||||
h.Version = version
|
||||
h.DeviceType = deviceType
|
||||
h.InitPubKey, _ = hex.DecodeString("047ebe7604acf072b0ab0177ea551a7b72588f9b5d3801dfd7bb1bca8e33d1c3b8fa6e4e4026eb38d5bb365088a3d3167c83bdd0bbb46255f88a16ede6f7ab43b5")
|
||||
}
|
||||
if Model == "Android" {
|
||||
h.Status = HYBRID_ENC
|
||||
h.Version = version
|
||||
h.DeviceType = deviceType
|
||||
h.InitPubKey, _ = hex.DecodeString("0495BC6E5C1331AD172D0F35B1792C3CE63F91572ABD2DD6DF6DAC2D70195C3F6627CCA60307305D8495A8C38B4416C75021E823B6C97DFFE79C14CB7C3AF8A586")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func GetECDH415Key() (privKey []byte, pubKey []byte) {
|
||||
privKey = nil
|
||||
pubKey = nil
|
||||
priv, _ := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
|
||||
pub := &priv.PublicKey
|
||||
pubKey = elliptic.Marshal(pub.Curve, pub.X, pub.Y)
|
||||
privKey = priv.D.Bytes()
|
||||
return
|
||||
}
|
||||
|
||||
func (h *Client) HybridEcdhPackAndroidEn(cmdid, cert, uin uint32, cookie, Data []byte) []byte {
|
||||
EnData := h.encryptAndroid(Data)
|
||||
//log.Infof("计算RQT数据: %s",hex.EncodeToString(EnData))
|
||||
//rqt := RQT(EnData)
|
||||
rqtx := CalcMsgCrcForData_7019(EnData)
|
||||
//log.Infof("原RQT: %v", rqt)
|
||||
//log.Infof("新RQT: %v", rqtx)
|
||||
inputlen := len(EnData)
|
||||
pack := append([]byte{}, cookie...)
|
||||
pack = proto.EncodeVarint(uint64(cmdid))
|
||||
pack = append(pack, proto.EncodeVarint(uint64(inputlen))...)
|
||||
pack = append(pack, proto.EncodeVarint(uint64(inputlen))...)
|
||||
pack = append(pack, proto.EncodeVarint(uint64(cert))...)
|
||||
pack = append(pack, 2)
|
||||
pack = append(pack, 0)
|
||||
pack = append(pack, 0xfe)
|
||||
pack = append(pack, proto.EncodeVarint(uint64(rqtx))...)
|
||||
pack = append(pack, 0)
|
||||
headLen := len(pack) + 11
|
||||
headFlag := (12 << 12) | (len(cookie) << 8) | (headLen << 2) | 2
|
||||
var hybridpack = new(bytes.Buffer)
|
||||
hybridpack.WriteByte(0xbf)
|
||||
binary.Write(hybridpack, binary.LittleEndian, uint16(headFlag))
|
||||
binary.Write(hybridpack, binary.BigEndian, uint32(h.Version))
|
||||
binary.Write(hybridpack, binary.BigEndian, uint32(uin))
|
||||
hybridpack.Write(pack)
|
||||
hybridpack.Write(EnData)
|
||||
return hybridpack.Bytes()
|
||||
}
|
||||
|
||||
func (h *Client) HybridEcdhPackAndroidUn(Data []byte) *PacketHeader {
|
||||
var ph PacketHeader
|
||||
readHeader := bytes.NewReader(Data)
|
||||
binary.Read(readHeader, binary.LittleEndian, &ph.PacketCryptType)
|
||||
binary.Read(readHeader, binary.LittleEndian, &ph.Flag)
|
||||
cookieLen := (ph.Flag >> 8) & 0x0f
|
||||
headerLen := (ph.Flag & 0xff) >> 2
|
||||
ph.Cookies = make([]byte, cookieLen)
|
||||
binary.Read(readHeader, binary.BigEndian, &ph.RetCode)
|
||||
binary.Read(readHeader, binary.BigEndian, &ph.UICrypt)
|
||||
binary.Read(readHeader, binary.LittleEndian, &ph.Cookies)
|
||||
ph.Data = h.decryptAndroid(Data[headerLen:])
|
||||
return &ph
|
||||
}
|
||||
|
||||
func (h *Client) decryptAndroid(input []byte) []byte {
|
||||
|
||||
if h.Status != HYBRID_DEC {
|
||||
return nil
|
||||
}
|
||||
|
||||
var resp mmproto.HybridEcdhResp
|
||||
proto.Unmarshal(input, &resp)
|
||||
|
||||
h.serverHash.Write(resp.GetGcm1())
|
||||
// hServ := h.serverHash.Sum(nil)
|
||||
// fmt.Printf("%x\n", hServ)
|
||||
|
||||
// ecdsa.Verify(h.clientEcdsaPub, resp.GetGcm2(), hServ)
|
||||
ecKey := Ecdh(h.curve, resp.GetSecKey().GetKey(), h.Privkey)
|
||||
|
||||
h.clientHash.Write([]byte("415"))
|
||||
h.clientHash.Write(resp.GetSecKey().GetKey())
|
||||
h.clientHash.Write([]byte("1"))
|
||||
hCli := h.clientHash.Sum(nil)
|
||||
plain, _ := AesGcmDecryptWithUnCompress(ecKey[0:0x18], resp.GetGcm1(), hCli)
|
||||
return plain
|
||||
}
|
||||
|
||||
func (h *Client) encryptAndroid(input []byte) []byte {
|
||||
if h.Status != HYBRID_ENC {
|
||||
return nil
|
||||
}
|
||||
|
||||
priv, x, y, error := elliptic.GenerateKey(h.curve, rand.Reader)
|
||||
if error != nil {
|
||||
return nil
|
||||
}
|
||||
h.Privkey = priv
|
||||
h.PubKey = elliptic.Marshal(h.curve, x, y)
|
||||
|
||||
ecdhKey := Ecdh(h.curve, h.InitPubKey, h.Privkey)
|
||||
|
||||
//hash1
|
||||
h1 := sha256.New()
|
||||
h1.Write([]byte("1"))
|
||||
h1.Write([]byte("415"))
|
||||
h1.Write(h.PubKey)
|
||||
h1Sum := h1.Sum(nil)
|
||||
|
||||
//Random
|
||||
random := make([]byte, 32)
|
||||
io.ReadFull(rand.Reader, random)
|
||||
|
||||
nonce1 := make([]byte, 12)
|
||||
io.ReadFull(rand.Reader, nonce1)
|
||||
gcm1, _ := AesGcmEncryptWithCompress(ecdhKey[0:0x18], nonce1, random, h1Sum)
|
||||
//hkdf
|
||||
salt, _ := hex.DecodeString("73656375726974792068646B6620657870616E64")
|
||||
hkdfKey := make([]byte, 56)
|
||||
hkdf.New(sha256.New, random, salt, h1Sum).Read(hkdfKey)
|
||||
|
||||
//hash2
|
||||
h2 := sha256.New()
|
||||
h2.Write([]byte("1"))
|
||||
h2.Write([]byte("415"))
|
||||
h2.Write(h.PubKey)
|
||||
h2.Write(gcm1)
|
||||
h2Sum := h2.Sum(nil)
|
||||
|
||||
nonce2 := make([]byte, 12)
|
||||
io.ReadFull(rand.Reader, nonce2)
|
||||
gcm2, _ := AesGcmEncryptWithCompress(hkdfKey[0:0x18], nonce2, input, h2Sum)
|
||||
var nid int32 = 415
|
||||
secKey := &mmproto.SecKey{
|
||||
Nid: &nid,
|
||||
Key: h.PubKey,
|
||||
}
|
||||
var ver int32 = 1
|
||||
he := &mmproto.HybridEcdhReq{
|
||||
Version: &ver,
|
||||
SecKey: secKey,
|
||||
Gcm1: gcm1,
|
||||
Autokey: []byte{},
|
||||
Gcm2: gcm2,
|
||||
}
|
||||
|
||||
protoMsg, _ := proto.Marshal(he)
|
||||
|
||||
// update client
|
||||
h.clientHash.Write(hkdfKey[0x18:0x38])
|
||||
h.clientHash.Write(input)
|
||||
|
||||
// update server
|
||||
h.serverHash.Write(gcm2)
|
||||
|
||||
h.Status = HYBRID_DEC
|
||||
|
||||
return protoMsg
|
||||
}
|
||||
|
||||
func RQT(data []byte) int {
|
||||
|
||||
salt1 := [16]byte{0x5c, 0x50, 0x7b, 0x6b, 0x65, 0x4a, 0x13, 0x09, 0x45, 0x58, 0x7e, 0x11, 0x0c, 0x1f, 0x68, 0x79}
|
||||
salt2 := [16]byte{0x36, 0x3a, 0x11, 0x01, 0x0f, 0x20, 0x79, 0x63, 0x2f, 0x32, 0x14, 0x7b, 0x66, 0x75, 0x02, 0x13}
|
||||
|
||||
pad1 := [0x30]byte{
|
||||
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
|
||||
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
|
||||
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
|
||||
}
|
||||
|
||||
pad2 := [0x30]byte{
|
||||
0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c,
|
||||
0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c,
|
||||
0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c,
|
||||
}
|
||||
|
||||
md5hash := md5.Sum(data)
|
||||
hashstr := hex.EncodeToString(md5hash[:])
|
||||
|
||||
hash1Data := make([]byte, 16)
|
||||
copy(hash1Data, salt1[:])
|
||||
hash1Data = append(hash1Data, pad1[:]...)
|
||||
|
||||
hash1 := sha1.New()
|
||||
hash1.Write(hash1Data)
|
||||
hash1.Write([]byte(hashstr))
|
||||
h1 := hash1.Sum(nil)
|
||||
|
||||
hash2Data := make([]byte, 16)
|
||||
copy(hash2Data, salt2[:])
|
||||
hash2Data = append(hash2Data, pad2[:]...)
|
||||
|
||||
hash2 := sha1.New()
|
||||
hash2.Write(hash2Data)
|
||||
hash2.Write(h1)
|
||||
h2 := hash2.Sum(nil)
|
||||
|
||||
var b1, b2, b3 byte
|
||||
size := len(h2)
|
||||
|
||||
for i := 0; i < size-2; i++ {
|
||||
b1 = h2[i+0] - b1*0x7d
|
||||
b2 = h2[i+1] - b2*0x7d
|
||||
b3 = h2[i+2] - b3*0x7d
|
||||
}
|
||||
|
||||
return (int(0x21) << 24) | ((int(b3) & 0x7f) << 16) | ((int(b2) & 0x7f) << 8) | (int(b1) & 0x7f)
|
||||
}
|
||||
|
||||
func HybridHkdfExpand(prikey []byte, salt []byte, info []byte, outLen int) []byte {
|
||||
h := hmac.New(sha256.New, prikey)
|
||||
h.Write(salt)
|
||||
T := h.Sum(nil)
|
||||
return HkdfExpand(sha256.New, T, info, outLen)
|
||||
}
|
||||
|
||||
func Hkdf_Expand(h func() hash.Hash, prk, info []byte, outLen int) []byte {
|
||||
out := []byte{}
|
||||
T := []byte{}
|
||||
i := byte(1)
|
||||
for len(out) < outLen {
|
||||
block := append(T, info...)
|
||||
block = append(block, i)
|
||||
|
||||
h := hmac.New(h, prk)
|
||||
h.Write(block)
|
||||
|
||||
T = h.Sum(nil)
|
||||
out = append(out, T...)
|
||||
i++
|
||||
}
|
||||
return out[:outLen]
|
||||
}
|
||||
|
||||
func HkdfExpand(h func() hash.Hash, prk, info []byte, outLen int) []byte {
|
||||
out := []byte{}
|
||||
T := []byte{}
|
||||
i := byte(1)
|
||||
for len(out) < outLen {
|
||||
block := append(T, info...)
|
||||
block = append(block, i)
|
||||
|
||||
h := hmac.New(h, prk)
|
||||
h.Write(block)
|
||||
|
||||
T = h.Sum(nil)
|
||||
out = append(out, T...)
|
||||
i++
|
||||
}
|
||||
return out[:outLen]
|
||||
}
|
||||
|
||||
// ios组包
|
||||
func (h *Client) HybridEcdhPackIosEn(Cgi, Uin uint32, Cookies, Data []byte) []byte {
|
||||
header := new(bytes.Buffer)
|
||||
header.Write([]byte{0xbf})
|
||||
header.Write([]byte{0x02}) //加密模式占坑,默认不压缩走12
|
||||
|
||||
encryptdata := h.encryptoIOS(Data)
|
||||
|
||||
cookielen := len(Cookies)
|
||||
header.Write([]byte{byte((12 << 4) + cookielen)})
|
||||
binary.Write(header, binary.BigEndian, int32(h.Version))
|
||||
if Uin != 0 {
|
||||
binary.Write(header, binary.BigEndian, int32(Uin))
|
||||
} else {
|
||||
header.Write([]byte{0x00, 0x00, 0x00, 0x00})
|
||||
}
|
||||
|
||||
if len(Cookies) == 0xF {
|
||||
header.Write(Cookies)
|
||||
}
|
||||
|
||||
//log.Infof("计算RQT数据: %s",hex.EncodeToString(encryptdata))
|
||||
//rqt := RQT(encryptdata)
|
||||
rqtx := CalcMsgCrcForData_7019(encryptdata)
|
||||
//log.Infof("原RQT: %v", rqt)
|
||||
//log.Infof("新RQT: %v", rqtx)
|
||||
|
||||
header.Write(proto.EncodeVarint(uint64(Cgi)))
|
||||
header.Write(proto.EncodeVarint(uint64(len(encryptdata))))
|
||||
header.Write(proto.EncodeVarint(uint64(len(encryptdata))))
|
||||
header.Write([]byte{0x90, 0x4E, 0x0D, 0x00, 0xFF})
|
||||
// header.Write(proto.EncodeVarint(uint64(RqtIOS(encryptdata))))
|
||||
header.Write(proto.EncodeVarint(uint64(rqtx)))
|
||||
header.Write([]byte{0x00})
|
||||
lens := len(header.Bytes())<<2 + 2
|
||||
header.Bytes()[1] = byte(lens)
|
||||
header.Write(encryptdata)
|
||||
return header.Bytes()
|
||||
}
|
||||
|
||||
func (h *Client) HybridEcdhPackIosUn(Data []byte) *PacketHeader {
|
||||
var ph PacketHeader
|
||||
var body []byte
|
||||
var nCur int64
|
||||
var bfbit byte
|
||||
srcreader := bytes.NewReader(Data)
|
||||
binary.Read(srcreader, binary.BigEndian, &bfbit)
|
||||
if bfbit == byte(0xbf) {
|
||||
nCur += 1
|
||||
}
|
||||
nLenHeader := Data[nCur] >> 2
|
||||
nCur += 1
|
||||
nLenCookie := Data[nCur] & 0xf
|
||||
nCur += 1
|
||||
nCur += 4
|
||||
srcreader.Seek(nCur, io.SeekStart)
|
||||
binary.Read(srcreader, binary.BigEndian, &ph.Uin)
|
||||
nCur += 4
|
||||
cookie_temp := Data[nCur : nCur+int64(nLenCookie)]
|
||||
ph.Cookies = cookie_temp
|
||||
nCur += int64(nLenCookie)
|
||||
cgidata := Data[nCur:]
|
||||
_, nSize := proto.DecodeVarint(cgidata)
|
||||
nCur += int64(nSize)
|
||||
LenProtobufData := Data[nCur:]
|
||||
_, nLenProtobuf := proto.DecodeVarint(LenProtobufData)
|
||||
nCur += int64(nLenProtobuf)
|
||||
body = Data[nLenHeader:]
|
||||
protobufdata := h.decryptoIOS(body)
|
||||
ph.Data = protobufdata
|
||||
return &ph
|
||||
}
|
||||
|
||||
func (h *Client) decryptoIOS(Data []byte) []byte {
|
||||
HybridEcdhResponse := &wechat.HybridEcdhResponse{}
|
||||
err := proto.Unmarshal(Data, HybridEcdhResponse)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
decrptecdhkey := DoECDH415Key(h.Privkey, HybridEcdhResponse.GetSecECDHKey().GetBuffer())
|
||||
m := sha256.New()
|
||||
m.Write(decrptecdhkey)
|
||||
decrptecdhkey = m.Sum(nil)
|
||||
h.serverHash.Write([]byte("415"))
|
||||
h.serverHash.Write(HybridEcdhResponse.GetSecECDHKey().GetBuffer())
|
||||
h.serverHash.Write([]byte("1"))
|
||||
mServerpubhashFinal_digest := h.serverHash.Sum(nil)
|
||||
|
||||
outdata := AesGcmDecryptWithcompressZlib(decrptecdhkey[:24], HybridEcdhResponse.GetDecryptdata(), mServerpubhashFinal_digest)
|
||||
return outdata
|
||||
}
|
||||
|
||||
func AesGcmDecryptWithcompressZlib(key []byte, ciphertext []byte, aad []byte) []byte {
|
||||
ciphertextinput := ciphertext[:len(ciphertext)-0x1c]
|
||||
endatanonce := ciphertext[len(ciphertext)-0x1c : len(ciphertext)-0x10]
|
||||
data := new(bytes.Buffer)
|
||||
data.Write(ciphertextinput)
|
||||
data.Write(ciphertext[len(ciphertext)-0x10 : len(ciphertext)])
|
||||
decrypt_data := NewAES_GCMDecrypter(key, data.Bytes(), endatanonce, aad)
|
||||
if len(decrypt_data) > 0 {
|
||||
return DoZlibUnCompress(decrypt_data)
|
||||
} else {
|
||||
return []byte{}
|
||||
}
|
||||
}
|
||||
|
||||
func RqtIOS(srcdata []byte) int {
|
||||
h := md5.New()
|
||||
h.Write(srcdata)
|
||||
md5sign := hex.EncodeToString(h.Sum(nil))
|
||||
key, _ := hex.DecodeString("6a664d5d537c253f736e48273a295e4f")
|
||||
mac := hmac.New(sha1.New, key)
|
||||
mac.Write([]byte(md5sign))
|
||||
my_sign := string(mac.Sum(nil))
|
||||
randvalue := 1
|
||||
index := 0
|
||||
temp0 := 0
|
||||
temp1 := 0
|
||||
temp2 := 0
|
||||
for index = 0; index+2 < 20; index++ {
|
||||
temp0 = (temp0&0xff)*0x83 + int(my_sign[index])
|
||||
temp1 = (temp1&0xff)*0x83 + int(my_sign[index+1])
|
||||
temp2 = (temp2&0xff)*0x83 + int(my_sign[index+2])
|
||||
|
||||
}
|
||||
result := (temp2<<16)&0x7f0000 | temp0&0x7f | (randvalue&0x1f|0x20)<<24 | ((temp1 & 0x7f) << 8)
|
||||
return result
|
||||
|
||||
}
|
||||
|
||||
func (h *Client) encryptoIOS(Data []byte) []byte {
|
||||
ecdhkey := DoECDH415Key(h.Privkey, h.InitPubKey)
|
||||
m := sha256.New()
|
||||
m.Write(ecdhkey)
|
||||
ecdhkey = m.Sum(nil)
|
||||
mClientpubhash := sha256.New()
|
||||
mClientpubhash.Write([]byte("1"))
|
||||
mClientpubhash.Write([]byte("415"))
|
||||
mClientpubhash.Write(h.PubKey)
|
||||
mClientpubhash_digest := mClientpubhash.Sum(nil)
|
||||
|
||||
mRandomEncryptKey := make([]byte, 32)
|
||||
io.ReadFull(rand.Reader, mRandomEncryptKey)
|
||||
mNonce := make([]byte, 12)
|
||||
io.ReadFull(rand.Reader, mNonce)
|
||||
|
||||
mEncryptdata := AesGcmEncryptWithCompressZlib(ecdhkey[:24], mRandomEncryptKey, mNonce, mClientpubhash_digest)
|
||||
var mExternEncryptdata []byte
|
||||
if len(h.Externkey) == 0x20 {
|
||||
mExternEncryptdata = AesGcmEncryptWithCompressZlib(h.Externkey[:24], mRandomEncryptKey, mNonce, mClientpubhash_digest)
|
||||
}
|
||||
hkdfexpand_security_key := HybridHkdfExpand([]byte("security hdkf expand"), mRandomEncryptKey, mClientpubhash_digest, 56)
|
||||
|
||||
mClientpubhashFinal := sha256.New()
|
||||
mClientpubhashFinal.Write([]byte("1"))
|
||||
mClientpubhashFinal.Write([]byte("415"))
|
||||
mClientpubhashFinal.Write(h.PubKey)
|
||||
mClientpubhashFinal.Write(mEncryptdata)
|
||||
mClientpubhashFinal.Write(mExternEncryptdata)
|
||||
mClientpubhashFinal_digest := mClientpubhashFinal.Sum(nil)
|
||||
|
||||
mEncryptdataFinal := AesGcmEncryptWithCompressZlib(hkdfexpand_security_key[:24], Data, mNonce, mClientpubhashFinal_digest)
|
||||
|
||||
h.clientHash.Write(mEncryptdataFinal)
|
||||
|
||||
h.serverHash.Write(hkdfexpand_security_key[24:56])
|
||||
h.serverHash.Write(Data)
|
||||
|
||||
HybridEcdhRequest := &wechat.HybridEcdhRequest{
|
||||
Type: proto.Int32(1),
|
||||
SecECDHKey: &wechat.BufferT{
|
||||
ILen: proto.Uint32(415),
|
||||
Buffer: h.PubKey,
|
||||
},
|
||||
Randomkeydata: mEncryptdata,
|
||||
Randomkeyextenddata: mExternEncryptdata,
|
||||
Encyptdata: mEncryptdataFinal,
|
||||
}
|
||||
reqdata, _ := proto.Marshal(HybridEcdhRequest)
|
||||
return reqdata
|
||||
}
|
||||
|
||||
func DoECDH415Key(privD, pubData []byte) []byte {
|
||||
X, Y := elliptic.Unmarshal(elliptic.P256(), pubData)
|
||||
if X == nil || Y == nil {
|
||||
return nil
|
||||
}
|
||||
x, _ := elliptic.P256().ScalarMult(X, Y, privD)
|
||||
return x.Bytes()
|
||||
}
|
||||
|
||||
func AesGcmEncryptWithCompressZlib(key []byte, plaintext []byte, nonce []byte, aad []byte) []byte {
|
||||
compressData := DoZlibCompress(plaintext)
|
||||
//nonce := []byte(randSeq(12)) //获取随机密钥
|
||||
encrypt_data := NewAES_GCMEncrypter(key, compressData, nonce, aad)
|
||||
outdata := encrypt_data[:len(encrypt_data)-16]
|
||||
retdata := new(bytes.Buffer)
|
||||
retdata.Write(outdata)
|
||||
retdata.Write(nonce)
|
||||
retdata.Write(encrypt_data[len(encrypt_data)-16:])
|
||||
return retdata.Bytes()
|
||||
}
|
||||
|
||||
func NewAES_GCMEncrypter(key []byte, plaintext []byte, nonce []byte, aad []byte) []byte {
|
||||
block, err := aes.NewCipher(key)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
aesgcm, err := cipher.NewGCM(block)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
ciphertext := aesgcm.Seal(nil, nonce, plaintext, aad)
|
||||
return ciphertext
|
||||
}
|
||||
|
||||
func NewAES_GCMDecrypter(key []byte, ciphertext []byte, nonce []byte, aad []byte) []byte {
|
||||
block, err := aes.NewCipher(key)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
aesgcm, err := cipher.NewGCM(block)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
plaintext, err := aesgcm.Open(nil, nonce, ciphertext, aad)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
return plaintext
|
||||
}
|
||||
@@ -0,0 +1,300 @@
|
||||
package android
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"time"
|
||||
"xiawan/wx/clientsdk/android/mmproto"
|
||||
|
||||
"github.com/golang/protobuf/proto"
|
||||
)
|
||||
|
||||
// iphone生成wcstf, 使用07加密
|
||||
func IphoneWcstf(Username string) *mmproto.ZTData {
|
||||
curtime := uint64(time.Now().UnixNano() / 1e6)
|
||||
contentlen := len(Username)
|
||||
|
||||
var ct []uint64
|
||||
ut := curtime
|
||||
for i := 0; i < contentlen; i++ {
|
||||
ut += uint64(rand.Intn(10000))
|
||||
ct = append(ct, ut)
|
||||
}
|
||||
ccd := &mmproto.Ccd1{
|
||||
StartTime: &curtime,
|
||||
CheckTime: &curtime,
|
||||
Count: proto.Uint32(uint32(contentlen)),
|
||||
EndTime: ct,
|
||||
}
|
||||
|
||||
pb, _ := proto.Marshal(ccd)
|
||||
|
||||
// Zero: 03加密改06加密
|
||||
//var b bytes.Buffer
|
||||
//w := zlib.NewWriter(&b)
|
||||
//w.Write(pb)
|
||||
//w.Close()
|
||||
//
|
||||
//zt := new(ZT)
|
||||
//zt.Init()
|
||||
//encData := zt.Encrypt(b.Bytes())
|
||||
compressData := DoZlibCompress(pb)
|
||||
encData := SaeEncrypt07(compressData)
|
||||
|
||||
Ztdata := &mmproto.ZTData{
|
||||
Version: proto.String("00000007\x00"),
|
||||
Encrypted: proto.Uint32(1),
|
||||
Data: encData,
|
||||
TimeStamp: proto.Uint32(uint32(time.Now().Unix())),
|
||||
Optype: proto.Uint32(5),
|
||||
Uin: proto.Uint32(0),
|
||||
}
|
||||
// MS, _ := proto.Marshal(Ztdata)
|
||||
return Ztdata
|
||||
}
|
||||
|
||||
// iphone生成wcste, 使用07加密
|
||||
func IphoneWcste(A, B uint64) *mmproto.ZTData {
|
||||
|
||||
curtime := uint32(time.Now().Unix())
|
||||
curNanoTime := uint64(time.Now().UnixNano())
|
||||
|
||||
ccd := &mmproto.Ccd2{
|
||||
Checkid: proto.String("<LoginByID>"),
|
||||
StartTime: &curtime,
|
||||
CheckTime: &curtime,
|
||||
Count1: proto.Uint32(0),
|
||||
Count2: proto.Uint32(1),
|
||||
Count3: proto.Uint32(0),
|
||||
Const1: proto.Uint64(A),
|
||||
Const2: &curNanoTime,
|
||||
Const3: &curNanoTime,
|
||||
Const4: &curNanoTime,
|
||||
Const5: &curNanoTime,
|
||||
Const6: proto.Uint64(B),
|
||||
}
|
||||
|
||||
pb, _ := proto.Marshal(ccd)
|
||||
|
||||
// Zero: 03加密改06加密
|
||||
//var b bytes.Buffer
|
||||
//w := zlib.NewWriter(&b)
|
||||
//w.Write(pb)
|
||||
//w.Close()
|
||||
//
|
||||
//zt := new(ZT)
|
||||
//zt.Init()
|
||||
//encData := zt.Encrypt(b.Bytes())
|
||||
compressData := DoZlibCompress(pb)
|
||||
encData := SaeEncrypt07(compressData)
|
||||
|
||||
Ztdata := &mmproto.ZTData{
|
||||
Version: proto.String("00000007\x00"),
|
||||
Encrypted: proto.Uint32(1),
|
||||
Data: encData,
|
||||
TimeStamp: proto.Uint32(uint32(time.Now().Unix())),
|
||||
Optype: proto.Uint32(5),
|
||||
Uin: proto.Uint32(0),
|
||||
}
|
||||
|
||||
// MS, _ := proto.Marshal(Ztdata)
|
||||
return Ztdata
|
||||
}
|
||||
|
||||
// ipad生成wcstf, 使用03加密
|
||||
func IpadWcstf(Username string) []byte {
|
||||
curtime := uint64(time.Now().UnixNano() / 1e6)
|
||||
contentlen := len(Username)
|
||||
|
||||
var ct []uint64
|
||||
ut := curtime
|
||||
for i := 0; i < contentlen; i++ {
|
||||
ut += uint64(rand.Intn(10000))
|
||||
ct = append(ct, ut)
|
||||
}
|
||||
ccd := &mmproto.Ccd1{
|
||||
StartTime: &curtime,
|
||||
CheckTime: &curtime,
|
||||
Count: proto.Uint32(uint32(contentlen)),
|
||||
EndTime: ct,
|
||||
}
|
||||
|
||||
pb, _ := proto.Marshal(ccd)
|
||||
|
||||
// 压缩然后03加密
|
||||
compressData := DoZlibCompress(pb)
|
||||
zt := new(ZT)
|
||||
zt.Init()
|
||||
encData := zt.Encrypt(compressData)
|
||||
|
||||
Ztdata := &mmproto.ZTData{
|
||||
Version: proto.String("00000003\x00"),
|
||||
Encrypted: proto.Uint32(1),
|
||||
Data: encData,
|
||||
TimeStamp: proto.Uint32(uint32(time.Now().Unix())),
|
||||
Optype: proto.Uint32(5),
|
||||
Uin: proto.Uint32(0),
|
||||
}
|
||||
MS, _ := proto.Marshal(Ztdata)
|
||||
return MS
|
||||
}
|
||||
|
||||
// ipad生成wcste, 使用03加密
|
||||
func IpadWcste(A, B uint64) []byte {
|
||||
|
||||
curtime := uint32(time.Now().Unix())
|
||||
curNanoTime := uint64(time.Now().UnixNano())
|
||||
|
||||
ccd := &mmproto.Ccd2{
|
||||
Checkid: proto.String("<LoginByID>"),
|
||||
StartTime: &curtime,
|
||||
CheckTime: &curtime,
|
||||
Count1: proto.Uint32(0),
|
||||
Count2: proto.Uint32(1),
|
||||
Count3: proto.Uint32(0),
|
||||
Const1: proto.Uint64(A),
|
||||
Const2: &curNanoTime,
|
||||
Const3: &curNanoTime,
|
||||
Const4: &curNanoTime,
|
||||
Const5: &curNanoTime,
|
||||
Const6: proto.Uint64(B),
|
||||
}
|
||||
|
||||
pb, _ := proto.Marshal(ccd)
|
||||
|
||||
// 压缩然后03加密
|
||||
compressData := DoZlibCompress(pb)
|
||||
zt := new(ZT)
|
||||
zt.Init()
|
||||
encData := zt.Encrypt(compressData)
|
||||
|
||||
Ztdata := &mmproto.ZTData{
|
||||
Version: proto.String("00000003\x00"),
|
||||
Encrypted: proto.Uint32(1),
|
||||
Data: encData,
|
||||
TimeStamp: proto.Uint32(uint32(time.Now().Unix())),
|
||||
Optype: proto.Uint32(5),
|
||||
Uin: proto.Uint32(0),
|
||||
}
|
||||
|
||||
MS, _ := proto.Marshal(Ztdata)
|
||||
return MS
|
||||
}
|
||||
|
||||
// android生成wcstf, 使用01加密
|
||||
func AndroidWcstf(Username string) *mmproto.ZTData {
|
||||
curtime := uint64(time.Now().UnixNano() / 1e6)
|
||||
contentlen := len(Username)
|
||||
|
||||
var ct []uint64
|
||||
ut := curtime
|
||||
for i := 0; i < contentlen; i++ {
|
||||
ut += uint64(rand.Intn(10000))
|
||||
ct = append(ct, ut)
|
||||
}
|
||||
ccd := &mmproto.Ccd1{
|
||||
StartTime: &curtime,
|
||||
CheckTime: &curtime,
|
||||
Count: proto.Uint32(uint32(contentlen)),
|
||||
EndTime: ct,
|
||||
}
|
||||
|
||||
pb, _ := proto.Marshal(ccd)
|
||||
|
||||
// Zero: 03加密改06加密
|
||||
//var b bytes.Buffer
|
||||
//w := zlib.NewWriter(&b)
|
||||
//w.Write(pb)
|
||||
//w.Close()
|
||||
//
|
||||
//zt := new(ZT)
|
||||
//zt.Init()
|
||||
//encData := zt.Encrypt(b.Bytes())
|
||||
// compressData := DoZlibCompress(pb)
|
||||
// encData := SaeEncrypt01(compressData)
|
||||
compressData := DoZlibCompress(pb)
|
||||
encData := SaeEncrypt07(compressData)
|
||||
|
||||
Ztdata := &mmproto.ZTData{
|
||||
Version: proto.String("00000007\x00"),
|
||||
Encrypted: proto.Uint32(1),
|
||||
Data: encData,
|
||||
TimeStamp: proto.Uint32(uint32(time.Now().Unix())),
|
||||
Optype: proto.Uint32(5),
|
||||
Uin: proto.Uint32(0),
|
||||
}
|
||||
// MS, _ := proto.Marshal(Ztdata)
|
||||
// return MS
|
||||
return Ztdata
|
||||
}
|
||||
|
||||
// android生成wcste, 使用01加密
|
||||
func AndroidWcste(A, B uint64) *mmproto.ZTData {
|
||||
|
||||
curtime := uint32(time.Now().Unix())
|
||||
curNanoTime := uint64(time.Now().UnixNano())
|
||||
|
||||
ccd := &mmproto.Ccd2{
|
||||
Checkid: proto.String("<LoginByID>"),
|
||||
StartTime: &curtime,
|
||||
CheckTime: &curtime,
|
||||
Count1: proto.Uint32(0),
|
||||
Count2: proto.Uint32(1),
|
||||
Count3: proto.Uint32(0),
|
||||
Const1: proto.Uint64(A),
|
||||
Const2: &curNanoTime,
|
||||
Const3: &curNanoTime,
|
||||
Const4: &curNanoTime,
|
||||
Const5: &curNanoTime,
|
||||
Const6: proto.Uint64(B),
|
||||
}
|
||||
|
||||
pb, _ := proto.Marshal(ccd)
|
||||
|
||||
// compressData := DoZlibCompress(pb)
|
||||
// encData := SaeEncrypt01(compressData)
|
||||
compressData := DoZlibCompress(pb)
|
||||
encData := SaeEncrypt07(compressData)
|
||||
|
||||
Ztdata := &mmproto.ZTData{
|
||||
Version: proto.String("00000007\x00"),
|
||||
Encrypted: proto.Uint32(1),
|
||||
Data: encData,
|
||||
TimeStamp: proto.Uint32(uint32(time.Now().Unix())),
|
||||
Optype: proto.Uint32(5),
|
||||
Uin: proto.Uint32(0),
|
||||
}
|
||||
|
||||
// MS, _ := proto.Marshal(Ztdata)
|
||||
// return MS
|
||||
return Ztdata
|
||||
}
|
||||
|
||||
type AndroidDeviceInfo struct {
|
||||
Imei string
|
||||
AndriodId string
|
||||
PhoneSerial string
|
||||
WidevineDeviceID string
|
||||
WidevineProvisionID string
|
||||
AndriodFsId string
|
||||
AndriodBssId string
|
||||
AndriodSsId string
|
||||
WLanAddress string
|
||||
PackageSign string
|
||||
Androidversion string
|
||||
RadioVersion string
|
||||
Manufacturer string
|
||||
BuildID string
|
||||
BuildFP string
|
||||
BuildBoard string
|
||||
PhoneModel string
|
||||
Hardware string
|
||||
Features string
|
||||
WifiName string
|
||||
WifiFullName string
|
||||
KernelReleaseNumber string
|
||||
Arch string
|
||||
SfMD5 string
|
||||
SfArmMD5 string
|
||||
SfArm64MD5 string
|
||||
SbMD5 string
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package android
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/md5"
|
||||
"encoding/binary"
|
||||
"encoding/hex"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func AndriodDeviceID(DeviceId string) string {
|
||||
Md5Data := strconv.Itoa(BytesToInt([]byte(MD5ToLower(DeviceId + "SM10000011"))))
|
||||
return "A0" + Md5Data[0:14]
|
||||
}
|
||||
|
||||
func AndriodImei(DeviceId string) string {
|
||||
Md5Data := strconv.Itoa(BytesToInt([]byte(MD5ToLower(DeviceId + "SM1000000"))))
|
||||
return "35" + Md5Data[0:13]
|
||||
}
|
||||
|
||||
func AndriodID(DeviceId string) string {
|
||||
Md5Data := MD5ToLower(DeviceId + "SM1000001")
|
||||
return "06" + Md5Data[0:14]
|
||||
}
|
||||
|
||||
func AndriodSerial(DeviceId string) string {
|
||||
Md5Data := MD5ToLower(DeviceId + "SM1000002")
|
||||
return "01" + Md5Data[0:14]
|
||||
}
|
||||
|
||||
func AndriodWidevineDeviceID(DeviceId string) string {
|
||||
Md5DataA := MD5ToLower(DeviceId + "SM1000003")
|
||||
Md5DataB := MD5ToLower(DeviceId + "SM1000004")
|
||||
return "657" + Md5DataA[0:29] + Md5DataB
|
||||
}
|
||||
|
||||
func AndriodWidevineProvisionID(DeviceId string) string {
|
||||
Md5DataA := MD5ToLower(DeviceId + "SM1000005")
|
||||
return "955" + Md5DataA[0:29]
|
||||
}
|
||||
|
||||
func AndriodFSID(DeviceId string) string {
|
||||
Md5DataA := strconv.Itoa(BytesToInt([]byte(MD5ToLower(DeviceId + "SM1000012"))))
|
||||
Md5DataB := strconv.Itoa(BytesToInt([]byte(MD5ToLower(DeviceId + "SM1000006"))))
|
||||
return "37063" + Md5DataA[0:2] + "|37063" + Md5DataA[2:4] + "@" + Md5DataA[4:19] + "|" + MD5ToLower(DeviceId+"SM1000007") + "@" + Md5DataB[0:16] + MD5ToLower(DeviceId+"SM1000008")
|
||||
}
|
||||
|
||||
func AndriodBssid(DeviceId string) string {
|
||||
Md5Data := MD5ToLower(DeviceId + "SM1000009")
|
||||
A := Md5Data[5:7] + ":"
|
||||
B := Md5Data[7:9] + ":"
|
||||
C := Md5Data[9:11] + ":"
|
||||
D := Md5Data[11:13] + ":"
|
||||
E := Md5Data[13:15] + ":"
|
||||
F := Md5Data[15:17]
|
||||
return A + B + C + D + E + F
|
||||
}
|
||||
|
||||
func AndriodWLanAddress(DeviceId string) string {
|
||||
Md5Data := MD5ToLower(DeviceId + "SM1000009")
|
||||
B := Md5Data[7:9] + ":"
|
||||
C := Md5Data[9:11] + ":"
|
||||
D := Md5Data[11:13] + ":"
|
||||
E := Md5Data[13:15] + ":"
|
||||
F := Md5Data[15:17]
|
||||
return "00:" + B + C + D + E + F
|
||||
}
|
||||
|
||||
func AndriodPackageSign(DeviceId string) string {
|
||||
Md5Data := MD5ToLower(DeviceId + "SM1000010")
|
||||
return "18" + Md5Data[0:30]
|
||||
}
|
||||
|
||||
func MD5ToLower(str string) string {
|
||||
h := md5.New()
|
||||
h.Write([]byte(str))
|
||||
return hex.EncodeToString(h.Sum(nil))
|
||||
}
|
||||
|
||||
func BytesToInt(bys []byte) int {
|
||||
bytebuff := bytes.NewBuffer(bys)
|
||||
var data int64
|
||||
binary.Read(bytebuff, binary.BigEndian, &data)
|
||||
return int(data)
|
||||
}
|
||||
@@ -0,0 +1,280 @@
|
||||
package android
|
||||
|
||||
var b2m_map map[byte]uint64 = map[byte]uint64{
|
||||
0x00: 0,
|
||||
0x01: 1,
|
||||
0x02: 2,
|
||||
0x03: 3,
|
||||
0x04: 4,
|
||||
0x05: 5,
|
||||
0x06: 6,
|
||||
0x07: 7,
|
||||
0x08: 8,
|
||||
0x09: 9,
|
||||
0x0A: 10,
|
||||
0x0B: 11,
|
||||
0x0C: 12,
|
||||
0x0D: 13,
|
||||
0x0E: 14,
|
||||
0x0F: 15,
|
||||
0x10: 16,
|
||||
0x11: 17,
|
||||
0x12: 18,
|
||||
0x13: 19,
|
||||
0x14: 20,
|
||||
0x15: 21,
|
||||
0x16: 22,
|
||||
0x17: 23,
|
||||
0x18: 24,
|
||||
0x19: 25,
|
||||
0x1A: 26,
|
||||
0x1B: 27,
|
||||
0x1C: 28,
|
||||
0x1D: 29,
|
||||
0x1E: 30,
|
||||
0x1F: 31,
|
||||
0x20: 32,
|
||||
0x21: 33,
|
||||
0x22: 34,
|
||||
0x23: 35,
|
||||
0x24: 36,
|
||||
0x25: 37,
|
||||
0x26: 38,
|
||||
0x27: 39,
|
||||
0x28: 40,
|
||||
0x29: 41,
|
||||
0x2A: 42,
|
||||
0x2B: 43,
|
||||
0x2C: 44,
|
||||
0x2D: 45,
|
||||
0x2E: 46,
|
||||
0x2F: 47,
|
||||
0x30: 48,
|
||||
0x31: 49,
|
||||
0x32: 50,
|
||||
0x33: 51,
|
||||
0x34: 52,
|
||||
0x35: 53,
|
||||
0x36: 54,
|
||||
0x37: 55,
|
||||
0x38: 56,
|
||||
0x39: 57,
|
||||
0x3A: 58,
|
||||
0x3B: 59,
|
||||
0x3C: 60,
|
||||
0x3D: 61,
|
||||
0x3E: 62,
|
||||
0x3F: 63,
|
||||
0x40: 64,
|
||||
0x41: 65,
|
||||
0x42: 66,
|
||||
0x43: 67,
|
||||
0x44: 68,
|
||||
0x45: 69,
|
||||
0x46: 70,
|
||||
0x47: 71,
|
||||
0x48: 72,
|
||||
0x49: 73,
|
||||
0x4A: 74,
|
||||
0x4B: 75,
|
||||
0x4C: 76,
|
||||
0x4D: 77,
|
||||
0x4E: 78,
|
||||
0x4F: 79,
|
||||
0x50: 80,
|
||||
0x51: 81,
|
||||
0x52: 82,
|
||||
0x53: 83,
|
||||
0x54: 84,
|
||||
0x55: 85,
|
||||
0x56: 86,
|
||||
0x57: 87,
|
||||
0x58: 88,
|
||||
0x59: 89,
|
||||
0x5A: 90,
|
||||
0x5B: 91,
|
||||
0x5C: 92,
|
||||
0x5D: 93,
|
||||
0x5E: 94,
|
||||
0x5F: 95,
|
||||
0x60: 96,
|
||||
0x61: 97,
|
||||
0x62: 98,
|
||||
0x63: 99,
|
||||
0x64: 100,
|
||||
0x65: 101,
|
||||
0x66: 102,
|
||||
0x67: 103,
|
||||
0x68: 104,
|
||||
0x69: 105,
|
||||
0x6A: 106,
|
||||
0x6B: 107,
|
||||
0x6C: 108,
|
||||
0x6D: 109,
|
||||
0x6E: 110,
|
||||
0x6F: 111,
|
||||
0x70: 112,
|
||||
0x71: 113,
|
||||
0x72: 114,
|
||||
0x73: 115,
|
||||
0x74: 116,
|
||||
0x75: 117,
|
||||
0x76: 118,
|
||||
0x77: 119,
|
||||
0x78: 120,
|
||||
0x79: 121,
|
||||
0x7A: 122,
|
||||
0x7B: 123,
|
||||
0x7C: 124,
|
||||
0x7D: 125,
|
||||
0x7E: 126,
|
||||
0x7F: 127,
|
||||
0x80: 128,
|
||||
0x81: 129,
|
||||
0x82: 130,
|
||||
0x83: 131,
|
||||
0x84: 132,
|
||||
0x85: 133,
|
||||
0x86: 134,
|
||||
0x87: 135,
|
||||
0x88: 136,
|
||||
0x89: 137,
|
||||
0x8A: 138,
|
||||
0x8B: 139,
|
||||
0x8C: 140,
|
||||
0x8D: 141,
|
||||
0x8E: 142,
|
||||
0x8F: 143,
|
||||
0x90: 144,
|
||||
0x91: 145,
|
||||
0x92: 146,
|
||||
0x93: 147,
|
||||
0x94: 148,
|
||||
0x95: 149,
|
||||
0x96: 150,
|
||||
0x97: 151,
|
||||
0x98: 152,
|
||||
0x99: 153,
|
||||
0x9A: 154,
|
||||
0x9B: 155,
|
||||
0x9C: 156,
|
||||
0x9D: 157,
|
||||
0x9E: 158,
|
||||
0x9F: 159,
|
||||
0xA0: 160,
|
||||
0xA1: 161,
|
||||
0xA2: 162,
|
||||
0xA3: 163,
|
||||
0xA4: 164,
|
||||
0xA5: 165,
|
||||
0xA6: 166,
|
||||
0xA7: 167,
|
||||
0xA8: 168,
|
||||
0xA9: 169,
|
||||
0xAA: 170,
|
||||
0xAB: 171,
|
||||
0xAC: 172,
|
||||
0xAD: 173,
|
||||
0xAE: 174,
|
||||
0xAF: 175,
|
||||
0xB0: 176,
|
||||
0xB1: 177,
|
||||
0xB2: 178,
|
||||
0xB3: 179,
|
||||
0xB4: 180,
|
||||
0xB5: 181,
|
||||
0xB6: 182,
|
||||
0xB7: 183,
|
||||
0xB8: 184,
|
||||
0xB9: 185,
|
||||
0xBA: 186,
|
||||
0xBB: 187,
|
||||
0xBC: 188,
|
||||
0xBD: 189,
|
||||
0xBE: 190,
|
||||
0xBF: 191,
|
||||
0xC0: 192,
|
||||
0xC1: 193,
|
||||
0xC2: 194,
|
||||
0xC3: 195,
|
||||
0xC4: 196,
|
||||
0xC5: 197,
|
||||
0xC6: 198,
|
||||
0xC7: 199,
|
||||
0xC8: 200,
|
||||
0xC9: 201,
|
||||
0xCA: 202,
|
||||
0xCB: 203,
|
||||
0xCC: 204,
|
||||
0xCD: 205,
|
||||
0xCE: 206,
|
||||
0xCF: 207,
|
||||
0xD0: 208,
|
||||
0xD1: 209,
|
||||
0xD2: 210,
|
||||
0xD3: 211,
|
||||
0xD4: 212,
|
||||
0xD5: 213,
|
||||
0xD6: 214,
|
||||
0xD7: 215,
|
||||
0xD8: 216,
|
||||
0xD9: 217,
|
||||
0xDA: 218,
|
||||
0xDB: 219,
|
||||
0xDC: 220,
|
||||
0xDD: 221,
|
||||
0xDE: 222,
|
||||
0xDF: 223,
|
||||
0xE0: 224,
|
||||
0xE1: 225,
|
||||
0xE2: 226,
|
||||
0xE3: 227,
|
||||
0xE4: 228,
|
||||
0xE5: 229,
|
||||
0xE6: 230,
|
||||
0xE7: 231,
|
||||
0xE8: 232,
|
||||
0xE9: 233,
|
||||
0xEA: 234,
|
||||
0xEB: 235,
|
||||
0xEC: 236,
|
||||
0xED: 237,
|
||||
0xEE: 238,
|
||||
0xEF: 239,
|
||||
0xF0: 240,
|
||||
0xF1: 241,
|
||||
0xF2: 242,
|
||||
0xF3: 243,
|
||||
0xF4: 244,
|
||||
0xF5: 245,
|
||||
0xF6: 246,
|
||||
0xF7: 247,
|
||||
0xF8: 248,
|
||||
0xF9: 249,
|
||||
0xFA: 250,
|
||||
0xFB: 251,
|
||||
0xFC: 252,
|
||||
0xFD: 253,
|
||||
0xFE: 254,
|
||||
0xFF: 255,
|
||||
}
|
||||
|
||||
func Hex2int(hexB *[]byte) uint64 {
|
||||
var retInt uint64
|
||||
hexLen := len(*hexB)
|
||||
for k, v := range *hexB {
|
||||
retInt += b2m_map[v] * exponent(16, uint64(2*(hexLen-k-1)))
|
||||
}
|
||||
return retInt
|
||||
}
|
||||
|
||||
func exponent(a, n uint64) uint64 {
|
||||
result := uint64(1)
|
||||
for i := n; i > 0; i >>= 1 {
|
||||
if i&1 != 0 {
|
||||
result *= a
|
||||
}
|
||||
a *= a
|
||||
}
|
||||
return result
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -0,0 +1,172 @@
|
||||
package android
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/aes"
|
||||
"crypto/cipher"
|
||||
"fmt"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func padding(src []byte, blocksize int) []byte {
|
||||
padnum := blocksize - len(src)%blocksize
|
||||
pad := bytes.Repeat([]byte{byte(padnum)}, padnum)
|
||||
return append(src, pad...)
|
||||
}
|
||||
|
||||
func unpadding(src []byte) []byte {
|
||||
n := len(src)
|
||||
unpadnum := int(src[n-1])
|
||||
return src[:n-unpadnum]
|
||||
}
|
||||
|
||||
func EncryptAES(src []byte, key []byte) []byte {
|
||||
block, _ := aes.NewCipher(key)
|
||||
src = padding(src, block.BlockSize())
|
||||
blockmode := cipher.NewCBCEncrypter(block, key)
|
||||
blockmode.CryptBlocks(src, src)
|
||||
return src
|
||||
}
|
||||
|
||||
func DecryptAES(src []byte, key []byte) []byte {
|
||||
block, _ := aes.NewCipher(key)
|
||||
blockmode := cipher.NewCBCDecrypter(block, key)
|
||||
blockmode.CryptBlocks(src, src)
|
||||
src = unpadding(src)
|
||||
return src
|
||||
}
|
||||
|
||||
func AESEncrypt(src []byte, key []byte) []byte {
|
||||
block, _ := aes.NewCipher(key)
|
||||
src = padding(src, block.BlockSize())
|
||||
blockmode := cipher.NewCBCEncrypter(block, key)
|
||||
blockmode.CryptBlocks(src, src)
|
||||
return src
|
||||
}
|
||||
|
||||
func AESDecrypt(src []byte, key []byte) []byte {
|
||||
block, _ := aes.NewCipher(key)
|
||||
blockmode := cipher.NewCBCDecrypter(block, key)
|
||||
blockmode.CryptBlocks(src, src)
|
||||
src = unpadding(src)
|
||||
return src
|
||||
}
|
||||
|
||||
func AesEncrypt(RequestSerialize []byte, key []byte) []byte {
|
||||
//根据key 生成密文
|
||||
block, err := aes.NewCipher(key)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
blockSize := block.BlockSize()
|
||||
RequestSerialize = PKCS5Padding(RequestSerialize, blockSize)
|
||||
|
||||
blockMode := cipher.NewCBCEncrypter(block, key)
|
||||
crypted := make([]byte, len(RequestSerialize))
|
||||
blockMode.CryptBlocks(crypted, RequestSerialize)
|
||||
|
||||
return crypted
|
||||
}
|
||||
|
||||
func AesDecrypt(body []byte, key []byte) []byte {
|
||||
// fmt.Printf("%x\n\n", body)
|
||||
// fmt.Printf("%x\n\n", key)
|
||||
block, err := aes.NewCipher(key)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
blockMode := cipher.NewCBCDecrypter(block, key)
|
||||
origData := make([]byte, len(body))
|
||||
blockMode.CryptBlocks(origData, body)
|
||||
origData = PKCS5UnPadding(origData)
|
||||
// fmt.Printf("%x\n", origData)
|
||||
return origData
|
||||
}
|
||||
|
||||
// =================== ECB ======================
|
||||
func AesEncryptECB(origData []byte, key []byte) (encrypted []byte) {
|
||||
cipher, _ := aes.NewCipher(generateKey(key))
|
||||
length := (len(origData) + aes.BlockSize) / aes.BlockSize
|
||||
plain := make([]byte, length*aes.BlockSize)
|
||||
copy(plain, origData)
|
||||
pad := byte(len(plain) - len(origData))
|
||||
for i := len(origData); i < len(plain); i++ {
|
||||
plain[i] = pad
|
||||
}
|
||||
encrypted = make([]byte, len(plain))
|
||||
// 分组分块加密
|
||||
for bs, be := 0, cipher.BlockSize(); bs <= len(origData); bs, be = bs+cipher.BlockSize(), be+cipher.BlockSize() {
|
||||
cipher.Encrypt(encrypted[bs:be], plain[bs:be])
|
||||
}
|
||||
|
||||
return encrypted
|
||||
}
|
||||
|
||||
func AesDecryptECB(encrypted []byte, key []byte) (decrypted []byte) {
|
||||
cipher, _ := aes.NewCipher(generateKey(key))
|
||||
decrypted = make([]byte, len(encrypted))
|
||||
//
|
||||
for bs, be := 0, cipher.BlockSize(); bs < len(encrypted); bs, be = bs+cipher.BlockSize(), be+cipher.BlockSize() {
|
||||
cipher.Decrypt(decrypted[bs:be], encrypted[bs:be])
|
||||
}
|
||||
|
||||
trim := 0
|
||||
if len(decrypted) > 0 {
|
||||
trim = len(decrypted) - int(decrypted[len(decrypted)-1])
|
||||
}
|
||||
|
||||
return decrypted[:trim]
|
||||
}
|
||||
func generateKey(key []byte) (genKey []byte) {
|
||||
genKey = make([]byte, 16)
|
||||
copy(genKey, key)
|
||||
for i := 16; i < len(key); {
|
||||
for j := 0; j < 16 && i < len(key); j, i = j+1, i+1 {
|
||||
genKey[j] ^= key[i]
|
||||
}
|
||||
}
|
||||
return genKey
|
||||
}
|
||||
|
||||
func CompressAndAes(RequestSerialize []byte, aeskey []byte) []byte {
|
||||
compressed := DoZlibCompress(RequestSerialize)
|
||||
return AesEncrypt(compressed, aeskey)
|
||||
}
|
||||
|
||||
func DecompressAndAesDecrypt(body []byte, key []byte) []byte {
|
||||
block, err := aes.NewCipher(key)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if len(body)%aes.BlockSize != 0 {
|
||||
log.Error(fmt.Sprintf("crypto/cipher: data is not a multiple of the block size,[BodyLength:%v] [AesLength:%v]", len(body), aes.BlockSize))
|
||||
return nil
|
||||
}
|
||||
|
||||
blockMode := cipher.NewCBCDecrypter(block, key)
|
||||
origData := make([]byte, len(body))
|
||||
blockMode.CryptBlocks(origData, body)
|
||||
origData = PKCS5UnPadding(origData)
|
||||
origData = DoZlibUnCompress(origData)
|
||||
return origData
|
||||
}
|
||||
|
||||
func PKCS5UnPadding(origData []byte) []byte {
|
||||
length := len(origData)
|
||||
unpadding := int(origData[length-1])
|
||||
if length < unpadding {
|
||||
return nil
|
||||
}
|
||||
return origData[:(length - unpadding)]
|
||||
}
|
||||
|
||||
func PKCS5Padding(ciphertext []byte, blockSize int) []byte {
|
||||
padding := blockSize - len(ciphertext)%blockSize
|
||||
//填充
|
||||
padtext := bytes.Repeat([]byte{byte(padding)}, padding)
|
||||
|
||||
return append(ciphertext, padtext...)
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package appproto
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"compress/zlib"
|
||||
"crypto/rand"
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
"io"
|
||||
"time"
|
||||
"xiawan/wx/clientsdk/android"
|
||||
"xiawan/wx/clientsdk/android/mmproto"
|
||||
)
|
||||
|
||||
type TrustInfo struct {
|
||||
uri string
|
||||
cmdid uint32
|
||||
}
|
||||
|
||||
//MakeTrustDeviceReq s
|
||||
|
||||
func (t *TrustInfo) GetUri() string {
|
||||
return "/cgi-bin/micromsg-bin/fpfreshnl"
|
||||
}
|
||||
|
||||
func (t *TrustInfo) GetCmdid() uint32 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (t *TrustInfo) MakeTrustDeviceReq() []byte {
|
||||
|
||||
trustInfo := &mmproto.TrustReq{
|
||||
Td: &mmproto.TrustData{
|
||||
Tdi: []*mmproto.TrustDeviceInfo{
|
||||
{Key: proto.String("IMEI"), Val: proto.String("353627078088849")},
|
||||
{Key: proto.String("AndroidID"), Val: proto.String("06a78780bc297bbd")},
|
||||
{Key: proto.String("PhoneSerial"), Val: proto.String("01c5cded725f4db6")},
|
||||
{Key: proto.String("cid"), Val: proto.String("")},
|
||||
{Key: proto.String("WidevineDeviceID"), Val: proto.String("657a6b657b4f79614563447b54796c526f67724c466b79644564634c45675600")},
|
||||
{Key: proto.String("WidevineProvisionID"), Val: proto.String("955e20f6b905cbadbe67a580129b8f36")},
|
||||
{Key: proto.String("GSFID"), Val: proto.String("")},
|
||||
{Key: proto.String("SoterID"), Val: proto.String("")},
|
||||
{Key: proto.String("SoterUid"), Val: proto.String("")},
|
||||
{Key: proto.String("FSID"), Val: proto.String("3706372|3706398@8c829c5f2697bfed|2fe1cc4100a798d0b60909e0ea1090e7@d3609fe804970d6b|2ee5e2decd893fffee73ceab66e30640")},
|
||||
{Key: proto.String("BootID"), Val: proto.String("")},
|
||||
{Key: proto.String("IMSI"), Val: proto.String("")},
|
||||
{Key: proto.String("PhoneNum"), Val: proto.String("")},
|
||||
{Key: proto.String("WeChatInstallTime"), Val: proto.String("1515061151")},
|
||||
{Key: proto.String("PhoneModel"), Val: proto.String("Nexus 5X")},
|
||||
{Key: proto.String("BuildBoard"), Val: proto.String("bullhead")},
|
||||
{Key: proto.String("BuildBootloader"), Val: proto.String("BHZ32c")},
|
||||
{Key: proto.String("SystemBuildDate"), Val: proto.String("Fri Sep 28 23:37:27 UTC 2018")},
|
||||
{Key: proto.String("SystemBuildDateUTC"), Val: proto.String("1538177847")},
|
||||
{Key: proto.String("BuildFP"), Val: proto.String("google/bullhead/bullhead:8.1.0/OPM7.181105.004/5038062:user/release-keys")},
|
||||
{Key: proto.String("BuildID"), Val: proto.String("OPM7.181105.004")},
|
||||
{Key: proto.String("BuildBrand"), Val: proto.String("google")},
|
||||
{Key: proto.String("BuildDevice"), Val: proto.String("bullhead")},
|
||||
{Key: proto.String("BuildProduct"), Val: proto.String("bullhead")},
|
||||
{Key: proto.String("Manufacturer"), Val: proto.String("LGE")},
|
||||
{Key: proto.String("RadioVersion"), Val: proto.String("M8994F-2.6.42.5.03")},
|
||||
{Key: proto.String("AndroidVersion"), Val: proto.String("8.1.0")},
|
||||
{Key: proto.String("SdkIntVersion"), Val: proto.String("27")},
|
||||
{Key: proto.String("ScreenWidth"), Val: proto.String("1080")},
|
||||
{Key: proto.String("ScreenHeight"), Val: proto.String("1794")},
|
||||
{Key: proto.String("SensorList"), Val: proto.String("BMI160 accelerometer#Bosch#0.004788#1,BMI160 gyroscope#Bosch#0.000533#1,BMM150 magnetometer#Bosch#0.000000#1,BMP280 pressure#Bosch#0.005000#1,BMP280 temperature#Bosch#0.010000#1,RPR0521 Proximity Sensor#Rohm#1.000000#1,RPR0521 Light Sensor#Rohm#10.000000#1,Orientation#Google#1.000000#1,BMI160 Step detector#Bosch#1.000000#1,Significant motion#Google#1.000000#1,Gravity#Google#1.000000#1,Linear Acceleration#Google#1.000000#1,Rotation Vector#Google#1.000000#1,Geomagnetic Rotation Vector#Google#1.000000#1,Game Rotation Vector#Google#1.000000#1,Pickup Gesture#Google#1.000000#1,Tilt Detector#Google#1.000000#1,BMI160 Step counter#Bosch#1.000000#1,BMM150 magnetometer (uncalibrated)#Bosch#0.000000#1,BMI160 gyroscope (uncalibrated)#Bosch#0.000533#1,Sensors Sync#Google#1.000000#1,Double Twist#Google#1.000000#1,Double Tap#Google#1.000000#1,Device Orientation#Google#1.000000#1,BMI160 accelerometer (uncalibrated)#Bosch#0.004788#1")},
|
||||
{Key: proto.String("DefaultInputMethod"), Val: proto.String("com.google.android.inputmethod.latin")},
|
||||
{Key: proto.String("InputMethodList"), Val: proto.String("Google \345\215\260\345\272\246\350\257\255\351\224\256\347\233\230#com.google.android.apps.inputmethod.hindi,Google \350\257\255\351\237\263\350\276\223\345\205\245#com.google.android.googlequicksearchbox,Google \346\227\245\350\257\255\350\276\223\345\205\245\346\263\225#com.google.android.inputmethod.japanese,Google \351\237\251\350\257\255\350\276\223\345\205\245\346\263\225#com.google.android.inputmethod.korean,Gboard#com.google.android.inputmethod.latin,\350\260\267\346\255\214\346\213\274\351\237\263\350\276\223\345\205\245\346\263\225#com.google.android.inputmethod.pinyin")},
|
||||
{Key: proto.String("DeviceID"), Val: proto.String("A0e4a76905e8f67b")},
|
||||
{Key: proto.String("OAID"), Val: proto.String("")},
|
||||
},
|
||||
},
|
||||
Md: proto.String("e05ac1f886668063fabe3231fd78a2cb"),
|
||||
}
|
||||
|
||||
pb, _ := proto.Marshal(trustInfo)
|
||||
//fmt.Printf("%x\n", pb)
|
||||
|
||||
var b bytes.Buffer
|
||||
w := zlib.NewWriter(&b)
|
||||
w.Write(pb)
|
||||
w.Close()
|
||||
|
||||
zt := new(android.ZT)
|
||||
zt.Init()
|
||||
encData := zt.Encrypt(b.Bytes())
|
||||
|
||||
//fmt.Printf("ZT: %x\n", encData)
|
||||
|
||||
randKey := make([]byte, 16)
|
||||
io.ReadFull(rand.Reader, randKey)
|
||||
|
||||
fp := &mmproto.FPFresh{
|
||||
BaseReq: &mmproto.BaseRequest{
|
||||
SessionKey: []byte{},
|
||||
Uin: proto.Uint64(0),
|
||||
DeviceID: append([]byte("A0e4a76905e8f67"), 0),
|
||||
ClientVersion: proto.Int32(0x27000b32),
|
||||
DeviceType: proto.String("android-27"),
|
||||
Scene: proto.Uint32(0),
|
||||
},
|
||||
SessKey: randKey,
|
||||
Ztdata: &mmproto.ZTData{
|
||||
Version: proto.String("00000003\x00"),
|
||||
Encrypted: proto.Uint32(1),
|
||||
Data: encData,
|
||||
TimeStamp: proto.Uint32(uint32(time.Now().Unix())),
|
||||
Optype: proto.Uint32(5),
|
||||
Uin: proto.Uint32(0),
|
||||
},
|
||||
}
|
||||
|
||||
fpPB, _ := proto.Marshal(fp)
|
||||
return fpPB
|
||||
}
|
||||
@@ -0,0 +1,248 @@
|
||||
// crypto.go
|
||||
package android
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"compress/zlib"
|
||||
"crypto/aes"
|
||||
"crypto/cipher"
|
||||
"crypto/elliptic"
|
||||
"crypto/rand"
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"golang.org/x/crypto/hkdf"
|
||||
"hash"
|
||||
"io"
|
||||
"xiawan/wx/clientsdk/android/mmproto"
|
||||
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
)
|
||||
|
||||
type HYBRID_STATUS int32
|
||||
|
||||
type HybridEcdhClient struct {
|
||||
hybridStatus HYBRID_STATUS
|
||||
|
||||
clientHash hash.Hash
|
||||
serverHash hash.Hash
|
||||
|
||||
clientStaticPub []byte
|
||||
clientEcdsaPub []byte
|
||||
|
||||
genClientPub []byte
|
||||
genClientPriv []byte
|
||||
|
||||
curve elliptic.Curve
|
||||
}
|
||||
|
||||
func AesGcmEncrypt(key, nonce, input, additional []byte) ([]byte, error) {
|
||||
|
||||
block, err := aes.NewCipher(key)
|
||||
|
||||
if err != nil {
|
||||
//fmt.Println("cipher init faile....")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
aesgcm, err := cipher.NewGCM(block)
|
||||
if err != nil {
|
||||
fmt.Println("gcm init faile....")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result := aesgcm.Seal(nil, nonce, input, additional)
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func AesGcmDecrypt(key, nonce, input, additional []byte) ([]byte, error) {
|
||||
|
||||
block, err := aes.NewCipher(key)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println("cipher init faile....")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
aesgcm, err := cipher.NewGCM(block)
|
||||
if err != nil {
|
||||
fmt.Println("gcm init faile....")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return aesgcm.Open(nil, nonce, input, additional)
|
||||
}
|
||||
|
||||
func AesGcmEncryptWithCompress(key, nonce, input, additional []byte) ([]byte, error) {
|
||||
|
||||
var b bytes.Buffer
|
||||
w := zlib.NewWriter(&b)
|
||||
w.Write(input)
|
||||
w.Close()
|
||||
|
||||
data, _ := AesGcmEncrypt(key, nonce, b.Bytes(), additional)
|
||||
|
||||
encData := data[:len(data)-16]
|
||||
tag := data[len(data)-16:]
|
||||
|
||||
totalData := []byte{}
|
||||
totalData = append(totalData, encData...)
|
||||
totalData = append(totalData, nonce...)
|
||||
totalData = append(totalData, tag...)
|
||||
return totalData, nil
|
||||
}
|
||||
|
||||
func AesGcmDecryptWithUnCompress(key, input, additional []byte) ([]byte, error) {
|
||||
|
||||
inputSize := len(input)
|
||||
|
||||
nonce := make([]byte, 12)
|
||||
copy(nonce, input[inputSize-28:inputSize-16])
|
||||
|
||||
tag := make([]byte, 16)
|
||||
copy(tag, input[inputSize-16:])
|
||||
|
||||
cipherText := make([]byte, inputSize-28)
|
||||
copy(cipherText, input[:inputSize-28])
|
||||
cipherText = append(cipherText, tag...)
|
||||
|
||||
result, _ := AesGcmDecrypt(key, nonce, cipherText, additional)
|
||||
|
||||
b := bytes.NewReader(result)
|
||||
|
||||
var out bytes.Buffer
|
||||
r, _ := zlib.NewReader(b)
|
||||
io.Copy(&out, r)
|
||||
r.Close()
|
||||
|
||||
return out.Bytes(), nil
|
||||
}
|
||||
|
||||
func Ecdh(curve elliptic.Curve, pub, priv []byte) []byte {
|
||||
|
||||
x, y := elliptic.Unmarshal(curve, pub)
|
||||
if x == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
xShared, _ := curve.ScalarMult(x, y, priv)
|
||||
sharedKey := make([]byte, (curve.Params().BitSize+7)>>3)
|
||||
xBytes := xShared.Bytes()
|
||||
copy(sharedKey[len(sharedKey)-len(xBytes):], xBytes)
|
||||
|
||||
dh := sha256.Sum256(sharedKey)
|
||||
return dh[:]
|
||||
}
|
||||
|
||||
func (h *HybridEcdhClient) Init() {
|
||||
|
||||
h.hybridStatus = HYBRID_ENC
|
||||
|
||||
h.clientHash = sha256.New()
|
||||
h.serverHash = sha256.New()
|
||||
|
||||
h.clientStaticPub, _ = hex.DecodeString("0495BC6E5C1331AD172D0F35B1792C3CE63F91572ABD2DD6DF6DAC2D70195C3F6627CCA60307305D8495A8C38B4416C75021E823B6C97DFFE79C14CB7C3AF8A586")
|
||||
h.clientEcdsaPub, _ = hex.DecodeString("2D2D2D2D2D424547494E205055424C4943204B45592D2D2D2D2D0A4D466B77457759484B6F5A497A6A3043415159494B6F5A497A6A3044415163445167414552497979694B33533950374854614B4C654750314B7A6243435139490A4C537845477861465645346A6E5A653646717777304A6877356D41716266574C4B364E69387075765356364371432B44324B65533373767059773D3D0A2D2D2D2D2D454E44205055424C4943204B45592D2D2D2D2D0A")
|
||||
|
||||
h.curve = elliptic.P256()
|
||||
}
|
||||
|
||||
func (h *HybridEcdhClient) Encrypt(input []byte) []byte {
|
||||
if h.hybridStatus != HYBRID_ENC {
|
||||
return nil
|
||||
}
|
||||
|
||||
priv, x, y, error := elliptic.GenerateKey(h.curve, rand.Reader)
|
||||
if error != nil {
|
||||
return nil
|
||||
}
|
||||
h.genClientPriv = priv
|
||||
h.genClientPub = elliptic.Marshal(h.curve, x, y)
|
||||
|
||||
ecdhKey := Ecdh(h.curve, h.clientStaticPub, h.genClientPriv)
|
||||
|
||||
//hash1
|
||||
h1 := sha256.New()
|
||||
h1.Write([]byte("1"))
|
||||
h1.Write([]byte("415"))
|
||||
h1.Write(h.genClientPub)
|
||||
h1Sum := h1.Sum(nil)
|
||||
|
||||
//Random
|
||||
random := make([]byte, 32)
|
||||
io.ReadFull(rand.Reader, random)
|
||||
|
||||
nonce1 := make([]byte, 12)
|
||||
io.ReadFull(rand.Reader, nonce1)
|
||||
gcm1, _ := AesGcmEncryptWithCompress(ecdhKey[0:0x18], nonce1, random, h1Sum)
|
||||
//hkdf
|
||||
salt, _ := hex.DecodeString("73656375726974792068646B6620657870616E64")
|
||||
hkdfKey := make([]byte, 56)
|
||||
hkdf.New(sha256.New, random, salt, h1Sum).Read(hkdfKey)
|
||||
|
||||
//hash2
|
||||
h2 := sha256.New()
|
||||
h2.Write([]byte("1"))
|
||||
h2.Write([]byte("415"))
|
||||
h2.Write(h.genClientPub)
|
||||
h2.Write(gcm1)
|
||||
h2Sum := h2.Sum(nil)
|
||||
|
||||
nonce2 := make([]byte, 12)
|
||||
io.ReadFull(rand.Reader, nonce2)
|
||||
gcm2, _ := AesGcmEncryptWithCompress(hkdfKey[0:0x18], nonce2, input, h2Sum)
|
||||
|
||||
var nid int32 = 415
|
||||
secKey := &mmproto.SecKey{
|
||||
Nid: &nid,
|
||||
Key: h.genClientPub,
|
||||
}
|
||||
|
||||
var ver int32 = 1
|
||||
he := &mmproto.HybridEcdhReq{
|
||||
Version: &ver,
|
||||
SecKey: secKey,
|
||||
Gcm1: gcm1,
|
||||
Autokey: []byte{},
|
||||
Gcm2: gcm2,
|
||||
}
|
||||
|
||||
protoMsg, _ := proto.Marshal(he)
|
||||
|
||||
// update client
|
||||
h.clientHash.Write(hkdfKey[0x18:0x38])
|
||||
h.clientHash.Write(input)
|
||||
|
||||
// update server
|
||||
h.serverHash.Write(gcm2)
|
||||
|
||||
h.hybridStatus = HYBRID_DEC
|
||||
|
||||
return protoMsg
|
||||
}
|
||||
|
||||
func (h *HybridEcdhClient) Decrypt(input []byte) []byte {
|
||||
|
||||
if h.hybridStatus != HYBRID_DEC {
|
||||
return nil
|
||||
}
|
||||
|
||||
var resp mmproto.HybridEcdhResp
|
||||
proto.Unmarshal(input, &resp)
|
||||
|
||||
h.serverHash.Write(resp.GetGcm1())
|
||||
// hServ := h.serverHash.Sum(nil)
|
||||
// fmt.Printf("%x\n", hServ)
|
||||
|
||||
// ecdsa.Verify(h.clientEcdsaPub, resp.GetGcm2(), hServ)
|
||||
ecKey := Ecdh(h.curve, resp.GetSecKey().GetKey(), h.genClientPriv)
|
||||
|
||||
h.clientHash.Write([]byte("415"))
|
||||
h.clientHash.Write(resp.GetSecKey().GetKey())
|
||||
h.clientHash.Write([]byte("1"))
|
||||
hCli := h.clientHash.Sum(nil)
|
||||
|
||||
plain, _ := AesGcmDecryptWithUnCompress(ecKey[0:0x18], resp.GetGcm1(), hCli)
|
||||
return plain
|
||||
}
|
||||
@@ -0,0 +1,699 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// source: base.proto
|
||||
|
||||
package mmproto
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
math "math"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
type SKBuiltinBuffert struct {
|
||||
ILen *uint32 `protobuf:"varint,1,req,name=iLen" json:"iLen,omitempty"`
|
||||
Buffer []byte `protobuf:"bytes,2,opt,name=Buffer" json:"Buffer,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *SKBuiltinBuffert) Reset() { *m = SKBuiltinBuffert{} }
|
||||
func (m *SKBuiltinBuffert) String() string { return proto.CompactTextString(m) }
|
||||
func (*SKBuiltinBuffert) ProtoMessage() {}
|
||||
func (*SKBuiltinBuffert) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_db1b6b0986796150, []int{0}
|
||||
}
|
||||
|
||||
func (m *SKBuiltinBuffert) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_SKBuiltinBuffert.Unmarshal(m, b)
|
||||
}
|
||||
func (m *SKBuiltinBuffert) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_SKBuiltinBuffert.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *SKBuiltinBuffert) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_SKBuiltinBuffert.Merge(m, src)
|
||||
}
|
||||
func (m *SKBuiltinBuffert) XXX_Size() int {
|
||||
return xxx_messageInfo_SKBuiltinBuffert.Size(m)
|
||||
}
|
||||
func (m *SKBuiltinBuffert) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_SKBuiltinBuffert.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_SKBuiltinBuffert proto.InternalMessageInfo
|
||||
|
||||
func (m *SKBuiltinBuffert) GetILen() uint32 {
|
||||
if m != nil && m.ILen != nil {
|
||||
return *m.ILen
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *SKBuiltinBuffert) GetBuffer() []byte {
|
||||
if m != nil {
|
||||
return m.Buffer
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type SKBuiltinStringt struct {
|
||||
String_ *string `protobuf:"bytes,1,opt,name=String" json:"String,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *SKBuiltinStringt) Reset() { *m = SKBuiltinStringt{} }
|
||||
func (m *SKBuiltinStringt) String() string { return proto.CompactTextString(m) }
|
||||
func (*SKBuiltinStringt) ProtoMessage() {}
|
||||
func (*SKBuiltinStringt) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_db1b6b0986796150, []int{1}
|
||||
}
|
||||
|
||||
func (m *SKBuiltinStringt) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_SKBuiltinStringt.Unmarshal(m, b)
|
||||
}
|
||||
func (m *SKBuiltinStringt) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_SKBuiltinStringt.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *SKBuiltinStringt) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_SKBuiltinStringt.Merge(m, src)
|
||||
}
|
||||
func (m *SKBuiltinStringt) XXX_Size() int {
|
||||
return xxx_messageInfo_SKBuiltinStringt.Size(m)
|
||||
}
|
||||
func (m *SKBuiltinStringt) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_SKBuiltinStringt.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_SKBuiltinStringt proto.InternalMessageInfo
|
||||
|
||||
func (m *SKBuiltinStringt) GetString_() string {
|
||||
if m != nil && m.String_ != nil {
|
||||
return *m.String_
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type BaseRequest struct {
|
||||
SessionKey []byte `protobuf:"bytes,1,req,name=SessionKey" json:"SessionKey,omitempty"`
|
||||
Uin *uint64 `protobuf:"varint,2,req,name=Uin" json:"Uin,omitempty"`
|
||||
DeviceID []byte `protobuf:"bytes,3,req,name=DeviceID" json:"DeviceID,omitempty"`
|
||||
ClientVersion *int32 `protobuf:"varint,4,req,name=ClientVersion" json:"ClientVersion,omitempty"`
|
||||
DeviceType *string `protobuf:"bytes,5,req,name=DeviceType" json:"DeviceType,omitempty"`
|
||||
Scene *uint32 `protobuf:"varint,6,req,name=Scene" json:"Scene,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *BaseRequest) Reset() { *m = BaseRequest{} }
|
||||
func (m *BaseRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*BaseRequest) ProtoMessage() {}
|
||||
func (*BaseRequest) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_db1b6b0986796150, []int{2}
|
||||
}
|
||||
|
||||
func (m *BaseRequest) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_BaseRequest.Unmarshal(m, b)
|
||||
}
|
||||
func (m *BaseRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_BaseRequest.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *BaseRequest) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_BaseRequest.Merge(m, src)
|
||||
}
|
||||
func (m *BaseRequest) XXX_Size() int {
|
||||
return xxx_messageInfo_BaseRequest.Size(m)
|
||||
}
|
||||
func (m *BaseRequest) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_BaseRequest.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_BaseRequest proto.InternalMessageInfo
|
||||
|
||||
func (m *BaseRequest) GetSessionKey() []byte {
|
||||
if m != nil {
|
||||
return m.SessionKey
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *BaseRequest) GetUin() uint64 {
|
||||
if m != nil && m.Uin != nil {
|
||||
return *m.Uin
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *BaseRequest) GetDeviceID() []byte {
|
||||
if m != nil {
|
||||
return m.DeviceID
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *BaseRequest) GetClientVersion() int32 {
|
||||
if m != nil && m.ClientVersion != nil {
|
||||
return *m.ClientVersion
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *BaseRequest) GetDeviceType() string {
|
||||
if m != nil && m.DeviceType != nil {
|
||||
return *m.DeviceType
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *BaseRequest) GetScene() uint32 {
|
||||
if m != nil && m.Scene != nil {
|
||||
return *m.Scene
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type BaseResponse struct {
|
||||
Ret *int32 `protobuf:"varint,1,req,name=Ret" json:"Ret,omitempty"`
|
||||
ErrMsg *SKBuiltinStringt `protobuf:"bytes,2,req,name=ErrMsg" json:"ErrMsg,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *BaseResponse) Reset() { *m = BaseResponse{} }
|
||||
func (m *BaseResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*BaseResponse) ProtoMessage() {}
|
||||
func (*BaseResponse) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_db1b6b0986796150, []int{3}
|
||||
}
|
||||
|
||||
func (m *BaseResponse) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_BaseResponse.Unmarshal(m, b)
|
||||
}
|
||||
func (m *BaseResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_BaseResponse.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *BaseResponse) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_BaseResponse.Merge(m, src)
|
||||
}
|
||||
func (m *BaseResponse) XXX_Size() int {
|
||||
return xxx_messageInfo_BaseResponse.Size(m)
|
||||
}
|
||||
func (m *BaseResponse) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_BaseResponse.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_BaseResponse proto.InternalMessageInfo
|
||||
|
||||
func (m *BaseResponse) GetRet() int32 {
|
||||
if m != nil && m.Ret != nil {
|
||||
return *m.Ret
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *BaseResponse) GetErrMsg() *SKBuiltinStringt {
|
||||
if m != nil {
|
||||
return m.ErrMsg
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type ECDHKey struct {
|
||||
Nid *int32 `protobuf:"varint,1,req,name=Nid" json:"Nid,omitempty"`
|
||||
Key *SKBuiltinBuffert `protobuf:"bytes,2,req,name=Key" json:"Key,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *ECDHKey) Reset() { *m = ECDHKey{} }
|
||||
func (m *ECDHKey) String() string { return proto.CompactTextString(m) }
|
||||
func (*ECDHKey) ProtoMessage() {}
|
||||
func (*ECDHKey) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_db1b6b0986796150, []int{4}
|
||||
}
|
||||
|
||||
func (m *ECDHKey) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_ECDHKey.Unmarshal(m, b)
|
||||
}
|
||||
func (m *ECDHKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_ECDHKey.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *ECDHKey) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_ECDHKey.Merge(m, src)
|
||||
}
|
||||
func (m *ECDHKey) XXX_Size() int {
|
||||
return xxx_messageInfo_ECDHKey.Size(m)
|
||||
}
|
||||
func (m *ECDHKey) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_ECDHKey.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_ECDHKey proto.InternalMessageInfo
|
||||
|
||||
func (m *ECDHKey) GetNid() int32 {
|
||||
if m != nil && m.Nid != nil {
|
||||
return *m.Nid
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *ECDHKey) GetKey() *SKBuiltinBuffert {
|
||||
if m != nil {
|
||||
return m.Key
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type ZTData struct {
|
||||
Version *string `protobuf:"bytes,1,req,name=version" json:"version,omitempty"`
|
||||
Encrypted *uint32 `protobuf:"varint,2,req,name=encrypted" json:"encrypted,omitempty"`
|
||||
Data []byte `protobuf:"bytes,3,req,name=data" json:"data,omitempty"`
|
||||
TimeStamp *uint32 `protobuf:"varint,4,req,name=timeStamp" json:"timeStamp,omitempty"`
|
||||
Optype *uint32 `protobuf:"varint,5,req,name=optype" json:"optype,omitempty"`
|
||||
Uin *uint32 `protobuf:"varint,6,req,name=uin" json:"uin,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *ZTData) Reset() { *m = ZTData{} }
|
||||
func (m *ZTData) String() string { return proto.CompactTextString(m) }
|
||||
func (*ZTData) ProtoMessage() {}
|
||||
func (*ZTData) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_db1b6b0986796150, []int{5}
|
||||
}
|
||||
|
||||
func (m *ZTData) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_ZTData.Unmarshal(m, b)
|
||||
}
|
||||
func (m *ZTData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_ZTData.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *ZTData) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_ZTData.Merge(m, src)
|
||||
}
|
||||
func (m *ZTData) XXX_Size() int {
|
||||
return xxx_messageInfo_ZTData.Size(m)
|
||||
}
|
||||
func (m *ZTData) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_ZTData.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_ZTData proto.InternalMessageInfo
|
||||
|
||||
func (m *ZTData) GetVersion() string {
|
||||
if m != nil && m.Version != nil {
|
||||
return *m.Version
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *ZTData) GetEncrypted() uint32 {
|
||||
if m != nil && m.Encrypted != nil {
|
||||
return *m.Encrypted
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *ZTData) GetData() []byte {
|
||||
if m != nil {
|
||||
return m.Data
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *ZTData) GetTimeStamp() uint32 {
|
||||
if m != nil && m.TimeStamp != nil {
|
||||
return *m.TimeStamp
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *ZTData) GetOptype() uint32 {
|
||||
if m != nil && m.Optype != nil {
|
||||
return *m.Optype
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *ZTData) GetUin() uint32 {
|
||||
if m != nil && m.Uin != nil {
|
||||
return *m.Uin
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type DeviceToken struct {
|
||||
Version *string `protobuf:"bytes,1,req,name=version" json:"version,omitempty"`
|
||||
Encrypted *uint32 `protobuf:"varint,2,req,name=encrypted" json:"encrypted,omitempty"`
|
||||
Data *SKBuiltinStringt `protobuf:"bytes,3,req,name=data" json:"data,omitempty"`
|
||||
TimeStamp *uint32 `protobuf:"varint,4,req,name=timeStamp" json:"timeStamp,omitempty"`
|
||||
Optype *uint32 `protobuf:"varint,5,req,name=optype" json:"optype,omitempty"`
|
||||
Uin *uint32 `protobuf:"varint,6,req,name=uin" json:"uin,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *DeviceToken) Reset() { *m = DeviceToken{} }
|
||||
func (m *DeviceToken) String() string { return proto.CompactTextString(m) }
|
||||
func (*DeviceToken) ProtoMessage() {}
|
||||
func (*DeviceToken) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_db1b6b0986796150, []int{6}
|
||||
}
|
||||
|
||||
func (m *DeviceToken) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_DeviceToken.Unmarshal(m, b)
|
||||
}
|
||||
func (m *DeviceToken) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_DeviceToken.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *DeviceToken) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_DeviceToken.Merge(m, src)
|
||||
}
|
||||
func (m *DeviceToken) XXX_Size() int {
|
||||
return xxx_messageInfo_DeviceToken.Size(m)
|
||||
}
|
||||
func (m *DeviceToken) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_DeviceToken.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_DeviceToken proto.InternalMessageInfo
|
||||
|
||||
func (m *DeviceToken) GetVersion() string {
|
||||
if m != nil && m.Version != nil {
|
||||
return *m.Version
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *DeviceToken) GetEncrypted() uint32 {
|
||||
if m != nil && m.Encrypted != nil {
|
||||
return *m.Encrypted
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *DeviceToken) GetData() *SKBuiltinStringt {
|
||||
if m != nil {
|
||||
return m.Data
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *DeviceToken) GetTimeStamp() uint32 {
|
||||
if m != nil && m.TimeStamp != nil {
|
||||
return *m.TimeStamp
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *DeviceToken) GetOptype() uint32 {
|
||||
if m != nil && m.Optype != nil {
|
||||
return *m.Optype
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *DeviceToken) GetUin() uint32 {
|
||||
if m != nil && m.Uin != nil {
|
||||
return *m.Uin
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type SpamDataSubBody struct {
|
||||
Ilen *uint32 `protobuf:"varint,1,req,name=ilen" json:"ilen,omitempty"`
|
||||
Ztdata *ZTData `protobuf:"bytes,2,req,name=ztdata" json:"ztdata,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *SpamDataSubBody) Reset() { *m = SpamDataSubBody{} }
|
||||
func (m *SpamDataSubBody) String() string { return proto.CompactTextString(m) }
|
||||
func (*SpamDataSubBody) ProtoMessage() {}
|
||||
func (*SpamDataSubBody) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_db1b6b0986796150, []int{7}
|
||||
}
|
||||
|
||||
func (m *SpamDataSubBody) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_SpamDataSubBody.Unmarshal(m, b)
|
||||
}
|
||||
func (m *SpamDataSubBody) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_SpamDataSubBody.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *SpamDataSubBody) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_SpamDataSubBody.Merge(m, src)
|
||||
}
|
||||
func (m *SpamDataSubBody) XXX_Size() int {
|
||||
return xxx_messageInfo_SpamDataSubBody.Size(m)
|
||||
}
|
||||
func (m *SpamDataSubBody) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_SpamDataSubBody.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_SpamDataSubBody proto.InternalMessageInfo
|
||||
|
||||
func (m *SpamDataSubBody) GetIlen() uint32 {
|
||||
if m != nil && m.Ilen != nil {
|
||||
return *m.Ilen
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *SpamDataSubBody) GetZtdata() *ZTData {
|
||||
if m != nil {
|
||||
return m.Ztdata
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type DeviceTokenBody struct {
|
||||
Ilen *uint32 `protobuf:"varint,1,req,name=ilen" json:"ilen,omitempty"`
|
||||
DeviceToken *DeviceToken `protobuf:"bytes,2,req,name=deviceToken" json:"deviceToken,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *DeviceTokenBody) Reset() { *m = DeviceTokenBody{} }
|
||||
func (m *DeviceTokenBody) String() string { return proto.CompactTextString(m) }
|
||||
func (*DeviceTokenBody) ProtoMessage() {}
|
||||
func (*DeviceTokenBody) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_db1b6b0986796150, []int{8}
|
||||
}
|
||||
|
||||
func (m *DeviceTokenBody) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_DeviceTokenBody.Unmarshal(m, b)
|
||||
}
|
||||
func (m *DeviceTokenBody) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_DeviceTokenBody.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *DeviceTokenBody) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_DeviceTokenBody.Merge(m, src)
|
||||
}
|
||||
func (m *DeviceTokenBody) XXX_Size() int {
|
||||
return xxx_messageInfo_DeviceTokenBody.Size(m)
|
||||
}
|
||||
func (m *DeviceTokenBody) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_DeviceTokenBody.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_DeviceTokenBody proto.InternalMessageInfo
|
||||
|
||||
func (m *DeviceTokenBody) GetIlen() uint32 {
|
||||
if m != nil && m.Ilen != nil {
|
||||
return *m.Ilen
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *DeviceTokenBody) GetDeviceToken() *DeviceToken {
|
||||
if m != nil {
|
||||
return m.DeviceToken
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type SpamDataBody struct {
|
||||
Ccd1 *SpamDataSubBody `protobuf:"bytes,1,opt,name=ccd1" json:"ccd1,omitempty"`
|
||||
Ccd2 *SpamDataSubBody `protobuf:"bytes,2,opt,name=ccd2" json:"ccd2,omitempty"`
|
||||
Ccd3 *SpamDataSubBody `protobuf:"bytes,3,opt,name=ccd3" json:"ccd3,omitempty"`
|
||||
Dt *DeviceTokenBody `protobuf:"bytes,7,opt,name=dt" json:"dt,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *SpamDataBody) Reset() { *m = SpamDataBody{} }
|
||||
func (m *SpamDataBody) String() string { return proto.CompactTextString(m) }
|
||||
func (*SpamDataBody) ProtoMessage() {}
|
||||
func (*SpamDataBody) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_db1b6b0986796150, []int{9}
|
||||
}
|
||||
|
||||
func (m *SpamDataBody) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_SpamDataBody.Unmarshal(m, b)
|
||||
}
|
||||
func (m *SpamDataBody) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_SpamDataBody.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *SpamDataBody) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_SpamDataBody.Merge(m, src)
|
||||
}
|
||||
func (m *SpamDataBody) XXX_Size() int {
|
||||
return xxx_messageInfo_SpamDataBody.Size(m)
|
||||
}
|
||||
func (m *SpamDataBody) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_SpamDataBody.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_SpamDataBody proto.InternalMessageInfo
|
||||
|
||||
func (m *SpamDataBody) GetCcd1() *SpamDataSubBody {
|
||||
if m != nil {
|
||||
return m.Ccd1
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *SpamDataBody) GetCcd2() *SpamDataSubBody {
|
||||
if m != nil {
|
||||
return m.Ccd2
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *SpamDataBody) GetCcd3() *SpamDataSubBody {
|
||||
if m != nil {
|
||||
return m.Ccd3
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *SpamDataBody) GetDt() *DeviceTokenBody {
|
||||
if m != nil {
|
||||
return m.Dt
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type SpamData struct {
|
||||
Totallen *uint32 `protobuf:"varint,1,req,name=totallen" json:"totallen,omitempty"`
|
||||
SpamDataBody *SpamDataBody `protobuf:"bytes,2,req,name=spamDataBody" json:"spamDataBody,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *SpamData) Reset() { *m = SpamData{} }
|
||||
func (m *SpamData) String() string { return proto.CompactTextString(m) }
|
||||
func (*SpamData) ProtoMessage() {}
|
||||
func (*SpamData) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_db1b6b0986796150, []int{10}
|
||||
}
|
||||
|
||||
func (m *SpamData) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_SpamData.Unmarshal(m, b)
|
||||
}
|
||||
func (m *SpamData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_SpamData.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *SpamData) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_SpamData.Merge(m, src)
|
||||
}
|
||||
func (m *SpamData) XXX_Size() int {
|
||||
return xxx_messageInfo_SpamData.Size(m)
|
||||
}
|
||||
func (m *SpamData) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_SpamData.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_SpamData proto.InternalMessageInfo
|
||||
|
||||
func (m *SpamData) GetTotallen() uint32 {
|
||||
if m != nil && m.Totallen != nil {
|
||||
return *m.Totallen
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *SpamData) GetSpamDataBody() *SpamDataBody {
|
||||
if m != nil {
|
||||
return m.SpamDataBody
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*SKBuiltinBuffert)(nil), "mmproto.SKBuiltinBuffert")
|
||||
proto.RegisterType((*SKBuiltinStringt)(nil), "mmproto.SKBuiltinStringt")
|
||||
proto.RegisterType((*BaseRequest)(nil), "mmproto.BaseRequest")
|
||||
proto.RegisterType((*BaseResponse)(nil), "mmproto.BaseResponse")
|
||||
proto.RegisterType((*ECDHKey)(nil), "mmproto.ECDHKey")
|
||||
proto.RegisterType((*ZTData)(nil), "mmproto.ZTData")
|
||||
proto.RegisterType((*DeviceToken)(nil), "mmproto.DeviceToken")
|
||||
proto.RegisterType((*SpamDataSubBody)(nil), "mmproto.SpamDataSubBody")
|
||||
proto.RegisterType((*DeviceTokenBody)(nil), "mmproto.DeviceTokenBody")
|
||||
proto.RegisterType((*SpamDataBody)(nil), "mmproto.SpamDataBody")
|
||||
proto.RegisterType((*SpamData)(nil), "mmproto.SpamData")
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterFile("base.proto", fileDescriptor_db1b6b0986796150)
|
||||
}
|
||||
|
||||
var fileDescriptor_db1b6b0986796150 = []byte{
|
||||
// 554 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x53, 0x5d, 0x8b, 0xd3, 0x40,
|
||||
0x14, 0x25, 0xe9, 0xd7, 0xee, 0x6d, 0x4b, 0x97, 0x61, 0x95, 0x51, 0x44, 0xc2, 0x20, 0x18, 0xfc,
|
||||
0x28, 0x6c, 0x17, 0x04, 0x5f, 0x7c, 0xe8, 0x76, 0x61, 0x65, 0xb5, 0x0f, 0x93, 0xd5, 0x07, 0xc1,
|
||||
0x87, 0xd9, 0xe6, 0xee, 0x32, 0xd8, 0x4e, 0x62, 0x32, 0x59, 0xa8, 0xbf, 0xc5, 0xff, 0xe1, 0x8b,
|
||||
0x4f, 0xfe, 0x32, 0x99, 0xc9, 0xa4, 0x49, 0x2b, 0xab, 0x22, 0xbe, 0xdd, 0x7b, 0x73, 0xe6, 0xe4,
|
||||
0x9c, 0x73, 0xb9, 0x00, 0x97, 0x22, 0xc7, 0x71, 0x9a, 0x25, 0x3a, 0x21, 0xbd, 0xd5, 0xca, 0x16,
|
||||
0xec, 0x15, 0x1c, 0x44, 0xe7, 0xd3, 0x42, 0x2e, 0xb5, 0x54, 0xd3, 0xe2, 0xea, 0x0a, 0x33, 0x4d,
|
||||
0x08, 0xb4, 0xe5, 0x1b, 0x54, 0xd4, 0x0b, 0xfc, 0x70, 0xc8, 0x6d, 0x4d, 0xee, 0x42, 0xb7, 0xfc,
|
||||
0x4c, 0xfd, 0xc0, 0x0b, 0x07, 0xdc, 0x75, 0xec, 0x49, 0xe3, 0x7d, 0xa4, 0x33, 0xa9, 0xae, 0xb5,
|
||||
0xc1, 0x96, 0x25, 0xf5, 0x02, 0x2f, 0xdc, 0xe7, 0xae, 0x63, 0xdf, 0x3c, 0xe8, 0x4f, 0x45, 0x8e,
|
||||
0x1c, 0x3f, 0x17, 0x98, 0x6b, 0xf2, 0x10, 0x20, 0xc2, 0x3c, 0x97, 0x89, 0x3a, 0xc7, 0xb5, 0xfd,
|
||||
0xdb, 0x80, 0x37, 0x26, 0xe4, 0x00, 0x5a, 0xef, 0xa4, 0xa2, 0x7e, 0xe0, 0x87, 0x6d, 0x6e, 0x4a,
|
||||
0x72, 0x1f, 0xf6, 0x66, 0x78, 0x23, 0x17, 0xf8, 0x7a, 0x46, 0x5b, 0x16, 0xbf, 0xe9, 0xc9, 0x23,
|
||||
0x18, 0x9e, 0x2c, 0x25, 0x2a, 0xfd, 0x1e, 0x33, 0xc3, 0x40, 0xdb, 0x81, 0x1f, 0x76, 0xf8, 0xf6,
|
||||
0xd0, 0xfc, 0xb3, 0x7c, 0x71, 0xb1, 0x4e, 0x91, 0x76, 0x02, 0x3f, 0xdc, 0xe7, 0x8d, 0x09, 0x39,
|
||||
0x84, 0x4e, 0xb4, 0x40, 0x85, 0xb4, 0x6b, 0xcd, 0x97, 0x0d, 0x8b, 0x60, 0x50, 0x0a, 0xcf, 0xd3,
|
||||
0x44, 0xe5, 0x68, 0x94, 0x71, 0xd4, 0x56, 0x72, 0x87, 0x9b, 0x92, 0x1c, 0x41, 0xf7, 0x34, 0xcb,
|
||||
0xde, 0xe6, 0xd7, 0x56, 0x6e, 0x7f, 0x72, 0x6f, 0xec, 0x12, 0x1e, 0xef, 0xc6, 0xc3, 0x1d, 0x90,
|
||||
0x9d, 0x41, 0xef, 0xf4, 0x64, 0x76, 0xe6, 0x9c, 0xce, 0x65, 0x5c, 0xf1, 0xcd, 0x65, 0x4c, 0x9e,
|
||||
0x42, 0xcb, 0x84, 0x72, 0x2b, 0x99, 0xdb, 0x15, 0x37, 0x28, 0xf6, 0xd5, 0x83, 0xee, 0x87, 0x8b,
|
||||
0x99, 0xd0, 0x82, 0x50, 0xe8, 0xdd, 0x38, 0xff, 0x9e, 0x35, 0x57, 0xb5, 0xe4, 0x01, 0xec, 0xa3,
|
||||
0x5a, 0x64, 0xeb, 0x54, 0x63, 0x6c, 0x79, 0x87, 0xbc, 0x1e, 0x98, 0x9d, 0xc7, 0x42, 0x0b, 0x97,
|
||||
0xaa, 0xad, 0xcd, 0x0b, 0x2d, 0x57, 0x18, 0x69, 0xb1, 0x4a, 0x6d, 0x9a, 0x43, 0x5e, 0x0f, 0xcc,
|
||||
0x96, 0x93, 0x54, 0x57, 0x29, 0x0e, 0xb9, 0xeb, 0x8c, 0x97, 0x42, 0x2a, 0x97, 0x9f, 0x29, 0xd9,
|
||||
0x77, 0x0f, 0xfa, 0x2e, 0xe2, 0xe4, 0x13, 0xaa, 0x7f, 0xd6, 0xf8, 0xbc, 0xa1, 0xf1, 0xb7, 0x09,
|
||||
0xff, 0x5f, 0xf9, 0x73, 0x18, 0x45, 0xa9, 0x58, 0x99, 0x78, 0xa3, 0xe2, 0x72, 0x9a, 0xc4, 0x6b,
|
||||
0x7b, 0x21, 0xcb, 0xc6, 0x85, 0x2c, 0x51, 0x91, 0xc7, 0xd0, 0xfd, 0xa2, 0xad, 0xbe, 0x72, 0x69,
|
||||
0xa3, 0x8d, 0xbe, 0x72, 0x35, 0xdc, 0x7d, 0x66, 0x1f, 0x61, 0xd4, 0x48, 0xe3, 0x56, 0xbe, 0x17,
|
||||
0xd0, 0x8f, 0x6b, 0x98, 0x23, 0x3d, 0xdc, 0x90, 0x36, 0x28, 0x78, 0x13, 0xc8, 0x7e, 0x78, 0x30,
|
||||
0xa8, 0xf4, 0x5a, 0xf2, 0x67, 0xd0, 0x5e, 0x2c, 0xe2, 0x23, 0x7b, 0x8c, 0xfd, 0x09, 0xad, 0x63,
|
||||
0xdb, 0x36, 0xc5, 0x2d, 0xca, 0xa1, 0x27, 0xf6, 0xcc, 0xff, 0x84, 0x9e, 0x38, 0xf4, 0x31, 0x6d,
|
||||
0xfd, 0x05, 0xfa, 0x98, 0x84, 0xe0, 0xc7, 0x9a, 0xf6, 0x76, 0xb0, 0x3b, 0x61, 0x70, 0x3f, 0xd6,
|
||||
0x4c, 0xc0, 0x5e, 0x45, 0x61, 0x8e, 0x5e, 0x27, 0x5a, 0x2c, 0xeb, 0x80, 0x36, 0x3d, 0x79, 0x09,
|
||||
0x83, 0xbc, 0xe1, 0xd5, 0xa5, 0x74, 0xe7, 0x17, 0x1d, 0x96, 0x78, 0x0b, 0xfa, 0x33, 0x00, 0x00,
|
||||
0xff, 0xff, 0x11, 0x3e, 0x7e, 0xb4, 0x0f, 0x05, 0x00, 0x00,
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,97 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// source: fpfresh.proto
|
||||
|
||||
package mmproto
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
math "math"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
type FPFresh struct {
|
||||
BaseReq *BaseRequest `protobuf:"bytes,1,req,name=baseReq" json:"baseReq,omitempty"`
|
||||
SessKey []byte `protobuf:"bytes,2,req,name=sessKey" json:"sessKey,omitempty"`
|
||||
Ztdata *ZTData `protobuf:"bytes,3,req,name=ztdata" json:"ztdata,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *FPFresh) Reset() { *m = FPFresh{} }
|
||||
func (m *FPFresh) String() string { return proto.CompactTextString(m) }
|
||||
func (*FPFresh) ProtoMessage() {}
|
||||
func (*FPFresh) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_f554f0ba3c0431bb, []int{0}
|
||||
}
|
||||
|
||||
func (m *FPFresh) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_FPFresh.Unmarshal(m, b)
|
||||
}
|
||||
func (m *FPFresh) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_FPFresh.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *FPFresh) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_FPFresh.Merge(m, src)
|
||||
}
|
||||
func (m *FPFresh) XXX_Size() int {
|
||||
return xxx_messageInfo_FPFresh.Size(m)
|
||||
}
|
||||
func (m *FPFresh) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_FPFresh.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_FPFresh proto.InternalMessageInfo
|
||||
|
||||
func (m *FPFresh) GetBaseReq() *BaseRequest {
|
||||
if m != nil {
|
||||
return m.BaseReq
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *FPFresh) GetSessKey() []byte {
|
||||
if m != nil {
|
||||
return m.SessKey
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *FPFresh) GetZtdata() *ZTData {
|
||||
if m != nil {
|
||||
return m.Ztdata
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*FPFresh)(nil), "mmproto.FPFresh")
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterFile("fpfresh.proto", fileDescriptor_f554f0ba3c0431bb)
|
||||
}
|
||||
|
||||
var fileDescriptor_f554f0ba3c0431bb = []byte{
|
||||
// 138 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x4d, 0x2b, 0x48, 0x2b,
|
||||
0x4a, 0x2d, 0xce, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0xcf, 0xcd, 0x05, 0x33, 0xa4,
|
||||
0xb8, 0x92, 0x12, 0x8b, 0x53, 0x21, 0x82, 0x4a, 0x35, 0x5c, 0xec, 0x6e, 0x01, 0x6e, 0x20, 0x55,
|
||||
0x42, 0x7a, 0x5c, 0xec, 0x20, 0x89, 0xa0, 0xd4, 0x42, 0x09, 0x46, 0x05, 0x26, 0x0d, 0x6e, 0x23,
|
||||
0x11, 0x3d, 0xa8, 0x0e, 0x3d, 0x27, 0x88, 0x78, 0x69, 0x6a, 0x71, 0x49, 0x10, 0x4c, 0x91, 0x90,
|
||||
0x04, 0x17, 0x7b, 0x71, 0x6a, 0x71, 0xb1, 0x77, 0x6a, 0xa5, 0x04, 0x93, 0x02, 0x93, 0x06, 0x4f,
|
||||
0x10, 0x8c, 0x2b, 0xa4, 0xce, 0xc5, 0x56, 0x55, 0x92, 0x92, 0x58, 0x92, 0x28, 0xc1, 0x0c, 0x36,
|
||||
0x88, 0x1f, 0x6e, 0x50, 0x54, 0x88, 0x4b, 0x62, 0x49, 0x62, 0x10, 0x54, 0x1a, 0x10, 0x00, 0x00,
|
||||
0xff, 0xff, 0x94, 0xe3, 0xc5, 0x83, 0xa2, 0x00, 0x00, 0x00,
|
||||
}
|
||||
@@ -0,0 +1,229 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// source: hybridecdh.proto
|
||||
|
||||
package mmproto
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
math "math"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
type SecKey struct {
|
||||
Nid *int32 `protobuf:"varint,1,req,name=nid" json:"nid,omitempty"`
|
||||
Key []byte `protobuf:"bytes,2,req,name=key" json:"key,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *SecKey) Reset() { *m = SecKey{} }
|
||||
func (m *SecKey) String() string { return proto.CompactTextString(m) }
|
||||
func (*SecKey) ProtoMessage() {}
|
||||
func (*SecKey) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_4c06398fabab09a9, []int{0}
|
||||
}
|
||||
|
||||
func (m *SecKey) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_SecKey.Unmarshal(m, b)
|
||||
}
|
||||
func (m *SecKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_SecKey.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *SecKey) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_SecKey.Merge(m, src)
|
||||
}
|
||||
func (m *SecKey) XXX_Size() int {
|
||||
return xxx_messageInfo_SecKey.Size(m)
|
||||
}
|
||||
func (m *SecKey) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_SecKey.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_SecKey proto.InternalMessageInfo
|
||||
|
||||
func (m *SecKey) GetNid() int32 {
|
||||
if m != nil && m.Nid != nil {
|
||||
return *m.Nid
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *SecKey) GetKey() []byte {
|
||||
if m != nil {
|
||||
return m.Key
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type HybridEcdhReq struct {
|
||||
Version *int32 `protobuf:"varint,1,req,name=version" json:"version,omitempty"`
|
||||
SecKey *SecKey `protobuf:"bytes,2,req,name=secKey" json:"secKey,omitempty"`
|
||||
Gcm1 []byte `protobuf:"bytes,3,req,name=gcm1" json:"gcm1,omitempty"`
|
||||
Autokey []byte `protobuf:"bytes,4,req,name=autokey" json:"autokey,omitempty"`
|
||||
Gcm2 []byte `protobuf:"bytes,5,req,name=gcm2" json:"gcm2,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *HybridEcdhReq) Reset() { *m = HybridEcdhReq{} }
|
||||
func (m *HybridEcdhReq) String() string { return proto.CompactTextString(m) }
|
||||
func (*HybridEcdhReq) ProtoMessage() {}
|
||||
func (*HybridEcdhReq) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_4c06398fabab09a9, []int{1}
|
||||
}
|
||||
|
||||
func (m *HybridEcdhReq) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_HybridEcdhReq.Unmarshal(m, b)
|
||||
}
|
||||
func (m *HybridEcdhReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_HybridEcdhReq.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *HybridEcdhReq) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_HybridEcdhReq.Merge(m, src)
|
||||
}
|
||||
func (m *HybridEcdhReq) XXX_Size() int {
|
||||
return xxx_messageInfo_HybridEcdhReq.Size(m)
|
||||
}
|
||||
func (m *HybridEcdhReq) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_HybridEcdhReq.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_HybridEcdhReq proto.InternalMessageInfo
|
||||
|
||||
func (m *HybridEcdhReq) GetVersion() int32 {
|
||||
if m != nil && m.Version != nil {
|
||||
return *m.Version
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *HybridEcdhReq) GetSecKey() *SecKey {
|
||||
if m != nil {
|
||||
return m.SecKey
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *HybridEcdhReq) GetGcm1() []byte {
|
||||
if m != nil {
|
||||
return m.Gcm1
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *HybridEcdhReq) GetAutokey() []byte {
|
||||
if m != nil {
|
||||
return m.Autokey
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *HybridEcdhReq) GetGcm2() []byte {
|
||||
if m != nil {
|
||||
return m.Gcm2
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type HybridEcdhResp struct {
|
||||
SecKey *SecKey `protobuf:"bytes,1,req,name=secKey" json:"secKey,omitempty"`
|
||||
Version *int32 `protobuf:"varint,2,req,name=version" json:"version,omitempty"`
|
||||
Gcm1 []byte `protobuf:"bytes,3,req,name=gcm1" json:"gcm1,omitempty"`
|
||||
Gcm2 []byte `protobuf:"bytes,4,req,name=gcm2" json:"gcm2,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *HybridEcdhResp) Reset() { *m = HybridEcdhResp{} }
|
||||
func (m *HybridEcdhResp) String() string { return proto.CompactTextString(m) }
|
||||
func (*HybridEcdhResp) ProtoMessage() {}
|
||||
func (*HybridEcdhResp) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_4c06398fabab09a9, []int{2}
|
||||
}
|
||||
|
||||
func (m *HybridEcdhResp) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_HybridEcdhResp.Unmarshal(m, b)
|
||||
}
|
||||
func (m *HybridEcdhResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_HybridEcdhResp.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *HybridEcdhResp) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_HybridEcdhResp.Merge(m, src)
|
||||
}
|
||||
func (m *HybridEcdhResp) XXX_Size() int {
|
||||
return xxx_messageInfo_HybridEcdhResp.Size(m)
|
||||
}
|
||||
func (m *HybridEcdhResp) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_HybridEcdhResp.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_HybridEcdhResp proto.InternalMessageInfo
|
||||
|
||||
func (m *HybridEcdhResp) GetSecKey() *SecKey {
|
||||
if m != nil {
|
||||
return m.SecKey
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *HybridEcdhResp) GetVersion() int32 {
|
||||
if m != nil && m.Version != nil {
|
||||
return *m.Version
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *HybridEcdhResp) GetGcm1() []byte {
|
||||
if m != nil {
|
||||
return m.Gcm1
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *HybridEcdhResp) GetGcm2() []byte {
|
||||
if m != nil {
|
||||
return m.Gcm2
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*SecKey)(nil), "mmproto.SecKey")
|
||||
proto.RegisterType((*HybridEcdhReq)(nil), "mmproto.HybridEcdhReq")
|
||||
proto.RegisterType((*HybridEcdhResp)(nil), "mmproto.HybridEcdhResp")
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterFile("hybridecdh.proto", fileDescriptor_4c06398fabab09a9)
|
||||
}
|
||||
|
||||
var fileDescriptor_4c06398fabab09a9 = []byte{
|
||||
// 201 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xc8, 0xa8, 0x4c, 0x2a,
|
||||
0xca, 0x4c, 0x49, 0x4d, 0x4e, 0xc9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0xcf, 0xcd,
|
||||
0x05, 0x33, 0x94, 0x74, 0xb8, 0xd8, 0x82, 0x53, 0x93, 0xbd, 0x53, 0x2b, 0x85, 0x04, 0xb8, 0x98,
|
||||
0xf3, 0x32, 0x53, 0x24, 0x18, 0x15, 0x98, 0x34, 0x58, 0x83, 0x40, 0x4c, 0x90, 0x48, 0x76, 0x6a,
|
||||
0xa5, 0x04, 0x93, 0x02, 0x93, 0x06, 0x4f, 0x10, 0x88, 0xa9, 0x34, 0x85, 0x91, 0x8b, 0xd7, 0x03,
|
||||
0x6c, 0x96, 0x6b, 0x72, 0x4a, 0x46, 0x50, 0x6a, 0xa1, 0x90, 0x04, 0x17, 0x7b, 0x59, 0x6a, 0x51,
|
||||
0x71, 0x66, 0x7e, 0x1e, 0x54, 0x27, 0x8c, 0x2b, 0xa4, 0xce, 0xc5, 0x56, 0x0c, 0x36, 0x19, 0x6c,
|
||||
0x00, 0xb7, 0x11, 0xbf, 0x1e, 0xd4, 0x4e, 0x3d, 0x88, 0x85, 0x41, 0x50, 0x69, 0x21, 0x21, 0x2e,
|
||||
0x96, 0xf4, 0xe4, 0x5c, 0x43, 0x09, 0x66, 0xb0, 0x3d, 0x60, 0x36, 0xc8, 0xd8, 0xc4, 0xd2, 0x92,
|
||||
0x7c, 0x90, 0xf5, 0x2c, 0x60, 0x61, 0x18, 0x17, 0xaa, 0xda, 0x48, 0x82, 0x15, 0xae, 0xda, 0x48,
|
||||
0xa9, 0x9a, 0x8b, 0x0f, 0xd9, 0x55, 0xc5, 0x05, 0x48, 0x96, 0x33, 0xe2, 0xb7, 0x1c, 0xc9, 0xfd,
|
||||
0x4c, 0xa8, 0xee, 0xc7, 0xe6, 0x2c, 0x98, 0xe5, 0x2c, 0x08, 0xcb, 0x01, 0x01, 0x00, 0x00, 0xff,
|
||||
0xff, 0x9e, 0xd5, 0x09, 0xdb, 0x5d, 0x01, 0x00, 0x00,
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// source: saeinfo.proto
|
||||
|
||||
package mmproto
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
math "math"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
type SaeInfo struct {
|
||||
Ver *string `protobuf:"bytes,1,req,name=ver" json:"ver,omitempty"`
|
||||
InitKey []byte `protobuf:"bytes,2,req,name=initKey" json:"initKey,omitempty"`
|
||||
TotalSize *int32 `protobuf:"varint,3,req,name=totalSize" json:"totalSize,omitempty"`
|
||||
XorKey1 []byte `protobuf:"bytes,9,req,name=xorKey1" json:"xorKey1,omitempty"`
|
||||
Key1 []byte `protobuf:"bytes,10,req,name=key1" json:"key1,omitempty"`
|
||||
XorKey2 []byte `protobuf:"bytes,11,req,name=xorKey2" json:"xorKey2,omitempty"`
|
||||
Key2 []byte `protobuf:"bytes,12,req,name=key2" json:"key2,omitempty"`
|
||||
Key3 []byte `protobuf:"bytes,18,req,name=key3" json:"key3,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *SaeInfo) Reset() { *m = SaeInfo{} }
|
||||
func (m *SaeInfo) String() string { return proto.CompactTextString(m) }
|
||||
func (*SaeInfo) ProtoMessage() {}
|
||||
func (*SaeInfo) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_35810a54fd6e608d, []int{0}
|
||||
}
|
||||
|
||||
func (m *SaeInfo) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_SaeInfo.Unmarshal(m, b)
|
||||
}
|
||||
func (m *SaeInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_SaeInfo.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *SaeInfo) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_SaeInfo.Merge(m, src)
|
||||
}
|
||||
func (m *SaeInfo) XXX_Size() int {
|
||||
return xxx_messageInfo_SaeInfo.Size(m)
|
||||
}
|
||||
func (m *SaeInfo) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_SaeInfo.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_SaeInfo proto.InternalMessageInfo
|
||||
|
||||
func (m *SaeInfo) GetVer() string {
|
||||
if m != nil && m.Ver != nil {
|
||||
return *m.Ver
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *SaeInfo) GetInitKey() []byte {
|
||||
if m != nil {
|
||||
return m.InitKey
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *SaeInfo) GetTotalSize() int32 {
|
||||
if m != nil && m.TotalSize != nil {
|
||||
return *m.TotalSize
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *SaeInfo) GetXorKey1() []byte {
|
||||
if m != nil {
|
||||
return m.XorKey1
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *SaeInfo) GetKey1() []byte {
|
||||
if m != nil {
|
||||
return m.Key1
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *SaeInfo) GetXorKey2() []byte {
|
||||
if m != nil {
|
||||
return m.XorKey2
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *SaeInfo) GetKey2() []byte {
|
||||
if m != nil {
|
||||
return m.Key2
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *SaeInfo) GetKey3() []byte {
|
||||
if m != nil {
|
||||
return m.Key3
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*SaeInfo)(nil), "mmproto.SaeInfo")
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterFile("saeinfo.proto", fileDescriptor_35810a54fd6e608d)
|
||||
}
|
||||
|
||||
var fileDescriptor_35810a54fd6e608d = []byte{
|
||||
// 163 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x2d, 0x4e, 0x4c, 0xcd,
|
||||
0xcc, 0x4b, 0xcb, 0xd7, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0xcf, 0xcd, 0x05, 0x33, 0x94,
|
||||
0x0e, 0x33, 0x72, 0xb1, 0x07, 0x27, 0xa6, 0x7a, 0xe6, 0xa5, 0xe5, 0x0b, 0x09, 0x70, 0x31, 0x97,
|
||||
0xa5, 0x16, 0x49, 0x30, 0x2a, 0x30, 0x69, 0x70, 0x06, 0x81, 0x98, 0x42, 0x12, 0x5c, 0xec, 0x99,
|
||||
0x79, 0x99, 0x25, 0xde, 0xa9, 0x95, 0x12, 0x4c, 0x0a, 0x4c, 0x1a, 0x3c, 0x41, 0x30, 0xae, 0x90,
|
||||
0x0c, 0x17, 0x67, 0x49, 0x7e, 0x49, 0x62, 0x4e, 0x70, 0x66, 0x55, 0xaa, 0x04, 0xb3, 0x02, 0x93,
|
||||
0x06, 0x6b, 0x10, 0x42, 0x00, 0xa4, 0xaf, 0x22, 0xbf, 0xc8, 0x3b, 0xb5, 0xd2, 0x50, 0x82, 0x13,
|
||||
0xa2, 0x0f, 0xca, 0x15, 0x12, 0xe2, 0x62, 0xc9, 0x06, 0x09, 0x73, 0x81, 0x85, 0xc1, 0x6c, 0x84,
|
||||
0x6a, 0x23, 0x09, 0x6e, 0x64, 0xd5, 0x46, 0x50, 0xd5, 0x46, 0x12, 0x3c, 0x70, 0xd5, 0x30, 0x31,
|
||||
0x63, 0x09, 0x21, 0xb8, 0x98, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0xd6, 0x7e, 0xa4, 0xed, 0xde,
|
||||
0x00, 0x00, 0x00,
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,340 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// source: trustInfo.proto
|
||||
|
||||
package mmproto
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
math "math"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
type TrustDeviceInfo struct {
|
||||
Key *string `protobuf:"bytes,1,req,name=Key" json:"Key,omitempty"`
|
||||
Val *string `protobuf:"bytes,2,req,name=val" json:"val,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *TrustDeviceInfo) Reset() { *m = TrustDeviceInfo{} }
|
||||
func (m *TrustDeviceInfo) String() string { return proto.CompactTextString(m) }
|
||||
func (*TrustDeviceInfo) ProtoMessage() {}
|
||||
func (*TrustDeviceInfo) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_efeafd76de4e3385, []int{0}
|
||||
}
|
||||
|
||||
func (m *TrustDeviceInfo) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_TrustDeviceInfo.Unmarshal(m, b)
|
||||
}
|
||||
func (m *TrustDeviceInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_TrustDeviceInfo.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *TrustDeviceInfo) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_TrustDeviceInfo.Merge(m, src)
|
||||
}
|
||||
func (m *TrustDeviceInfo) XXX_Size() int {
|
||||
return xxx_messageInfo_TrustDeviceInfo.Size(m)
|
||||
}
|
||||
func (m *TrustDeviceInfo) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_TrustDeviceInfo.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_TrustDeviceInfo proto.InternalMessageInfo
|
||||
|
||||
func (m *TrustDeviceInfo) GetKey() string {
|
||||
if m != nil && m.Key != nil {
|
||||
return *m.Key
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *TrustDeviceInfo) GetVal() string {
|
||||
if m != nil && m.Val != nil {
|
||||
return *m.Val
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type TrustData struct {
|
||||
Tdi []*TrustDeviceInfo `protobuf:"bytes,1,rep,name=tdi" json:"tdi,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *TrustData) Reset() { *m = TrustData{} }
|
||||
func (m *TrustData) String() string { return proto.CompactTextString(m) }
|
||||
func (*TrustData) ProtoMessage() {}
|
||||
func (*TrustData) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_efeafd76de4e3385, []int{1}
|
||||
}
|
||||
|
||||
func (m *TrustData) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_TrustData.Unmarshal(m, b)
|
||||
}
|
||||
func (m *TrustData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_TrustData.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *TrustData) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_TrustData.Merge(m, src)
|
||||
}
|
||||
func (m *TrustData) XXX_Size() int {
|
||||
return xxx_messageInfo_TrustData.Size(m)
|
||||
}
|
||||
func (m *TrustData) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_TrustData.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_TrustData proto.InternalMessageInfo
|
||||
|
||||
func (m *TrustData) GetTdi() []*TrustDeviceInfo {
|
||||
if m != nil {
|
||||
return m.Tdi
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type TrustReq struct {
|
||||
Td *TrustData `protobuf:"bytes,1,req,name=td" json:"td,omitempty"`
|
||||
Md *string `protobuf:"bytes,2,opt,name=md" json:"md,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *TrustReq) Reset() { *m = TrustReq{} }
|
||||
func (m *TrustReq) String() string { return proto.CompactTextString(m) }
|
||||
func (*TrustReq) ProtoMessage() {}
|
||||
func (*TrustReq) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_efeafd76de4e3385, []int{2}
|
||||
}
|
||||
|
||||
func (m *TrustReq) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_TrustReq.Unmarshal(m, b)
|
||||
}
|
||||
func (m *TrustReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_TrustReq.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *TrustReq) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_TrustReq.Merge(m, src)
|
||||
}
|
||||
func (m *TrustReq) XXX_Size() int {
|
||||
return xxx_messageInfo_TrustReq.Size(m)
|
||||
}
|
||||
func (m *TrustReq) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_TrustReq.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_TrustReq proto.InternalMessageInfo
|
||||
|
||||
func (m *TrustReq) GetTd() *TrustData {
|
||||
if m != nil {
|
||||
return m.Td
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *TrustReq) GetMd() string {
|
||||
if m != nil && m.Md != nil {
|
||||
return *m.Md
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type TrustSoftData struct {
|
||||
SoftConfig []byte `protobuf:"bytes,1,req,name=softConfig" json:"softConfig,omitempty"`
|
||||
SoftData []byte `protobuf:"bytes,2,req,name=softData" json:"softData,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *TrustSoftData) Reset() { *m = TrustSoftData{} }
|
||||
func (m *TrustSoftData) String() string { return proto.CompactTextString(m) }
|
||||
func (*TrustSoftData) ProtoMessage() {}
|
||||
func (*TrustSoftData) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_efeafd76de4e3385, []int{3}
|
||||
}
|
||||
|
||||
func (m *TrustSoftData) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_TrustSoftData.Unmarshal(m, b)
|
||||
}
|
||||
func (m *TrustSoftData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_TrustSoftData.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *TrustSoftData) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_TrustSoftData.Merge(m, src)
|
||||
}
|
||||
func (m *TrustSoftData) XXX_Size() int {
|
||||
return xxx_messageInfo_TrustSoftData.Size(m)
|
||||
}
|
||||
func (m *TrustSoftData) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_TrustSoftData.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_TrustSoftData proto.InternalMessageInfo
|
||||
|
||||
func (m *TrustSoftData) GetSoftConfig() []byte {
|
||||
if m != nil {
|
||||
return m.SoftConfig
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *TrustSoftData) GetSoftData() []byte {
|
||||
if m != nil {
|
||||
return m.SoftData
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type TrustResponseData struct {
|
||||
SoftData *TrustSoftData `protobuf:"bytes,2,req,name=softData" json:"softData,omitempty"`
|
||||
DeviceToken *string `protobuf:"bytes,3,req,name=deviceToken" json:"deviceToken,omitempty"`
|
||||
TimeStamp *uint32 `protobuf:"varint,4,req,name=timeStamp" json:"timeStamp,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *TrustResponseData) Reset() { *m = TrustResponseData{} }
|
||||
func (m *TrustResponseData) String() string { return proto.CompactTextString(m) }
|
||||
func (*TrustResponseData) ProtoMessage() {}
|
||||
func (*TrustResponseData) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_efeafd76de4e3385, []int{4}
|
||||
}
|
||||
|
||||
func (m *TrustResponseData) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_TrustResponseData.Unmarshal(m, b)
|
||||
}
|
||||
func (m *TrustResponseData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_TrustResponseData.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *TrustResponseData) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_TrustResponseData.Merge(m, src)
|
||||
}
|
||||
func (m *TrustResponseData) XXX_Size() int {
|
||||
return xxx_messageInfo_TrustResponseData.Size(m)
|
||||
}
|
||||
func (m *TrustResponseData) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_TrustResponseData.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_TrustResponseData proto.InternalMessageInfo
|
||||
|
||||
func (m *TrustResponseData) GetSoftData() *TrustSoftData {
|
||||
if m != nil {
|
||||
return m.SoftData
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *TrustResponseData) GetDeviceToken() string {
|
||||
if m != nil && m.DeviceToken != nil {
|
||||
return *m.DeviceToken
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *TrustResponseData) GetTimeStamp() uint32 {
|
||||
if m != nil && m.TimeStamp != nil {
|
||||
return *m.TimeStamp
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type TrustResponse struct {
|
||||
BaseResponse *BaseResponse `protobuf:"bytes,1,req,name=BaseResponse" json:"BaseResponse,omitempty"`
|
||||
TrustResponseData *TrustResponseData `protobuf:"bytes,2,req,name=TrustResponseData" json:"TrustResponseData,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *TrustResponse) Reset() { *m = TrustResponse{} }
|
||||
func (m *TrustResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*TrustResponse) ProtoMessage() {}
|
||||
func (*TrustResponse) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_efeafd76de4e3385, []int{5}
|
||||
}
|
||||
|
||||
func (m *TrustResponse) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_TrustResponse.Unmarshal(m, b)
|
||||
}
|
||||
func (m *TrustResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_TrustResponse.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *TrustResponse) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_TrustResponse.Merge(m, src)
|
||||
}
|
||||
func (m *TrustResponse) XXX_Size() int {
|
||||
return xxx_messageInfo_TrustResponse.Size(m)
|
||||
}
|
||||
func (m *TrustResponse) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_TrustResponse.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_TrustResponse proto.InternalMessageInfo
|
||||
|
||||
func (m *TrustResponse) GetBaseResponse() *BaseResponse {
|
||||
if m != nil {
|
||||
return m.BaseResponse
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *TrustResponse) GetTrustResponseData() *TrustResponseData {
|
||||
if m != nil {
|
||||
return m.TrustResponseData
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*TrustDeviceInfo)(nil), "mmproto.TrustDeviceInfo")
|
||||
proto.RegisterType((*TrustData)(nil), "mmproto.TrustData")
|
||||
proto.RegisterType((*TrustReq)(nil), "mmproto.TrustReq")
|
||||
proto.RegisterType((*TrustSoftData)(nil), "mmproto.TrustSoftData")
|
||||
proto.RegisterType((*TrustResponseData)(nil), "mmproto.TrustResponseData")
|
||||
proto.RegisterType((*TrustResponse)(nil), "mmproto.TrustResponse")
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterFile("trustInfo.proto", fileDescriptor_efeafd76de4e3385)
|
||||
}
|
||||
|
||||
var fileDescriptor_efeafd76de4e3385 = []byte{
|
||||
// 312 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x50, 0xcf, 0x4a, 0xfb, 0x30,
|
||||
0x1c, 0xa7, 0xe9, 0x0f, 0x7e, 0xeb, 0xb7, 0x9b, 0xd3, 0x80, 0x12, 0x86, 0x48, 0xc9, 0xa9, 0x78,
|
||||
0xd8, 0xa1, 0x20, 0xe2, 0xc5, 0x83, 0x7a, 0x50, 0x76, 0xcb, 0xf6, 0x02, 0xd1, 0xa4, 0x52, 0x5c,
|
||||
0x9a, 0xba, 0xc4, 0x82, 0x4f, 0xe0, 0x0b, 0xf8, 0xc0, 0xd2, 0x34, 0xdd, 0xda, 0xea, 0x2d, 0xf9,
|
||||
0xe4, 0xf3, 0x37, 0x30, 0xb7, 0xbb, 0x0f, 0x63, 0x9f, 0xca, 0x5c, 0x2f, 0xab, 0x9d, 0xb6, 0x1a,
|
||||
0xff, 0x57, 0xca, 0x1d, 0x16, 0xf0, 0xcc, 0x8d, 0x6c, 0x41, 0x7a, 0x05, 0xf3, 0x4d, 0xc3, 0x7b,
|
||||
0x90, 0x75, 0xf1, 0x22, 0x1b, 0x36, 0x3e, 0x86, 0x70, 0x25, 0x3f, 0x49, 0x90, 0xa0, 0x34, 0x62,
|
||||
0xcd, 0xb1, 0x41, 0x6a, 0xbe, 0x25, 0xa8, 0x45, 0x6a, 0xbe, 0xa5, 0xd7, 0x10, 0xb5, 0x32, 0x6e,
|
||||
0x39, 0xbe, 0x84, 0xd0, 0x8a, 0x82, 0x04, 0x49, 0x98, 0xc6, 0x19, 0x59, 0xfa, 0x98, 0xe5, 0xc8,
|
||||
0x97, 0x35, 0x24, 0x7a, 0x0b, 0x13, 0x87, 0x33, 0xf9, 0x8e, 0x29, 0x20, 0x2b, 0x5c, 0x4e, 0x9c,
|
||||
0xe1, 0x91, 0x8c, 0x5b, 0xce, 0x90, 0x15, 0xf8, 0x08, 0x90, 0x12, 0x04, 0x25, 0x41, 0x1a, 0x31,
|
||||
0xa4, 0x04, 0x5d, 0xc1, 0xcc, 0x11, 0xd6, 0x3a, 0x6f, 0xc3, 0x2f, 0x00, 0x8c, 0xce, 0xed, 0xbd,
|
||||
0x2e, 0xf3, 0xe2, 0xd5, 0x99, 0x4d, 0x59, 0x0f, 0xc1, 0x0b, 0x98, 0x18, 0xcf, 0x75, 0x03, 0xa6,
|
||||
0x6c, 0x7f, 0xa7, 0x5f, 0x01, 0x9c, 0xf8, 0x36, 0xa6, 0xd2, 0xa5, 0x91, 0xce, 0x31, 0x1b, 0x29,
|
||||
0xe2, 0xec, 0x6c, 0x58, 0xae, 0xcb, 0x3e, 0x38, 0xe1, 0x04, 0x62, 0xe1, 0x96, 0x6e, 0xf4, 0x9b,
|
||||
0x2c, 0x49, 0xe8, 0x7e, 0xaa, 0x0f, 0xe1, 0x73, 0x88, 0x6c, 0xa1, 0xe4, 0xda, 0x72, 0x55, 0x91,
|
||||
0x7f, 0x09, 0x4a, 0x67, 0xec, 0x00, 0xd0, 0xef, 0xc0, 0xef, 0xea, 0x9a, 0xe0, 0x1b, 0x98, 0xde,
|
||||
0x71, 0x23, 0xbb, 0xbb, 0xff, 0xa6, 0xd3, 0x7d, 0x93, 0xfe, 0x23, 0x1b, 0x50, 0xf1, 0xe3, 0x1f,
|
||||
0xab, 0xfc, 0x92, 0xc5, 0x70, 0x49, 0x9f, 0xc1, 0x7e, 0x8b, 0x7e, 0x02, 0x00, 0x00, 0xff, 0xff,
|
||||
0x48, 0x36, 0x78, 0x61, 0x44, 0x02, 0x00, 0x00,
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package android
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"crypto/sha1"
|
||||
"encoding/hex"
|
||||
)
|
||||
|
||||
// CalcMsgCrc calc msg hash
|
||||
func CalcMsgCrc(data []byte) int {
|
||||
|
||||
salt1 := [16]byte{0x5c, 0x50, 0x7b, 0x6b, 0x65, 0x4a, 0x13, 0x09, 0x45, 0x58, 0x7e, 0x11, 0x0c, 0x1f, 0x68, 0x79}
|
||||
salt2 := [16]byte{0x36, 0x3a, 0x11, 0x01, 0x0f, 0x20, 0x79, 0x63, 0x2f, 0x32, 0x14, 0x7b, 0x66, 0x75, 0x02, 0x13}
|
||||
|
||||
pad1 := [0x30]byte{
|
||||
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
|
||||
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
|
||||
0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
|
||||
}
|
||||
|
||||
pad2 := [0x30]byte{
|
||||
0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c,
|
||||
0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c,
|
||||
0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c,
|
||||
}
|
||||
|
||||
md5hash := md5.Sum(data)
|
||||
hashstr := hex.EncodeToString(md5hash[:])
|
||||
|
||||
hash1Data := make([]byte, 16)
|
||||
copy(hash1Data, salt1[:])
|
||||
hash1Data = append(hash1Data, pad1[:]...)
|
||||
|
||||
hash1 := sha1.New()
|
||||
hash1.Write(hash1Data)
|
||||
hash1.Write([]byte(hashstr))
|
||||
h1 := hash1.Sum(nil)
|
||||
|
||||
hash2Data := make([]byte, 16)
|
||||
copy(hash2Data, salt2[:])
|
||||
hash2Data = append(hash2Data, pad2[:]...)
|
||||
|
||||
hash2 := sha1.New()
|
||||
hash2.Write(hash2Data)
|
||||
hash2.Write(h1)
|
||||
h2 := hash2.Sum(nil)
|
||||
|
||||
var b1, b2, b3 byte
|
||||
size := len(h2)
|
||||
|
||||
for i := 0; i < size-2; i++ {
|
||||
b1 = h2[i+0] - b1*0x7d
|
||||
b2 = h2[i+1] - b2*0x7d
|
||||
b3 = h2[i+2] - b3*0x7d
|
||||
}
|
||||
|
||||
return (int(0x21) << 24) | ((int(b3) & 0x7f) << 16) | ((int(b2) & 0x7f) << 8) | (int(b1) & 0x7f)
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
package android
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"compress/zlib"
|
||||
"encoding/binary"
|
||||
"io"
|
||||
|
||||
"github.com/golang/protobuf/proto"
|
||||
)
|
||||
|
||||
type PacketHeader struct {
|
||||
PacketCryptType byte
|
||||
Flag uint16
|
||||
RetCode uint32
|
||||
UICrypt uint32
|
||||
Uin uint32
|
||||
Cookies []byte
|
||||
Data []byte
|
||||
}
|
||||
|
||||
func DoZlibCompress(src []byte) []byte {
|
||||
|
||||
var in bytes.Buffer
|
||||
w := zlib.NewWriter(&in)
|
||||
w.Write(src)
|
||||
w.Close()
|
||||
return in.Bytes()
|
||||
}
|
||||
|
||||
// 进行zlib解压缩
|
||||
func DoZlibUnCompress(compressSrc []byte) []byte {
|
||||
b := bytes.NewReader(compressSrc)
|
||||
var out bytes.Buffer
|
||||
r, _ := zlib.NewReader(b)
|
||||
io.Copy(&out, r)
|
||||
return out.Bytes()
|
||||
}
|
||||
|
||||
func PackHybridEcdh(cmdid, cert, uin uint32, cookie, input []byte) []byte {
|
||||
|
||||
inputlen := len(input)
|
||||
|
||||
crc := CalcMsgCrc(input)
|
||||
pack := append([]byte{}, cookie...)
|
||||
pack = proto.EncodeVarint(uint64(cmdid))
|
||||
pack = append(pack, proto.EncodeVarint(uint64(inputlen))...)
|
||||
pack = append(pack, proto.EncodeVarint(uint64(inputlen))...)
|
||||
pack = append(pack, proto.EncodeVarint(uint64(cert))...)
|
||||
pack = append(pack, 2)
|
||||
pack = append(pack, 0)
|
||||
pack = append(pack, 0xfe)
|
||||
pack = append(pack, proto.EncodeVarint(uint64(crc))...)
|
||||
pack = append(pack, 0)
|
||||
|
||||
headLen := len(pack) + 11
|
||||
headFlag := (12 << 12) | (len(cookie) << 8) | (headLen << 2) | 2
|
||||
|
||||
var hybridpack = new(bytes.Buffer)
|
||||
hybridpack.WriteByte(0xbf)
|
||||
binary.Write(hybridpack, binary.LittleEndian, uint16(headFlag))
|
||||
binary.Write(hybridpack, binary.BigEndian, uint32(0x27000b32))
|
||||
binary.Write(hybridpack, binary.BigEndian, uint32(uin))
|
||||
hybridpack.Write(pack)
|
||||
hybridpack.Write(input)
|
||||
|
||||
return hybridpack.Bytes()
|
||||
}
|
||||
|
||||
func UnpackHybridEcdh(input []byte) *PacketHeader {
|
||||
|
||||
var ph PacketHeader
|
||||
readHeader := bytes.NewReader(input)
|
||||
binary.Read(readHeader, binary.LittleEndian, &ph.PacketCryptType)
|
||||
binary.Read(readHeader, binary.LittleEndian, &ph.Flag)
|
||||
|
||||
cookieLen := (ph.Flag >> 8) & 0x0f
|
||||
headerLen := (ph.Flag & 0xff) >> 2
|
||||
ph.Cookies = make([]byte, cookieLen)
|
||||
binary.Read(readHeader, binary.BigEndian, &ph.RetCode)
|
||||
binary.Read(readHeader, binary.BigEndian, &ph.UICrypt)
|
||||
binary.Read(readHeader, binary.LittleEndian, &ph.Cookies)
|
||||
ph.Data = input[headerLen:]
|
||||
|
||||
return &ph
|
||||
}
|
||||
|
||||
func Pack(cmdid, cert, algo, uin uint32, cookies, authecdhkey, sesskey, input []byte) []byte {
|
||||
|
||||
inputlen := len(input)
|
||||
|
||||
crc := CalcMsgCrc(input)
|
||||
sign := GenSignature(uin, authecdhkey, input)
|
||||
|
||||
b := new(bytes.Buffer)
|
||||
binary.Write(b, binary.BigEndian, uin)
|
||||
b.Write(cookies)
|
||||
b.Write(proto.EncodeVarint(uint64(cmdid)))
|
||||
b.Write(proto.EncodeVarint(uint64(inputlen)))
|
||||
b.Write(proto.EncodeVarint(uint64(inputlen)))
|
||||
b.Write(proto.EncodeVarint(uint64(cert)))
|
||||
b.Write(proto.EncodeVarint(uint64(2)))
|
||||
b.Write(proto.EncodeVarint(uint64(sign)))
|
||||
b.Write([]byte{0xfe})
|
||||
b.Write(proto.EncodeVarint(uint64(crc)))
|
||||
b.Write([]byte{0x00})
|
||||
|
||||
var encData []byte
|
||||
var compress uint32
|
||||
if algo == 5 {
|
||||
encData = EncryptAES(input, sesskey)
|
||||
compress = 2
|
||||
}
|
||||
|
||||
subHead := b.Bytes()
|
||||
flag := (algo << 12) | (uint32(len(cookies)) << 8) | ((7 + uint32(len(subHead))) << 2) | compress
|
||||
|
||||
bb := new(bytes.Buffer)
|
||||
bb.Write([]byte{0xbf})
|
||||
binary.Write(bb, binary.LittleEndian, uint16(flag))
|
||||
binary.Write(bb, binary.BigEndian, uint32(0x27000b32))
|
||||
bb.Write(subHead)
|
||||
bb.Write(encData)
|
||||
|
||||
return bb.Bytes()
|
||||
}
|
||||
|
||||
func Unpack(input, key []byte) *PacketHeader {
|
||||
|
||||
var ph PacketHeader
|
||||
readHeader := bytes.NewReader(input)
|
||||
binary.Read(readHeader, binary.LittleEndian, &ph.PacketCryptType)
|
||||
binary.Read(readHeader, binary.LittleEndian, &ph.Flag)
|
||||
|
||||
cookieLen := (ph.Flag >> 8) & 0x0f
|
||||
headerLen := (ph.Flag & 0xff) >> 2
|
||||
algo := ph.Flag >> 12
|
||||
comp := ph.Flag & 3
|
||||
|
||||
ph.Cookies = make([]byte, cookieLen)
|
||||
binary.Read(readHeader, binary.BigEndian, &ph.RetCode)
|
||||
binary.Read(readHeader, binary.BigEndian, &ph.UICrypt)
|
||||
binary.Read(readHeader, binary.LittleEndian, &ph.Cookies)
|
||||
Data := input[headerLen:]
|
||||
|
||||
var DecData []byte
|
||||
if algo == 5 {
|
||||
DecData = DecryptAES(Data, key)
|
||||
}
|
||||
|
||||
if comp == 1 {
|
||||
ph.Data = DoZlibUnCompress(DecData)
|
||||
} else {
|
||||
ph.Data = DecData
|
||||
}
|
||||
|
||||
return &ph
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package android
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/elliptic"
|
||||
"crypto/md5"
|
||||
"crypto/rand"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"hash/adler32"
|
||||
"io"
|
||||
"time"
|
||||
)
|
||||
|
||||
func RandBytes(size int) []byte {
|
||||
|
||||
r := make([]byte, size)
|
||||
n, err := io.ReadFull(rand.Reader, r)
|
||||
if err != nil || n != size {
|
||||
fmt.Println("Gen rand faile")
|
||||
return nil
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func Gen713Key() ([]byte, []byte) {
|
||||
|
||||
priv, x, y, _ := elliptic.GenerateKey(elliptic.P224(), rand.Reader)
|
||||
|
||||
pub := elliptic.Marshal(elliptic.P224(), x, y)
|
||||
|
||||
return pub, priv
|
||||
}
|
||||
|
||||
func Do713Ecdh(pub, priv []byte) []byte {
|
||||
curve := elliptic.P224()
|
||||
x, y := elliptic.Unmarshal(curve, pub)
|
||||
if x == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
xShared, _ := curve.ScalarMult(x, y, priv)
|
||||
sharedKey := make([]byte, (curve.Params().BitSize+7)>>3)
|
||||
xBytes := xShared.Bytes()
|
||||
copy(sharedKey[len(sharedKey)-len(xBytes):], xBytes)
|
||||
|
||||
dh := md5.Sum(sharedKey)
|
||||
return dh[:]
|
||||
}
|
||||
|
||||
func GenSignature(uiCryptin uint32, salt, data []byte) uint32 {
|
||||
|
||||
var b1 bytes.Buffer
|
||||
binary.Write(&b1, binary.BigEndian, uiCryptin)
|
||||
|
||||
h1 := md5.New()
|
||||
h1.Write(b1.Bytes())
|
||||
h1.Write(salt)
|
||||
sum1 := h1.Sum(nil)
|
||||
|
||||
dataSize := len(data)
|
||||
var b2 bytes.Buffer
|
||||
binary.Write(&b2, binary.BigEndian, dataSize)
|
||||
|
||||
h2 := md5.New()
|
||||
h2.Write(b2.Bytes())
|
||||
h2.Write(salt)
|
||||
h2.Write(sum1)
|
||||
sum2 := h2.Sum(nil)
|
||||
|
||||
a := adler32.New()
|
||||
a.Write(nil)
|
||||
a.Write(sum2)
|
||||
a.Write(data)
|
||||
|
||||
return a.Sum32()
|
||||
}
|
||||
|
||||
func GenUUID() string {
|
||||
|
||||
randomData := make([]byte, 0x100)
|
||||
io.ReadFull(rand.Reader, randomData)
|
||||
|
||||
h := md5.New()
|
||||
h.Write(randomData)
|
||||
|
||||
nanoTime := time.Now().UnixNano()
|
||||
secTime := time.Now().Unix()
|
||||
|
||||
h.Write([]byte(fmt.Sprintf("%v_%v", secTime, nanoTime)))
|
||||
sum := h.Sum(nil)
|
||||
|
||||
return fmt.Sprintf("%x-%x-%x-%x-%x", sum[:4], sum[4:6], sum[6:8], sum[8:10], sum[10:])
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,266 @@
|
||||
package android
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/aes"
|
||||
"crypto/cipher"
|
||||
"encoding/hex"
|
||||
)
|
||||
|
||||
var Sea06_Data, _ = hex.DecodeString(SeaDatIpad)
|
||||
var Sea01_Data, _ = hex.DecodeString(SeaDatAndroid)
|
||||
|
||||
//////////////////////////////////////////////// sae06加密 /////////////////////////////////////////////////////
|
||||
|
||||
func SaeEncrypt06(data []byte) []byte {
|
||||
sae := Sea06_Data
|
||||
in_bytes := data
|
||||
in_len := len(data)
|
||||
xor := sae[9:25]
|
||||
input_val := []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
output_val := []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
var result []byte
|
||||
for i := 0; i < in_len/16; i++ {
|
||||
for j := 0; j < 16; j++ {
|
||||
input_val[j] = xor[j] ^ in_bytes[i*16+j]
|
||||
}
|
||||
output_val = DoEncryptInput(input_val, sae)
|
||||
xor = output_val
|
||||
result = BytesCombine1(result, output_val)
|
||||
input_val = []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
output_val = []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func PKCS7Padding(ciphertext []byte, blockSize int) []byte {
|
||||
padding := blockSize - len(ciphertext)%blockSize
|
||||
padtext := bytes.Repeat([]byte{byte(padding)}, padding)
|
||||
return append(ciphertext, padtext...)
|
||||
}
|
||||
|
||||
// todo
|
||||
// new sae 白盒aes加密
|
||||
func SaeEncrypt07(data []byte) []byte {
|
||||
var key, iv []byte
|
||||
|
||||
key, _ = hex.DecodeString("24E545FC309F1CC92B0223FAFA8C84F4")
|
||||
iv, _ = hex.DecodeString("6d1f24b8e29268d6efbf55cafb27d3bf")
|
||||
block, err := aes.NewCipher(key)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
blockMode := cipher.NewCBCEncrypter(block, iv)
|
||||
src := PKCS7Padding(data, block.BlockSize())
|
||||
origData := make([]byte, len(src))
|
||||
blockMode.CryptBlocks(origData, src)
|
||||
return origData
|
||||
}
|
||||
|
||||
func SaeEncrypt01(data []byte) []byte {
|
||||
sae := Sea01_Data
|
||||
in_bytes := data
|
||||
in_len := len(data)
|
||||
xor := sae[9:25]
|
||||
input_val := []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
output_val := []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
var result []byte
|
||||
for i := 0; i < int(in_len/16); i++ {
|
||||
for j := 0; j < 16; j++ {
|
||||
input_val[j] = xor[j] ^ in_bytes[i*16+j]
|
||||
}
|
||||
output_val = DoEncryptInput(input_val, sae)
|
||||
xor = output_val
|
||||
result = BytesCombine1(result, output_val)
|
||||
input_val = []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
output_val = []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func DoEncryptInput(input_val, sae_val []byte) []byte {
|
||||
in_p := input_val
|
||||
output := []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
for i := 0; i < 4; i++ {
|
||||
for j := 0; j < 4; j++ {
|
||||
output[i*4+j] = in_p[j*4+i]
|
||||
}
|
||||
}
|
||||
pos := -0x24000
|
||||
sae_pos := 0x82030
|
||||
for {
|
||||
output = LeftShift(output, 4, 1)
|
||||
output = LeftShift(output, 8, 2)
|
||||
output = LeftShift(output, 12, 3)
|
||||
if pos < 0 {
|
||||
buf := []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
buf = Sub106c03420(buf, output, sae_val[0x43030+pos:])
|
||||
output = Sub106c036a8(output, buf, sae_val[sae_pos-0x3f000:])
|
||||
sae_pos = sae_pos + 0x3000
|
||||
pos = pos + 0x4000
|
||||
continue
|
||||
}
|
||||
break
|
||||
}
|
||||
result := Sub106c0397c(output, sae_val[0xbc030:])
|
||||
result_p := []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
for i := 0; i < 0x10; i++ {
|
||||
result_p[i] = result[int(i/4)+int((i%4)*4)]
|
||||
}
|
||||
return result_p
|
||||
}
|
||||
|
||||
func LeftShift(data []byte, offset, distance int) []byte {
|
||||
|
||||
/*左轮转
|
||||
:param data: 需要被轮转的数据
|
||||
:param offset: 偏移量
|
||||
:param distance: 轮转距离
|
||||
:return 轮转结果*/
|
||||
|
||||
for i := 0; i < distance; i++ {
|
||||
tmp := data[offset]
|
||||
data[offset] = data[1+offset]
|
||||
data[1+offset] = data[2+offset]
|
||||
data[2+offset] = data[3+offset]
|
||||
data[3+offset] = tmp
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
func Sub106c03420(buf, data, sae []byte) []byte {
|
||||
//sae06字典加密
|
||||
v3 := 0
|
||||
buf_pos := 0
|
||||
sae_pos := 0
|
||||
for {
|
||||
if v3 == 4 {
|
||||
break
|
||||
}
|
||||
v4 := 0
|
||||
v5 := buf_pos
|
||||
v6 := sae_pos
|
||||
for {
|
||||
if v4 == 4 {
|
||||
break
|
||||
}
|
||||
v7 := 0
|
||||
v8 := v6
|
||||
for {
|
||||
if v7 == 0x40 {
|
||||
break
|
||||
}
|
||||
buf[v5+v7] = sae[v8+4*int(data[4*v3+v4])] //根据data序列查字典, 结果放入buf
|
||||
v8 = v8 + 1
|
||||
v7 = v7 + 0x10
|
||||
}
|
||||
v4 = v4 + 1
|
||||
v6 = v6 + 0x400
|
||||
v5 = v5 + 4
|
||||
}
|
||||
v3 = v3 + 1
|
||||
sae_pos = sae_pos + 0x1000
|
||||
buf_pos = buf_pos + 1
|
||||
}
|
||||
return buf
|
||||
}
|
||||
|
||||
func Sub106c036a8(data, buf, sae []byte) []byte {
|
||||
v3 := 0
|
||||
v4 := 0
|
||||
v5 := 0
|
||||
v6 := 0x200
|
||||
v7 := 0
|
||||
for {
|
||||
if v5 == 4 {
|
||||
break
|
||||
}
|
||||
v8 := 0
|
||||
v14 := v6
|
||||
v9 := v7
|
||||
for {
|
||||
if v8 == 4 {
|
||||
break
|
||||
}
|
||||
result := buf[v3+16*v5+4*v8+3]
|
||||
v11 := v4 + 4*v5 + v8
|
||||
data[v11] = result
|
||||
v12 := v6
|
||||
v13 := 2
|
||||
for {
|
||||
if v13 == -1 {
|
||||
break
|
||||
}
|
||||
result = Sub106c033bc(buf[v9+v13], result, sae[v12:])
|
||||
data[v11] = result
|
||||
v13 = v13 - 1
|
||||
v12 = v12 - 0x100
|
||||
}
|
||||
v8 = v8 + 1
|
||||
v9 = v9 + 4
|
||||
v6 = v6 + 0x300
|
||||
}
|
||||
v5 = v5 + 1
|
||||
v7 = v7 + 0x10
|
||||
v6 = v14 + 0xc00
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
func Sub106c033bc(a1 byte, a2 byte, sae []byte) byte {
|
||||
temp := 0xffffff0f
|
||||
v3 := (a1 & 0xf0) | (a2 >> 4)
|
||||
if v3&0x80 != 0 {
|
||||
v3 = sae[(0+(v3&0x7f))] >> 4
|
||||
} else {
|
||||
v3 = sae[(0+v3)] & 0xf
|
||||
}
|
||||
v4 := ((a2 & 0xf) | 0x10*a1) & 0xff
|
||||
var v5 byte
|
||||
if v4&0x80 != 0 {
|
||||
v5 = sae[(0+int(v4&0x7f)+0x80)] >> 4
|
||||
} else {
|
||||
v5 = sae[(0+int(v4&0xff)+0x80)] & 0xf
|
||||
}
|
||||
return (v5 & uint8(temp)) | 0x10*(v3&0xf)
|
||||
}
|
||||
|
||||
func Sub106c0397c(output, sae []byte) []byte {
|
||||
v3 := 0
|
||||
v5 := 0
|
||||
result := []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
v4 := 0
|
||||
for {
|
||||
if v3 == 4 {
|
||||
break
|
||||
}
|
||||
v6 := 0
|
||||
v7 := 0
|
||||
for {
|
||||
if v6 == 4 {
|
||||
break
|
||||
}
|
||||
result[v4+v6] = sae[v7+int(output[v5+v6])]
|
||||
v6 = v6 + 1
|
||||
v7 = v7 + 0x100
|
||||
}
|
||||
v3 = v3 + 1
|
||||
v5 = v5 + 4
|
||||
sae = sae[0x400:]
|
||||
v4 = v4 + 4
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func BytesCombine1(pBytes ...[]byte) []byte {
|
||||
length := len(pBytes)
|
||||
s := make([][]byte, length)
|
||||
for index := 0; index < length; index++ {
|
||||
s[index] = pBytes[index]
|
||||
}
|
||||
sep := []byte("")
|
||||
return bytes.Join(s, sep)
|
||||
}
|
||||
@@ -0,0 +1,216 @@
|
||||
package android
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"xiawan/wx/protobuf/wechat"
|
||||
)
|
||||
|
||||
// ZT SS
|
||||
type ZT struct {
|
||||
ver string
|
||||
initKey []byte
|
||||
totalSize int32
|
||||
xorKey1 []byte
|
||||
key1 []byte
|
||||
xorKey2 []byte
|
||||
key2 []byte
|
||||
key3 []byte
|
||||
}
|
||||
|
||||
// Init s
|
||||
func (z *ZT) Init() {
|
||||
saeData, _ := hex.DecodeString(SeaDatAndroidOld)
|
||||
saePB := new(wechat.SaeInfoAndroid)
|
||||
proto.Unmarshal(saeData, saePB)
|
||||
z.ver = saePB.GetVer()
|
||||
z.initKey = saePB.GetInitKey()
|
||||
z.totalSize = saePB.GetTotalSize()
|
||||
z.xorKey1 = saePB.GetXorKey1()
|
||||
z.key1 = saePB.GetKey1()
|
||||
z.xorKey2 = saePB.GetXorKey2()
|
||||
z.key2 = saePB.GetKey2()
|
||||
z.key3 = saePB.GetKey3()
|
||||
}
|
||||
|
||||
func (z *ZT) chooseKey(in, key []byte) []byte {
|
||||
|
||||
var randKey [4][4][4]byte
|
||||
|
||||
for i := 0; i < 4; i++ {
|
||||
for j := 0; j < 4; j++ {
|
||||
for k := 0; k < 4; k++ {
|
||||
randKey[k][j][i] = key[i*0x1000+j*0x400+int(in[i*4+j])*4+k]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var ret []byte
|
||||
for i := 0; i < 4; i++ {
|
||||
for j := 0; j < 4; j++ {
|
||||
for k := 0; k < 4; k++ {
|
||||
ret = append(ret, randKey[i][j][k])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
func (z *ZT) chooseKey2Sub(a, b byte, key []byte) byte {
|
||||
var keySub1 = (a & 0xf0) | (b >> 4)
|
||||
if (keySub1 & 0x80) != 0 {
|
||||
keySub1 = key[keySub1&0x7f] >> 4
|
||||
} else {
|
||||
keySub1 = key[keySub1] & 0xf
|
||||
}
|
||||
|
||||
var keySub2 = ((a & 0xf) << 4) | (b & 0xf)
|
||||
if (keySub2 & 0x80) != 0 {
|
||||
keySub2 = key[keySub2&0x7f+0x80] >> 4
|
||||
} else {
|
||||
keySub2 = key[keySub2+0x80] & 0x0f
|
||||
}
|
||||
|
||||
return ((keySub1 & 0xf) << 4) | (keySub2 & 0x0f)
|
||||
}
|
||||
|
||||
func (z *ZT) chooseKey2(keyA, keyB []byte) []byte {
|
||||
|
||||
result := make([]byte, 16)
|
||||
|
||||
for k := 0; k < 4; k++ {
|
||||
for j := 0; j < 4; j++ {
|
||||
|
||||
result[4*k+j] = keyA[16*k+4*j+3]
|
||||
offset := 0
|
||||
for i := 2; i != -1; i-- {
|
||||
|
||||
result[4*k+j] = z.chooseKey2Sub(keyA[16*k+j*4+i], result[4*k+j], keyB[(k*0xc00+j*0x300+0x200-offset*0x100):])
|
||||
offset++
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
func (z *ZT) chooseKey3(in, key []byte) []byte {
|
||||
|
||||
result := make([]byte, 16)
|
||||
for k := 0; k < 4; k++ {
|
||||
for j := 0; j < 4; j++ {
|
||||
result[k*4+j] = key[uint(in[k*4+j])+uint(j)*0x100+uint(k)*0x400]
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
func (z *ZT) shiftKey(in [4][4]byte) []byte {
|
||||
|
||||
var ret [4][4]byte
|
||||
ret[0][0] = in[0][0]
|
||||
ret[0][1] = in[0][1]
|
||||
ret[0][2] = in[0][2]
|
||||
ret[0][3] = in[0][3]
|
||||
|
||||
ret[1][0] = in[1][1]
|
||||
ret[1][1] = in[1][2]
|
||||
ret[1][2] = in[1][3]
|
||||
ret[1][3] = in[1][0]
|
||||
|
||||
ret[2][0] = in[2][2]
|
||||
ret[2][1] = in[2][3]
|
||||
ret[2][2] = in[2][0]
|
||||
ret[2][3] = in[2][1]
|
||||
|
||||
ret[3][0] = in[3][3]
|
||||
ret[3][1] = in[3][0]
|
||||
ret[3][2] = in[3][1]
|
||||
ret[3][3] = in[3][2]
|
||||
|
||||
var result []byte
|
||||
|
||||
for i := 0; i < 4; i++ {
|
||||
for j := 0; j < 4; j++ {
|
||||
result = append(result, ret[i][j])
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
func (z *ZT) reAssemble(in []byte) []byte {
|
||||
|
||||
result := make([]byte, 16)
|
||||
|
||||
for i := 0; i < 4; i++ {
|
||||
for j := 0; j < 4; j++ {
|
||||
result[i*4+j] = in[j*4+i]
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func (z *ZT) byte2Array(in []byte) [4][4]byte {
|
||||
var r [4][4]byte
|
||||
for i := 0; i < 4; i++ {
|
||||
for j := 0; j < 4; j++ {
|
||||
r[i][j] = in[i*4+j]
|
||||
}
|
||||
}
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
// Encrypt s
|
||||
func (z *ZT) Encrypt(in []byte) []byte {
|
||||
|
||||
size := len(in)
|
||||
pad := 16 - (size % 16)
|
||||
for i := 0; i < pad; i++ {
|
||||
in = append(in, byte(pad))
|
||||
}
|
||||
|
||||
initKey := z.initKey
|
||||
totalRound := len(in) / 16
|
||||
|
||||
result := make([]byte, len(in))
|
||||
|
||||
for i := 0; i < totalRound; i++ {
|
||||
//step1
|
||||
var step1 [4][4]byte
|
||||
for j := 0; j < 16; j++ {
|
||||
step1[j/4][j%4] = in[i*16+j] ^ initKey[j]
|
||||
}
|
||||
|
||||
//step2
|
||||
var step2 [4][4]byte
|
||||
for k := 0; k < 4; k++ {
|
||||
for m := 0; m < 4; m++ {
|
||||
step2[k][m] = step1[m][k]
|
||||
}
|
||||
}
|
||||
|
||||
//step3
|
||||
for l := 0; l < 9; l++ {
|
||||
step3 := z.shiftKey(step2)
|
||||
|
||||
step4 := z.chooseKey(step3, z.key1[0x4000*l:])
|
||||
|
||||
step5 := z.chooseKey2(step4, z.key2[0x3000*l:])
|
||||
|
||||
step2 = z.byte2Array(step5)
|
||||
}
|
||||
|
||||
step6 := z.shiftKey(step2)
|
||||
step7 := z.chooseKey3(step6, z.key3)
|
||||
step8 := z.reAssemble(step7)
|
||||
|
||||
copy(result[i*16:], step8)
|
||||
initKey = step8
|
||||
}
|
||||
return result
|
||||
}
|
||||
Reference in New Issue
Block a user