Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,43 @@ public static void RemoveCertificate_NonExisting_CollectionContainsAttributeCert
}
}

[Fact]
public static void ComputeCounterSignature_PreservesAttributeCertificate()
{
SignedCms signedCms = new SignedCms();
signedCms.Decode(SignedDocuments.TstWithAttributeCertificate);
int countBefore = CountCertificateChoices(SignedDocuments.TstWithAttributeCertificate);

using (X509Certificate2 cert = Certificates.RSA2048SignatureOnly.TryGetCertificateWithPrivateKey())
{
CmsSigner signer = new CmsSigner(cert);
SignerInfo info = signedCms.SignerInfos[0];
info.ComputeCounterSignature(signer);
}

byte[] encoded = signedCms.Encode();
int countAfter = CountCertificateChoices(encoded);
Assert.Equal(countBefore + 1, countAfter);
}

[Fact]
public static void ComputeSignature_PreservesAttributeCertificate()
{
SignedCms signedCms = new SignedCms();
signedCms.Decode(SignedDocuments.TstWithAttributeCertificate);
int countBefore = CountCertificateChoices(SignedDocuments.TstWithAttributeCertificate);

using (X509Certificate2 cert = Certificates.RSA2048SignatureOnly.TryGetCertificateWithPrivateKey())
{
CmsSigner signer = new CmsSigner(cert);
signedCms.ComputeSignature(signer);
}

byte[] encoded = signedCms.Encode();
int countAfter = CountCertificateChoices(encoded);
Assert.Equal(countBefore + 1, countAfter);
}

private static void VerifyWithExplicitPrivateKey(X509Certificate2 cert, AsymmetricAlgorithm key)
{
using (var pubCert = new X509Certificate2(cert.RawData))
Expand Down