Example #1
0
        public void TestDiffieHelman(ElipticCurve curve, int iterations)
        {
            ECKeysGenerator keyGen = new ECKeysGenerator(curve);
            ECDiffieHelman  diffie = new ECDiffieHelman(curve);

            //generovanie klucoveho paru
            byte[] privateKeyAlice;
            byte[] publicKeyAlice;
            byte[] privateKeyBob;
            byte[] publicKeyBob;
            for (int i = 0; i < iterations; i++)
            {
                Console.WriteLine($"diffie-helman curve {curve.Name} test {i}... ");
                keyGen.GenerateKeyPair(out privateKeyAlice, out publicKeyAlice);
                keyGen.GenerateKeyPair(out privateKeyBob, out publicKeyBob);
                string commnonAlices = Convert.ToBase64String(diffie.SharedSecret(privateKeyAlice, publicKeyBob));
                string commnonBobs   = Convert.ToBase64String(diffie.SharedSecret(privateKeyBob, publicKeyAlice));
                Console.WriteLine(commnonAlices);
                if (commnonAlices != commnonBobs)
                {
                    throw new Exception("Fatal Error");
                }
                Write("OK", ConsoleColor.Green);
            }
        }
Example #2
0
        /// <summary>
        /// initialise updater.
        /// </summary>
        /// <param name="updateDir"></param>
        public UpdateController(string updateDir, TroubleShooterClient client)
        {
            this._client = client;
            _updateDir   = updateDir;
            ElipticCurve curve = ElipticCurve.secp160r1();

            _keyGen       = new ECKeysGenerator(curve);
            _verifier     = new ECSignature(curve);
            _diffieHelman = new ECDiffieHelman(curve);
        }
Example #3
0
        /// <summary>
        /// <see cref="TroubleshooterController"/>
        /// </summary>
        public TroubleshooterController(ServisContext ctx)
        {
            this.ctx = ctx;
            ElipticCurve curve = ElipticCurve.secp160r1();

            signatureMaker = new ECSignature(curve);
            keyGen         = new ECKeysGenerator(curve);
            diffieHelman   = new ECDiffieHelman(curve);
            sourceFiles    = SourceFileInfoBuilder.GetSourceFiles(SOURCE_FILES_DIR);
            rnd            = new Random();
        }