libgocryptfs: fix config loading by scrypt hash

This commit is contained in:
Matéo Duparc 2023-05-03 14:13:18 +02:00
parent a238cc392f
commit 6308adf8e5
Signed by: hardcoresushi
GPG Key ID: AFE384344A45E13A

View File

@ -271,10 +271,10 @@ func (cf *ConfFile) EncryptKey(key []byte, password []byte, logN int, giveHash b
func (cf *ConfFile) GetMasterkey(password, givenScryptHash, returnedScryptHashBuff []byte) ([]byte, error) { func (cf *ConfFile) GetMasterkey(password, givenScryptHash, returnedScryptHashBuff []byte) ([]byte, error) {
var masterkey []byte var masterkey []byte
var err error var err error
var scryptHash []byte
if len(givenScryptHash) > 0 { //decrypt with hash if len(givenScryptHash) > 0 { //decrypt with hash
masterkey, err = cf.DecryptMasterKeyWithScryptHash(scryptHash) masterkey, err = cf.DecryptMasterKeyWithScryptHash(givenScryptHash)
} else { //decrypt with password } else { //decrypt with password
var scryptHash []byte
masterkey, scryptHash, err = cf.DecryptMasterKey(password, len(returnedScryptHashBuff) > 0) masterkey, scryptHash, err = cf.DecryptMasterKey(password, len(returnedScryptHashBuff) > 0)
//copy and wipe scryptHash //copy and wipe scryptHash
for i := range scryptHash { for i := range scryptHash {