Exemple #1
0
        public DNSCrypt(IOptionsMonitor <DNSCryptOptions> DNSCryptOptions)
        {
            Options = DNSCryptOptions;

            Random = new Random();

            Client = new UdpClient
            {
                Client =
                {
                    SendTimeout    = Options.CurrentValue.Timeout,
                    ReceiveTimeout = Options.CurrentValue.Timeout
                }
            };

            Stamp = (DNSCryptStamp)Options.CurrentValue.Stamp.Value;

            IPEndPoint = IPEndPoint.Parse(Stamp.Address);

            var ClientCurve25519 = new Curve25519();

            ClientPublicKey = ClientCurve25519.GetPublicKey();

            ClientPrivateKey = ClientCurve25519.GetPrivateKey();

            ChaCha20Poly1305 = new ChaCha20Poly1305();

            IsInitialized = false;
        }
Exemple #2
0
        public void TestExternal()
        {
            for (int i = 0; i < 100; i++)
            {
                var privateKey = (i % 2 == 0) ? Utils.CreateProcess(wg, "genkey") : Curve25519.GetPrivateKey();
                var publicKey1 = Utils.CreateProcess(wg, "pubkey", privateKey);
                var publicKey2 = Curve25519.GetPublicKey(privateKey);

                Assert.AreEqual(publicKey1, publicKey2);
            }
        }