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")); } }
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")); } }
public void Decrypt_throws_on_unsupported_invalid_kdf() { Assert.That(DecryptPad("gsencst1\x00" + "\x05"), ExceptionsTest.ThrowsParseErrorWithMessage("KDF/encryption type")); }
public void Decrypt_throws_on_invalid_signature() { Assert.That(DecryptPad("invalid!"), ExceptionsTest.ThrowsParseErrorWithMessage("signature")); }
public void Decrypt_throws_on_no_content() { Assert.That(Decrypt("too short".ToBytes()), ExceptionsTest.ThrowsParseErrorWithMessage("too short")); }
public void Parse_throws_on_too_short_content() { Assert.That(ParsePad("onefile1\x07\x01\x02\x00\x00\x00" + "invalid checksum" + "!"), ExceptionsTest.ThrowsParseErrorWithMessage("too short")); }
public void Parse_throws_on_invalid_checksum() { Assert.That(ParsePad("onefile1\x07\x01\x01\x00\x00\x00" + "invalid checksum" + "!"), ExceptionsTest.ThrowsParseErrorWithMessage("Checksum")); }
public void Parse_throws_on_invalid_checksum_type() { Assert.That(ParsePad("onefile1\x07" + "\x13"), ExceptionsTest.ThrowsParseErrorWithMessage("checksum")); }
public void ParseJson_throws_on_invalid_json() { Assert.That(() => OneFile.ParseJson("}{".ToBytes()), ExceptionsTest.ThrowsParseErrorWithMessage("Corrupted")); }
public void Decrypt_throws_on_too_short_extra() { Assert.That(DecryptPad("gsencst1\x10\x02\x00\x10\x00\x00\x10saltsaltsaltsalt" + "extra..."), ExceptionsTest.ThrowsParseErrorWithMessage("too short")); }