@Hobbit00 thanks for the detailed report and for trying the new group.
I tried to reproduce this with a TlsLib server (Compatible preset) using the group and cipher lists you posted, with the new group inserted at several positions, and so far I don't see a failure. The likeliest explanation is where the new group sits in the list.
How the server picks a groupThe server walks its own list, in order, and takes the first group the client says it supports. It does not look at which group the client already sent a key share for. If the client sent no key share for the chosen group, the server sends a HelloRetryRequest (HRR), which is one extra round trip, and the client sends a second ClientHello. Suite preference is not affected.
What I saw (OpenSSL 3.6.1 and TlsLib's own client against a loopback TlsLib server, about 80 handshakes)
- With SecP256r1MLKEM768 after X25519MlKem768 (second, middle or last), every client that offers X25519MLKEM768 or only classical groups behaved exactly as without the group: same group, same suite, same HRR or no HRR. The one difference is that a client offering only SecP256r1MLKEM768 now connects, where before it got handshake_failure.
- With SecP256r1MLKEM768 first in the list, any client that merely lists it in supported_groups is moved onto it. If that client had sent its key share for X25519MLKEM768 or x25519, the server now answers with an HRR. The handshake still completes.
- Classical-only clients (x25519, P-256, P-384, and TLS 1.2) got identical results with and without the group.
- Offering a single suite, or the suites in reversed order, gave the same answers in every variant. The reversed-order probe still got the server's first choice, TLS_AES_256_GCM_SHA384.
Your questions- I don't think the loss of "server preference" comes from the server's suite choice. If SecP256r1MLKEM768 sits first in your list, my best guess is that the scanner advertises it, gets an HRR for it, and cannot finish that handshake, so only a classical probe works. That fits the single "ECDH x25519" line you got. This part is a guess, because I don't have your scanner here.
- For the old devices I could not reproduce a failure. If a particular device really fails, I would need a capture to look at.
What to tryPut the new group right after X25519MLKEM768, which is where the library's own defaults put it. This is your list with the group inserted second, the order I tested as "second":
TNamedGroupCatalog.X25519MlKem768, TNamedGroupCatalog.SecP256r1MlKem768,
TNamedGroupCatalog.MlKem768, TNamedGroupCatalog.X25519, TNamedGroupCatalog.Secp521r1,
TNamedGroupCatalog.Secp384r1, TNamedGroupCatalog.Secp256r1
What would settle itCould you tell me:
- where in your list you inserted SecP256r1MlKem768,
- which scanner you used (name and version),
- what the scanner's ClientHello contains (the groups it lists and the key share it sends)?
For the last one, if you already set a credential through a resolver, or can use one, this logs it. Adjust the unit names to your project:
uses SysUtils, TlpITlsCredentialResolver, TlpTlsCredential;
type
TLogResolver = class(TInterfacedObject, ITlsServerCredentialResolver)
public
Cred: TTlsCredential; // your existing server credential
function TryResolve(const AClientHello: TTlsClientHelloInfo;
out ACredential: TTlsCredential): Boolean;
end;
function TLogResolver.TryResolve(const AClientHello: TTlsClientHelloInfo;
out ACredential: TTlsCredential): Boolean;
var
LI: Integer;
LGroups, LSuites: string;
begin
LGroups := '';
for LI := 0 to High(AClientHello.SupportedGroups) do
LGroups := LGroups + '0x' + IntToHex(AClientHello.SupportedGroups[LI], 4) + ' ';
LSuites := '';
for LI := 0 to High(AClientHello.CipherSuites) do
LSuites := LSuites + '0x' + IntToHex(AClientHello.CipherSuites[LI], 4) + ' ';
Writeln('ClientHello groups: ', LGroups);
Writeln('ClientHello suites: ', LSuites);
ACredential := Cred;
Result := True;
end;
// ... Builder.WithCredentialResolver(LResolver as ITlsServerCredentialResolver);
Group 0x11EC is X25519MLKEM768, 0x11EB is SecP256r1MLKEM768, 0x001D is x25519 and 0x0017 is secp256r1. A line is printed once per ClientHello, so if the server sent an HRR you will see a second line from the same scan.
If you have OpenSSL 3.5 or newer, you can try the same probes yourself against your server:
openssl s_client -connect host:443 -tls1_3 -groups X25519MLKEM768:SecP256r1MLKEM768:X25519
openssl s_client -connect host:443 -tls1_3 -groups "*X25519:X25519MLKEM768:SecP256r1MLKEM768"
openssl s_client -connect host:443 -tls1_3 -groups SecP256r1MLKEM768
The second one sends a key share for x25519 only, which is the case that triggers an HRR when the hybrid is first in your list. The output shows the negotiated group.