Skip to content

Commit

Permalink
Merge pull request #36 from Devolutions/validate-signature-wrapper-cs…
Browse files Browse the repository at this point in the history
…harp

Validate cipher signature method in csharp wrapper
  • Loading branch information
MathieuMorrissette authored Oct 24, 2019
2 parents 7e0e175 + a20c3fa commit 37f313d
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 6 deletions.
2 changes: 1 addition & 1 deletion devolutionscrypto/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "devolutionscrypto"
version = "0.1.6"
version = "0.1.7"
authors = ["Philippe Dugre <[email protected]>", "Mathieu Morrissette <[email protected]>"]
edition = "2018"
readme = "../README.md"
Expand Down
9 changes: 9 additions & 0 deletions wrappers/csharp/Enums.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Devolutions.Cryptography
{
enum DataType
{
Key = 1,
Cipher = 2,
Hash = 3
}
}
10 changes: 5 additions & 5 deletions wrappers/csharp/GeneratePackage.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
if rdm:
define += ";RDM"

command= subprocess.Popen([csc_path,"-out:./" + folder + "/bin/Devolutions.Crypto.dll", "-debug:pdbonly" ,"-pdb:./" + folder + "/bin/Devolutions.Crypto.pdb", "-target:library", "-platform:anycpu", define ,"NativeError.cs", "Native.cs", "Native.Xamarin.cs", "ManagedError.cs", "Managed.cs", "KeyExchange.cs", "Utils.cs", "./" + folder + "/bin/AssemblyInfo.cs"], stdout=subprocess.PIPE)
command= subprocess.Popen([csc_path,"-out:./" + folder + "/bin/Devolutions.Crypto.dll", "-debug:pdbonly" ,"-pdb:./" + folder + "/bin/Devolutions.Crypto.pdb", "-target:library", "-platform:anycpu", define ,"NativeError.cs", "Native.cs", "Native.Xamarin.cs", "ManagedError.cs", "Managed.cs", "KeyExchange.cs", "Utils.cs", "Enums.cs", "./" + folder + "/bin/AssemblyInfo.cs"], stdout=subprocess.PIPE)
output = command.stdout.read().decode('utf-8')

print(output)
Expand Down Expand Up @@ -182,7 +182,7 @@

print("Building Managed Library...")
# TODO create universal library with lipo
command= subprocess.Popen(["csc", "-out:./macos/bin/Devolutions.Crypto.dll", "-debug:pdbonly" ,"-pdb:./macos/bin/Devolutions.Crypto.pdb", "-target:library", "-platform:anycpu", "-define:MAC" ,"NativeError.cs", "Native.cs", "Native.Xamarin.cs", "ManagedError.cs", "Managed.cs", "KeyExchange.cs", "Utils.cs", "./macos/bin/AssemblyInfo.cs"], stdout=subprocess.PIPE)
command= subprocess.Popen(["csc", "-out:./macos/bin/Devolutions.Crypto.dll", "-debug:pdbonly" ,"-pdb:./macos/bin/Devolutions.Crypto.pdb", "-target:library", "-platform:anycpu", "-define:MAC" ,"NativeError.cs", "Native.cs", "Native.Xamarin.cs", "ManagedError.cs", "Managed.cs", "KeyExchange.cs", "Utils.cs", "Enums.cs", "./macos/bin/AssemblyInfo.cs"], stdout=subprocess.PIPE)
output = command.stdout.read().decode('utf-8')

print(output)
Expand Down Expand Up @@ -256,7 +256,7 @@

print("Building Managed Library...")
# TODO create universal library with lipo
command= subprocess.Popen(["csc", "-out:./ios/bin/Devolutions.Crypto.dll", "-debug:pdbonly" ,"-pdb:./ios/bin/Devolutions.Crypto.pdb", "-target:library", "-platform:anycpu", "-define:IOS" ,"NativeError.cs", "Native.cs", "Native.Xamarin.cs", "ManagedError.cs", "Managed.cs", "KeyExchange.cs", "Utils.cs", "./ios/bin/AssemblyInfo.cs"], stdout=subprocess.PIPE)
command= subprocess.Popen(["csc", "-out:./ios/bin/Devolutions.Crypto.dll", "-debug:pdbonly" ,"-pdb:./ios/bin/Devolutions.Crypto.pdb", "-target:library", "-platform:anycpu", "-define:IOS" ,"NativeError.cs", "Native.cs", "Native.Xamarin.cs", "ManagedError.cs", "Managed.cs", "KeyExchange.cs", "Utils.cs", "Enums.cs", "./ios/bin/AssemblyInfo.cs"], stdout=subprocess.PIPE)
output = command.stdout.read().decode('utf-8')

