From f9a7d8dde7b260d19a042729d20dd1c6d68a6276 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Thu, 20 Feb 2020 01:08:52 +0700 Subject: Stricter header validation for PEM files --- crypto/test/src/util/io/pem/test/AllTests.cs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'crypto/test') diff --git a/crypto/test/src/util/io/pem/test/AllTests.cs b/crypto/test/src/util/io/pem/test/AllTests.cs index 921c40cb8..c0ca667f5 100644 --- a/crypto/test/src/util/io/pem/test/AllTests.cs +++ b/crypto/test/src/util/io/pem/test/AllTests.cs @@ -63,6 +63,14 @@ namespace Org.BouncyCastle.Utilities.IO.Pem.Tests lengthTest("RSA PRIVATE KEY", headers, new byte[103]); } + [Test] + public void TestMalformed() + { + PemReader rd = new PemReader(new StringReader("-----BEGIN \n")); + + Assert.IsNull(rd.ReadPemObject()); + } + private void lengthTest(string type, IList headers, byte[] data) { StringWriter sw = new StringWriter(); -- cgit 1.4.1