public bool Handshake(Packet outer) { var linkData = Packet.DecodePacket (outer.Body); if (Exchange == null) { Exchange = new Exchange (Mesh.Self, 0x1a, linkData.Body); Exchange.OutAt = (uint)outer.Head ["at"]; var tokenData = outer.Parent.Body.Take (16).ToArray (); var tokenHash = Helpers.SHA256Hash (tokenData).Take (16).ToArray (); Token = Helpers.ToHexSring (tokenHash); } if (!Exchange.Verify (outer.Parent)) { return false; } Exchange.Sync (outer); return true; }
public void Handshake() { byte[] A_KEY = Telehash.Base32Encoder.Decode("anfpjrveyyloypswpqzlfkjpwynahohffy"); byte[] A_SEC = Telehash.Base32Encoder.Decode("cgcsbs7yphotlb5fxls5ogy2lrc7yxbg"); byte[] B_KEY = Telehash.Base32Encoder.Decode("amhofcnwgmolf3owg2kipr5vus7uifydsy"); byte[] B_SEC = Telehash.Base32Encoder.Decode("ge4i7h3jln4kltngwftg2yqtjjvemerw"); Self localSelf = new Self (); CipherSet1a cs = new CipherSet1a (); cs.LoadKeys (A_KEY, A_SEC); localSelf.CipherSets.Add(0x1a, cs); Exchange ex = new Exchange (localSelf, 0x1a, B_KEY); var outPacket = ex.Handshake (0x1a); Console.Write (outPacket); Self remoteSelf = new Self (); CipherSet1a remoteCs = new CipherSet1a (); remoteCs.LoadKeys (B_KEY, B_SEC); remoteSelf.CipherSets.Add (0x1a, remoteCs); CS1ARemoteInfo ri = new CS1ARemoteInfo (); ri.RemotePublicKey = A_KEY; var decryptedPacket = remoteCs.MessageDecrypt (outPacket); System.Diagnostics.Debug.Write (decryptedPacket); }
public Link (Mesh mesh, string hashname, byte[] remotePublicKey) { sharedSetup (hashname); Mesh = mesh; Exchange = new Exchange (Mesh.Self, 0x1a, remotePublicKey); }