コード例 #1
0
        public static Server_keys get_keys()
        {
            RSA rsa = new RSA(Primes.getPrime(), Primes.getPrime());
            ulong public_key = 0;
            ulong private_key =0;
            ulong shared_key = 0;
            rsa.getPublicKey(ref public_key, ref shared_key);
            rsa.getPrivateKey(ref private_key, ref shared_key);

            // should be using scotts key generator
            //Random rand = new Random();
            return new Server_keys((long)public_key, (long)private_key, (long)shared_key);
        }
コード例 #2
0
        public void randomInfoTest()
        {
            //string output = "";

            //for (int i = 0; i < 4; i++)
            //{
            //    output += "fun "[i] + ":" + Convert.ToInt64("fun "[i]) + "\n";
            //}

            //output = "1 He, that being often reproved hardeneth his neck, shall suddenly be destroyed, and that without remedy. 2 When the righteous are in authority, the people rejoice: but when the wicked beareth rule, the people mourn. 3 Whoso loveth wisdom rejoiceth his father: but he that keepeth company with harlots spendeth his substance. 4 The king by judgment establisheth the land: but he that receiveth gifts overthroweth it. 5 A man that flattereth his neighbour spreadeth a net for his feet. 6 In the transgression of an evil man there is a snare: but the righteous doth sing and rejoice.".Length.ToString();// 7 The righteous considereth the cause of the poor: but the wicked regardeth not to know it. 8 Scornful men bring a city into a snare: but wise men turn away wrath. 9 If a wise man contendeth with a foolish man, whether he rage or laugh, there is no rest. 10 The bloodthirsty hate the upright: but the just seek his soul. 11 A fool uttereth all his mind: but a wise man keepeth it in till afterwards. 12 If a ruler hearken to lies, all his servants are wicked. 13 The poor and the deceitful man meet together: the LORD lighteneth both their eyes. 14 The king that faithfully judgeth the poor, his throne shall be established for ever. 15 The rod and reproof give wisdom: but a child left to himself bringeth his mother to shame. 16 When the wicked are multiplied, transgression increaseth: but the righteous shall see their fall. 17 Correct thy son, and he shall give thee rest; yea, he shall give delight unto thy soul. 18 Where there is no vision, the people perish: but he that keepeth the law, happy is he. 19 A servant will not be corrected by words: for though he understand he will not answer. 20 Seest thou a man that is hasty in his words? there is more hope of a fool than of him. 21 He that delicately bringeth up his servant from a child shall have him become his son at the length. 22 An angry man stirreth up strife, and a furious man aboundeth in transgression. 23 A man's pride shall bring him low: but honour shall uphold the humble in spirit. 24 Whoso is partner with a thief hateth his own soul: he heareth cursing, and bewrayeth it not. 25 The fear of man bringeth a snare: but whoso putteth his trust in the LORD shall be safe. 26 Many seek the ruler's favour; but every man's judgment cometh from the LORD. 27 An unjust man is an abomination to the just: and he that is upright in the way is abomination to the wicked.".Length.ToString();

            //System.Windows.Forms.MessageBox.Show(output);

            RSA fun = new RSA(1301, 1061);

            ulong a = 0;
            ulong b = 0;
            ulong c = 0;

            fun.getPublicKey(ref a, ref c);
            fun.getPrivateKey(ref b, ref c);

            //System.Windows.Forms.MessageBox.Show("Pub:"+a.ToString()+"\nPriv:"+b.ToString()+"\nMod:"+c.ToString());
        }
コード例 #3
0
        public void setPrivateKeyTest()
        {
            RSA target = new RSA();
            target.setPrivateKey(13, 10);

            ulong exponentActual = 0;
            ulong modulusActual = 0;
            target.getPrivateKey(ref exponentActual, ref modulusActual);

            ulong exponentExpected = 3;
            ulong modulusExpected = 10;
            Assert.AreEqual(exponentExpected, exponentActual);
            Assert.AreEqual(modulusExpected, modulusActual);
        }
コード例 #4
0
        public void getPrivateKeyTest()
        {
            RSA target = new RSA(53, 89, 16);

            ulong exponent = 0;
            ulong modulus = 0;
            target.getPrivateKey(ref exponent, ref modulus);

            ulong exponentExpected = 2961;
            ulong modulusExpected = 4717;
            Assert.AreEqual(exponentExpected, exponent);
            Assert.AreEqual(modulusExpected, modulus);

            //Assert.AreEqual(2961, exponent);
            //Assert.AreEqual(4717, modulus);
        }