-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathkdf_test.go
80 lines (76 loc) · 1.73 KB
/
kdf_test.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
74
75
76
77
78
79
80
package simba
import (
"bytes"
"encoding/hex"
"testing"
)
func TestKDF(t *testing.T) {
cases := []struct {
name string
input []byte
labal string
context string
expected []byte
}{
{
name: "case 1",
input: func() []byte {
r, _ := hex.DecodeString("7CD451825D0450D235424E44BA6E78CC")
return r
}(),
labal: "SMB2AESCMAC\x00",
context: "SmbSign\x00",
expected: func() []byte {
r, _ := hex.DecodeString("0B7E9C5CAC36C0F6EA9AB275298CEDCE")
return r
}(),
},
{
name: "case 2",
input: func() []byte {
r, _ := hex.DecodeString("7CD451825D0450D235424E44BA6E78CC")
return r
}(),
labal: "SMB2APP\x00",
context: "SmbRpc\x00",
expected: func() []byte {
r, _ := hex.DecodeString("BB23A4575AA26C721AF525AF15A87B4F")
return r
}(),
},
{
name: "case 3",
input: func() []byte {
r, _ := hex.DecodeString("7CD451825D0450D235424E44BA6E78CC")
return r
}(),
labal: "SMB2AESCCM\x00",
context: "ServerIn \x00",
expected: func() []byte {
r, _ := hex.DecodeString("FAD27796665B313EBB578F388632B4F7")
return r
}(),
},
{
name: "case 4",
input: func() []byte {
r, _ := hex.DecodeString("7CD451825D0450D235424E44BA6E78CC")
return r
}(),
labal: "SMB2AESCCM\x00",
context: "ServerOut\x00",
expected: func() []byte {
r, _ := hex.DecodeString("B0F0427F7CEB416D1D9DCC0CD4F99447")
return r
}(),
},
}
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
actual := smb3kdf(c.input, c.labal, c.context)
if !bytes.Equal(actual, c.expected) {
t.Errorf("expected %0x, actual %0x", c.expected, actual)
}
})
}
}