diff options
Diffstat (limited to 'crypto/src/asn1/x9/X9ECParametersHolder.cs')
-rw-r--r-- | crypto/src/asn1/x9/X9ECParametersHolder.cs | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/crypto/src/asn1/x9/X9ECParametersHolder.cs b/crypto/src/asn1/x9/X9ECParametersHolder.cs index e802b738c..ea72cc6ac 100644 --- a/crypto/src/asn1/x9/X9ECParametersHolder.cs +++ b/crypto/src/asn1/x9/X9ECParametersHolder.cs @@ -1,25 +1,49 @@ +using Org.BouncyCastle.Math.EC; + namespace Org.BouncyCastle.Asn1.X9 { public abstract class X9ECParametersHolder { - private X9ECParameters parameters; + private ECCurve m_curve; + private X9ECParameters m_parameters; + + public ECCurve Curve + { + get + { + lock (this) + { + if (m_curve == null) + { + m_curve = CreateCurve(); + } - public X9ECParameters Parameters + return m_curve; + } + } + } + + public X9ECParameters Parameters { get { lock (this) { - if (parameters == null) + if (m_parameters == null) { - parameters = CreateParameters(); + m_parameters = CreateParameters(); } - return parameters; + return m_parameters; } } } - protected abstract X9ECParameters CreateParameters(); + protected virtual ECCurve CreateCurve() + { + return CreateParameters().Curve; + } + + protected abstract X9ECParameters CreateParameters(); } } |