Ejemplo n.º 1
0
 public void Init()
 {
     mb1 = 1024 * 1024;
     mb5 = mb1 * 5;
     mb10 = mb1 * 10;
     aes = new CryptAES();
 }
Ejemplo n.º 2
0
		[TestFixtureSetUp] public void Init()
		{ 
			mb1 = 1024 * 1024;
			mb5 = mb1 * 5;
			mb10 = mb1 * 10;
			aes = new CryptAES();
		}
Ejemplo n.º 3
0
 public virtual void testEncryptDecrypt256()
 {
     System.Console.Out.WriteLine("encrypt and decrypt testphrase");
     byte[] plainInput = Encoding.UTF8.GetBytes("Text to Test for Testing from Tester by Testcase"
         );
     KeyGenSHA3 keyGen = new KeyGenSHA3();
     string hexKey = keyGen.generateKey(256, "password");
     byte[] bKey = CryptobyHelper.hexStringToBytes(hexKey);
     CryptAES instance = new CryptAES();
     byte[] expResult = plainInput;
     byte[] result = instance.encrypt(plainInput, bKey);
     result = instance.decrypt(result, bKey);
     Assert.AreEqual(expResult, result);
 }
Ejemplo n.º 4
0
        public virtual void testEncryptDecrypt256()
        {
            System.Console.Out.WriteLine("encrypt and decrypt testphrase");
            byte[] plainInput = Encoding.UTF8.GetBytes("Text to Test for Testing from Tester by Testcase"
                                                       );
            KeyGenSHA3 keyGen = new KeyGenSHA3();
            string     hexKey = keyGen.generateKey(256, "password");

            byte[]   bKey     = CryptobyHelper.hexStringToBytes(hexKey);
            CryptAES instance = new CryptAES();

            byte[] expResult = plainInput;
            byte[] result    = instance.encrypt(plainInput, bKey);
            result = instance.decrypt(result, bKey);
            Assert.AreEqual(expResult, result);
        }
Ejemplo n.º 5
0
 public virtual void testEncryptDecrypt256_false()
 {
     System.Console.Out.WriteLine("crypt almost false key");
     byte[] plainInput = Encoding.UTF8.GetBytes("Text to Test for Testing from Tester by Testcase"
         );
     string hexKey = "13A9489AF957FF7B5E8E712737D0B4A0C92AE8EBAE9DD11E9C11B8CB79707017";
     byte[] bKey = CryptobyHelper.hexStringToBytes(hexKey);
     CryptAES instance = new CryptAES();
     byte[] expResult = plainInput;
     byte[] result = instance.encrypt(plainInput, bKey);
     hexKey = "13A9489AF957FF7B5E8E712737D0B4A0C92AE8EBAE9DD11E9C11B8CB79707011";
     bKey = CryptobyHelper.hexStringToBytes(hexKey);
     result = instance.decrypt(result, bKey);
     Assert.IsFalse(Encoding.UTF8.GetString(expResult).Equals
         (Encoding.UTF8.GetString(result)));
 }
Ejemplo n.º 6
0
        public virtual void testEncryptDecrypt256_false()
        {
            System.Console.Out.WriteLine("crypt almost false key");
            byte[] plainInput = Encoding.UTF8.GetBytes("Text to Test for Testing from Tester by Testcase"
                                                       );
            string hexKey = "13A9489AF957FF7B5E8E712737D0B4A0C92AE8EBAE9DD11E9C11B8CB79707017";

            byte[]   bKey     = CryptobyHelper.hexStringToBytes(hexKey);
            CryptAES instance = new CryptAES();

            byte[] expResult = plainInput;
            byte[] result    = instance.encrypt(plainInput, bKey);
            hexKey = "13A9489AF957FF7B5E8E712737D0B4A0C92AE8EBAE9DD11E9C11B8CB79707011";
            bKey   = CryptobyHelper.hexStringToBytes(hexKey);
            result = instance.decrypt(result, bKey);
            Assert.IsFalse(Encoding.UTF8.GetString(expResult).Equals
                               (Encoding.UTF8.GetString(result)));
        }
