refactor: Refactor encryption modules for Chromium browsers.

This commit is contained in:
moonD4rk 2024-04-15 16:11:25 +08:00 committed by ᴍᴏᴏɴD4ʀᴋ
parent 6237658fe7
commit fc8a3515d8
4 changed files with 6 additions and 8 deletions

View File

@ -12,8 +12,8 @@ import (
"os/exec"
"strings"
"github.com/moond4rk/hackbrowserdata/crypto"
"github.com/moond4rk/hackbrowserdata/types"
"github.com/moond4rk/hackbrowserdata/utils/cryptoutil"
)
var (
@ -49,7 +49,7 @@ func (c *Chromium) GetMasterKey() ([]byte, error) {
}
salt := []byte("saltysalt")
// @https://source.chromium.org/chromium/chromium/src/+/master:components/os_crypt/os_crypt_mac.mm;l=157
key := cryptoutil.PBKDF2Key(secret, salt, 1003, 16, sha1.New)
key := crypto.PBKDF2Key(secret, salt, 1003, 16, sha1.New)
if key == nil {
return nil, errWrongSecurityCommand
}

View File

@ -11,8 +11,8 @@ import (
"github.com/godbus/dbus/v5"
keyring "github.com/ppacher/go-dbus-keyring"
"github.com/moond4rk/hackbrowserdata/crypto"
"github.com/moond4rk/hackbrowserdata/types"
"github.com/moond4rk/hackbrowserdata/utils/cryptoutil"
)
func (c *Chromium) GetMasterKey() ([]byte, error) {
@ -69,7 +69,7 @@ func (c *Chromium) GetMasterKey() ([]byte, error) {
}
salt := []byte("saltysalt")
// @https://source.chromium.org/chromium/chromium/src/+/master:components/os_crypt/os_crypt_linux.cc
key := cryptoutil.PBKDF2Key(secret, salt, 1, 16, sha1.New)
key := crypto.PBKDF2Key(secret, salt, 1, 16, sha1.New)
c.masterKey = key
slog.Info("get master key success", "browser", c.name)
return key, nil

View File

@ -6,8 +6,6 @@ import (
"crypto/sha256"
"encoding/asn1"
"errors"
"github.com/moond4rk/hackbrowserdata/utils/cryptoutil"
)
type ASN1PBE interface {
@ -158,7 +156,7 @@ func (m metaPBE) deriveKeyAndIV(globalSalt []byte) ([]byte, []byte) {
iter := m.AlgoAttr.Data.Data.SlatAttr.IterationCount
keyLen := m.AlgoAttr.Data.Data.SlatAttr.KeySize
key := cryptoutil.PBKDF2Key(password[:], salt, iter, keyLen, sha256.New)
key := PBKDF2Key(password[:], salt, iter, keyLen, sha256.New)
iv := append([]byte{4, 14}, m.AlgoAttr.Data.IVData.IV...)
return key, iv
}

View File

@ -1,4 +1,4 @@
package cryptoutil
package crypto
import (
"crypto/hmac"