-
Notifications
You must be signed in to change notification settings - Fork 242
/
device_claims.go
39 lines (33 loc) · 927 Bytes
/
device_claims.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
package pac
import (
"fmt"
"gopkg.in/jcmturner/gokrb5.v5/mstypes"
"gopkg.in/jcmturner/rpc.v0/ndr"
)
// DeviceClaimsInfo implements https://msdn.microsoft.com/en-us/library/hh554226.aspx
type DeviceClaimsInfo struct {
Claims mstypes.ClaimsSetMetadata
}
// Unmarshal bytes into the DeviceClaimsInfo struct
func (k *DeviceClaimsInfo) Unmarshal(b []byte) error {
ch, _, p, err := ndr.ReadHeaders(&b)
if err != nil {
return fmt.Errorf("error parsing byte stream headers of DEVICE_CLAIMS_INFO: %v", err)
}
e := &ch.Endianness
//The next 4 bytes are an RPC unique pointer referent. We just skip these
p += 4
k.Claims, err = mstypes.ReadClaimsSetMetadata(&b, &p, e)
if err != nil {
return err
}
//Check that there is only zero padding left
if len(b) >= p {
for _, v := range b[p:] {
if v != 0 {
return ndr.Malformed{EText: "non-zero padding left over at end of data stream"}
}
}
}
return nil
}