Beispiel #1
0
		/// <summary>
		/// Load the keys and secrets.
		/// </summary>
		public void Load(string jsonIdentityFilePath)
		{
			JArray keys = (JArray)JToken.Parse (File.ReadAllText (jsonIdentityFilePath));


			foreach (var idEntry in keys) {
				if (idEntry ["cs"].Value<string>() == "1a") {
					// Create a 1a
					string keyData = idEntry ["secret"].Value<string>();
					if (keyData.Length == 0) {
						continue;
					}
					byte[] privKey = Base32Encoder.Decode (keyData);
					keyData = idEntry ["public"].Value<string>();
					if (keyData.Length == 0) {
						continue;
					}
					byte[] publicKey = Base32Encoder.Decode (keyData);

					CipherSet1a cs1a = new CipherSet1a ();
					cs1a.LoadKeys (publicKey, privKey);
					Self.CipherSets.Add (0x1a, cs1a);
				}
			}
		}
Beispiel #2
0
		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);
		}
Beispiel #3
0
		/// <summary>
		/// Generate new keys for this Mesh instance.  The hashname of this Mesh will change.
		/// </summary>
		public void Generate()
		{
			var cs = new CipherSet1a ();
			cs.Generate ();
			Self.CipherSets.Add (cs.CSID, cs);
		}