Ejemplo n.º 1
0
        private void VolumeKeyTest()
        {
            CipherDescription cd1 = new CipherDescription(
                SymmetricEngines.RHX,
                192, IVSizes.V128,
                CipherModes.CTR,
                PaddingModes.None,
                BlockSizes.B128,
                RoundCounts.R22);

            MemoryStream mk;

            using (VolumeCipher vc = new VolumeCipher())
                mk = vc.CreateKey(cd1, 100);

            VolumeKey         vk1 = new VolumeKey(mk);
            CipherDescription cd2 = vk1.Description;

            if (!cd1.Equals(cd2))
            {
                throw new Exception("KeyFactoryTest: VolumeKey serialization has failed!");
            }

            VolumeKey vk2 = new VolumeKey(mk.ToArray());

            if (!vk1.Equals(vk2))
            {
                throw new Exception("KeyFactoryTest: VolumeKey serialization has failed!");
            }
            if (vk1.GetHashCode() != vk2.GetHashCode())
            {
                throw new Exception("KeyFactoryTest: VolumeKey hash code test has failed!");
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Test the VolumeCipher class implementation
        /// </summary>
        public static void VolumeCipherTest(string InputDirectory)
        {
            string[] paths = DirectoryTools.GetFiles(InputDirectory);

            // key will be written to this stream
            MemoryStream keyStream = new MemoryStream();

            // encrypt the files in the directory
            using (VolumeCipher vc = new VolumeCipher())
            {
                keyStream = vc.CreateKey(CipherDescription.AES256CTR, paths.Length);
                vc.Initialize(keyStream);
                vc.Encrypt(paths);
            }

            // decrypt the files
            using (VolumeCipher vc = new VolumeCipher())
            {
                vc.Initialize(keyStream);
                vc.Decrypt(paths);
            }

            // manual inspection of files..
        }