Skip to content

Commit fc8a351

Browse files
committed
refactor: Refactor encryption modules for Chromium browsers.
1 parent 6237658 commit fc8a351

4 files changed

Lines changed: 6 additions & 8 deletions

File tree

browser/chromium/chromium_darwin.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import (
1212
"os/exec"
1313
"strings"
1414

15+
"github.com/moond4rk/hackbrowserdata/crypto"
1516
"github.com/moond4rk/hackbrowserdata/types"
16-
"github.com/moond4rk/hackbrowserdata/utils/cryptoutil"
1717
)
1818

1919
var (
@@ -49,7 +49,7 @@ func (c *Chromium) GetMasterKey() ([]byte, error) {
4949
}
5050
salt := []byte("saltysalt")
5151
// @https://source.chromium.org/chromium/chromium/src/+/master:components/os_crypt/os_crypt_mac.mm;l=157
52-
key := cryptoutil.PBKDF2Key(secret, salt, 1003, 16, sha1.New)
52+
key := crypto.PBKDF2Key(secret, salt, 1003, 16, sha1.New)
5353
if key == nil {
5454
return nil, errWrongSecurityCommand
5555
}

browser/chromium/chromium_linux.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import (
1111
"github.com/godbus/dbus/v5"
1212
keyring "github.com/ppacher/go-dbus-keyring"
1313

14+
"github.com/moond4rk/hackbrowserdata/crypto"
1415
"github.com/moond4rk/hackbrowserdata/types"
15-
"github.com/moond4rk/hackbrowserdata/utils/cryptoutil"
1616
)
1717

1818
func (c *Chromium) GetMasterKey() ([]byte, error) {
@@ -69,7 +69,7 @@ func (c *Chromium) GetMasterKey() ([]byte, error) {
6969
}
7070
salt := []byte("saltysalt")
7171
// @https://source.chromium.org/chromium/chromium/src/+/master:components/os_crypt/os_crypt_linux.cc
72-
key := cryptoutil.PBKDF2Key(secret, salt, 1, 16, sha1.New)
72+
key := crypto.PBKDF2Key(secret, salt, 1, 16, sha1.New)
7373
c.masterKey = key
7474
slog.Info("get master key success", "browser", c.name)
7575
return key, nil

crypto/asn1pbe.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import (
66
"crypto/sha256"
77
"encoding/asn1"
88
"errors"
9-
10-
"github.com/moond4rk/hackbrowserdata/utils/cryptoutil"
119
)
1210

1311
type ASN1PBE interface {
@@ -158,7 +156,7 @@ func (m metaPBE) deriveKeyAndIV(globalSalt []byte) ([]byte, []byte) {
158156
iter := m.AlgoAttr.Data.Data.SlatAttr.IterationCount
159157
keyLen := m.AlgoAttr.Data.Data.SlatAttr.KeySize
160158

161-
key := cryptoutil.PBKDF2Key(password[:], salt, iter, keyLen, sha256.New)
159+
key := PBKDF2Key(password[:], salt, iter, keyLen, sha256.New)
162160
iv := append([]byte{4, 14}, m.AlgoAttr.Data.IVData.IV...)
163161
return key, iv
164162
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package cryptoutil
1+
package crypto
22

33
import (
44
"crypto/hmac"

0 commit comments

Comments
 (0)