diff --git a/Esiur.Generator/AES.cs b/Esiur.Generator/AES.cs new file mode 100644 index 0000000..3a39606 --- /dev/null +++ b/Esiur.Generator/AES.cs @@ -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(); + } + } +} diff --git a/Esiur.Generator/ECDH.cs b/Esiur.Generator/ECDH.cs new file mode 100644 index 0000000..30a251d --- /dev/null +++ b/Esiur.Generator/ECDH.cs @@ -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; + } + } +} diff --git a/Esiur.Generator/Esiur.Security.Cryptography.csproj b/Esiur.Generator/Esiur.Security.Cryptography.csproj new file mode 100644 index 0000000..2c9618b --- /dev/null +++ b/Esiur.Generator/Esiur.Security.Cryptography.csproj @@ -0,0 +1,12 @@ + + + + netstandard2.1 + latest + + + + + + + diff --git a/Esiur.Stores.EntityCore/Esiur.Stores.EntityCore.csproj b/Esiur.Stores.EntityCore/Esiur.Stores.EntityCore.csproj index 32ca7ad..2213ce8 100644 --- a/Esiur.Stores.EntityCore/Esiur.Stores.EntityCore.csproj +++ b/Esiur.Stores.EntityCore/Esiur.Stores.EntityCore.csproj @@ -9,7 +9,7 @@ Esiur Entity Framework Extension true Esiur.Stores.EntityCore - 1.3.3 + 1.3.4 latest @@ -22,7 +22,7 @@ - + diff --git a/Esiur.Stores.MongoDB/Esiur.Stores.MongoDB.csproj b/Esiur.Stores.MongoDB/Esiur.Stores.MongoDB.csproj index 82dd06d..adbeaac 100644 --- a/Esiur.Stores.MongoDB/Esiur.Stores.MongoDB.csproj +++ b/Esiur.Stores.MongoDB/Esiur.Stores.MongoDB.csproj @@ -11,14 +11,14 @@ http://www.esiur.com https://github.com/esiur/esiur-dotnet/ True - 1.5.5 + 1.5.6 Esiur.Stores.MongoDB latest - - + + diff --git a/Esiur.Stores.MongoDB/MongoDBStore.cs b/Esiur.Stores.MongoDB/MongoDBStore.cs index 67567d7..86dc591 100644 --- a/Esiur.Stores.MongoDB/MongoDBStore.cs +++ b/Esiur.Stores.MongoDB/MongoDBStore.cs @@ -51,15 +51,15 @@ public class MongoDBStore : IStore KeyList resources = new KeyList(); - [Public] + [Export] public event ResourceEventHandler ResourceAdded; - [Public] + [Export] public event ResourceEventHandler 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(); diff --git a/Esiur.Stores.MongoDB/MongoDBStoreGeneric.cs b/Esiur.Stores.MongoDB/MongoDBStoreGeneric.cs index 11f2e78..9815d44 100644 --- a/Esiur.Stores.MongoDB/MongoDBStoreGeneric.cs +++ b/Esiur.Stores.MongoDB/MongoDBStoreGeneric.cs @@ -35,7 +35,7 @@ namespace Esiur.Stores.MongoDB { public class MongoDBStore : MongoDBStore where T:IResource { - [Public] + [Export] public async AsyncReply New(string name = null, object properties = null) { var resource = await Warehouse.New(name, this, null, null, null, properties); @@ -43,7 +43,7 @@ namespace Esiur.Stores.MongoDB return resource; } - [Public] + [Export] public async AsyncReply Slice(int index, int limit) { var list = await this.Instance.Children(); diff --git a/Esiur.sln b/Esiur.sln index 4925865..b3aa713 100644 --- a/Esiur.sln +++ b/Esiur.sln @@ -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 \ No newline at end of file +EndGlobal diff --git a/Esiur/Esiur.csproj b/Esiur/Esiur.csproj index abf4ed2..bbda5b7 100644 --- a/Esiur/Esiur.csproj +++ b/Esiur/Esiur.csproj @@ -1,7 +1,6 @@  - netstandard2.0 Distributed Resources Platform Ahmed Kh. Zamil http://www.esiur.com @@ -18,6 +17,7 @@ Esiur latest LICENSE + netstandard2.0 @@ -83,10 +83,10 @@ - + - - + + diff --git a/Esiur/Net/IIP/DistributedConnection.cs b/Esiur/Net/IIP/DistributedConnection.cs index 68cac4a..3bdb5fc 100644 --- a/Esiur/Net/IIP/DistributedConnection.cs +++ b/Esiur/Net/IIP/DistributedConnection.cs @@ -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 diff --git a/Esiur/Security/Authority/Session.cs b/Esiur/Security/Authority/Session.cs index 32eb05c..e25a83e 100644 --- a/Esiur/Security/Authority/Session.cs +++ b/Esiur/Security/Authority/Session.cs @@ -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) diff --git a/Esiur/Security/Cryptography/IKeyExchanger.cs b/Esiur/Security/Cryptography/IKeyExchanger.cs new file mode 100644 index 0000000..362a2fd --- /dev/null +++ b/Esiur/Security/Cryptography/IKeyExchanger.cs @@ -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); + } +} diff --git a/Esiur/Security/Cryptography/ISymetricCipher.cs b/Esiur/Security/Cryptography/ISymetricCipher.cs new file mode 100644 index 0000000..694577c --- /dev/null +++ b/Esiur/Security/Cryptography/ISymetricCipher.cs @@ -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); + } +} diff --git a/Test/MyChildRecord.cs b/Test/MyChildRecord.cs index 124ce53..9596436 100644 --- a/Test/MyChildRecord.cs +++ b/Test/MyChildRecord.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; namespace Test { - [Public] + [Export] public class MyChildRecord : MyRecord { public string ChildName { get; set; } diff --git a/Test/MyChildResource.cs b/Test/MyChildResource.cs index a32349d..f655da0 100644 --- a/Test/MyChildResource.cs +++ b/Test/MyChildResource.cs @@ -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"; } } diff --git a/Test/MyGenericRecord.cs b/Test/MyGenericRecord.cs index 782ea5f..f354aa6 100644 --- a/Test/MyGenericRecord.cs +++ b/Test/MyGenericRecord.cs @@ -10,10 +10,10 @@ namespace Test { public class MyGenericRecord : 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; } } } diff --git a/Test/MyRecord.cs b/Test/MyRecord.cs index 0946d86..0b7206b 100644 --- a/Test/MyRecord.cs +++ b/Test/MyRecord.cs @@ -8,7 +8,7 @@ using System.Threading.Tasks; namespace Test { - [Public] + [Export] public class MyRecord:IRecord { public string Name { get; set; } diff --git a/Test/MyResource.cs b/Test/MyResource.cs index 191bf57..5eab3bb 100644 --- a/Test/MyResource.cs +++ b/Test/MyResource.cs @@ -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"; } } diff --git a/Test/MyService.cs b/Test/MyService.cs index 54426e3..e07d7d9 100644 --- a/Test/MyService.cs +++ b/Test/MyService.cs @@ -25,73 +25,73 @@ public enum SizeEnum:short public partial class MyService { - [Public] public event ResourceEventHandler StringEvent; - [Public] public event ResourceEventHandler ArrayEvent; + [Export] public event ResourceEventHandler StringEvent; + [Export] public event ResourceEventHandler 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 GetGenericRecord() { return new MyGenericRecord() { 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 stringMap = new Map() { ["int"] = 33, ["string"] = "Hello World" }; - [Public] + [Export] Map 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 PropertyContext { get => new DistributedPropertyContext((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 IntList => new List() { 1, 2, 3, 4, 5 }; + [Export] public List IntList => new List() { 1, 2, 3, 4, 5 }; - [Public] public IRecord[] RecordsArray => new IRecord[] { new MyRecord() { Id = 22, Name = "Test", Score = 22.1 } }; - [Public] public List 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 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?>> AsyncHello() { var rt = new List?>(); @@ -160,32 +160,32 @@ public partial class MyService return new AsyncReply?>>(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; } diff --git a/Test/Program.cs b/Test/Program.cs index ac72019..3543033 100644 --- a/Test/Program.cs +++ b/Test/Program.cs @@ -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()); diff --git a/Test/Test.csproj b/Test/Test.csproj index 00950c4..299d50e 100644 --- a/Test/Test.csproj +++ b/Test/Test.csproj @@ -2,10 +2,11 @@ Exe - net6.0 + net8.0 +