public void testRun()
        {
            int rounds = 50;

            Console.WriteLine("Test Performance Cryptoby FileManager");
            Console.WriteLine("Rounds: " + rounds);
            Console.WriteLine("Cycles per Round: " + cycles);

            Console.WriteLine("\nWrite 1MB to File");
            file1 = new byte[mb1];
            PerfMeter.run(new Action(testWrite1ToFile), rounds);
            Console.WriteLine("\nRead 1MB from File");
            PerfMeter.run(new Action(testRead1FromFile), rounds);
            file1 = null;

            Console.WriteLine("\nWrite 10MB to File");
            file10 = new byte[mb10];
            PerfMeter.run(new Action(testWrite10ToFile), rounds);
            Console.WriteLine("\nRead 10MB from File");
            PerfMeter.run(new Action(testRead10FromFile), rounds);
            file10 = null;

            Console.WriteLine("\nWrite 100MB to File");
            file100 = new byte[mb100];
            PerfMeter.run(new Action(testWrite100ToFile), rounds);
            Console.WriteLine("\nRead 100MB from File");
            PerfMeter.run(new Action(testRead100FromFile), rounds);
            file100 = null;

            CryptobyFileManager.putBytesToFile(filePath, new byte[0]);
        }
Beispiel #2
0
        public void testRun()
        {
            const int rounds = 50;

            Console.WriteLine("Test Performance RSA Key Generation");
            Console.WriteLine("Rounds: " + rounds);
            Console.WriteLine("Cycles per Round: " + cycles);

            keySize = 1024;
            Console.WriteLine("\nGenerate RSA Key 1024 Bit");
            PerfMeter.run(new Action(testGenRSAKey), rounds);
            privKey = keyGen.getPrivateKeyByte();
            pubKey  = keyGen.getPublicKeyByte();
            Assert.AreEqual(privKey.Length * 4, keySize);
            Assert.AreEqual(pubKey.Length * 8, keySize);

            keySize = 2048;
            Console.WriteLine("\nGenerate RSA Key 2048 Bit");
            PerfMeter.run(new Action(testGenRSAKey), rounds);
            privKey = keyGen.getPrivateKeyByte();
            pubKey  = keyGen.getPublicKeyByte();
            Assert.AreEqual(privKey.Length * 4, keySize);
            Assert.AreEqual(pubKey.Length * 8, keySize);

            keySize = 4096;
            Console.WriteLine("\nGenerate RSA Key 4096 Bit");
            PerfMeter.run(new Action(testGenRSAKey), rounds);
            privKey = keyGen.getPrivateKeyByte();
            pubKey  = keyGen.getPublicKeyByte();
            Assert.AreEqual(privKey.Length * 4, keySize);
            Assert.AreEqual(pubKey.Length * 8, keySize);
        }
Beispiel #3
0
        public void testRun()
        {
            const int rounds = 50;

            Console.WriteLine("Test Performance SHA3 Key Generation");
            Console.WriteLine("Rounds: " + rounds);
            Console.WriteLine("Cycles per Round: " + cycles);

            keySize = 224;
            Console.WriteLine("\nGenerate SHA3 Key 224 Bit");
            PerfMeter.run(new Action(testGenSHA3Key), rounds);
            Assert.AreEqual(privKey.Length * 8, keySize);

            keySize = 256;
            Console.WriteLine("\nGenerate SHA3 Key 256 Bit");
            PerfMeter.run(new Action(testGenSHA3Key), rounds);
            Assert.AreEqual(privKey.Length * 8, keySize);

            keySize = 384;
            Console.WriteLine("\nGenerate SHA3 Key 384 Bit");
            PerfMeter.run(new Action(testGenSHA3Key), rounds);
            Assert.AreEqual(privKey.Length * 8, keySize);

            keySize = 512;
            Console.WriteLine("\nGenerate SHA3 Key 512 Bit");
            PerfMeter.run(new Action(testGenSHA3Key), rounds);
            Assert.AreEqual(privKey.Length * 8, keySize);
        }
