public Exchange (Self localIdentity, byte csid, byte[] publicKey) { Local = localIdentity; cipherSet = localIdentity.CipherSets [csid]; var ri = new CS1ARemoteInfo (); ri.RemotePublicKey = publicKey; cipherSet.GenerateEphemeralKeys (ri); remoteInfo = ri; var idKey = localIdentity.CipherSets [csid].Keys.PublicKey; for (int i = 0; i < publicKey.Length; ++i) { if (publicKey [i] == idKey [i]) { continue; } if (publicKey [i] > idKey [i]) { Order = HashOrder.High; At = 1; break; } else { Order = HashOrder.Low; At = 2; break; } } }
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 Mesh () { self = new Telehash.E3X.Self (); Links = new Dictionary<string, Link> (); }