diff --git a/crypto/src/pkcs/Pkcs8EncryptedPrivateKeyInfo.cs b/crypto/src/pkcs/Pkcs8EncryptedPrivateKeyInfo.cs
index 4c4ae83eb..5882dee38 100644
--- a/crypto/src/pkcs/Pkcs8EncryptedPrivateKeyInfo.cs
+++ b/crypto/src/pkcs/Pkcs8EncryptedPrivateKeyInfo.cs
@@ -1,10 +1,11 @@
-
+using System;
+using System.IO;
+
using Org.BouncyCastle.Asn1.Pkcs;
using Org.BouncyCastle.Asn1.X509;
using Org.BouncyCastle.Crypto;
+using Org.BouncyCastle.Utilities;
using Org.BouncyCastle.Utilities.IO;
-using System;
-using System.IO;
namespace Org.BouncyCastle.Pkcs
{
@@ -90,12 +91,11 @@ namespace Org.BouncyCastle.Pkcs
ICipher encIn = decryptorBuilder.BuildCipher(new MemoryInputStream(encryptedPrivateKeyInfo.GetEncryptedData()));
- using (Stream strm = encIn.Stream)
- {
- byte[] data = Streams.ReadAll(encIn.Stream);
-
- return PrivateKeyInfo.GetInstance(data);
- }
+ Stream strm = encIn.Stream;
+ byte[] data = Streams.ReadAll(encIn.Stream);
+ Platform.Dispose(strm);
+
+ return PrivateKeyInfo.GetInstance(data);
}
catch (Exception e)
{
diff --git a/crypto/src/pkcs/Pkcs8EncryptedPrivateKeyInfoBuilder.cs b/crypto/src/pkcs/Pkcs8EncryptedPrivateKeyInfoBuilder.cs
index 3b05deea7..8f751492f 100644
--- a/crypto/src/pkcs/Pkcs8EncryptedPrivateKeyInfoBuilder.cs
+++ b/crypto/src/pkcs/Pkcs8EncryptedPrivateKeyInfoBuilder.cs
@@ -1,11 +1,11 @@
-using Org.BouncyCastle.Asn1.Pkcs;
+using System;
+using System.IO;
+
+using Org.BouncyCastle.Asn1.Pkcs;
using Org.BouncyCastle.Asn1.X509;
using Org.BouncyCastle.Crypto;
+using Org.BouncyCastle.Utilities;
using Org.BouncyCastle.Utilities.IO;
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Text;
namespace Org.BouncyCastle.Pkcs
{
@@ -36,10 +36,9 @@ namespace Org.BouncyCastle.Pkcs
ICipher cOut = encryptor.BuildCipher(bOut);
byte[] keyData = privateKeyInfo.GetEncoded();
- using (var str = cOut.Stream)
- {
- str.Write(keyData, 0, keyData.Length);
- }
+ Stream str = cOut.Stream;
+ str.Write(keyData, 0, keyData.Length);
+ Platform.Dispose(str);
return new Pkcs8EncryptedPrivateKeyInfo(new EncryptedPrivateKeyInfo((AlgorithmIdentifier)encryptor.AlgorithmDetails, bOut.ToArray()));
}
diff --git a/crypto/src/pkcs/PkcsException.cs b/crypto/src/pkcs/PkcsException.cs
index f82d36724..7a69ff736 100644
--- a/crypto/src/pkcs/PkcsException.cs
+++ b/crypto/src/pkcs/PkcsException.cs
@@ -5,13 +5,16 @@ namespace Org.BouncyCastle.Pkcs
/// <summary>
/// Base exception for PKCS related issues.
/// </summary>
- public class PkcsException : Exception
+ public class PkcsException
+ : Exception
{
- public PkcsException(String message) : base(message)
+ public PkcsException(string message)
+ : base(message)
{
}
- public PkcsException(String message, Exception underlying) : base(message, underlying)
+ public PkcsException(string message, Exception underlying)
+ : base(message, underlying)
{
}
}
|