Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions include/libvgp.h
Original file line number Diff line number Diff line change
@@ -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
Binary file added nuget/VGP.20.7.22.nupkg
Binary file not shown.
37 changes: 37 additions & 0 deletions nuget/Vgp.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
14 changes: 14 additions & 0 deletions nuget/vgp.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<PackageId>vgp</PackageId>
<Authors>vgp</Authors>
<Product>VGP</Product>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\vgp-lib.vcxproj" />
</ItemGroup>

</Project>
22 changes: 22 additions & 0 deletions nuget/vgp.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0"?>
<package >
<metadata>
<id>VGP</id>
<title>Very Good Privacy</title>
<version>20.7.22</version>
<authors>InvalidTag, HiddenField, Duality Blockchain Solutions</authors>
<owners>Duality Blockchain Solutions</owners>
<licenseUrl>https://github.com/duality-solutions/VGP/blob/master/LICENSE.md</licenseUrl>
<projectUrl>https://github.com/duality-solutions/VGP/</projectUrl>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<description>A .NET wrapper to invoke a C++ implementation of the VGP encryption library.</description>
<releaseNotes>Initial NuGet implementation.</releaseNotes>
<copyright>Copyright 2020</copyright>
<tags>ed25519 curve25519 aes-ctr aes-gcm shake ephemeral key-exchange crypto cryptographic cryptography</tags>
<dependencies />
</metadata>
<files>
<file src="..\Release\vgp-lib.dll" target="net35\x64" />
<file src="..\x64\Release\libvgp.dll" target="net35\x64" />
</files>
</package>
11 changes: 11 additions & 0 deletions src/libvgp.cpp
Original file line number Diff line number Diff line change
@@ -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);
}
3 changes: 3 additions & 0 deletions test/Resource.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by app.rc
Binary file added test/app.aps
Binary file not shown.
Binary file added test/app.ico
Binary file not shown.
Binary file added test/app.rc
Binary file not shown.
121 changes: 121 additions & 0 deletions test/vgp-test.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<ProjectGuid>{B5403B91-DF63-497E-8279-421A8703B4A7}</ProjectGuid>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<Keyword>ManagedCProj</Keyword>
<RootNamespace>vgptest</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CLRSupport>true</CLRSupport>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CLRSupport>true</CLRSupport>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CLRSupport>true</CLRSupport>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CLRSupport>false</CLRSupport>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LibraryPath>$(LibraryPath)</LibraryPath>
<IncludePath>C:\developer\openssl\lib;$(IncludePath)</IncludePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<AdditionalIncludeDirectories>$(ProjectDir)\..\src;$(ProjectDir)\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalUsingDirectories>C:\developer\openssl;%(AdditionalUsingDirectories)</AdditionalUsingDirectories>
</ClCompile>
<Link>
<AdditionalDependencies>C:\developer\openssl\lib\libeay32.dll;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ResourceCompile Include="app.rc" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="vgp_assert.h" />
<ClInclude Include="Resource.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="aes256ctr_test.c" />
<ClCompile Include="aes256gcm_test.c" />
<ClCompile Include="aes256_test.c" />
<ClCompile Include="convert_test.c" />
<ClCompile Include="curve25519_test.c" />
<ClCompile Include="encryption_core_test.c" />
<ClCompile Include="encryption_test.cpp" />
<ClCompile Include="shake256_test.c" />
<ClCompile Include="test.c" />
<ClCompile Include="vgp_assert.c" />
</ItemGroup>
<ItemGroup>
<Image Include="app.ico" />
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\vgp-lib.vcxproj">
<Project>{07161e0b-54f8-4e6d-b61b-cde7e620f9c1}</Project>
</ProjectReference>
</ItemGroup>
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
67 changes: 67 additions & 0 deletions test/vgp-test.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="app.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Resource.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="vgp_assert.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="encryption_test.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="aes256_test.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="aes256ctr_test.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="aes256gcm_test.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="convert_test.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="curve25519_test.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="encryption_core_test.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="shake256_test.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="test.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="vgp_assert.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Image Include="app.ico">
<Filter>Resource Files</Filter>
</Image>
</ItemGroup>
</Project>
7 changes: 3 additions & 4 deletions vgp-lib.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@
<Keyword>Win32Proj</Keyword>
<RootNamespace>vgp</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<ProjectName>vgp-lib</ProjectName>
<ProjectName>libvgp</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
Expand Down Expand Up @@ -55,7 +54,6 @@
<CLRSupport>false</CLRSupport>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
Expand Down Expand Up @@ -143,6 +141,7 @@
<ClInclude Include="include\fe.h" />
<ClInclude Include="include\fe_25_5.h" />
<ClInclude Include="include\ge.h" />
<ClInclude Include="include\libvgp.h" />
<ClInclude Include="include\os_rand.h" />
<ClInclude Include="include\rand.h" />
<ClInclude Include="include\sha512.h" />
Expand All @@ -161,14 +160,14 @@
<ClCompile Include="src\encryption_error.c" />
<ClCompile Include="src\fe.c" />
<ClCompile Include="src\ge.c" />
<ClCompile Include="src\libvgp.cpp" />
<ClCompile Include="src\os_rand.c" />
<ClCompile Include="src\rand.c" />
<ClCompile Include="src\sha512.c" />
<ClCompile Include="src\shake256.c" />
<ClCompile Include="src\shake256_rand.c" />
<ClCompile Include="src\utils.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
Loading