public void GivenContainer16bppPng_WrongDecryptionKey_ExpectedInvalidOperationExceptionThrown()
        {
            //Arrange
            string outputDirPath = Path.Combine(TestsSetUp.TempDirectory, System.Reflection.MethodBase.GetCurrentMethod().Name);

            Directory.CreateDirectory(outputDirPath);

            string containerPath = Path.Combine(TestContext.CurrentContext.TestDirectory, "TestData", "Containers",
                                                "254x256_16.png");

            string secretPath = Path.Combine(TestContext.CurrentContext.TestDirectory, "TestData", "Secrets",
                                             "gecon.jpg");

            var encryptionKey = new PasswordKey("9hwT5nnp");
            var decryptionKey = new PasswordKey("GhEP7vgDS");

            IStegoSystem <string, ImageStegoConstraints> stegoSystem =
                new SudokuImageStegoSystem <byte, string>(new SudokuStegoMethod256(), new SudokuByPasswordMatrixFactory <byte>(),
                                                          new Method256ImageStegoConstraints());

            string stegocontainerPath = stegoSystem.Encrypt(containerPath, secretPath, encryptionKey, outputDirPath);

            //Act & Assert
            Assert.Throws(Is.TypeOf <InvalidOperationException>()
                          .And.Message.EqualTo("Unable to extract secret data. Either the password is wrong or there is no secret data at all"),
                          () => stegoSystem.Decrypt(stegocontainerPath, decryptionKey, outputDirPath));
        }
        public void Given_Container16bppPng_UsedCapacityIsLow_ExpectedDecryptedEqualsInitialSecret()
        {
            //Arrange
            string outputDirPath = Path.Combine(TestsSetUp.TempDirectory, System.Reflection.MethodBase.GetCurrentMethod().Name);

            Directory.CreateDirectory(outputDirPath);

            string containerPath = Path.Combine(TestContext.CurrentContext.TestDirectory, "TestData", "Containers",
                                                "254x256_16.png");

            string secretPath = Path.Combine(TestContext.CurrentContext.TestDirectory, "TestData", "Secrets",
                                             "gecon.jpg");

            var key = new PasswordKey("aaaaaa");

            IStegoSystem <string, ImageStegoConstraints> stegoSystem =
                new SudokuImageStegoSystem <byte, string>(new SudokuStegoMethod256(), new SudokuByPasswordMatrixFactory <byte>(),
                                                          new Method256ImageStegoConstraints());

            //Act
            string stegocontainerPath = stegoSystem.Encrypt(containerPath, secretPath, key, outputDirPath);
            string restoredSecretPath = stegoSystem.Decrypt(stegocontainerPath, key, outputDirPath);

            //Assert
            //restored and initial secrets are equal
            FileAssert.AreEqual(secretPath, restoredSecretPath);
        }
Esempio n. 3
0
        public void GivenContainer24bppBmp_PasswordIsNull_ExpectedArgumentExceptionThrown()
        {
            //Arrange
            string outputDirPath = TestsSetUp.TempDirectory;

            string stegocontainerPath = Path.Combine(TestContext.CurrentContext.TestDirectory, "TestData", "Containers",
                                                     "158x200_24.bmp");

            var key = new PasswordKey(null);

            IStegoSystem <string, ImageStegoConstraints> stegoSystem =
                new SudokuImageStegoSystem <byte, string>(new SudokuStegoMethod256(), new SudokuByPasswordMatrixFactory <byte>(),
                                                          new Method256ImageStegoConstraints());

            //Act & Assert
            Assert.Throws(Is.TypeOf <ArgumentException>()
                          .And.Message.Contains("Wrong password format"),
                          () => stegoSystem.Decrypt(stegocontainerPath, key, outputDirPath));
        }
