Example #1
0
        public double Run()
        {
            PerfWatch t = new PerfWatch();
            byte[] key = new byte[(keybits + 7) / 8];
            byte[] input = new byte[megabytes * 1048576];
            byte[] output = new byte[megabytes * 1048576];
            t.Start();
            t.Stop();
            using (Blockcipher bc = new Blockcipher(cipherkind)) {
                byte[] iv = new byte[bc.Blocksize];

                bc.SetMode(ciphermode);
                bc.SetKey(keytype, key, keybits);
                bc.SetIV(iv);
                bc.Update(input, output);
                GC.Collect();
                t.Start();
                bc.Update(input, output);
                t.Stop();
            }
            GC.Collect();
            return megabytes / t.seconds();
        }
Example #2
0
        public bool Test()
        {
            bool enc = false, dec = false;
            byte[] ciphertext = null;
            byte[] plaintext = null;

            using (Blockcipher cipher = new Blockcipher(Cipher)) {
                cipher.SetMode(Mode);
                if (_iv != null)
                    cipher.SetIV(_iv);
                cipher.SetKey(KeyKind.Encrypt, _key);
                ciphertext = new byte[_plaintext.Length];
                cipher.Update(_plaintext, ciphertext);
                enc = CipherMatch(ciphertext);

                cipher.SetKey(KeyKind.Decrypt, _key);
                if (_iv != null)
                    cipher.SetIV(_iv);
                plaintext = new byte[_ciphertext.Length];
                cipher.Update(_ciphertext, plaintext);
                dec = PlainMatch(plaintext);
            }
            return enc && dec;
        }