From 67d33a2258f53f50f348a1362335e8201d3a77b2 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Sat, 11 Sep 2021 12:00:39 +0700 Subject: Check DH standard group lookup --- crypto/test/src/tls/crypto/test/BcTlsCryptoTest.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/crypto/test/src/tls/crypto/test/BcTlsCryptoTest.cs b/crypto/test/src/tls/crypto/test/BcTlsCryptoTest.cs index 60f88bd05..a274cc5ba 100644 --- a/crypto/test/src/tls/crypto/test/BcTlsCryptoTest.cs +++ b/crypto/test/src/tls/crypto/test/BcTlsCryptoTest.cs @@ -4,6 +4,7 @@ using System.IO; using NUnit.Framework; +using Org.BouncyCastle.Math; using Org.BouncyCastle.Security; using Org.BouncyCastle.Tls.Crypto.Impl.BC; using Org.BouncyCastle.Tls.Tests; @@ -183,7 +184,15 @@ namespace Org.BouncyCastle.Tls.Crypto.Tests IList groups = new TestTlsDHGroupVerifier().Groups; foreach (DHGroup dhGroup in groups) { - int namedGroup = TlsDHUtilities.GetNamedGroupForDHParameters(dhGroup.P, dhGroup.G); + BigInteger p = dhGroup.P, g = dhGroup.G; + + /* + * DefaultTlsDHGroupVerifier default groups are configured from DHStandardGroups, so + * we expect to recover the exact instance here. + */ + Assert.AreSame(dhGroup, TlsDHUtilities.GetStandardGroupForDHParameters(p, g)); + + int namedGroup = TlsDHUtilities.GetNamedGroupForDHParameters(p, g); // Already tested the named groups if (NamedGroup.RefersToASpecificFiniteField(namedGroup)) -- cgit 1.4.1