Debian Codegraph @

ntlm_test.go

raw symbols SCIP
1 // +build !windows
2
3 package mssql
4
5 import (
6 "encoding/hex"
7 "testing"
8 )
9
10 func TestLMOWFv1(t *testing.T) {
11 hash := lmHash("Password")
12 val := [21]byte{
13 0xe5, 0x2c, 0xac, 0x67, 0x41, 0x9a, 0x9a, 0x22,
14 0x4a, 0x3b, 0x10, 0x8f, 0x3f, 0xa6, 0xcb, 0x6d,
15 0, 0, 0, 0, 0,
16 }
17 if hash != val {
18 t.Errorf("got:\n%sexpected:\n%s", hex.Dump(hash[:]), hex.Dump(val[:]))
19 }
20 }
21
22 func TestNTLMOWFv1(t *testing.T) {
23 hash := ntlmHash("Password")
24 val := [21]byte{
25 0xa4, 0xf4, 0x9c, 0x40, 0x65, 0x10, 0xbd, 0xca, 0xb6, 0x82, 0x4e, 0xe7, 0xc3, 0x0f, 0xd8, 0x52,
26 0, 0, 0, 0, 0,
27 }
28 if hash != val {
29 t.Errorf("got:\n%sexpected:\n%s", hex.Dump(hash[:]), hex.Dump(val[:]))
30 }
31 }
32
33 func TestNTLMv1Response(t *testing.T) {
34 challenge := [8]byte{
35 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
36 }
37 nt := ntResponse(challenge, "Password")
38 val := [24]byte{
39 0x67, 0xc4, 0x30, 0x11, 0xf3, 0x02, 0x98, 0xa2, 0xad, 0x35, 0xec, 0xe6, 0x4f, 0x16, 0x33, 0x1c,
40 0x44, 0xbd, 0xbe, 0xd9, 0x27, 0x84, 0x1f, 0x94,
41 }
42 if nt != val {
43 t.Errorf("got:\n%sexpected:\n%s", hex.Dump(nt[:]), hex.Dump(val[:]))
44 }
45 }
46
47 func TestLMv1Response(t *testing.T) {
48 challenge := [8]byte{
49 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
50 }
51 nt := lmResponse(challenge, "Password")
52 val := [24]byte{
53 0x98, 0xde, 0xf7, 0xb8, 0x7f, 0x88, 0xaa, 0x5d, 0xaf, 0xe2, 0xdf, 0x77, 0x96, 0x88, 0xa1, 0x72,
54 0xde, 0xf1, 0x1c, 0x7d, 0x5c, 0xcd, 0xef, 0x13,
55 }
56 if nt != val {
57 t.Errorf("got:\n%sexpected:\n%s", hex.Dump(nt[:]), hex.Dump(val[:]))
58 }
59 }
60
61 func TestNTLMSessionResponse(t *testing.T) {
62 challenge := [8]byte{
63 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
64 }
65 nonce := [8]byte{
66 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
67 }
68 nt := ntlmSessionResponse(nonce, challenge, "Password")
69 val := [24]byte{
70 0x75, 0x37, 0xf8, 0x03, 0xae, 0x36, 0x71, 0x28, 0xca, 0x45, 0x82, 0x04, 0xbd, 0xe7, 0xca, 0xf8,
71 0x1e, 0x97, 0xed, 0x26, 0x83, 0x26, 0x72, 0x32,
72 }
73 if nt != val {
74 t.Errorf("got:\n%sexpected:\n%s", hex.Dump(nt[:]), hex.Dump(val[:]))
75 }
76 }