summary refs log tree commit diff
path: root/crypto/src/asn1/LazyDERSequence.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2019-08-01 20:30:22 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2019-08-01 20:30:22 +0700
commitf06dc7c2f2e578c77bdb53ff981c578c3fe017eb (patch)
treeda2e616d2554028d0314681abacc5632aa523627 /crypto/src/asn1/LazyDERSequence.cs
parentDon't create a SecureRandom unnecessarily (diff)
downloadBouncyCastle.NET-ed25519-f06dc7c2f2e578c77bdb53ff981c578c3fe017eb.tar.xz
Rewrite Asn1Sequence/Set to store elements as Asn1Encodable[]
Diffstat (limited to 'crypto/src/asn1/LazyDERSequence.cs')
-rw-r--r--crypto/src/asn1/LazyDERSequence.cs22
1 files changed, 12 insertions, 10 deletions
diff --git a/crypto/src/asn1/LazyDERSequence.cs b/crypto/src/asn1/LazyDERSequence.cs
index 7301bc158..8fa7a0792 100644
--- a/crypto/src/asn1/LazyDERSequence.cs
+++ b/crypto/src/asn1/LazyDERSequence.cs
@@ -19,18 +19,20 @@ namespace Org.BouncyCastle.Asn1
 		{
 			lock (this)
 			{
-				if (encoded != null)
-				{
-					Asn1InputStream e = new LazyAsn1InputStream(encoded);
+                if (null != encoded)
+                {
+                    Asn1EncodableVector v = new Asn1EncodableVector();
+                    Asn1InputStream e = new LazyAsn1InputStream(encoded);
 
-					Asn1Object o;
-					while ((o = e.ReadObject()) != null)
-					{
-						AddObject(o);
-					}
+                    Asn1Object o;
+                    while ((o = e.ReadObject()) != null)
+                    {
+                        v.Add(o);
+                    }
 
-					encoded = null;
-				}
+                    this.elements = v.TakeElements();
+                    this.encoded = null;
+                }
 			}
 		}