Esempio n. 1
0
        public void Parse_throws_on_invalid_content_length()
        {
            var lengths = new[] { new byte[] { 0, 0, 0, 0x80 }, new byte[] { 0xFF, 0xFF, 0xFF, 0xFF } };

            foreach (var i in lengths)
            {
                Assert.That(ParsePad("onefile1\x07\x01".ToBytes().Concat(i).ToArray()),
                            ExceptionsTest.ThrowsParseErrorWithMessage("negative"));
            }
        }
Esempio n. 2
0
        public void Decrypt_throws_on_invalid_iteration_count()
        {
            var iterations = new[] { new byte[] { 0, 0, 0, 0 }, new byte[] { 0, 0x08, 0, 1 } };

            foreach (var i in iterations)
            {
                Assert.That(DecryptPad("gsencst1\x00\x02".ToBytes().Concat(i).ToArray()),
                            ExceptionsTest.ThrowsParseErrorWithMessage("iteration count"));
            }
        }
Esempio n. 3
0
 public void Decrypt_throws_on_unsupported_invalid_kdf()
 {
     Assert.That(DecryptPad("gsencst1\x00" + "\x05"),
                 ExceptionsTest.ThrowsParseErrorWithMessage("KDF/encryption type"));
 }
Esempio n. 4
0
 public void Decrypt_throws_on_invalid_signature()
 {
     Assert.That(DecryptPad("invalid!"),
                 ExceptionsTest.ThrowsParseErrorWithMessage("signature"));
 }
Esempio n. 5
0
 public void Decrypt_throws_on_no_content()
 {
     Assert.That(Decrypt("too short".ToBytes()),
                 ExceptionsTest.ThrowsParseErrorWithMessage("too short"));
 }
Esempio n. 6
0
 public void Parse_throws_on_too_short_content()
 {
     Assert.That(ParsePad("onefile1\x07\x01\x02\x00\x00\x00" + "invalid checksum" + "!"),
                 ExceptionsTest.ThrowsParseErrorWithMessage("too short"));
 }
Esempio n. 7
0
 public void Parse_throws_on_invalid_checksum()
 {
     Assert.That(ParsePad("onefile1\x07\x01\x01\x00\x00\x00" + "invalid checksum" + "!"),
                 ExceptionsTest.ThrowsParseErrorWithMessage("Checksum"));
 }
Esempio n. 8
0
 public void Parse_throws_on_invalid_checksum_type()
 {
     Assert.That(ParsePad("onefile1\x07" + "\x13"),
                 ExceptionsTest.ThrowsParseErrorWithMessage("checksum"));
 }
Esempio n. 9
0
 public void ParseJson_throws_on_invalid_json()
 {
     Assert.That(() => OneFile.ParseJson("}{".ToBytes()),
                 ExceptionsTest.ThrowsParseErrorWithMessage("Corrupted"));
 }
Esempio n. 10
0
 public void Decrypt_throws_on_too_short_extra()
 {
     Assert.That(DecryptPad("gsencst1\x10\x02\x00\x10\x00\x00\x10saltsaltsaltsalt" + "extra..."),
                 ExceptionsTest.ThrowsParseErrorWithMessage("too short"));
 }