diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2021-10-14 17:02:39 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2021-10-14 17:02:39 +0700 |
commit | 7405bffe8d645745d2c7e0a292df33c6b9bcdaa9 (patch) | |
tree | d0adec968c0f1121e7dc03bb15e7719120be6026 | |
parent | Some Obsolete cleanup (diff) | |
download | BouncyCastle.NET-ed25519-7405bffe8d645745d2c7e0a292df33c6b9bcdaa9.tar.xz |
Null check and reformatting
-rw-r--r-- | crypto/src/asn1/LazyDERSequence.cs | 104 | ||||
-rw-r--r-- | crypto/src/asn1/LazyDERSet.cs | 110 |
2 files changed, 109 insertions, 105 deletions
diff --git a/crypto/src/asn1/LazyDERSequence.cs b/crypto/src/asn1/LazyDERSequence.cs index d0548ebb2..bd14b6578 100644 --- a/crypto/src/asn1/LazyDERSequence.cs +++ b/crypto/src/asn1/LazyDERSequence.cs @@ -1,24 +1,26 @@ using System; using System.Collections; -using System.Diagnostics; namespace Org.BouncyCastle.Asn1 { - internal class LazyDerSequence - : DerSequence - { - private byte[] encoded; + internal class LazyDerSequence + : DerSequence + { + private byte[] encoded; - internal LazyDerSequence( - byte[] encoded) - { - this.encoded = encoded; - } + internal LazyDerSequence(byte[] encoded) + : base() + { + if (null == encoded) + throw new ArgumentNullException("encoded"); - private void Parse() - { - lock (this) - { + this.encoded = encoded; + } + + private void Parse() + { + lock (this) + { if (null != encoded) { Asn1InputStream e = new LazyAsn1InputStream(encoded); @@ -28,48 +30,48 @@ namespace Org.BouncyCastle.Asn1 this.encoded = null; } } - } + } - public override Asn1Encodable this[int index] - { - get - { - Parse(); + public override Asn1Encodable this[int index] + { + get + { + Parse(); - return base[index]; - } - } + return base[index]; + } + } - public override IEnumerator GetEnumerator() - { - Parse(); + public override IEnumerator GetEnumerator() + { + Parse(); - return base.GetEnumerator(); - } + return base.GetEnumerator(); + } - public override int Count - { - get - { - Parse(); + public override int Count + { + get + { + Parse(); - return base.Count; - } - } + return base.Count; + } + } - internal override void Encode(Asn1OutputStream asn1Out) - { - lock (this) - { - if (encoded == null) - { - base.Encode(asn1Out); - } - else - { - asn1Out.WriteEncoded(Asn1Tags.Sequence | Asn1Tags.Constructed, encoded); - } - } - } - } + internal override void Encode(Asn1OutputStream asn1Out) + { + lock (this) + { + if (encoded == null) + { + base.Encode(asn1Out); + } + else + { + asn1Out.WriteEncoded(Asn1Tags.Sequence | Asn1Tags.Constructed, encoded); + } + } + } + } } diff --git a/crypto/src/asn1/LazyDERSet.cs b/crypto/src/asn1/LazyDERSet.cs index 653054bf9..f8271f330 100644 --- a/crypto/src/asn1/LazyDERSet.cs +++ b/crypto/src/asn1/LazyDERSet.cs @@ -1,75 +1,77 @@ using System; using System.Collections; -using System.Diagnostics; namespace Org.BouncyCastle.Asn1 { - internal class LazyDerSet - : DerSet - { - private byte[] encoded; + internal class LazyDerSet + : DerSet + { + private byte[] encoded; - internal LazyDerSet( - byte[] encoded) - { - this.encoded = encoded; - } + internal LazyDerSet(byte[] encoded) + : base() + { + if (null == encoded) + throw new ArgumentNullException("encoded"); - private void Parse() - { - lock (this) - { - if (encoded != null) - { + this.encoded = encoded; + } + + private void Parse() + { + lock (this) + { + if (encoded != null) + { Asn1InputStream e = new LazyAsn1InputStream(encoded); Asn1EncodableVector v = e.ReadVector(); this.elements = v.TakeElements(); this.encoded = null; } - } - } + } + } - public override Asn1Encodable this[int index] - { - get - { - Parse(); + public override Asn1Encodable this[int index] + { + get + { + Parse(); - return base[index]; - } - } + return base[index]; + } + } - public override IEnumerator GetEnumerator() - { - Parse(); + public override IEnumerator GetEnumerator() + { + Parse(); - return base.GetEnumerator(); - } + return base.GetEnumerator(); + } - public override int Count - { - get - { - Parse(); + public override int Count + { + get + { + Parse(); - return base.Count; - } - } + return base.Count; + } + } - internal override void Encode(Asn1OutputStream asn1Out) - { - lock (this) - { - if (encoded == null) - { - base.Encode(asn1Out); - } - else - { - asn1Out.WriteEncoded(Asn1Tags.Set | Asn1Tags.Constructed, encoded); - } - } - } - } + internal override void Encode(Asn1OutputStream asn1Out) + { + lock (this) + { + if (encoded == null) + { + base.Encode(asn1Out); + } + else + { + asn1Out.WriteEncoded(Asn1Tags.Set | Asn1Tags.Constructed, encoded); + } + } + } + } } |