Mass rename

This commit is contained in:
TheXamlGuy
2024-05-12 11:02:19 +01:00
parent 0860e286e2
commit c1b6e595bc
102 changed files with 412 additions and 448 deletions
+34
View File
@@ -0,0 +1,34 @@
using Toolkit.Foundation;
namespace Bitvault;
public class SecurityKeyFactory(IKeyGenerator generator,
IKeyDeriver deriver,
IEncryptor encryptor,
IDecryptor decryptor) :
ISecurityKeyFactory
{
public SecurityKey? Create(byte[] phrase,
byte[]? encryptedKey = null,
byte[]? salt = null)
{
salt ??= generator.Generate(16);
byte[] derivedKey = deriver.DeriveKey(phrase, salt);
if (encryptedKey is null)
{
if (!encryptor.TryEncrypt(generator.Generate(32), derivedKey, out encryptedKey) || encryptedKey is null)
{
return default;
}
}
if (!decryptor.TryDecrypt(encryptedKey, derivedKey, out byte[]? decryptedKey) || decryptedKey is null)
{
return default;
}
return new SecurityKey(salt, encryptedKey, decryptedKey);
}
}