diff options
author | David Hook <dgh@cryptoworkshop.com> | 2023-08-14 13:30:36 +1000 |
---|---|---|
committer | David Hook <dgh@cryptoworkshop.com> | 2023-08-14 13:30:36 +1000 |
commit | f3dac948c7e6214663e58dc966bd10cb31689411 (patch) | |
tree | 60742057ef07d02d80162165b849a15a842503cb /crypto/src/asn1/DerObjectIdentifier.cs | |
parent | test vector updates to Kyber and Dilithium (diff) | |
parent | Microsoft.NET.Test.Sdk 17.7.0 (diff) | |
download | BouncyCastle.NET-ed25519-f3dac948c7e6214663e58dc966bd10cb31689411.tar.xz |
Merge remote-tracking branch 'refs/remotes/origin/master'
Diffstat (limited to 'crypto/src/asn1/DerObjectIdentifier.cs')
-rw-r--r-- | crypto/src/asn1/DerObjectIdentifier.cs | 20 |
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) |