Closed
Description
Description
Using a invalid private key for ECDsa.Create throws a CryptographicException using net10 (also net9 and net8) on windows and linux platforms.
With net11 an exception is thrown with windows. On linux no exception occurs.
Reproduction Steps
using System.Security.Cryptography;
using System.Buffers.Text;
try
{
var PrivateKeyA = @"WRONGKmLEFIVvPP3cNX9kE0OF6PV9TJQXVbnKU2xEHI";
var PublicKeyA = @"BCvKwB2lbVUYMFAaBUygooKheqcEU-GDrVRnu8k33yJCZkNBNqjZj0VdxQ2QIZa4kV5kpX9aAqyBKZHURm6eG1A";
var privateKey = Base64Url.DecodeFromChars(PrivateKeyA);
var publicKey = Base64Url.DecodeFromChars(PublicKeyA);
var keypair = ECDsa.Create(new ECParameters
{
Curve = ECCurve.NamedCurves.nistP256,
D = privateKey,
Q = new ECPoint
{
X = [.. publicKey.Skip(1).Take(32)],
Y = [.. publicKey.Skip(33)],
}
});
Console.WriteLine($"Should never reach here: null={keypair is null}");
if(keypair is not null)
{
var ep = keypair.ExportParameters(includePrivateParameters: true);
if (ep.D is null) throw new InvalidOperationException();
Console.WriteLine($"Private key: {Base64Url.EncodeToString([..ep.D])}");
}
}
catch (CryptographicException e)
{
Console.WriteLine($"Expected CryptographicException: {e.ToString()}");
}
catch (Exception e)
{
Console.WriteLine($"Exception {e.Message} {e.ToString()}");
}Expected behavior
Consistent behavior on net(X) and platforms.
Actual behavior
With net11 an exception is thrown with windows. On linux no exception occurs.
Regression?
yes, works under linux and windows for net10/net9 and net8.
doesn't work under net11 and linux.
Known Workarounds
No response
Configuration
dotnet --version => '11.0.100'
test performed with windows 11 and debian trixie, both latest versions.
Other information
No response
Activity
dotnet-policy-service commentedon Nov 11, 2026
Tagging subscribers to this area: @bartonjs, @vcsjones, @dotnet/area-system-security
See info in area-owners.md if you want to be subscribed.
vcsjones commentedon Nov 12, 2026
Thanks for the report. This was a regression in .NET 11 that has been fixed in
main. A pull request to service this in .NET 11 has been opened here #137433.Note that the presence of the pull request does not guaranteed it will be serviced. When it is approved or rejected it will either be merged or closed.
Personally I don't see any strong reasons it would be rejected though.
[release/11.0] Restore EC consistency checks for Linux (#137433)
vcsjones commentedon Nov 14, 2026
Backported to .NET 11 with #137433. There is no work remaining for this, so closing this out as complete.