Add testcase for RAW PKCS#1 signatures missing DER NULL
4 files changed, 20 insertions, 0 deletions
diff --git a/crypto/test/UnitTests.csproj b/crypto/test/UnitTests.csproj
index d4456b9c4..67d3e1b91 100644
--- a/crypto/test/UnitTests.csproj
+++ b/crypto/test/UnitTests.csproj
@@ -1046,6 +1046,8 @@
<EmbeddedResource Include="data\cms\sigs\PSSSignDataSHA512.sig" />
<EmbeddedResource Include="data\cms\sigs\PSSSignDataSHA512Enc.sig" />
<EmbeddedResource Include="data\cms\sigs\counterSig.p7m" />
+ <EmbeddedResource Include="data\cms\sigs\rawsha256nonull.p7m" />
+ <EmbeddedResource Include="data\cms\sigs\SignedMSPkcs7.sig" />
<EmbeddedResource Include="data\hc256\hc128\ecrypt_HC-128.txt" />
<EmbeddedResource Include="data\hc256\hc256\ecrypt_HC-256_128K_128IV.txt" />
<EmbeddedResource Include="data\hc256\hc256\ecrypt_HC-256_128K_256IV.txt" />
diff --git a/crypto/test/data/cms/sigs/SignedMSPkcs7.sig b/crypto/test/data/cms/sigs/SignedMSPkcs7.sig
new file mode 100644
index 000000000..df9a09b0d
--- /dev/null
+++ b/crypto/test/data/cms/sigs/SignedMSPkcs7.sig
Binary files differdiff --git a/crypto/test/data/cms/sigs/rawsha256nonull.p7m b/crypto/test/data/cms/sigs/rawsha256nonull.p7m
new file mode 100644
index 000000000..5d29760cb
--- /dev/null
+++ b/crypto/test/data/cms/sigs/rawsha256nonull.p7m
Binary files differdiff --git a/crypto/test/src/cms/test/SignedDataTest.cs b/crypto/test/src/cms/test/SignedDataTest.cs
index 89f7eea7d..29d0464c2 100644
--- a/crypto/test/src/cms/test/SignedDataTest.cs
+++ b/crypto/test/src/cms/test/SignedDataTest.cs
@@ -672,6 +672,24 @@ namespace Org.BouncyCastle.Cms.Tests
VerifySignatures(s, hash);
}
+ [Test]
+ public void TestRawSha256MissingNull()
+ {
+ byte[] document = GetInput("rawsha256nonull.p7m");
+
+ CmsSignedData s = new CmsSignedData(document);
+
+ IX509Store certStore = s.GetCertificates("Collection");
+ foreach (SignerInformation signerInformation in s.GetSignerInfos().GetSigners())
+ {
+ ICollection certCollection = certStore.GetMatches(signerInformation.SignerID);
+ foreach (X509Certificate cert in certCollection)
+ {
+ Assert.IsTrue(signerInformation.Verify(cert), "raw sig failed");
+ }
+ }
+ }
+
[Test]
public void TestSha1WithRsaEncapsulated()
{
|