diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2019-01-31 19:26:09 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2019-01-31 19:26:09 +0700 |
commit | 65b588a45feb07f27716288ff15f784b5bf73812 (patch) | |
tree | 41d4d9e5d939e32008460cee18d6fc3dd6857ce0 /crypto/src/pkcs | |
parent | removed unnecessary extra ECGOST3410 class (diff) | |
download | BouncyCastle.NET-ed25519-65b588a45feb07f27716288ff15f784b5bf73812.tar.xz |
Fixes and tidying up for release
Diffstat (limited to 'crypto/src/pkcs')
-rw-r--r-- | crypto/src/pkcs/Pkcs8EncryptedPrivateKeyInfo.cs | 18 | ||||
-rw-r--r-- | crypto/src/pkcs/Pkcs8EncryptedPrivateKeyInfoBuilder.cs | 17 | ||||
-rw-r--r-- | crypto/src/pkcs/PkcsException.cs | 9 |
3 files changed, 23 insertions, 21 deletions
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) { } } |