Esempio n. 4
0
        public void GivenEmptyStegoContainer32bppBmp_2_ExpectedInvalidOperationExceptionThrown()
        {
            //Arrange
            string outputDirPath = TestsSetUp.TempDirectory;

            string stegocontainerPath = Path.Combine(TestContext.CurrentContext.TestDirectory, "TestData", "Containers",
                                                     "490x364_32.bmp");

            var key = new PasswordKey("utGpgfC");

            IStegoSystem <string, ImageStegoConstraints> stegoSystem =
                new SudokuImageStegoSystem <byte, string>(new SudokuStegoMethod256(), new SudokuByPasswordMatrixFactory <byte>(),
                                                          new Method256ImageStegoConstraints());

            //Act & Assert
            Assert.Throws(Is.TypeOf <InvalidOperationException>()
                          .And.Message.EqualTo("Unable to extract secret data. Either the password is wrong or there is no secret data at all"),
                          () => stegoSystem.Decrypt(stegocontainerPath, key, outputDirPath));
        }
Esempio n. 5
0
        public void Given_Container8bppBmp_ExpectedArgumentExceptionThrown()
        {
            //Arrange
            string outputDirPath = TestsSetUp.TempDirectory;

            string containerPath = Path.Combine(TestContext.CurrentContext.TestDirectory, "TestData", "Containers",
                                                "320x235_8.bmp");

            string secretPath = Path.Combine(TestContext.CurrentContext.TestDirectory, "TestData", "Secrets",
                                             "gecon.jpg");

            var key = new PasswordKey("123456");

            IStegoSystem <string, ImageStegoConstraints> stegoSystem =
                new SudokuImageStegoSystem <byte, string>(new SudokuStegoMethod256(), new SudokuByPasswordMatrixFactory <byte>(),
                                                          new Method256ImageStegoConstraints());

            //Act & Assert
            Assert.Throws(Is.TypeOf <ArgumentException>()
                          .And.Message.EqualTo("8 bpp image is not allowed to use as container"),
                          () => stegoSystem.Encrypt(containerPath, secretPath, key, outputDirPath));
        }
Esempio n. 6
0
        public void GivenContainer24bppBmp_PasswordIsTooLong_ExpectedArgumentExceptionThrown()
        {
            //Arrange
            string outputDirPath = TestsSetUp.TempDirectory;

            string containerPath = Path.Combine(TestContext.CurrentContext.TestDirectory, "TestData", "Containers",
                                                "158x200_24.bmp");

            string secretPath = Path.Combine(TestContext.CurrentContext.TestDirectory, "TestData", "Secrets",
                                             "lemur.jpg");

            var key = new PasswordKey("s8uyrf7erFOefueRhiye6gUn9851tyhgyv0utMh");

            IStegoSystem <string, ImageStegoConstraints> stegoSystem =
                new SudokuImageStegoSystem <byte, string>(new SudokuStegoMethod256(), new SudokuByPasswordMatrixFactory <byte>(),
                                                          new Method256ImageStegoConstraints());

            //Act & Assert
            Assert.Throws(Is.TypeOf <ArgumentException>()
                          .And.Message.Contains("Wrong password format"),
                          () => stegoSystem.Encrypt(containerPath, secretPath, key, outputDirPath));
        }
Esempio n. 7
0
        public void Given_Container16bppPng_CapacityIsNotEnough_ExpectedInvalidOperationExceptionThrown()
        {
            //Arrange
            string outputDirPath = TestsSetUp.TempDirectory;

            string containerPath = Path.Combine(TestContext.CurrentContext.TestDirectory, "TestData", "Containers",
                                                "254x256_16.png");

            string secretPath = Path.Combine(TestContext.CurrentContext.TestDirectory, "TestData", "Secrets",
                                             "fox.jpg");

            var key = new PasswordKey("123456");

            IStegoSystem <string, ImageStegoConstraints> stegoSystem =
                new SudokuImageStegoSystem <byte, string>(new SudokuStegoMethod256(), new SudokuByPasswordMatrixFactory <byte>(),
                                                          new Method256ImageStegoConstraints());

            //Act & Assert
            Assert.Throws(Is.TypeOf <InvalidOperationException>()
                          .And.Message.EqualTo("Cannot encrypt secret data because container image is too small"),
                          () => stegoSystem.Encrypt(containerPath, secretPath, key, outputDirPath));
        }