diff --git a/include/libvgp.h b/include/libvgp.h new file mode 100644 index 0000000..be3684b --- /dev/null +++ b/include/libvgp.h @@ -0,0 +1,40 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2020 Duality Blockchain Solutions + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef LIBVGP_H +#define LIBVGP_H + +#include "encryption.h" + +#ifdef LIBVGP_EXPORTS +#define LIBVGP_DLLEXPORT __declspec(dllexport) +#else +#define LIBVGP_DLLEXPORT __declspec(dllimport) +#endif + +LIBVGP_DLLEXPORT bool Encrypt(const vCharVector& vchPubKeys, const CharVector& vchData, CharVector& vchCipherText, std::string& strErrorMessage); + +LIBVGP_DLLEXPORT bool Decrypt(const CharVector& vchPrivKeySeed, const CharVector& vchCipherText, CharVector& vchData, std::string& strErrorMessage); + +#endif \ No newline at end of file diff --git a/nuget/VGP.20.7.22.nupkg b/nuget/VGP.20.7.22.nupkg new file mode 100644 index 0000000..18f91e5 Binary files /dev/null and b/nuget/VGP.20.7.22.nupkg differ diff --git a/nuget/Vgp.cs b/nuget/Vgp.cs new file mode 100644 index 0000000..6e450b8 --- /dev/null +++ b/nuget/Vgp.cs @@ -0,0 +1,37 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2020 Duality Blockchain Solutions + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +using System; +using System.Runtime.InteropServices; + +namespace VeryGoodPrivacy +{ + public class VGP + { + [DllImport("libvgp.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int Encrypt(byte[] vchPubKeys, byte[] vchData, byte[] vchCipherText, string strErrorMessage); + + [DllImport("libvgp.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int Decrypt(byte[] vchPrivKeySeed, byte[] vchCipherText, byte[] vchData, string strErrorMessage); + } +} diff --git a/nuget/vgp.csproj b/nuget/vgp.csproj new file mode 100644 index 0000000..ce3adc7 --- /dev/null +++ b/nuget/vgp.csproj @@ -0,0 +1,14 @@ + + + + netcoreapp3.1 + vgp + vgp + VGP + + + + + + + diff --git a/nuget/vgp.nuspec b/nuget/vgp.nuspec new file mode 100644 index 0000000..021a60e --- /dev/null +++ b/nuget/vgp.nuspec @@ -0,0 +1,22 @@ + + + + VGP + Very Good Privacy + 20.7.22 + InvalidTag, HiddenField, Duality Blockchain Solutions + Duality Blockchain Solutions + https://github.com/duality-solutions/VGP/blob/master/LICENSE.md + https://github.com/duality-solutions/VGP/ + true + A .NET wrapper to invoke a C++ implementation of the VGP encryption library. + Initial NuGet implementation. + Copyright 2020 + ed25519 curve25519 aes-ctr aes-gcm shake ephemeral key-exchange crypto cryptographic cryptography + + + + + + + \ No newline at end of file diff --git a/src/libvgp.cpp b/src/libvgp.cpp new file mode 100644 index 0000000..0d36389 --- /dev/null +++ b/src/libvgp.cpp @@ -0,0 +1,11 @@ +#include "libvgp.h" + +bool Encrypt(const vCharVector& vchPubKeys, const CharVector& vchData, CharVector& vchCipherText, std::string& strErrorMessage) +{ + return EncryptBDAPData(vchPubKeys, vchData, vchCipherText, strErrorMessage); +} + +bool Decrypt(const CharVector& vchPrivKeySeed, const CharVector& vchCipherText, CharVector& vchData, std::string& strErrorMessage) +{ + return DecryptBDAPData(vchPrivKeySeed, vchCipherText, vchData, strErrorMessage); +} diff --git a/test/Resource.h b/test/Resource.h new file mode 100644 index 0000000..d5ac7c4 --- /dev/null +++ b/test/Resource.h @@ -0,0 +1,3 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc diff --git a/test/app.aps b/test/app.aps new file mode 100644 index 0000000..f5a3018 Binary files /dev/null and b/test/app.aps differ diff --git a/test/app.ico b/test/app.ico new file mode 100644 index 0000000..789d7cc Binary files /dev/null and b/test/app.ico differ diff --git a/test/app.rc b/test/app.rc new file mode 100644 index 0000000..eab4306 Binary files /dev/null and b/test/app.rc differ diff --git a/test/vgp-test.vcxproj b/test/vgp-test.vcxproj new file mode 100644 index 0000000..8495717 --- /dev/null +++ b/test/vgp-test.vcxproj @@ -0,0 +1,121 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + {B5403B91-DF63-497E-8279-421A8703B4A7} + v4.7.2 + ManagedCProj + vgptest + 10.0 + + + Application + true + v142 + true + Unicode + + + Application + false + v142 + true + Unicode + + + Application + true + v142 + true + Unicode + + + Application + false + v142 + false + Unicode + + + + + + + + + + + + + + + + + + + + $(LibraryPath) + C:\developer\openssl\lib;$(IncludePath) + + + + $(ProjectDir)\..\src;$(ProjectDir)\..\include;%(AdditionalIncludeDirectories) + C:\developer\openssl;%(AdditionalUsingDirectories) + + + C:\developer\openssl\lib\libeay32.dll;%(AdditionalDependencies) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {07161e0b-54f8-4e6d-b61b-cde7e620f9c1} + + + + + \ No newline at end of file diff --git a/test/vgp-test.vcxproj.filters b/test/vgp-test.vcxproj.filters new file mode 100644 index 0000000..99bde49 --- /dev/null +++ b/test/vgp-test.vcxproj.filters @@ -0,0 +1,67 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Resource Files + + + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Resource Files + + + \ No newline at end of file diff --git a/vgp-lib.vcxproj b/vgp-lib.vcxproj index 3f9c7c7..71589df 100644 --- a/vgp-lib.vcxproj +++ b/vgp-lib.vcxproj @@ -24,9 +24,8 @@ Win32Proj vgp 10.0 - vgp-lib + libvgp - DynamicLibrary true @@ -55,7 +54,6 @@ false Unicode - @@ -143,6 +141,7 @@ + @@ -161,6 +160,7 @@ + @@ -168,7 +168,6 @@ - \ No newline at end of file diff --git a/vgp.sln b/vgp.sln index be636a6..0d5d9d7 100644 --- a/vgp.sln +++ b/vgp.sln @@ -3,24 +3,54 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.30011.22 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vgp-lib", "vgp-lib.vcxproj", "{07161E0B-54F8-4E6D-B61B-CDE7E620F9C1}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libvgp", "vgp-lib.vcxproj", "{07161E0B-54F8-4E6D-B61B-CDE7E620F9C1}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "vgp", "nuget\vgp.csproj", "{7777C5EE-06A2-4268-8B17-40901E27E062}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU Debug|x64 = Debug|x64 Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU Release|x64 = Release|x64 Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {07161E0B-54F8-4E6D-B61B-CDE7E620F9C1}.Debug|Any CPU.ActiveCfg = Debug|Win32 {07161E0B-54F8-4E6D-B61B-CDE7E620F9C1}.Debug|x64.ActiveCfg = Debug|x64 {07161E0B-54F8-4E6D-B61B-CDE7E620F9C1}.Debug|x64.Build.0 = Debug|x64 {07161E0B-54F8-4E6D-B61B-CDE7E620F9C1}.Debug|x86.ActiveCfg = Debug|Win32 {07161E0B-54F8-4E6D-B61B-CDE7E620F9C1}.Debug|x86.Build.0 = Debug|Win32 + {07161E0B-54F8-4E6D-B61B-CDE7E620F9C1}.Release|Any CPU.ActiveCfg = Release|Win32 {07161E0B-54F8-4E6D-B61B-CDE7E620F9C1}.Release|x64.ActiveCfg = Release|x64 {07161E0B-54F8-4E6D-B61B-CDE7E620F9C1}.Release|x64.Build.0 = Release|x64 {07161E0B-54F8-4E6D-B61B-CDE7E620F9C1}.Release|x86.ActiveCfg = Release|Win32 {07161E0B-54F8-4E6D-B61B-CDE7E620F9C1}.Release|x86.Build.0 = Release|Win32 + {4579AB19-3455-41C0-BCD7-118CD0902398}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4579AB19-3455-41C0-BCD7-118CD0902398}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4579AB19-3455-41C0-BCD7-118CD0902398}.Debug|x64.ActiveCfg = Debug|Any CPU + {4579AB19-3455-41C0-BCD7-118CD0902398}.Debug|x64.Build.0 = Debug|Any CPU + {4579AB19-3455-41C0-BCD7-118CD0902398}.Debug|x86.ActiveCfg = Debug|Any CPU + {4579AB19-3455-41C0-BCD7-118CD0902398}.Debug|x86.Build.0 = Debug|Any CPU + {4579AB19-3455-41C0-BCD7-118CD0902398}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4579AB19-3455-41C0-BCD7-118CD0902398}.Release|Any CPU.Build.0 = Release|Any CPU + {4579AB19-3455-41C0-BCD7-118CD0902398}.Release|x64.ActiveCfg = Release|Any CPU + {4579AB19-3455-41C0-BCD7-118CD0902398}.Release|x64.Build.0 = Release|Any CPU + {4579AB19-3455-41C0-BCD7-118CD0902398}.Release|x86.ActiveCfg = Release|Any CPU + {4579AB19-3455-41C0-BCD7-118CD0902398}.Release|x86.Build.0 = Release|Any CPU + {7777C5EE-06A2-4268-8B17-40901E27E062}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7777C5EE-06A2-4268-8B17-40901E27E062}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7777C5EE-06A2-4268-8B17-40901E27E062}.Debug|x64.ActiveCfg = Debug|Any CPU + {7777C5EE-06A2-4268-8B17-40901E27E062}.Debug|x64.Build.0 = Debug|Any CPU + {7777C5EE-06A2-4268-8B17-40901E27E062}.Debug|x86.ActiveCfg = Debug|Any CPU + {7777C5EE-06A2-4268-8B17-40901E27E062}.Debug|x86.Build.0 = Debug|Any CPU + {7777C5EE-06A2-4268-8B17-40901E27E062}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7777C5EE-06A2-4268-8B17-40901E27E062}.Release|Any CPU.Build.0 = Release|Any CPU + {7777C5EE-06A2-4268-8B17-40901E27E062}.Release|x64.ActiveCfg = Release|Any CPU + {7777C5EE-06A2-4268-8B17-40901E27E062}.Release|x64.Build.0 = Release|Any CPU + {7777C5EE-06A2-4268-8B17-40901E27E062}.Release|x86.ActiveCfg = Release|Any CPU + {7777C5EE-06A2-4268-8B17-40901E27E062}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE