Use the same buffer for decryption

This commit is contained in:
Alexander Neumann 2017-01-13 21:23:47 +01:00
parent 710499cf46
commit e571b6a656
1 changed files with 2 additions and 4 deletions

View File

@ -64,15 +64,13 @@ func (r *Repository) LoadAndDecrypt(t restic.FileType, id restic.ID) ([]byte, er
return nil, errors.New("invalid data returned")
}
plain := make([]byte, len(buf))
// decrypt
n, err := r.decryptTo(plain, buf)
n, err := r.decryptTo(buf, buf)
if err != nil {
return nil, err
}
return plain[:n], nil
return buf[:n], nil
}
// loadBlob tries to load and decrypt content identified by t and id from a