bunch of fixes

This commit is contained in:
TheXamlGuy
2024-05-02 20:58:12 +01:00
parent e98e622003
commit 4b05abad9b
23 changed files with 115 additions and 192 deletions
+24
View File
@@ -0,0 +1,24 @@
using Toolkit.Foundation;
namespace Bitvault;
public class VaultKeyFactory(IKeyGenerator generator,
IKeyDeriver deriver,
IEncryptor encryptor,
IDecryptor decryptor) :
IVaultKeyFactory
{
public VaultKey Create(string password)
{
byte[] salt = generator.Generate(16);
byte[] key = generator.Generate(32);
byte[] derivedKey = deriver.DeriveKey(password, salt);
byte[] publicKey = encryptor.Encrypt(key, derivedKey);
byte[] privateKey = decryptor.Decrypt(publicKey, derivedKey);
return new VaultKey(salt, publicKey, privateKey);
}
}