From 0eb75e3c71890e27256b839b58103a8e6cd42e7f Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Fri, 2 Sep 2022 16:01:46 +0700 Subject: NullOutputStream => Stream.Null --- crypto/src/cms/CMSSignedDataStreamGenerator.cs | 4 +--- crypto/src/tls/DtlsServerProtocol.cs | 2 +- crypto/src/util/io/NullOutputStream.cs | 17 ----------------- 3 files changed, 2 insertions(+), 21 deletions(-) delete mode 100644 crypto/src/util/io/NullOutputStream.cs diff --git a/crypto/src/cms/CMSSignedDataStreamGenerator.cs b/crypto/src/cms/CMSSignedDataStreamGenerator.cs index 0dbdccbeb..5587a9d07 100644 --- a/crypto/src/cms/CMSSignedDataStreamGenerator.cs +++ b/crypto/src/cms/CMSSignedDataStreamGenerator.cs @@ -741,9 +741,7 @@ namespace Org.BouncyCastle.Cms private static Stream GetSafeOutputStream(Stream s) { - if (s == null) - return new NullOutputStream(); - return s; + return s ?? Stream.Null; } private static Stream GetSafeTeeOutputStream(Stream s1, Stream s2) diff --git a/crypto/src/tls/DtlsServerProtocol.cs b/crypto/src/tls/DtlsServerProtocol.cs index 51e013290..e4ce4d6be 100644 --- a/crypto/src/tls/DtlsServerProtocol.cs +++ b/crypto/src/tls/DtlsServerProtocol.cs @@ -667,7 +667,7 @@ namespace Org.BouncyCastle.Tls protected virtual void ProcessClientHello(ServerHandshakeState state, byte[] body) { MemoryStream buf = new MemoryStream(body, false); - ClientHello clientHello = ClientHello.Parse(buf, new NullOutputStream()); + ClientHello clientHello = ClientHello.Parse(buf, Stream.Null); ProcessClientHello(state, clientHello); } diff --git a/crypto/src/util/io/NullOutputStream.cs b/crypto/src/util/io/NullOutputStream.cs deleted file mode 100644 index c435549d2..000000000 --- a/crypto/src/util/io/NullOutputStream.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; - -namespace Org.BouncyCastle.Utilities.IO -{ - internal class NullOutputStream - : BaseOutputStream - { - public override void Write(byte[] buffer, int offset, int count) - { - Streams.ValidateBufferArguments(buffer, offset, count); - } - - public override void WriteByte(byte value) - { - } - } -} -- cgit 1.4.1