mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-12-04 05:43:27 +01:00
Comments that restated names or narrated the code are gone, and multi-line ones are cut to a line of why. Only comments change: each edited Go file has the same token stream as before. winapi and abe come later.
35 lines
1.1 KiB
Go
35 lines
1.1 KiB
Go
package chromium
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/moond4rk/hackbrowserdata/internal/masterkey"
|
|
)
|
|
|
|
// A profile can mix versions, so a missing key fails only the values sealed under that version.
|
|
func decryptValue(masterKeys masterkey.Set, ciphertext []byte) ([]byte, error) {
|
|
if len(ciphertext) == 0 {
|
|
return nil, nil
|
|
}
|
|
|
|
version := detectVersion(ciphertext)
|
|
switch version {
|
|
case cipherV10:
|
|
// Key length tells which platform sealed v10: 32 bytes is GCM, 16 is CBC, so a key from another OS still works.
|
|
if len(masterKeys[masterkey.V10]) == 32 {
|
|
return decryptGCM(masterKeys[masterkey.V10], ciphertext)
|
|
}
|
|
return decryptCBC(masterKeys[masterkey.V10], ciphertext)
|
|
case cipherV11:
|
|
return decryptCBC(masterKeys[masterkey.V11], ciphertext)
|
|
case cipherV20:
|
|
return decryptGCM(masterKeys[masterkey.V20], ciphertext)
|
|
case cipherV12:
|
|
return nil, fmt.Errorf("unsupported cipher version v12 (Chromium SecretPortal / Flatpak; not yet implemented)")
|
|
case cipherDPAPI:
|
|
return masterkey.DecryptDPAPI(ciphertext)
|
|
default:
|
|
return nil, fmt.Errorf("unsupported cipher version: %s", version)
|
|
}
|
|
}
|