コード例 #1
0
        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));
        }
コード例 #2
0
        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);
        }
コード例 #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));
        }
コード例 #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));
        }