mirror of
https://github.com/esiur/esiur-dotnet.git
synced 2025-05-06 03:32:57 +00:00
cipher
This commit is contained in:
parent
81f9f92755
commit
8ab0e811bd
32
Esiur.Generator/AES.cs
Normal file
32
Esiur.Generator/AES.cs
Normal file
@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace Esiur.Security.Cryptography
|
||||
{
|
||||
public class AES : ISymetricCipher
|
||||
{
|
||||
Aes aes = Aes.Create();
|
||||
|
||||
public ushort Identifier => 1;
|
||||
|
||||
public byte[] Decrypt(byte[] data)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public byte[] Encrypt(byte[] data)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public byte[] SetKey(byte[] key)
|
||||
{
|
||||
//aes.Key = key;
|
||||
//aes.IV = key;
|
||||
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
49
Esiur.Generator/ECDH.cs
Normal file
49
Esiur.Generator/ECDH.cs
Normal file
@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using Esiur.Security.Cryptography;
|
||||
using Esiur.Data;
|
||||
using System.Linq;
|
||||
|
||||
namespace Esiur.Security.Cryptography
|
||||
{
|
||||
public class ECDH : IKeyExchanger
|
||||
{
|
||||
public ushort Identifier => 1;
|
||||
|
||||
ECDiffieHellman ecdh = ECDiffieHellman.Create(ECCurve.NamedCurves.brainpoolP256r1);
|
||||
|
||||
public byte[] ComputeSharedKey(byte[] key)
|
||||
{
|
||||
var x = key.Clip(0, (uint)key.Length / 2);
|
||||
var y = key.Clip((uint)key.Length / 2, (uint)key.Length / 2);
|
||||
|
||||
ECParameters parameters = new ECParameters
|
||||
{
|
||||
Curve = ECCurve.NamedCurves.brainpoolP256r1,
|
||||
Q = {
|
||||
X = x,
|
||||
Y = y,
|
||||
}
|
||||
};
|
||||
|
||||
byte[] derivedKey;
|
||||
using (ECDiffieHellman peer = ECDiffieHellman.Create(parameters))
|
||||
using (ECDiffieHellmanPublicKey peerPublic = peer.PublicKey)
|
||||
{
|
||||
return derivedKey = ecdh.DeriveKeyMaterial(peerPublic);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public byte[] GetPublicKey()
|
||||
{
|
||||
var kp = ecdh.PublicKey.ExportParameters();
|
||||
|
||||
var key = DC.Combine(kp.Q.X, 0, (uint)kp.Q.X.Length, kp.Q.Y, 0, (uint)kp.Q.Y.Length);
|
||||
|
||||
return key;
|
||||
}
|
||||
}
|
||||
}
|
12
Esiur.Generator/Esiur.Security.Cryptography.csproj
Normal file
12
Esiur.Generator/Esiur.Security.Cryptography.csproj
Normal file
@ -0,0 +1,12 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
<LangVersion>latest</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Esiur\Esiur.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -9,7 +9,7 @@
|
||||
<Product>Esiur Entity Framework Extension</Product>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<PackageId>Esiur.Stores.EntityCore</PackageId>
|
||||
<Version>1.3.3</Version>
|
||||
<Version>1.3.4</Version>
|
||||
<LangVersion>latest</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.2" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.3" />
|
||||
<PackageReference Include="System.Collections" Version="4.3.0" />
|
||||
</ItemGroup>
|
||||
|
||||
|
@ -11,14 +11,14 @@
|
||||
<PackageProjectUrl>http://www.esiur.com</PackageProjectUrl>
|
||||
<RepositoryUrl>https://github.com/esiur/esiur-dotnet/</RepositoryUrl>
|
||||
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
|
||||
<Version>1.5.5</Version>
|
||||
<Version>1.5.6</Version>
|
||||
<PackageId>Esiur.Stores.MongoDB</PackageId>
|
||||
<LangVersion>latest</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MongoDB.Bson" Version="2.12.3" />
|
||||
<PackageReference Include="MongoDB.Driver" Version="2.12.3" />
|
||||
<PackageReference Include="MongoDB.Bson" Version="2.24.0" />
|
||||
<PackageReference Include="MongoDB.Driver" Version="2.24.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -51,15 +51,15 @@ public class MongoDBStore : IStore
|
||||
KeyList<string, WeakReference> resources = new KeyList<string, WeakReference>();
|
||||
|
||||
|
||||
[Public]
|
||||
[Export]
|
||||
public event ResourceEventHandler<IResource> ResourceAdded;
|
||||
|
||||
[Public]
|
||||
[Export]
|
||||
public event ResourceEventHandler<IResource> ResourceRemoved;
|
||||
|
||||
int count = 0;
|
||||
|
||||
[Public]
|
||||
[Export]
|
||||
public virtual int Count
|
||||
{
|
||||
get
|
||||
@ -109,7 +109,7 @@ public class MongoDBStore : IStore
|
||||
return true;
|
||||
}
|
||||
|
||||
[Public]
|
||||
[Export]
|
||||
public bool Remove(IResource resource)
|
||||
{
|
||||
var objectId = resource.Instance.Variables["objectId"].ToString();
|
||||
|
@ -35,7 +35,7 @@ namespace Esiur.Stores.MongoDB
|
||||
{
|
||||
public class MongoDBStore<T> : MongoDBStore where T:IResource
|
||||
{
|
||||
[Public]
|
||||
[Export]
|
||||
public async AsyncReply<T> New(string name = null, object properties = null)
|
||||
{
|
||||
var resource = await Warehouse.New<T>(name, this, null, null, null, properties);
|
||||
@ -43,7 +43,7 @@ namespace Esiur.Stores.MongoDB
|
||||
return resource;
|
||||
}
|
||||
|
||||
[Public]
|
||||
[Export]
|
||||
public async AsyncReply<IResource[]> Slice(int index, int limit)
|
||||
{
|
||||
var list = await this.Instance.Children<IResource>();
|
||||
|
@ -10,6 +10,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Esiur.Stores.EntityCore", "
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Test", "Test\Test.csproj", "{331F82B6-6B90-4533-9718-F7C8090D8F19}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Esiur.Security.Cryptography", "Esiur.Generator\Esiur.Security.Cryptography.csproj", "{C0C55C1A-7C48-41EB-9A65-27BC99D82F6D}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -32,6 +34,10 @@ Global
|
||||
{331F82B6-6B90-4533-9718-F7C8090D8F19}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{331F82B6-6B90-4533-9718-F7C8090D8F19}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{331F82B6-6B90-4533-9718-F7C8090D8F19}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{C0C55C1A-7C48-41EB-9A65-27BC99D82F6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C0C55C1A-7C48-41EB-9A65-27BC99D82F6D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C0C55C1A-7C48-41EB-9A65-27BC99D82F6D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C0C55C1A-7C48-41EB-9A65-27BC99D82F6D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@ -39,4 +45,4 @@ Global
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {C584421D-5EC0-4821-B7D8-2633D8D405F2}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
EndGlobal
|
||||
|
@ -1,7 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<Description>Distributed Resources Platform</Description>
|
||||
<Copyright>Ahmed Kh. Zamil</Copyright>
|
||||
<PackageProjectUrl>http://www.esiur.com</PackageProjectUrl>
|
||||
@ -18,6 +17,7 @@
|
||||
<Product>Esiur</Product>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<PackageLicenseFile>LICENSE</PackageLicenseFile>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
@ -83,10 +83,10 @@
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="$(OutputPath)\$(AssemblyName).dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
|
||||
<None Include="$(OutputPath)\$(AssemblyName).dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
|
||||
<!-- Package the Newtonsoft.Json dependency alongside the generator assembly -->
|
||||
<None Include="$(PkgSystem_Text_Json)\lib\netstandard2.0\*.dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
|
||||
<None Include="Tools/*" Pack="true" PackagePath="tools/" />
|
||||
<None Include="$(PkgSystem_Text_Json)\lib\netstandard2.0\*.dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
|
||||
<None Include="Tools/*" Pack="true" PackagePath="tools/" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
|
@ -228,10 +228,10 @@ public partial class DistributedConnection : NetworkConnection, IStore
|
||||
{
|
||||
var dmn = DC.ToBytes(session.LocalAuthentication.Domain);
|
||||
|
||||
if (session.Encrypted)
|
||||
if (session.KeyExchanger != null)
|
||||
{
|
||||
// create key
|
||||
//var ecdh = System.Security.Cryptography.ECAlgorithm.ECDiffieHellman.Create();
|
||||
var key = session.KeyExchanger.GetPublicKey();
|
||||
|
||||
if (session.LocalAuthentication.Method == AuthenticationMethod.Credentials)
|
||||
{
|
||||
@ -240,9 +240,12 @@ public partial class DistributedConnection : NetworkConnection, IStore
|
||||
var un = DC.ToBytes(session.LocalAuthentication.Username);
|
||||
|
||||
SendParams()
|
||||
.AddUInt8(0x60)
|
||||
.AddUInt8(0x60 | 0x2)
|
||||
.AddUInt8((byte)dmn.Length)
|
||||
.AddUInt8Array(dmn)
|
||||
.AddUInt16(session.KeyExchanger.Identifier)
|
||||
.AddUInt16((ushort)key.Length)
|
||||
.AddUInt8Array(key)
|
||||
.AddUInt8Array(localNonce)
|
||||
.AddUInt8((byte)un.Length)
|
||||
.AddUInt8Array(un)
|
||||
@ -252,9 +255,12 @@ public partial class DistributedConnection : NetworkConnection, IStore
|
||||
{
|
||||
|
||||
SendParams()
|
||||
.AddUInt8(0x70)
|
||||
.AddUInt8(0x70 | 0x2)
|
||||
.AddUInt8((byte)dmn.Length)
|
||||
.AddUInt8Array(dmn)
|
||||
.AddUInt16(session.KeyExchanger.Identifier)
|
||||
.AddUInt16((ushort)key.Length)
|
||||
.AddUInt8Array(key)
|
||||
.AddUInt8Array(localNonce)
|
||||
.AddUInt64(session.LocalAuthentication.TokenIndex)
|
||||
.Done();//, dmn, localNonce, token
|
||||
@ -262,10 +268,14 @@ public partial class DistributedConnection : NetworkConnection, IStore
|
||||
}
|
||||
else if (session.LocalAuthentication.Method == AuthenticationMethod.None)
|
||||
{
|
||||
// @REVIEW: MITM Attack can still occure
|
||||
SendParams()
|
||||
.AddUInt8(0x40)
|
||||
.AddUInt8(0x40 | 0x2)
|
||||
.AddUInt8((byte)dmn.Length)
|
||||
.AddUInt8Array(dmn)
|
||||
.AddUInt16(session.KeyExchanger.Identifier)
|
||||
.AddUInt16((ushort)key.Length)
|
||||
.AddUInt8Array(key)
|
||||
.Done();//, dmn, localNonce, token
|
||||
}
|
||||
else
|
||||
|
@ -30,6 +30,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Esiur.Security.Cryptography;
|
||||
|
||||
namespace Esiur.Security.Authority;
|
||||
public class Session
|
||||
@ -50,7 +51,9 @@ public class Session
|
||||
Authentication localAuth, remoteAuth;
|
||||
//string domain;
|
||||
|
||||
public bool Encrypted { get; set; }
|
||||
|
||||
public IKeyExchanger KeyExchanger { get; set; } = null;
|
||||
public ISymetricCipher SymetricCipher { get; set; } = null;
|
||||
|
||||
|
||||
public Session(Authentication localAuthentication, Authentication remoteAuthentication)
|
||||
|
14
Esiur/Security/Cryptography/IKeyExchanger.cs
Normal file
14
Esiur/Security/Cryptography/IKeyExchanger.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
|
||||
namespace Esiur.Security.Cryptography
|
||||
{
|
||||
public interface IKeyExchanger
|
||||
{
|
||||
public ushort Identifier { get; }
|
||||
public byte[] GetPublicKey();
|
||||
public byte[] ComputeSharedKey(byte[] key);
|
||||
}
|
||||
}
|
14
Esiur/Security/Cryptography/ISymetricCipher.cs
Normal file
14
Esiur/Security/Cryptography/ISymetricCipher.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Esiur.Security.Cryptography
|
||||
{
|
||||
public interface ISymetricCipher
|
||||
{
|
||||
public ushort Identifier { get; }
|
||||
public byte[] Encrypt(byte[] data);
|
||||
public byte[] Decrypt(byte[] data);
|
||||
public byte[] SetKey(byte[] key);
|
||||
}
|
||||
}
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Test
|
||||
{
|
||||
[Public]
|
||||
[Export]
|
||||
public class MyChildRecord : MyRecord
|
||||
{
|
||||
public string ChildName { get; set; }
|
||||
|
@ -10,11 +10,11 @@ namespace Test
|
||||
[Resource]
|
||||
public partial class MyChildResource : MyResource
|
||||
{
|
||||
[Public] string childName;
|
||||
[Public("Hell2o")] public int ChildMethod(string childName) => 111;
|
||||
[Public] public new string Hello() => "Hi from Child";
|
||||
[Export] string childName;
|
||||
[Export("Hell2o")] public int ChildMethod(string childName) => 111;
|
||||
[Export] public new string Hello() => "Hi from Child";
|
||||
|
||||
[Public] public string HelloChild() => "Hi from Child";
|
||||
[Export] public string HelloChild() => "Hi from Child";
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -10,10 +10,10 @@ namespace Test
|
||||
{
|
||||
public class MyGenericRecord<T> : IRecord where T : IResource
|
||||
{
|
||||
[Public] public int Start { get; set; }
|
||||
[Public] public int Needed { get; set; }
|
||||
[Public] public int Total { get; set; }
|
||||
[Public] public T[] Results { get; set; }
|
||||
[Export] public int Start { get; set; }
|
||||
[Export] public int Needed { get; set; }
|
||||
[Export] public int Total { get; set; }
|
||||
[Export] public T[] Results { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Test
|
||||
{
|
||||
[Public]
|
||||
[Export]
|
||||
public class MyRecord:IRecord
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
@ -12,12 +12,12 @@ namespace Test
|
||||
[Annotation("A", "B", "C", "D")]
|
||||
public partial class MyResource
|
||||
{
|
||||
[Public][Annotation("Comment")] string description;
|
||||
[Public] int categoryId;
|
||||
[Export][Annotation("Comment")] string description;
|
||||
[Export] int categoryId;
|
||||
|
||||
[Public] public string Hello() => "Hi";
|
||||
[Export] public string Hello() => "Hi";
|
||||
|
||||
[Public] public string HelloParent() => "Hi from Parent";
|
||||
[Export] public string HelloParent() => "Hi from Parent";
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -25,73 +25,73 @@ public enum SizeEnum:short
|
||||
public partial class MyService
|
||||
{
|
||||
|
||||
[Public] public event ResourceEventHandler<string> StringEvent;
|
||||
[Public] public event ResourceEventHandler<object[]> ArrayEvent;
|
||||
[Export] public event ResourceEventHandler<string> StringEvent;
|
||||
[Export] public event ResourceEventHandler<object[]> ArrayEvent;
|
||||
|
||||
[Public] bool boolean = true;
|
||||
[Public] bool[] booleanArray = new bool[] { true, false, true, false, true };
|
||||
[Export] bool boolean = true;
|
||||
[Export] bool[] booleanArray = new bool[] { true, false, true, false, true };
|
||||
|
||||
[Public]
|
||||
[Export]
|
||||
public MyGenericRecord<MyResource> GetGenericRecord()
|
||||
{
|
||||
return new MyGenericRecord<MyResource>() { Needed = 3, Start = 10, Results = new MyResource[0], Total = 102 };
|
||||
}
|
||||
|
||||
[Public] public static string staticFunction(string name) => $"Hello {name}";
|
||||
[Export] public static string staticFunction(string name) => $"Hello {name}";
|
||||
|
||||
[Public] byte uInt8Test = 8;
|
||||
[Public] byte? uInt8Null = null;
|
||||
[Public] byte[] uInt8Array = new byte[] { 0, 1, 2, 3, 4, 5 };
|
||||
[Public] byte?[] uInt8ArrayNull = new byte?[] { 0, null, 2, null, 4, null };
|
||||
[Export] byte uInt8Test = 8;
|
||||
[Export] byte? uInt8Null = null;
|
||||
[Export] byte[] uInt8Array = new byte[] { 0, 1, 2, 3, 4, 5 };
|
||||
[Export] byte?[] uInt8ArrayNull = new byte?[] { 0, null, 2, null, 4, null };
|
||||
|
||||
[Public] sbyte int8 = -8;
|
||||
[Public] sbyte[] int8Array = new sbyte[] { -3, -2, -1, 0, 1, 2 };
|
||||
[Export] sbyte int8 = -8;
|
||||
[Export] sbyte[] int8Array = new sbyte[] { -3, -2, -1, 0, 1, 2 };
|
||||
|
||||
[Public] char char16 = 'ح';
|
||||
[Public] char[] char16Array = new char[] { 'م', 'ر', 'ح', 'ب', 'ا' };
|
||||
[Export] char char16 = 'ح';
|
||||
[Export] char[] char16Array = new char[] { 'م', 'ر', 'ح', 'ب', 'ا' };
|
||||
|
||||
[Public] short int16 = -16;
|
||||
[Public] short[] int16Array = new short[] { -3, -2, -1, 0, 1, 2 };
|
||||
[Export] short int16 = -16;
|
||||
[Export] short[] int16Array = new short[] { -3, -2, -1, 0, 1, 2 };
|
||||
|
||||
[Public] ushort uInt16 = 16;
|
||||
[Public] ushort[] uInt16Array = new ushort[] { 0, 1, 2, 3, 4, 5 };
|
||||
[Export] ushort uInt16 = 16;
|
||||
[Export] ushort[] uInt16Array = new ushort[] { 0, 1, 2, 3, 4, 5 };
|
||||
|
||||
|
||||
[Public] int int32Prop = -32;
|
||||
[Public] int[] int32Array = new int[] { -3, -2, -1, 0, 1, 2 };
|
||||
[Export] int int32Prop = -32;
|
||||
[Export] int[] int32Array = new int[] { -3, -2, -1, 0, 1, 2 };
|
||||
|
||||
[Public] uint uInt32 = 32;
|
||||
[Public] uint[] uInt32Array = new uint[] { 0, 1, 2, 3, 4, 5 };
|
||||
[Export] uint uInt32 = 32;
|
||||
[Export] uint[] uInt32Array = new uint[] { 0, 1, 2, 3, 4, 5 };
|
||||
|
||||
[Public] long int64 = 323232323232;
|
||||
[Public] long[] int64Array = new long[] { -3, -2, -1, 0, 1, 2 };
|
||||
[Export] long int64 = 323232323232;
|
||||
[Export] long[] int64Array = new long[] { -3, -2, -1, 0, 1, 2 };
|
||||
|
||||
[Public] ulong uInt64;
|
||||
[Public] ulong[] uInt64Array = new ulong[] { 0, 1, 2, 3, 4, 5 };
|
||||
[Export] ulong uInt64;
|
||||
[Export] ulong[] uInt64Array = new ulong[] { 0, 1, 2, 3, 4, 5 };
|
||||
|
||||
[Public] float float32 = 32.32f;
|
||||
[Public] float[] float32Array = new float[] { -3.3f, -2.2f, -1.1f, 0, 1.1f, 2.2f };
|
||||
[Export] float float32 = 32.32f;
|
||||
[Export] float[] float32Array = new float[] { -3.3f, -2.2f, -1.1f, 0, 1.1f, 2.2f };
|
||||
|
||||
[Public] double float64 = 32.323232;
|
||||
[Public] double[] float64Array = new double[] { -3.3, -2.2, -1.1, 0, 1.1, 2.2 };
|
||||
[Export] double float64 = 32.323232;
|
||||
[Export] double[] float64Array = new double[] { -3.3, -2.2, -1.1, 0, 1.1, 2.2 };
|
||||
|
||||
[Public] decimal float128 = 3232.323232323232m;
|
||||
[Public] decimal[] float128Array = new decimal[] { -3.3m, -2.2m, -1.1m, 0, 1.1m, 2.2m };
|
||||
[Export] decimal float128 = 3232.323232323232m;
|
||||
[Export] decimal[] float128Array = new decimal[] { -3.3m, -2.2m, -1.1m, 0, 1.1m, 2.2m };
|
||||
|
||||
[Public("Text")] string stringTest = "Hello World";
|
||||
[Public] string[] stringArray = new string[] { "Hello", "World" };
|
||||
[Export("Text")] string stringTest = "Hello World";
|
||||
[Export] string[] stringArray = new string[] { "Hello", "World" };
|
||||
|
||||
[Public] DateTime time = DateTime.Now;
|
||||
[Export] DateTime time = DateTime.Now;
|
||||
|
||||
|
||||
[Public]
|
||||
[Export]
|
||||
Map<string, object> stringMap = new Map<string, object>()
|
||||
{
|
||||
["int"] = 33,
|
||||
["string"] = "Hello World"
|
||||
};
|
||||
|
||||
[Public]
|
||||
[Export]
|
||||
Map<int, string> intStringMap = new()
|
||||
{
|
||||
[4] = "Abcd",
|
||||
@ -99,11 +99,11 @@ public partial class MyService
|
||||
};
|
||||
|
||||
|
||||
[Public("Object")] object objectTest = "object";
|
||||
[Export("Object")] object objectTest = "object";
|
||||
|
||||
[Public] object[] objectArray = new object[] { 1, 1.2f, Math.PI, "Hello World" };
|
||||
[Export] object[] objectArray = new object[] { 1, 1.2f, Math.PI, "Hello World" };
|
||||
|
||||
[Public]
|
||||
[Export]
|
||||
public DistributedPropertyContext<int> PropertyContext
|
||||
{
|
||||
get => new DistributedPropertyContext<int>((sender) => sender.RemoteEndPoint.Port);
|
||||
@ -113,38 +113,38 @@ public partial class MyService
|
||||
}
|
||||
}
|
||||
|
||||
[Public] public SizeEnum Enum => SizeEnum.Medium;
|
||||
[Export] public SizeEnum Enum => SizeEnum.Medium;
|
||||
|
||||
|
||||
[Public] public MyRecord Record => new MyRecord() { Id = 33, Name = "Test", Score = 99.33 };
|
||||
[Export] public MyRecord Record => new MyRecord() { Id = 33, Name = "Test", Score = 99.33 };
|
||||
|
||||
[Public] public List<int> IntList => new List<int>() { 1, 2, 3, 4, 5 };
|
||||
[Export] public List<int> IntList => new List<int>() { 1, 2, 3, 4, 5 };
|
||||
|
||||
[Public] public IRecord[] RecordsArray => new IRecord[] { new MyRecord() { Id = 22, Name = "Test", Score = 22.1 } };
|
||||
[Public] public List<MyRecord> RecordsList => new() { new MyRecord() { Id = 22, Name = "Test", Score = 22.1 } };
|
||||
[Export] public IRecord[] RecordsArray => new IRecord[] { new MyRecord() { Id = 22, Name = "Test", Score = 22.1 } };
|
||||
[Export] public List<MyRecord> RecordsList => new() { new MyRecord() { Id = 22, Name = "Test", Score = 22.1 } };
|
||||
|
||||
|
||||
[Public] public MyResource[] myResources;
|
||||
[Export] public MyResource[] myResources;
|
||||
|
||||
[Public] public MyResource Resource { get; set; }
|
||||
[Public] public MyChildResource ChildResource { get; set; }
|
||||
[Export] public MyResource Resource { get; set; }
|
||||
[Export] public MyChildResource ChildResource { get; set; }
|
||||
|
||||
[Public] public MyChildRecord ChildRecord { get; set; } = new MyChildRecord() { ChildName = "Child", Id = 12, Name = "Parent", Score = 12.2 };
|
||||
[Export] public MyChildRecord ChildRecord { get; set; } = new MyChildRecord() { ChildName = "Child", Id = 12, Name = "Parent", Score = 12.2 };
|
||||
|
||||
[Public] public IResource[] Resources { get; set; }
|
||||
[Export] public IResource[] Resources { get; set; }
|
||||
|
||||
[Public]
|
||||
[Export]
|
||||
public void Void() =>
|
||||
Console.WriteLine("Void()");
|
||||
|
||||
[Public]
|
||||
[Export]
|
||||
public void InvokeEvents(string msg)
|
||||
{
|
||||
StringEvent?.Invoke(msg);
|
||||
ArrayEvent?.Invoke(new object[] { DateTime.UtcNow, "Event", msg });
|
||||
}
|
||||
|
||||
[Public]
|
||||
[Export]
|
||||
public double Optional(object a1, int a2, string a3 = "Hello", string a4 = "World")
|
||||
{
|
||||
Console.WriteLine($"VoidArgs {a1} {a2} {a3}");
|
||||
@ -152,7 +152,7 @@ public partial class MyService
|
||||
}
|
||||
|
||||
|
||||
[Public]
|
||||
[Export]
|
||||
public AsyncReply<List<Map<int, string?>?>> AsyncHello()
|
||||
{
|
||||
var rt = new List<Map<int, string?>?>();
|
||||
@ -160,32 +160,32 @@ public partial class MyService
|
||||
return new AsyncReply<List<Map<int, string?>?>>(rt);
|
||||
}
|
||||
|
||||
[Public]
|
||||
[Export]
|
||||
public void Connection(object a1, int a2, DistributedConnection a3) =>
|
||||
Console.WriteLine($"VoidArgs {a1} {a2} {a3}");
|
||||
|
||||
|
||||
[Public]
|
||||
[Export]
|
||||
public void ConnectionOptional(object a1, int a2, string a3 = "sss", DistributedConnection a4 = null) =>
|
||||
Console.WriteLine($"VoidArgs {a1} {a2} {a3}");
|
||||
|
||||
[Public]
|
||||
[Export]
|
||||
public (int, string) GetTuple2(int a1, string a2) => (a1, a2);
|
||||
|
||||
[Public]
|
||||
[Export]
|
||||
public (int, string, double) GetTuple3(int a1, string a2, double a3) => (a1, a2, a3);
|
||||
|
||||
[Public]
|
||||
[Export]
|
||||
public (int, string, double, bool) GetTuple4(int a1, string a2, double a3, bool a4) => (a1, a2, a3, a4);
|
||||
|
||||
[Public]
|
||||
[Export]
|
||||
public MyRecord SendRecord(MyRecord record)
|
||||
{
|
||||
Console.WriteLine(record.ToString());
|
||||
return record;
|
||||
}
|
||||
|
||||
[Public] public const double PI = Math.PI;
|
||||
[Export] public const double PI = Math.PI;
|
||||
|
||||
[Public] public MyService Me => this;
|
||||
[Export] public MyService Me => this;
|
||||
}
|
||||
|
@ -45,7 +45,8 @@ using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
using Esiur.Security.Cryptography;
|
||||
|
||||
namespace Test
|
||||
{
|
||||
|
||||
@ -53,6 +54,19 @@ namespace Test
|
||||
{
|
||||
static async Task Main(string[] args)
|
||||
{
|
||||
|
||||
var a = new ECDH();
|
||||
var b = new ECDH();
|
||||
|
||||
var apk = a.GetPublicKey();
|
||||
var bpk = b.GetPublicKey();
|
||||
|
||||
var ska = a.ComputeSharedKey(bpk);
|
||||
var skb = b.ComputeSharedKey(apk);
|
||||
|
||||
Console.WriteLine(ska.ToHex());
|
||||
Console.WriteLine(skb.ToHex());
|
||||
|
||||
// Create stores to keep objects.
|
||||
var system = await Warehouse.Put("sys", new MemoryStore());
|
||||
var server = await Warehouse.Put("sys/server", new DistributedServer());
|
||||
|
@ -2,10 +2,11 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Esiur.Generator\Esiur.Security.Cryptography.csproj" />
|
||||
<ProjectReference Include="..\Esiur\Esiur.csproj" OutputItemType="Analyzer" />
|
||||
</ItemGroup>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user