From b260a9581c16a77d52ce9d6b7a3b81aa33cadebb Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Thu, 14 Oct 2021 12:37:35 +0700 Subject: ASN.1 Obsolete cleanup --- crypto/src/asn1/Asn1OutputStream.cs | 25 ++----------------------- crypto/src/asn1/BerNull.cs | 13 ++++--------- crypto/src/asn1/BerOutputStream.cs | 25 ++----------------------- crypto/src/asn1/DerNull.cs | 19 ++++++------------- crypto/src/asn1/DerOutputStream.cs | 22 ---------------------- 5 files changed, 14 insertions(+), 90 deletions(-) diff --git a/crypto/src/asn1/Asn1OutputStream.cs b/crypto/src/asn1/Asn1OutputStream.cs index 39c8b1e5e..9ed3fbe4a 100644 --- a/crypto/src/asn1/Asn1OutputStream.cs +++ b/crypto/src/asn1/Asn1OutputStream.cs @@ -6,30 +6,9 @@ namespace Org.BouncyCastle.Asn1 public class Asn1OutputStream : DerOutputStream { - public Asn1OutputStream(Stream os) : base(os) + public Asn1OutputStream(Stream os) + : base(os) { - } - - [Obsolete("Use version taking an Asn1Encodable arg instead")] - public override void WriteObject( - object obj) - { - if (obj == null) - { - WriteNull(); - } - else if (obj is Asn1Object) - { - ((Asn1Object)obj).Encode(this); - } - else if (obj is Asn1Encodable) - { - ((Asn1Encodable)obj).ToAsn1Object().Encode(this); - } - else - { - throw new IOException("object not Asn1Encodable"); - } } } } diff --git a/crypto/src/asn1/BerNull.cs b/crypto/src/asn1/BerNull.cs index 0751bbac3..cf669914b 100644 --- a/crypto/src/asn1/BerNull.cs +++ b/crypto/src/asn1/BerNull.cs @@ -8,19 +8,14 @@ namespace Org.BouncyCastle.Asn1 public class BerNull : DerNull { - public static new readonly BerNull Instance = new BerNull(0); + public static new readonly BerNull Instance = new BerNull(); - [Obsolete("Use static Instance object")] - public BerNull() + private BerNull() + : base() { } - private BerNull(int dummy) : base(dummy) - { - } - - internal override void Encode( - DerOutputStream derOut) + internal override void Encode(DerOutputStream derOut) { if (derOut is Asn1OutputStream || derOut is BerOutputStream) { diff --git a/crypto/src/asn1/BerOutputStream.cs b/crypto/src/asn1/BerOutputStream.cs index b3ece10d3..4ed28d8f3 100644 --- a/crypto/src/asn1/BerOutputStream.cs +++ b/crypto/src/asn1/BerOutputStream.cs @@ -7,30 +7,9 @@ namespace Org.BouncyCastle.Asn1 public class BerOutputStream : DerOutputStream { - public BerOutputStream(Stream os) : base(os) + public BerOutputStream(Stream os) + : base(os) { - } - - [Obsolete("Use version taking an Asn1Encodable arg instead")] - public override void WriteObject( - object obj) - { - if (obj == null) - { - WriteNull(); - } - else if (obj is Asn1Object) - { - ((Asn1Object)obj).Encode(this); - } - else if (obj is Asn1Encodable) - { - ((Asn1Encodable)obj).ToAsn1Object().Encode(this); - } - else - { - throw new IOException("object not BerEncodable"); - } } } } diff --git a/crypto/src/asn1/DerNull.cs b/crypto/src/asn1/DerNull.cs index a802f6486..fd7049699 100644 --- a/crypto/src/asn1/DerNull.cs +++ b/crypto/src/asn1/DerNull.cs @@ -8,27 +8,20 @@ namespace Org.BouncyCastle.Asn1 public class DerNull : Asn1Null { - public static readonly DerNull Instance = new DerNull(0); + public static readonly DerNull Instance = new DerNull(); - byte[] zeroBytes = new byte[0]; + private static readonly byte[] ZeroBytes = new byte[0]; - [Obsolete("Use static Instance object")] - public DerNull() + protected internal DerNull() { } - protected internal DerNull(int dummy) + internal override void Encode(DerOutputStream derOut) { + derOut.WriteEncoded(Asn1Tags.Null, ZeroBytes); } - internal override void Encode( - DerOutputStream derOut) - { - derOut.WriteEncoded(Asn1Tags.Null, zeroBytes); - } - - protected override bool Asn1Equals( - Asn1Object asn1Object) + protected override bool Asn1Equals(Asn1Object asn1Object) { return asn1Object is DerNull; } diff --git a/crypto/src/asn1/DerOutputStream.cs b/crypto/src/asn1/DerOutputStream.cs index 69d5d5f28..52b3a704d 100644 --- a/crypto/src/asn1/DerOutputStream.cs +++ b/crypto/src/asn1/DerOutputStream.cs @@ -120,28 +120,6 @@ namespace Org.BouncyCastle.Asn1 WriteByte(0x00); } - [Obsolete("Use version taking an Asn1Encodable arg instead")] - public virtual void WriteObject( - object obj) - { - if (obj == null) - { - WriteNull(); - } - else if (obj is Asn1Object) - { - ((Asn1Object)obj).Encode(this); - } - else if (obj is Asn1Encodable) - { - ((Asn1Encodable)obj).ToAsn1Object().Encode(this); - } - else - { - throw new IOException("object not Asn1Object"); - } - } - public virtual void WriteObject( Asn1Encodable obj) { -- cgit 1.4.1