From a8603e00e390b07c036384285412eda5e07beda7 Mon Sep 17 00:00:00 2001 From: vnugent Date: Sun, 3 Mar 2024 15:06:26 -0500 Subject: fix: fix library handle leak in hot-reload --- lib/NVault.Crypto.Noscrypt/src/NostrCrypto.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'lib') diff --git a/lib/NVault.Crypto.Noscrypt/src/NostrCrypto.cs b/lib/NVault.Crypto.Noscrypt/src/NostrCrypto.cs index e4d4574..1bfccb0 100644 --- a/lib/NVault.Crypto.Noscrypt/src/NostrCrypto.cs +++ b/lib/NVault.Crypto.Noscrypt/src/NostrCrypto.cs @@ -15,11 +15,11 @@ using System; using System.Runtime.CompilerServices; -using System.Xml; using VNLib.Utils; using NCResult = System.Int64; +using static NVault.Crypto.Noscrypt.LibNoscrypt; namespace NVault.Crypto.Noscrypt { @@ -56,10 +56,10 @@ namespace NVault.Crypto.Noscrypt //Copy nonce to struct memory buffer Unsafe.CopyBlock( - ref Unsafe.AsRef(data.nonce), - in nonce, - LibNoscrypt.NC_ENCRYPTION_NONCE_SIZE - ); + ref Unsafe.AsRef(data.nonce), + in nonce, + NC_ENCRYPTION_NONCE_SIZE + ); fixed (NCSecretKey* pSecKey = &secretKey) fixed (NCPublicKey* pPubKey = &publicKey) @@ -96,7 +96,7 @@ namespace NVault.Crypto.Noscrypt Unsafe.CopyBlock( ref Unsafe.AsRef(data.nonce), in nonce, - LibNoscrypt.NC_ENCRYPTION_NONCE_SIZE + NC_ENCRYPTION_NONCE_SIZE ); fixed (NCSecretKey* pSecKey = &secretKey) @@ -187,7 +187,7 @@ namespace NVault.Crypto.Noscrypt NCResult result = Functions.NCVerifyData.Invoke(libCtx, pPubKey, pData, dataSize, pSig); NCUtil.CheckResult(result, false); - return result == LibNoscrypt.NC_SUCCESS; + return result == NC_SUCCESS; } } @@ -230,14 +230,14 @@ namespace NVault.Crypto.Noscrypt Unsafe.CopyBlock( ref Unsafe.AsRef(args.nonce), in nonce32, - LibNoscrypt.NC_ENCRYPTION_NONCE_SIZE + NC_ENCRYPTION_NONCE_SIZE ); //Copy mac to struct memory buffer Unsafe.CopyBlock( ref Unsafe.AsRef(args.mac), in mac32, - LibNoscrypt.NC_ENCRYPTION_MAC_SIZE + NC_ENCRYPTION_MAC_SIZE ); fixed(NCSecretKey* pSecKey = &secretKey) @@ -251,7 +251,7 @@ namespace NVault.Crypto.Noscrypt NCUtil.CheckResult(result, false); //Result should be success if the hmac is valid - return result == LibNoscrypt.NC_SUCCESS; + return result == NC_SUCCESS; } } -- cgit