This repository has been archived by the owner on Nov 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
chrome_darwin_test.go
109 lines (104 loc) · 2.36 KB
/
chrome_darwin_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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
package main
import (
"bytes"
"reflect"
"testing"
)
func must(b []byte, e error) []byte {
if e != nil {
panic(e)
}
return b
}
var chromeIV = bytes.Repeat([]byte(" "), 16)
func TestChrome_decryptv10(t *testing.T) {
type fields struct {
key []byte
data chan *LoginInfo
openSSL bool
}
type args struct {
ct []byte
iv []byte
key []byte
}
tests := []struct {
name string
fields fields
args args
want []byte
wantErr bool
}{
{"1",
fields{},
args{
ct: []byte{0x95, 0xb, 0x51, 0x16, 0x69, 0xaf, 0xd9, 0xc5, 0xeb, 0x29, 0x4a, 0x6f, 0xd4, 0xf0, 0x6d, 0x51},
iv: chromeIV,
key: []byte{0x49, 0x94, 0x3d, 0x44, 0x11, 0xe2, 0x16, 0x98, 0x7, 0x4b, 0xde, 0xd9, 0xa0, 0x55, 0xd3, 0x3d},
},
[]byte("Passw0rd*/*"), false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
c := &Chrome{
key: tt.fields.key,
data: tt.fields.data,
openSSL: tt.fields.openSSL,
}
got, err := c.decryptv10(tt.args.ct, tt.args.iv, tt.args.key)
if (err != nil) != tt.wantErr {
t.Errorf("Chrome.decryptv10() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("Chrome.decryptv10() = %v, want %v", got, tt.want)
}
})
}
}
func TestChrome_openSSLdecryptv10(t *testing.T) {
type fields struct {
key []byte
data chan *LoginInfo
openSSL bool
}
type args struct {
ct []byte
iv []byte
key []byte
}
tests := []struct {
name string
fields fields
args args
want []byte
wantErr bool
}{
{"ok",
fields{},
args{ct: []byte{0x95, 0xb, 0x51, 0x16, 0x69, 0xaf, 0xd9, 0xc5, 0xeb, 0x29, 0x4a, 0x6f, 0xd4, 0xf0, 0x6d, 0x51},
iv: chromeIV,
key: []byte{0x49, 0x94, 0x3d, 0x44, 0x11, 0xe2, 0x16, 0x98, 0x7, 0x4b, 0xde, 0xd9, 0xa0, 0x55, 0xd3, 0x3d},
},
[]byte("Passw0rd*/*"), false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
c := &Chrome{
key: tt.fields.key,
data: tt.fields.data,
openSSL: tt.fields.openSSL,
}
got, err := c.openSSLdecryptv10(tt.args.ct, tt.args.iv, tt.args.key)
if (err != nil) != tt.wantErr {
t.Errorf("Chrome.openSSLdecryptv10() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("Chrome.openSSLdecryptv10() = %v, want %v", got, tt.want)
}
})
}
}