aboutsummaryrefslogtreecommitdiff
path: root/lib/Plugins.Essentials/src/Accounts
diff options
context:
space:
mode:
authorLibravatar vnugent <public@vaughnnugent.com>2023-03-27 02:20:06 -0400
committerLibravatar vnugent <public@vaughnnugent.com>2023-03-27 02:20:06 -0400
commit6f7f4a4f03c7e62db64c01b2a0b128586bf11dad (patch)
tree2ef00d7d8527f5153ccd4188665bd9b47573cf27 /lib/Plugins.Essentials/src/Accounts
parent6b5ca9e49e33eb3e03d6f7333661da7e6d0546fa (diff)
Native heap api and alloc optimizations
Diffstat (limited to 'lib/Plugins.Essentials/src/Accounts')
-rw-r--r--lib/Plugins.Essentials/src/Accounts/NonceExtensions.cs4
-rw-r--r--lib/Plugins.Essentials/src/Accounts/PasswordHashing.cs10
2 files changed, 7 insertions, 7 deletions
diff --git a/lib/Plugins.Essentials/src/Accounts/NonceExtensions.cs b/lib/Plugins.Essentials/src/Accounts/NonceExtensions.cs
index 5a40d29..0d9ca10 100644
--- a/lib/Plugins.Essentials/src/Accounts/NonceExtensions.cs
+++ b/lib/Plugins.Essentials/src/Accounts/NonceExtensions.cs
@@ -44,7 +44,7 @@ namespace VNLib.Plugins.Essentials.Accounts
public static string ComputeNonce<T>(this T nonce, int size) where T: INonce
{
//Alloc bin buffer
- using UnsafeMemoryHandle<byte> buffer = MemoryUtil.UnsafeAlloc<byte>(size);
+ using UnsafeMemoryHandle<byte> buffer = MemoryUtil.UnsafeAlloc(size);
//Compute nonce
nonce.ComputeNonce(buffer.Span);
@@ -63,7 +63,7 @@ namespace VNLib.Plugins.Essentials.Accounts
public static bool VerifyNonce<T>(this T nonce, ReadOnlySpan<char> base32Nonce) where T : INonce
{
//Alloc bin buffer
- using UnsafeMemoryHandle<byte> buffer = MemoryUtil.UnsafeAlloc<byte>(base32Nonce.Length);
+ using UnsafeMemoryHandle<byte> buffer = MemoryUtil.UnsafeAlloc(base32Nonce.Length);
//Decode base32 nonce
ERRNO count = VnEncoding.TryFromBase32Chars(base32Nonce, buffer.Span);
diff --git a/lib/Plugins.Essentials/src/Accounts/PasswordHashing.cs b/lib/Plugins.Essentials/src/Accounts/PasswordHashing.cs
index db5b309..32e04e3 100644
--- a/lib/Plugins.Essentials/src/Accounts/PasswordHashing.cs
+++ b/lib/Plugins.Essentials/src/Accounts/PasswordHashing.cs
@@ -96,7 +96,7 @@ namespace VNLib.Plugins.Essentials.Accounts
else
{
//Alloc heap buffer
- using UnsafeMemoryHandle<byte> secretBuffer = MemoryUtil.UnsafeAlloc<byte>(_secret.BufferSize, true);
+ using UnsafeMemoryHandle<byte> secretBuffer = MemoryUtil.UnsafeAlloc(_secret.BufferSize, true);
return VerifyInternal(passHash, password, secretBuffer);
}
@@ -130,7 +130,7 @@ namespace VNLib.Plugins.Essentials.Accounts
public bool Verify(ReadOnlySpan<byte> hash, ReadOnlySpan<byte> salt, ReadOnlySpan<byte> password)
{
//Alloc a buffer with the same size as the hash
- using UnsafeMemoryHandle<byte> hashBuf = MemoryUtil.UnsafeAlloc<byte>(hash.Length, true);
+ using UnsafeMemoryHandle<byte> hashBuf = MemoryUtil.UnsafeAlloc(hash.Length, true);
//Hash the password with the current config
Hash(password, salt, hashBuf.Span);
//Compare the hashed password to the specified hash and return results
@@ -143,7 +143,7 @@ namespace VNLib.Plugins.Essentials.Accounts
public PrivateString Hash(ReadOnlySpan<char> password)
{
//Alloc shared buffer for the salt and secret buffer
- using UnsafeMemoryHandle<byte> buffer = MemoryUtil.UnsafeAlloc<byte>(SaltLen + _secret.BufferSize, true);
+ using UnsafeMemoryHandle<byte> buffer = MemoryUtil.UnsafeAlloc(SaltLen + _secret.BufferSize, true);
try
{
//Split buffers
@@ -170,7 +170,7 @@ namespace VNLib.Plugins.Essentials.Accounts
/// <returns>A <see cref="PrivateString"/> of the hashed and encoded password</returns>
public PrivateString Hash(ReadOnlySpan<byte> password)
{
- using UnsafeMemoryHandle<byte> buffer = MemoryUtil.UnsafeAlloc<byte>(SaltLen + _secret.BufferSize, true);
+ using UnsafeMemoryHandle<byte> buffer = MemoryUtil.UnsafeAlloc(SaltLen + _secret.BufferSize, true);
try
{
//Split buffers
@@ -203,7 +203,7 @@ namespace VNLib.Plugins.Essentials.Accounts
public void Hash(ReadOnlySpan<byte> password, ReadOnlySpan<byte> salt, Span<byte> hashOutput)
{
//alloc secret buffer
- using UnsafeMemoryHandle<byte> secretBuffer = MemoryUtil.UnsafeAlloc<byte>(_secret.BufferSize, true);
+ using UnsafeMemoryHandle<byte> secretBuffer = MemoryUtil.UnsafeAlloc(_secret.BufferSize, true);
try
{
//Get the secret from the callback