Beispiel #4
0
		public void testRun(){
			const int rounds = 3;

			Console.WriteLine ("Test Performance AES Data Enc/Dec");
			Console.WriteLine ("Rounds: " + rounds);
			Console.WriteLine ("Cycles per Round: " + cycles);

			KeyGenSHA3 keyGen = new KeyGenSHA3();
			privKey = keyGen.generateKeyByte(keySize, "password");

			preData = new byte[mb1];
			Console.WriteLine ("\nEncrypt AES 256 Bit 1MB");
			PerfMeter.run(new Action(testAESEnc),rounds);
			Console.WriteLine ("\nDecrypt AES 256 Bit 1MB");
			PerfMeter.run(new Action(testAESDec),rounds);
			Assert.AreEqual (preData,resData);

			preData = new byte[mb5];
			Console.WriteLine ("\nEncrypt AES 256 Bit 5MB");
			PerfMeter.run(new Action(testAESEnc),rounds);
			Console.WriteLine ("\nDecrypt AES 256 Bit 5MB");
			PerfMeter.run(new Action(testAESDec),rounds);
			Assert.AreEqual (preData,resData);

			preData = new byte[mb10];
			Console.WriteLine ("\nEncrypt AES 256 Bit 10MB");
			PerfMeter.run(new Action(testAESEnc),rounds);
			Console.WriteLine ("\nDecrypt AES 256 Bit 10MB");
			PerfMeter.run(new Action(testAESDec),rounds);
			Assert.AreEqual (preData,resData);
		}
Beispiel #5
0
        public void testRun()
        {
            const int rounds = 1;
            Random    rand   = new Random();

            Console.WriteLine("Test Performance Blockwise RSA Enc/Dec");
            Console.WriteLine("Rounds: " + rounds);
            Console.WriteLine("Cycles per Round: " + cycles);

            keyGen.initGenerator(keySize1024);
            privKey = keyGen.getPrivateKeyByte();
            testGetDfromKey();
            testGetNfromKey();

            data = new byte[nVal.Length - 1];
            rand.NextBytes(data);
            Console.WriteLine("\nBlockwise 1024 Bit Key");
            Console.WriteLine("Encrypt One Block with N");
            PerfMeter.run(new Action(testEncryptBlock), rounds);
            Console.WriteLine("\nDecrypt One Block with N and D");
            PerfMeter.run(new Action(testDecryptBlock), rounds);
            Assert.AreEqual(data, decBlock);

            keyGen.initGenerator(keySize2048);
            privKey = keyGen.getPrivateKeyByte();
            testGetDfromKey();
            testGetNfromKey();

            data = new byte[nVal.Length - 1];
            rand.NextBytes(data);
            Console.WriteLine("\nBlockwise 2048 Bit Key");
            Console.WriteLine("Encrypt One Block with N");
            PerfMeter.run(new Action(testEncryptBlock), rounds);
            Console.WriteLine("\nDecrypt One Block with N and D");
            PerfMeter.run(new Action(testDecryptBlock), rounds);
            Assert.AreEqual(data, decBlock);

            keyGen.initGenerator(keySize4096);
            privKey = keyGen.getPrivateKeyByte();
            testGetDfromKey();
            testGetNfromKey();

            data = new byte[nVal.Length - 1];
            rand.NextBytes(data);
            Console.WriteLine("\nBlockwise 4096 Bit Key");
            Console.WriteLine("Encrypt One Block with N");
            PerfMeter.run(new Action(testEncryptBlock), rounds);
            Console.WriteLine("\nDecrypt One Block with N and D");
            PerfMeter.run(new Action(testDecryptBlock), rounds);
            Assert.AreEqual(data, decBlock);
        }
Beispiel #6
0
        public void testRun()
        {
            int rounds = 50;

            Console.WriteLine("Test Performance C# BigInteger Generation");
            Console.WriteLine("Rounds: " + rounds);
            Console.WriteLine("Cycles per Round" + cycles);
            Console.WriteLine("\nGenerate BigInteger 512 Bit");
            PerfMeter.run(new Action(testBigInt512), rounds);
            Console.WriteLine("\nGenerate BigInteger 1024 Bit");
            PerfMeter.run(new Action(testBigInt1024), rounds);
            Console.WriteLine("\nGenerate BigInteger 2048 Bit");
            PerfMeter.run(new Action(testBigInt2048), rounds);
        }
Beispiel #7
0
        public void testRun()
        {
            int rounds = 50;

            Console.WriteLine("Test Performance OpenJDK BigInteger Primes with SecureRandom");
            Console.WriteLine("Rounds: " + rounds);
            Console.WriteLine("Cycles per Round" + cycles);
            Console.WriteLine("\nGenerate Secure Random Prime 512 Bit");
            PerfMeter.run(new Action(testRandPrim512), rounds);
            Console.WriteLine("\nGenerate Secure Random Prime 1024 Bit");
            PerfMeter.run(new Action(testRandPrim1024), rounds);
            Console.WriteLine("\nGenerate Secure Random Prime 2048 Bit");
            PerfMeter.run(new Action(testRandPrim2048), rounds);
        }
