summary refs log tree commit diff
path: root/crypto/src/asn1/DerObjectIdentifier.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/asn1/DerObjectIdentifier.cs')
-rw-r--r--crypto/src/asn1/DerObjectIdentifier.cs20
1 files changed, 5 insertions, 15 deletions
diff --git a/crypto/src/asn1/DerObjectIdentifier.cs b/crypto/src/asn1/DerObjectIdentifier.cs
index 91e427d0b..12e8ea0a8 100644
--- a/crypto/src/asn1/DerObjectIdentifier.cs
+++ b/crypto/src/asn1/DerObjectIdentifier.cs
@@ -168,8 +168,11 @@ namespace Org.BouncyCastle.Asn1
             return new PrimitiveDerEncoding(tagClass, tagNo, GetContents());
         }
 
-        private void DoOutput(MemoryStream bOut)
+        private byte[] GetContents() => Objects.EnsureSingletonInitialized(ref contents, identifier, CreateContents);
+
+        private static byte[] CreateContents(string identifier)
         {
+            MemoryStream bOut = new MemoryStream();
             OidTokenizer tok = new OidTokenizer(identifier);
 
             string token = tok.NextToken();
@@ -197,21 +200,8 @@ namespace Org.BouncyCastle.Asn1
                     Asn1RelativeOid.WriteField(bOut, new BigInteger(token));
                 }
             }
-        }
-
-        private byte[] GetContents()
-        {
-            lock (this)
-            {
-                if (contents == null)
-                {
-                    MemoryStream bOut = new MemoryStream();
-                    DoOutput(bOut);
-                    contents = bOut.ToArray();
-                }
 
-                return contents;
-            }
+            return bOut.ToArray();
         }
 
         internal static DerObjectIdentifier CreatePrimitive(byte[] contents, bool clone)