Skip to content

Commit b90398d

Browse files
committed
Add testcase for RAW PKCS#1 signatures missing DER NULL
1 parent 70fe4f6 commit b90398d

File tree

5 files changed

+28
-0
lines changed

5 files changed

+28
-0
lines changed

crypto/crypto.csproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7596,6 +7596,14 @@
75967596
RelPath = "test\data\cms\sigs\PSSSignDataSHA512Enc.sig"
75977597
BuildAction = "EmbeddedResource"
75987598
/>
7599+
<File
7600+
RelPath = "test\data\cms\sigs\rawsha256nonull.p7m"
7601+
BuildAction = "EmbeddedResource"
7602+
/>
7603+
<File
7604+
RelPath = "test\data\cms\sigs\SignedMSPkcs7.sig"
7605+
BuildAction = "EmbeddedResource"
7606+
/>
75997607
<File
76007608
RelPath = "test\data\crypto\SHA3TestVectors.txt"
76017609
BuildAction = "EmbeddedResource"

crypto/test/UnitTests.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,6 +1046,8 @@
10461046
<EmbeddedResource Include="data\cms\sigs\PSSSignDataSHA512.sig" />
10471047
<EmbeddedResource Include="data\cms\sigs\PSSSignDataSHA512Enc.sig" />
10481048
<EmbeddedResource Include="data\cms\sigs\counterSig.p7m" />
1049+
<EmbeddedResource Include="data\cms\sigs\rawsha256nonull.p7m" />
1050+
<EmbeddedResource Include="data\cms\sigs\SignedMSPkcs7.sig" />
10491051
<EmbeddedResource Include="data\hc256\hc128\ecrypt_HC-128.txt" />
10501052
<EmbeddedResource Include="data\hc256\hc256\ecrypt_HC-256_128K_128IV.txt" />
10511053
<EmbeddedResource Include="data\hc256\hc256\ecrypt_HC-256_128K_256IV.txt" />
4.81 KB
Binary file not shown.
1.38 KB
Binary file not shown.

crypto/test/src/cms/test/SignedDataTest.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,24 @@ public void TestSha1WithRsaAndAttributeTable()
672672
VerifySignatures(s, hash);
673673
}
674674

675+
[Test]
676+
public void TestRawSha256MissingNull()
677+
{
678+
byte[] document = GetInput("rawsha256nonull.p7m");
679+
680+
CmsSignedData s = new CmsSignedData(document);
681+
682+
IX509Store certStore = s.GetCertificates("Collection");
683+
foreach (SignerInformation signerInformation in s.GetSignerInfos().GetSigners())
684+
{
685+
ICollection certCollection = certStore.GetMatches(signerInformation.SignerID);
686+
foreach (X509Certificate cert in certCollection)
687+
{
688+
Assert.IsTrue(signerInformation.Verify(cert), "raw sig failed");
689+
}
690+
}
691+
}
692+
675693
[Test]
676694
public void TestSha1WithRsaEncapsulated()
677695
{

0 commit comments

Comments
 (0)