diff options
Diffstat (limited to 'crypto/src/crmf/EncryptedValueBuilder.cs')
-rw-r--r-- | crypto/src/crmf/EncryptedValueBuilder.cs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/crypto/src/crmf/EncryptedValueBuilder.cs b/crypto/src/crmf/EncryptedValueBuilder.cs index 0154be58c..37f38df1c 100644 --- a/crypto/src/crmf/EncryptedValueBuilder.cs +++ b/crypto/src/crmf/EncryptedValueBuilder.cs @@ -112,12 +112,14 @@ namespace Org.BouncyCastle.Crmf private EncryptedValue EncryptData(byte[] data) { MemoryOutputStream bOut = new MemoryOutputStream(); - Stream eOut = encryptor.BuildCipher(bOut).Stream; + var cipher = encryptor.BuildCipher(bOut); try { - eOut.Write(data, 0, data.Length); - Platform.Dispose(eOut); + using (var eOut = cipher.Stream) + { + eOut.Write(data, 0, data.Length); + } } catch (IOException e) { |