@@ -654,6 +654,43 @@ public static void RemoveCertificate_NonExisting_CollectionContainsAttributeCert
654654 }
655655 }
656656
657+ [ Fact ]
658+ public static void ComputeCounterSignature_PreservesAttributeCertificate ( )
659+ {
660+ SignedCms signedCms = new SignedCms ( ) ;
661+ signedCms . Decode ( SignedDocuments . TstWithAttributeCertificate ) ;
662+ int countBefore = CountCertificateChoices ( SignedDocuments . TstWithAttributeCertificate ) ;
663+
664+ using ( X509Certificate2 cert = Certificates . RSA2048SignatureOnly . TryGetCertificateWithPrivateKey ( ) )
665+ {
666+ CmsSigner signer = new CmsSigner ( cert ) ;
667+ SignerInfo info = signedCms . SignerInfos [ 0 ] ;
668+ info . ComputeCounterSignature ( signer ) ;
669+ }
670+
671+ byte [ ] encoded = signedCms . Encode ( ) ;
672+ int countAfter = CountCertificateChoices ( encoded ) ;
673+ Assert . Equal ( countBefore + 1 , countAfter ) ;
674+ }
675+
676+ [ Fact ]
677+ public static void ComputeSignature_PreservesAttributeCertificate ( )
678+ {
679+ SignedCms signedCms = new SignedCms ( ) ;
680+ signedCms . Decode ( SignedDocuments . TstWithAttributeCertificate ) ;
681+ int countBefore = CountCertificateChoices ( SignedDocuments . TstWithAttributeCertificate ) ;
682+
683+ using ( X509Certificate2 cert = Certificates . RSA2048SignatureOnly . TryGetCertificateWithPrivateKey ( ) )
684+ {
685+ CmsSigner signer = new CmsSigner ( cert ) ;
686+ signedCms . ComputeSignature ( signer ) ;
687+ }
688+
689+ byte [ ] encoded = signedCms . Encode ( ) ;
690+ int countAfter = CountCertificateChoices ( encoded ) ;
691+ Assert . Equal ( countBefore + 1 , countAfter ) ;
692+ }
693+
657694 private static void VerifyWithExplicitPrivateKey ( X509Certificate2 cert , AsymmetricAlgorithm key )
658695 {
659696 using ( var pubCert = new X509Certificate2 ( cert . RawData ) )
0 commit comments