print(output)
Expand Down Expand Up @@ -328,7 +328,7 @@

print("Building Managed Library...")

command = subprocess.Popen(["csc", "-out:./android/bin/Devolutions.Crypto.dll", "-debug:pdbonly" ,"-pdb:./android/bin/Devolutions.Crypto.pdb", "-target:library", "-platform:anycpu", "-define:ANDROID" ,"NativeError.cs", "Native.cs", "Native.Xamarin.cs", "ManagedError.cs", "Managed.cs", "KeyExchange.cs", "Utils.cs", "./android/bin/AssemblyInfo.cs"], stdout=subprocess.PIPE)
command = subprocess.Popen(["csc", "-out:./android/bin/Devolutions.Crypto.dll", "-debug:pdbonly" ,"-pdb:./android/bin/Devolutions.Crypto.pdb", "-target:library", "-platform:anycpu", "-define:ANDROID" ,"NativeError.cs", "Native.cs", "Native.Xamarin.cs", "ManagedError.cs", "Managed.cs", "KeyExchange.cs", "Utils.cs", "Enums.cs", "./android/bin/AssemblyInfo.cs"], stdout=subprocess.PIPE)
output = command.stdout.read().decode('utf-8')

print(output)
Expand Down Expand Up @@ -385,7 +385,7 @@

print("Building Managed Library...")

command= subprocess.Popen(["csc", "-out:./linux/bin/Devolutions.Crypto.dll", "-debug:pdbonly" ,"-pdb:./linux/bin/Devolutions.Crypto.pdb", "-target:library", "-platform:anycpu", "-define:LINUX" ,"NativeError.cs", "Native.cs", "Native.Xamarin.cs", "ManagedError.cs", "Managed.cs", "KeyExchange.cs", "Utils.cs", "./linux/bin/AssemblyInfo.cs"], stdout=subprocess.PIPE)
command= subprocess.Popen(["csc", "-out:./linux/bin/Devolutions.Crypto.dll", "-debug:pdbonly" ,"-pdb:./linux/bin/Devolutions.Crypto.pdb", "-target:library", "-platform:anycpu", "-define:LINUX" ,"NativeError.cs", "Native.cs", "Native.Xamarin.cs", "ManagedError.cs", "Managed.cs", "KeyExchange.cs", "Utils.cs", "Enums.cs", "./linux/bin/AssemblyInfo.cs"], stdout=subprocess.PIPE)
output = command.stdout.read().decode('utf-8')

print(output)
Expand Down
15 changes: 15 additions & 0 deletions wrappers/csharp/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@ namespace Devolutions.Cryptography

public static partial class Utils
{
public static bool ValidateCiphertextSignature(byte[] data)
{
if(data == null)
{
return false;
}

if(data.Length >= 8)
{
return data[0] == '\xD' && data[1] == '\xC' && data[2] == (int)DataType.Cipher && data[3] == 0 && data[4] == 0 && data[5] == 0;
}

return false;
}

public static byte[] StringToByteArray(string data)
{
if (data == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@
</Compile>
<Compile Include="..\..\..\..\Utils.cs">
<Link>Utils.cs</Link>
</Compile>
<Compile Include="..\..\..\..\Enums.cs">
<Link>Enums.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@
</Compile>
<Compile Include="..\..\..\..\Utils.cs">
<Link>Utils.cs</Link>
</Compile>
<Compile Include="..\..\..\..\Enums.cs">
<Link>Enums.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@
<Compile Include="..\..\..\..\..\Utils.cs">
<Link>Utils.cs</Link>
</Compile>
<Compile Include="..\..\..\..\..\Enums.cs">
<Link>Enums.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<ObjcBindingApiDefinition Include="ApiDefinition.cs" />
Expand Down

0 comments on commit 37f313d

Please sign in to comment.