Ejemplo n.º 7
0
        public virtual void testEncryptDecrypt256_HugeData()
        {
            System.Console.Out.WriteLine("encrypt and decrypt huge Data");
            byte[]     plainInput = new byte[1000000];
            KeyGenSHA3 keyGen     = new KeyGenSHA3();
            string     hexKey     = keyGen.generateKey(256, "password");

            byte[]   bKey     = CryptobyHelper.hexStringToBytes(hexKey);
            CryptAES instance = new CryptAES();

            byte[] expResult = plainInput;
            byte[] result    = instance.encrypt(plainInput, bKey);
            result = instance.decrypt(result, bKey);
            for (int i = 0; i < 10; i++)
            {
                result = instance.encrypt(plainInput, bKey);
                result = instance.decrypt(result, bKey);
            }
            Assert.AreEqual(expResult, result);
        }
Ejemplo n.º 8
0
        public virtual void testEncryptDecrypt256_CBC()
        {
            System.Console.Out.WriteLine("encrypt and decrypt recurring words");
            byte[] plainInput = Encoding.UTF8.GetBytes("TestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTest"
                );
            KeyGenSHA3 keyGen = new KeyGenSHA3();
            string hexKey = keyGen.generateKey(256, "password");
            byte[] bKey = CryptobyHelper.hexStringToBytes(hexKey);
            CryptAES instance = new CryptAES();
            byte[] expResult = plainInput;
            byte[] result = instance.encrypt(plainInput, bKey);
            string resString = CryptobyHelper.bytesToHexStringUpper(result);
            for (int i = 0; i < resString.Length - 32; i += 32)
            {
                Assert.IsFalse(resString.Substring(i, 32).Equals
                    (resString.Substring(i + 32, 32)));

            }
            result = instance.decrypt(result, bKey);
            Assert.AreEqual(expResult, result);
        }
Ejemplo n.º 9
0
        public virtual void testEncryptDecrypt256_CBC()
        {
            System.Console.Out.WriteLine("encrypt and decrypt recurring words");
            byte[] plainInput = Encoding.UTF8.GetBytes("TestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTest"
                                                       );
            KeyGenSHA3 keyGen = new KeyGenSHA3();
            string     hexKey = keyGen.generateKey(256, "password");

            byte[]   bKey     = CryptobyHelper.hexStringToBytes(hexKey);
            CryptAES instance = new CryptAES();

            byte[] expResult = plainInput;
            byte[] result    = instance.encrypt(plainInput, bKey);
            string resString = CryptobyHelper.bytesToHexStringUpper(result);

            for (int i = 0; i < resString.Length - 32; i += 32)
            {
                Assert.IsFalse(resString.Substring(i, 32).Equals
                                   (resString.Substring(i + 32, 32)));
            }
            result = instance.decrypt(result, bKey);
            Assert.AreEqual(expResult, result);
        }
Ejemplo n.º 10
0
        public virtual void testEncryptDecrypt256_HugeData()
        {
            System.Console.Out.WriteLine("encrypt and decrypt huge Data");
            byte[] plainInput = new byte[1000000];
            KeyGenSHA3 keyGen = new KeyGenSHA3();
            string hexKey = keyGen.generateKey(256, "password");
            byte[] bKey = CryptobyHelper.hexStringToBytes(hexKey);
            CryptAES instance = new CryptAES();
            byte[] expResult = plainInput;
            byte[] result = instance.encrypt(plainInput, bKey);
            result = instance.decrypt(result, bKey);
            for (int i = 0; i < 10;i++){

                result = instance.encrypt(plainInput, bKey);
                result = instance.decrypt(result, bKey);
            }
            Assert.AreEqual(expResult, result);
        }