summary refs log tree commit diff
path: root/crypto/src/cmp/ProtectedPkiMessageBuilder.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2023-01-28 18:57:30 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2023-01-28 18:57:30 +0700
commit558aef70537b3882e5616e9d0e7b40d971e2dd42 (patch)
tree1ac43c975f414e69a268dca315a10a87fa406ea8 /crypto/src/cmp/ProtectedPkiMessageBuilder.cs
parentAdd Xoodyak to the master branch (diff)
downloadBouncyCastle.NET-ed25519-558aef70537b3882e5616e9d0e7b40d971e2dd42.tar.xz
Misc. cleanup after bc-fips-csharp updates
Diffstat (limited to 'crypto/src/cmp/ProtectedPkiMessageBuilder.cs')
-rw-r--r--crypto/src/cmp/ProtectedPkiMessageBuilder.cs11
1 files changed, 7 insertions, 4 deletions
diff --git a/crypto/src/cmp/ProtectedPkiMessageBuilder.cs b/crypto/src/cmp/ProtectedPkiMessageBuilder.cs
index 505747960..508b00ff5 100644
--- a/crypto/src/cmp/ProtectedPkiMessageBuilder.cs
+++ b/crypto/src/cmp/ProtectedPkiMessageBuilder.cs
@@ -3,7 +3,6 @@ using System.Collections.Generic;
 
 using Org.BouncyCastle.Asn1;
 using Org.BouncyCastle.Asn1.Cmp;
-using Org.BouncyCastle.Asn1.Cms;
 using Org.BouncyCastle.Asn1.X509;
 using Org.BouncyCastle.Crypto;
 using Org.BouncyCastle.X509;
@@ -98,7 +97,7 @@ namespace Org.BouncyCastle.Cmp
             if (null == body)
                 throw new InvalidOperationException("body must be set before building");
 
-            IStreamCalculator<IBlockResult> calculator = signatureFactory.CreateCalculator();
+            var calculator = signatureFactory.CreateCalculator();
 
             if (!(signatureFactory.AlgorithmDetails is AlgorithmIdentifier algorithmDetails))
                 throw new ArgumentException("AlgorithmDetails is not AlgorithmIdentifier");
@@ -114,7 +113,7 @@ namespace Org.BouncyCastle.Cmp
             if (null == body)
                 throw new InvalidOperationException("body must be set before building");
 
-            IStreamCalculator<IBlockResult> calculator = macFactory.CreateCalculator();
+            var calculator = macFactory.CreateCalculator();
 
             if (!(macFactory.AlgorithmDetails is AlgorithmIdentifier algorithmDetails))
                 throw new ArgumentException("AlgorithmDetails is not AlgorithmIdentifier");
@@ -150,7 +149,11 @@ namespace Org.BouncyCastle.Cmp
 
         private byte[] CalculateSignature(IStreamCalculator<IBlockResult> signer, PkiHeader header, PkiBody body)
         {
-            new DerSequence(header, body).EncodeTo(signer.Stream);
+            using (var s = signer.Stream)
+            {
+                new DerSequence(header, body).EncodeTo(s);
+            }
+
             return signer.GetResult().Collect();
         }
     }