Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions Passwork/Attachment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,25 @@ private async Task Unlock()
//get the details about this password
var singleitem = await conn.Get<AttachmentSingleItem>($"passwords/{parent.Id}/attachment/{Id}");

var vsi = await this.conn.Get<VaultSingleItem>($"vaults/{parent.VaultId}");
IVault vault = new Vault(conn, vsi);
if (conn.WithMasterPassword)
{
var vsi = await this.conn.Get<VaultSingleItem>($"vaults/{parent.VaultId}");
IVault vault = new Vault(conn, vsi);

var masterPass = await vault.GetMaster();
var key = CryptoUtils.Decode(singleitem.encryptedKey, masterPass);
var masterPass = await vault.GetMaster();
var key = CryptoUtils.Decode(singleitem.encryptedKey, masterPass);

//TODO i skipped the has check..
//if (cryptoInterface.hash(byteCharacters) !== attachment.hash)
//{
// throw "Can't decrypt attachment: hashes are not equal";
//}
data = CryptoUtils.DecodeFile(singleitem.encryptedData, key);
//TODO i skipped the has check..
//if (cryptoInterface.hash(byteCharacters) !== attachment.hash)
//{
// throw "Can't decrypt attachment: hashes are not equal";
//}
data = CryptoUtils.DecodeFile(singleitem.encryptedData, key);
}
else
{
data = Convert.FromBase64String(Base64.Decode(singleitem.encryptedData));
}
}


Expand Down