diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-09-03 00:36:40 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-09-03 00:36:40 +0700 |
commit | aa5f3f0929c50fc942325f18ed7ae48129d4c992 (patch) | |
tree | 0382f7336cb55c4a01bd38782d7694d1cb094921 /crypto/src/openpgp | |
parent | Clean up tests (diff) | |
download | BouncyCastle.NET-ed25519-aa5f3f0929c50fc942325f18ed7ae48129d4c992.tar.xz |
Stream modernization
Diffstat (limited to 'crypto/src/openpgp')
-rw-r--r-- | crypto/src/openpgp/PgpCompressedDataGenerator.cs | 36 | ||||
-rw-r--r-- | crypto/src/openpgp/PgpEncryptedData.cs | 2 | ||||
-rw-r--r-- | crypto/src/openpgp/PgpEncryptedDataGenerator.cs | 2 | ||||
-rw-r--r-- | crypto/src/openpgp/WrappedGeneratorStream.cs | 6 |
4 files changed, 8 insertions, 38 deletions
diff --git a/crypto/src/openpgp/PgpCompressedDataGenerator.cs b/crypto/src/openpgp/PgpCompressedDataGenerator.cs index 88a1070d1..791aac0bf 100644 --- a/crypto/src/openpgp/PgpCompressedDataGenerator.cs +++ b/crypto/src/openpgp/PgpCompressedDataGenerator.cs @@ -76,7 +76,7 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp this.pkOut = new BcpgOutputStream(outStr, PacketTag.CompressedData); - doOpen(); + DoOpen(); return new WrappedGeneratorStream(this, dOut); } @@ -120,12 +120,12 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp this.pkOut = new BcpgOutputStream(outStr, PacketTag.CompressedData, buffer); - doOpen(); + DoOpen(); return new WrappedGeneratorStream(this, dOut); } - private void doOpen() + private void DoOpen() { pkOut.WriteByte((byte) algorithm); @@ -173,22 +173,10 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp { } -#if PORTABLE protected override void Dispose(bool disposing) { - if (disposing) - { - Finish(); - return; - } - base.Dispose(disposing); + Detach(disposing); } -#else - public override void Close() - { - Finish(); - } -#endif } private class SafeZOutputStream : ZOutputStream @@ -198,24 +186,10 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp { } -#if PORTABLE protected override void Dispose(bool disposing) { - if (disposing) - { - Finish(); - End(); - return; - } - base.Dispose(disposing); + Detach(disposing); } -#else - public override void Close() - { - Finish(); - End(); - } -#endif } } } diff --git a/crypto/src/openpgp/PgpEncryptedData.cs b/crypto/src/openpgp/PgpEncryptedData.cs index d3220fe86..5cdc0d533 100644 --- a/crypto/src/openpgp/PgpEncryptedData.cs +++ b/crypto/src/openpgp/PgpEncryptedData.cs @@ -140,7 +140,7 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp // byte[] lookAhead = truncStream.GetLookAhead(); - IDigest hash = dIn.ReadDigest(); + IDigest hash = dIn.ReadDigest; hash.BlockUpdate(lookAhead, 0, 2); byte[] digest = DigestUtilities.DoFinal(hash); diff --git a/crypto/src/openpgp/PgpEncryptedDataGenerator.cs b/crypto/src/openpgp/PgpEncryptedDataGenerator.cs index d16f328d9..f086aaf75 100644 --- a/crypto/src/openpgp/PgpEncryptedDataGenerator.cs +++ b/crypto/src/openpgp/PgpEncryptedDataGenerator.cs @@ -561,7 +561,7 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp digestOut.Flush(); // TODO - byte[] dig = DigestUtilities.DoFinal(digestOut.WriteDigest()); + byte[] dig = DigestUtilities.DoFinal(digestOut.WriteDigest); cOut.Write(dig, 0, dig.Length); } diff --git a/crypto/src/openpgp/WrappedGeneratorStream.cs b/crypto/src/openpgp/WrappedGeneratorStream.cs index df31d71f0..c54ee0b3b 100644 --- a/crypto/src/openpgp/WrappedGeneratorStream.cs +++ b/crypto/src/openpgp/WrappedGeneratorStream.cs @@ -31,11 +31,7 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp m_generator = null; } - // Don't dispose the wrapped Stream - if (!disposing) - { - base.Dispose(disposing); - } + Detach(disposing); } } } |