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/x9/X9ECParametersHolder.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/x9/X9ECParametersHolder.cs')
-rw-r--r-- | crypto/src/asn1/x9/X9ECParametersHolder.cs | 39 |
1 files changed, 5 insertions, 34 deletions
diff --git a/crypto/src/asn1/x9/X9ECParametersHolder.cs b/crypto/src/asn1/x9/X9ECParametersHolder.cs index ea72cc6ac..535dad9f7 100644 --- a/crypto/src/asn1/x9/X9ECParametersHolder.cs +++ b/crypto/src/asn1/x9/X9ECParametersHolder.cs @@ -1,4 +1,5 @@ using Org.BouncyCastle.Math.EC; +using Org.BouncyCastle.Utilities; namespace Org.BouncyCastle.Asn1.X9 { @@ -7,42 +8,12 @@ namespace Org.BouncyCastle.Asn1.X9 private ECCurve m_curve; private X9ECParameters m_parameters; - public ECCurve Curve - { - get - { - lock (this) - { - if (m_curve == null) - { - m_curve = CreateCurve(); - } + public ECCurve Curve => Objects.EnsureSingletonInitialized(ref m_curve, this, self => self.CreateCurve()); - return m_curve; - } - } - } + public X9ECParameters Parameters => + Objects.EnsureSingletonInitialized(ref m_parameters, this, self => self.CreateParameters()); - public X9ECParameters Parameters - { - get - { - lock (this) - { - if (m_parameters == null) - { - m_parameters = CreateParameters(); - } - - return m_parameters; - } - } - } - - protected virtual ECCurve CreateCurve() - { - return CreateParameters().Curve; - } + protected virtual ECCurve CreateCurve() => Parameters.Curve; protected abstract X9ECParameters CreateParameters(); } |