summary refs log tree commit diff
path: root/crypto/src/crmf/ProofOfPossessionSigningKeyBuilder.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/crmf/ProofOfPossessionSigningKeyBuilder.cs')
-rw-r--r--crypto/src/crmf/ProofOfPossessionSigningKeyBuilder.cs10
1 files changed, 6 insertions, 4 deletions
diff --git a/crypto/src/crmf/ProofOfPossessionSigningKeyBuilder.cs b/crypto/src/crmf/ProofOfPossessionSigningKeyBuilder.cs
index eed66b083..4cd568e81 100644
--- a/crypto/src/crmf/ProofOfPossessionSigningKeyBuilder.cs
+++ b/crypto/src/crmf/ProofOfPossessionSigningKeyBuilder.cs
@@ -38,11 +38,13 @@ namespace Org.BouncyCastle.Crmf
         {
             IMacFactory fact = generator.Build(password);
 
-            IStreamCalculator<IBlockResult> calc = fact.CreateCalculator();
             byte[] d = _pubKeyInfo.GetDerEncoded();
-            calc.Stream.Write(d, 0, d.Length);
-            calc.Stream.Flush();
-            Platform.Dispose(calc.Stream);
+
+            IStreamCalculator<IBlockResult> calc = fact.CreateCalculator();
+            using (var stream = calc.Stream)
+            {
+                stream.Write(d, 0, d.Length);
+            }
 
             this._publicKeyMAC = new PKMacValue(
                 (AlgorithmIdentifier)fact.AlgorithmDetails,