diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-06-29 21:37:59 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-06-29 21:37:59 +0700 |
commit | 98c8cbf49384796d55cd05a766e2429d8a4262d2 (patch) | |
tree | d7e195fc5835e03398ee5a670829470d7633623d /crypto/src/bcpg/SymmetricKeyEncSessionPacket.cs | |
parent | Refactoring around Stream signers (diff) | |
download | BouncyCastle.NET-ed25519-98c8cbf49384796d55cd05a766e2429d8a4262d2.tar.xz |
Cleanup Stream disposing in Bcpg
Diffstat (limited to '')
-rw-r--r-- | crypto/src/bcpg/SymmetricKeyEncSessionPacket.cs | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/crypto/src/bcpg/SymmetricKeyEncSessionPacket.cs b/crypto/src/bcpg/SymmetricKeyEncSessionPacket.cs index 0381fa386..85bcc2874 100644 --- a/crypto/src/bcpg/SymmetricKeyEncSessionPacket.cs +++ b/crypto/src/bcpg/SymmetricKeyEncSessionPacket.cs @@ -68,21 +68,18 @@ namespace Org.BouncyCastle.Bcpg get { return version; } } - public override void Encode( - BcpgOutputStream bcpgOut) + public override void Encode(BcpgOutputStream bcpgOut) { MemoryStream bOut = new MemoryStream(); - BcpgOutputStream pOut = new BcpgOutputStream(bOut); + using (var pOut = new BcpgOutputStream(bOut)) + { + pOut.Write((byte)version, (byte)encAlgorithm); + pOut.WriteObject(s2k); - pOut.Write( - (byte) version, - (byte) encAlgorithm); - - pOut.WriteObject(s2k); - - if (secKeyData != null && secKeyData.Length > 0) - { - pOut.Write(secKeyData); + if (secKeyData != null && secKeyData.Length > 0) + { + pOut.Write(secKeyData); + } } bcpgOut.WritePacket(PacketTag.SymmetricKeyEncryptedSessionKey, bOut.ToArray(), true); |