Beispiel #8
0
        public void testRun()
        {
            int rounds = 50;

            Console.WriteLine("Test Performance OpenJDK SecureRandom");
            Console.WriteLine("Rounds: " + rounds);
            Console.WriteLine("Cycles per Round" + cycles);
            Console.WriteLine("\nGenerate Secure Random 512 Bit");
            PerfMeter.run(new Action(testSecRand512), rounds);
            Console.WriteLine("\nGenerate Secure Random 1024 Bit");
            PerfMeter.run(new Action(testSecRand1024), rounds);
            Console.WriteLine("\nGenerate Secure Random 2048 Bit");
            PerfMeter.run(new Action(testSecRand2048), rounds);
        }
Beispiel #9
0
        public void testRun()
        {
            const int rounds = 50;

            Console.WriteLine("Test Performance of Miller Rabin Prime Probe");
            Console.WriteLine("Rounds: " + rounds);
            Console.WriteLine("Cycles per Round: " + cycles);


            prime = BigPrimes.Dig100;
            ptest = new MillerRabin(round5);
            Console.WriteLine("\nTest 100 Number Prime 5 Rounds");
            PerfMeter.run(new Action(testPrimeProbe), rounds);
            ptest = new MillerRabin(round10);
            Console.WriteLine("\nTest 100 Number Prime 10 Rounds");
            PerfMeter.run(new Action(testPrimeProbe), rounds);
            ptest = new MillerRabin(round15);
            Console.WriteLine("\nTest 100 Number Prime 15 Rounds");
            PerfMeter.run(new Action(testPrimeProbe), rounds);
            Assert.AreEqual(prime.isProbablePrime(round15), bolprime);


            prime = BigPrimes.Dig500;
            ptest = new MillerRabin(round5);
            Console.WriteLine("\nTest 5000 Number Prime 5 Rounds");
            PerfMeter.run(new Action(testPrimeProbe), rounds);
            ptest = new MillerRabin(round10);
            Console.WriteLine("\nTest 5000 Number Prime 10 Rounds");
            PerfMeter.run(new Action(testPrimeProbe), rounds);
            ptest = new MillerRabin(round15);
            Console.WriteLine("\nTest 5000 Number Prime 15 Rounds");
            PerfMeter.run(new Action(testPrimeProbe), rounds);
            Assert.AreEqual(prime.isProbablePrime(round15), bolprime);

            prime = BigPrimes.Dig1000;
            ptest = new MillerRabin(round5);
            Console.WriteLine("\nTest 10000 Number Prime 5 Rounds");
            PerfMeter.run(new Action(testPrimeProbe), rounds);
            ptest = new MillerRabin(round10);
            Console.WriteLine("\nTest 10000 Number Prime 10 Rounds");
            PerfMeter.run(new Action(testPrimeProbe), rounds);
            ptest = new MillerRabin(round15);
            Console.WriteLine("\nTest 10000 Number Prime 15 Rounds");
            PerfMeter.run(new Action(testPrimeProbe), rounds);
            Assert.AreEqual(prime.isProbablePrime(round15), bolprime);
        }
Beispiel #10
0
        public void testRun()
        {
            const int rounds = 50;

            Console.WriteLine("Test Performance RSA Data Enc/Dec");
            Console.WriteLine("Rounds: " + rounds);
            Console.WriteLine("Cycles per Round: " + cycles);

            keyGen.initGenerator(keySize);
            pubKey  = keyGen.getPublicKeyByte();
            privKey = keyGen.getPrivateKeyByte();

            preData = new byte[kb10];
            rand.NextBytes(preData);
            Console.WriteLine("\nEncrypt RSA 1024 Bit 10KB");
            PerfMeter.run(new Action(testRSAEnc), rounds);
            Console.WriteLine("\nDecrypt RSA 1024 Bit 10KB");
            PerfMeter.run(new Action(testRSADec), rounds);
            Assert.AreEqual(preData, resData);

            modData = null;
            resData = null;
            preData = new byte[kb50];
            rand.NextBytes(preData);
            Console.WriteLine("\nEncrypt RSA 1024 Bit 50KB");
            PerfMeter.run(new Action(testRSAEnc), rounds);
            Console.WriteLine("\nDecrypt RSA 1024 Bit 50KB");
            PerfMeter.run(new Action(testRSADec), rounds);
            Assert.AreEqual(preData, resData);

            modData = null;
            resData = null;
            preData = new byte[kb100];
            rand.NextBytes(preData);
            Console.WriteLine("\nEncrypt RSA 1024 Bit 100KB");
            PerfMeter.run(new Action(testRSAEnc), rounds);
            Console.WriteLine("\nDecrypt RSA 1024 Bit 100KB");
            PerfMeter.run(new Action(testRSADec), rounds);
            Assert.AreEqual(preData, resData);
        }