-
Notifications
You must be signed in to change notification settings - Fork 8
/
bindings.go
55 lines (42 loc) · 1.23 KB
/
bindings.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
package ntlmssp
import (
"bytes"
"encoding/binary"
)
const (
// TLSServerEndPoint is defined in RFC 5929 and stores the hash of the server certificate.
TLSServerEndPoint string = "tls-server-end-point"
)
// ChannelBindings models the GSS-API channel bindings defined in RFC 2744.
type ChannelBindings struct {
InitiatorAddrtype uint32
InitiatorAddress []uint8
AcceptorAddrtype uint32
AcceptorAddress []uint8
ApplicationData []uint8
}
func (c *ChannelBindings) marshal() ([]byte, error) {
b := bytes.Buffer{}
if err := binary.Write(&b, binary.LittleEndian, &c.InitiatorAddrtype); err != nil {
return nil, err
}
length := uint32(len(c.InitiatorAddress))
if err := binary.Write(&b, binary.LittleEndian, &length); err != nil {
return nil, err
}
b.Write(c.InitiatorAddress)
if err := binary.Write(&b, binary.LittleEndian, &c.AcceptorAddrtype); err != nil {
return nil, err
}
length = uint32(len(c.AcceptorAddress))
if err := binary.Write(&b, binary.LittleEndian, &length); err != nil {
return nil, err
}
b.Write(c.AcceptorAddress)
length = uint32(len(c.ApplicationData))
if err := binary.Write(&b, binary.LittleEndian, &length); err != nil {
return nil, err
}
b.Write(c.ApplicationData)
return b.Bytes(), nil
}