diff options
Diffstat (limited to 'wrappers/dotnet/VNLib.Utils.Cryptography.Noscrypt/src/internal')
3 files changed, 44 insertions, 95 deletions
diff --git a/wrappers/dotnet/VNLib.Utils.Cryptography.Noscrypt/src/internal/FunctionTable.cs b/wrappers/dotnet/VNLib.Utils.Cryptography.Noscrypt/src/internal/FunctionTable.cs index 17b66b2..0cda5e2 100644 --- a/wrappers/dotnet/VNLib.Utils.Cryptography.Noscrypt/src/internal/FunctionTable.cs +++ b/wrappers/dotnet/VNLib.Utils.Cryptography.Noscrypt/src/internal/FunctionTable.cs @@ -34,13 +34,16 @@ namespace VNLib.Utils.Cryptography.Noscrypt.@internal public readonly NCValidateSecretKeyDelegate NCValidateSecretKey; public readonly NCSignDataDelegate NCSignData; public readonly NCVerifyDataDelegate NCVerifyData; - public readonly NCEncryptDelegate NCEncrypt; - public readonly NCDecryptDelegate NCDecrypt; - public readonly NCVerifyMacDelegate NCVerifyMac; - public readonly NCComputeMacDelegate NCComputeMac; - public readonly NCSetEncryptionDataDelegate NCSetEncryptionData; - public readonly NCSetEncryptionPropertyDelegate NCSetEncryptionProperty; - public readonly NCSetEncryptionPropertyExDelegate NCSetEncryptionPropertyEx; + public readonly NCUtilCipherAllocDelegate NCUtilCipherAlloc; + public readonly NCUtilCipherFreeDelegate NCUtilCipherFree; + public readonly NCUtilCipherInitDelegate NCUtilCipherInit; + public readonly NCUtilCipherGetFlagsDelegate NCUtilCipherGetFlags; + public readonly NCUtilCipherGetOutputSizeDelegate NCUtilCipherGetOutputSize; + public readonly NCUtilCipherReadOutputDelegate NCUtilCipherReadOutput; + public readonly NCUtilCipherSetPropertyDelegate NCUtilCipherSetProperty; + public readonly NCUtilCipherUpdateDelegate NCUtilCipherUpdate; + public readonly NCUtilCipherGetIvSizeDelegate NCUtilCipherGetIvSize; + #if DEBUG public readonly NCGetConversationKeyDelegate NCGetConversationKey; @@ -59,13 +62,17 @@ namespace VNLib.Utils.Cryptography.Noscrypt.@internal NCVerifyData = library.DangerousGetFunction<NCVerifyDataDelegate>(); NCSignData = library.DangerousGetFunction<NCSignDataDelegate>(); NCVerifyData = library.DangerousGetFunction<NCVerifyDataDelegate>(); - NCEncrypt = library.DangerousGetFunction<NCEncryptDelegate>(); - NCDecrypt = library.DangerousGetFunction<NCDecryptDelegate>(); - NCVerifyMac = library.DangerousGetFunction<NCVerifyMacDelegate>(); - NCComputeMac = library.DangerousGetFunction<NCComputeMacDelegate>(); - NCSetEncryptionData = library.DangerousGetFunction<NCSetEncryptionDataDelegate>(); - NCSetEncryptionProperty = library.DangerousGetFunction<NCSetEncryptionPropertyDelegate>(); - NCSetEncryptionPropertyEx = library.DangerousGetFunction<NCSetEncryptionPropertyExDelegate>(); + + //Cipher util library functions + NCUtilCipherAlloc = library.DangerousGetFunction<NCUtilCipherAllocDelegate>(); + NCUtilCipherFree = library.DangerousGetFunction<NCUtilCipherFreeDelegate>(); + NCUtilCipherInit = library.DangerousGetFunction<NCUtilCipherInitDelegate>(); + NCUtilCipherGetFlags = library.DangerousGetFunction<NCUtilCipherGetFlagsDelegate>(); + NCUtilCipherGetOutputSize = library.DangerousGetFunction<NCUtilCipherGetOutputSizeDelegate>(); + NCUtilCipherReadOutput = library.DangerousGetFunction<NCUtilCipherReadOutputDelegate>(); + NCUtilCipherSetProperty = library.DangerousGetFunction<NCUtilCipherSetPropertyDelegate>(); + NCUtilCipherUpdate = library.DangerousGetFunction<NCUtilCipherUpdateDelegate>(); + NCUtilCipherGetIvSize = library.DangerousGetFunction<NCUtilCipherGetIvSizeDelegate>(); #if DEBUG NCGetConversationKey = library.DangerousGetFunction<NCGetConversationKeyDelegate>(); @@ -114,28 +121,35 @@ namespace VNLib.Utils.Cryptography.Noscrypt.@internal [SafeMethodName("NCVerifyData")] internal delegate NCResult NCVerifyDataDelegate(IntPtr ctx, NCPublicKey* sk, byte* data, uint dataSize, byte* sig64); - [SafeMethodName("NCEncrypt")] - internal delegate NCResult NCEncryptDelegate(IntPtr ctx, NCSecretKey* sk, NCPublicKey* pk, NCEncryptionArgs* data); + [SafeMethodName("NCGetConversationKey")] + internal delegate NCResult NCGetConversationKeyDelegate(IntPtr ctx, NCSecretKey* sk, NCPublicKey* pk, byte* keyOut32); - [SafeMethodName("NCDecrypt")] - internal delegate NCResult NCDecryptDelegate(IntPtr ctx, NCSecretKey* sk, NCPublicKey* pk, NCEncryptionArgs* data); - [SafeMethodName("NCVerifyMac")] - internal delegate NCResult NCVerifyMacDelegate(IntPtr ctx, NCSecretKey* sk, NCPublicKey* pk, NCMacVerifyArgs* args); + [SafeMethodName("NCUtilCipherAlloc")] + internal delegate IntPtr NCUtilCipherAllocDelegate(uint version, uint flags); - [SafeMethodName("NCComputeMac")] - internal delegate NCResult NCComputeMacDelegate(IntPtr ctx, byte* hmacKey32, byte* payload, uint payloadSize, byte* hmacOut32); + [SafeMethodName("NCUtilCipherFree")] + internal delegate void NCUtilCipherFreeDelegate(IntPtr cipher); - [SafeMethodName("NCGetConversationKey")] - internal delegate NCResult NCGetConversationKeyDelegate(nint ctx, NCSecretKey* sk, NCPublicKey* pk, byte* keyOut32); + [SafeMethodName("NCUtilCipherInit")] + internal delegate NCResult NCUtilCipherInitDelegate(IntPtr cipher, byte* inputData, uint inputLen); + + [SafeMethodName("NCUtilCipherGetFlags")] + internal delegate NCResult NCUtilCipherGetFlagsDelegate(IntPtr cipher); + + [SafeMethodName("NCUtilCipherGetOutputSize")] + internal delegate NCResult NCUtilCipherGetOutputSizeDelegate(IntPtr cipher); + + [SafeMethodName("NCUtilCipherReadOutput")] + internal delegate NCResult NCUtilCipherReadOutputDelegate(IntPtr cipher, byte* outputData, uint outputLen); - [SafeMethodName("NCSetEncryptionProperty")] - internal delegate NCResult NCSetEncryptionPropertyDelegate(NCEncryptionArgs* args, uint property, uint value); + [SafeMethodName("NCUtilCipherSetProperty")] + internal delegate NCResult NCUtilCipherSetPropertyDelegate(IntPtr cipher, uint property, byte* value, uint valueLen); - [SafeMethodName("NCSetEncryptionPropertyEx")] - internal delegate NCResult NCSetEncryptionPropertyExDelegate(NCEncryptionArgs* args, uint property, byte* value, uint valueLen); + [SafeMethodName("NCUtilCipherUpdate")] + internal delegate NCResult NCUtilCipherUpdateDelegate(IntPtr cipher, IntPtr libContext, NCSecretKey* secKey, NCPublicKey* pubKey); - [SafeMethodName("NCSetEncryptionData")] - internal delegate NCResult NCSetEncryptionDataDelegate(NCEncryptionArgs* args, byte* input, byte* output, uint dataSize); + [SafeMethodName("NCUtilCipherGetIvSize")] + internal delegate NCResult NCUtilCipherGetIvSizeDelegate(IntPtr cipher); } } diff --git a/wrappers/dotnet/VNLib.Utils.Cryptography.Noscrypt/src/internal/NCEncryptionArgs.cs b/wrappers/dotnet/VNLib.Utils.Cryptography.Noscrypt/src/internal/NCEncryptionArgs.cs deleted file mode 100644 index 91f0ff5..0000000 --- a/wrappers/dotnet/VNLib.Utils.Cryptography.Noscrypt/src/internal/NCEncryptionArgs.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2024 Vaughn Nugent -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see <https://www.gnu.org/licenses/>. - -using System; -using System.Runtime.InteropServices; - -namespace VNLib.Utils.Cryptography.Noscrypt.@internal -{ - [StructLayout(LayoutKind.Sequential)] - internal unsafe struct NCEncryptionArgs - { - public byte* nonceData; - public byte* keyData; - public byte* inputData; - public byte* outputData; - public uint dataSize; - public uint version; - } -} diff --git a/wrappers/dotnet/VNLib.Utils.Cryptography.Noscrypt/src/internal/NCMacVerifyArgs.cs b/wrappers/dotnet/VNLib.Utils.Cryptography.Noscrypt/src/internal/NCMacVerifyArgs.cs deleted file mode 100644 index 8a9ba1f..0000000 --- a/wrappers/dotnet/VNLib.Utils.Cryptography.Noscrypt/src/internal/NCMacVerifyArgs.cs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2024 Vaughn Nugent -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see <https://www.gnu.org/licenses/>. - -using System; - -namespace VNLib.Utils.Cryptography.Noscrypt.@internal -{ - internal unsafe struct NCMacVerifyArgs - { - /* The message authentication code certifying the Nip44 payload */ - public byte* mac32; - - /* The nonce used for the original message encryption */ - public byte* nonce32; - - /* The message payload data */ - public byte* payload; - - /* The size of the payload data */ - public uint payloadSize; - } -} |