public async void ECDH_KEYS() { var pair = await ECKeyPair.Generate(); var pair2 = await ECKeyPair.Generate(); string myDevice = "Test"; string yourDevice = Guid.NewGuid().ToString(); var packed = new ECDHDevice(myDevice, yourDevice); var serial = packed.Serialize(); var packed2 = ChadderEncryptedContent.Deserialize(serial) as ECDHDevice; Assert.NotNull(packed2); Assert.AreEqual(packed.sourceId, packed2.sourceId); Assert.AreEqual(packed.targetId, packed2.targetId); var packed3 = new ECDHUser(yourDevice, myDevice); serial = packed3.Serialize(); var packed4 = ChadderEncryptedContent.Deserialize(serial) as ECDHUser; Assert.NotNull(packed4); Assert.AreEqual(packed3.sourceId, packed4.sourceId); Assert.AreEqual(packed3.targetId, packed4.targetId); }
public async Task <Content> EncryptForDevice(Content content, ChadderUserDevice device) { var key = new ECDHDevice(db.LocalDevice.DeviceId, device.DeviceId); return(await AES256WithKey.Encrypt(this, key, content)); }