From 9762da219c208cd71e0173a89f7a88e214ce23bd Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Fri, 5 Apr 2024 14:26:01 +0700 Subject: TLS: Use more appropriate method to check for ECDH curve --- crypto/src/tls/NamedGroup.cs | 2 -- crypto/src/tls/TlsServerProtocol.cs | 2 +- crypto/src/tls/TlsUtilities.cs | 6 +++--- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/crypto/src/tls/NamedGroup.cs b/crypto/src/tls/NamedGroup.cs index 15671a837..a345b8ce0 100644 --- a/crypto/src/tls/NamedGroup.cs +++ b/crypto/src/tls/NamedGroup.cs @@ -224,9 +224,7 @@ namespace Org.BouncyCastle.Tls public static string GetCurveName(int namedGroup) { if (RefersToASpecificCurve(namedGroup)) - { return CurveNames[namedGroup - sect163k1]; - } return null; } diff --git a/crypto/src/tls/TlsServerProtocol.cs b/crypto/src/tls/TlsServerProtocol.cs index 528440272..252660a16 100644 --- a/crypto/src/tls/TlsServerProtocol.cs +++ b/crypto/src/tls/TlsServerProtocol.cs @@ -356,7 +356,7 @@ namespace Org.BouncyCastle.Tls int namedGroup = clientShare.NamedGroup; TlsAgreement agreement; - if (NamedGroup.RefersToASpecificCurve(namedGroup)) + if (NamedGroup.RefersToAnECDHCurve(namedGroup)) { agreement = crypto.CreateECDomain(new TlsECConfig(namedGroup)).CreateECDH(); } diff --git a/crypto/src/tls/TlsUtilities.cs b/crypto/src/tls/TlsUtilities.cs index 67a49e5ef..c6c4a052a 100644 --- a/crypto/src/tls/TlsUtilities.cs +++ b/crypto/src/tls/TlsUtilities.cs @@ -5019,7 +5019,7 @@ namespace Org.BouncyCastle.Tls } TlsAgreement agreement = null; - if (NamedGroup.RefersToASpecificCurve(supportedGroup)) + if (NamedGroup.RefersToAnECDHCurve(supportedGroup)) { if (crypto.HasECDHAgreement()) { @@ -5079,7 +5079,7 @@ namespace Org.BouncyCastle.Tls if (!crypto.HasNamedGroup(group)) continue; - if ((NamedGroup.RefersToASpecificCurve(group) && !crypto.HasECDHAgreement()) || + if ((NamedGroup.RefersToAnECDHCurve(group) && !crypto.HasECDHAgreement()) || (NamedGroup.RefersToASpecificFiniteField(group) && !crypto.HasDHAgreement())) { continue; @@ -5107,7 +5107,7 @@ namespace Org.BouncyCastle.Tls if (!crypto.HasNamedGroup(group)) continue; - if ((NamedGroup.RefersToASpecificCurve(group) && !crypto.HasECDHAgreement()) || + if ((NamedGroup.RefersToAnECDHCurve(group) && !crypto.HasECDHAgreement()) || (NamedGroup.RefersToASpecificFiniteField(group) && !crypto.HasDHAgreement())) { continue; -- cgit 1.4.1