-
-
Notifications
You must be signed in to change notification settings - Fork 182
/
pair_save.go
73 lines (67 loc) · 1.99 KB
/
pair_save.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package ios
type SavePair struct {
BundleID string
ClientVersionString string
MessageType string
ProgName string
LibUSBMuxVersion uint32 `plist:"kLibUSBMuxVersion"`
PairRecordID string
PairRecordData []byte
}
type savePairRecordData struct {
DeviceCertificate []byte
HostPrivateKey []byte
HostCertificate []byte
RootPrivateKey []byte
RootCertificate []byte
EscrowBag []byte
WiFiMACAddress string
HostID string
SystemBUID string
}
func newSavePair(udid string, savePairRecordData []byte) SavePair {
data := SavePair{
BundleID: "go.ios.control",
ClientVersionString: "go-ios-1.0.0",
MessageType: "SavePairRecord",
ProgName: "go-ios",
LibUSBMuxVersion: 3,
PairRecordID: udid,
PairRecordData: savePairRecordData,
}
return data
}
func newSavePairRecordData(DeviceCertificate []byte,
HostPrivateKey []byte,
HostCertificate []byte,
RootPrivateKey []byte,
RootCertificate []byte,
EscrowBag []byte,
WiFiMACAddress string,
HostID string,
SystemBUID string) []byte {
result := savePairRecordData{DeviceCertificate, HostPrivateKey, HostCertificate, RootPrivateKey, RootCertificate, EscrowBag, WiFiMACAddress, HostID, SystemBUID}
bytes := []byte(ToPlist(result))
return bytes
}
func (muxConn *UsbMuxConnection) savePair(udid string, DeviceCertificate []byte,
HostPrivateKey []byte,
HostCertificate []byte,
RootPrivateKey []byte,
RootCertificate []byte,
EscrowBag []byte,
WiFiMACAddress string,
HostID string,
SystemBUID string) (bool, error) {
bytes := newSavePairRecordData(DeviceCertificate, HostPrivateKey, HostCertificate, RootPrivateKey, RootCertificate, EscrowBag, WiFiMACAddress, HostID, SystemBUID)
err := muxConn.Send(newSavePair(udid, bytes))
if err != nil {
return false, err
}
resp, err := muxConn.ReadMessage()
if err != nil {
return false, err
}
muxresponse := MuxResponsefromBytes(resp.Payload)
return muxresponse.IsSuccessFull(), nil
}