From 9fded768463da6937c0c4fc5a93c1b2de250726d Mon Sep 17 00:00:00 2001 From: austinw-fineart <40481873+austinw-fineart@users.noreply.github.com> Date: Thu, 12 Nov 2026 11:14:14 +0800 Subject: [PATCH] Match ECDSA algorithms to their key size --- .../OpenIddictClientWebIntegrationConfiguration.liquid | 8 ++++---- src/OpenIddict.Client/OpenIddictClientBuilder.cs | 4 ++-- src/OpenIddict.Server/OpenIddictServerBuilder.cs | 4 ++-- src/OpenIddict.Validation/OpenIddictValidationBuilder.cs | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/gen/OpenIddict.Client.WebIntegration.Generators/OpenIddictClientWebIntegrationConfiguration.liquid b/gen/OpenIddict.Client.WebIntegration.Generators/OpenIddictClientWebIntegrationConfiguration.liquid index c5901713..6222a010 100644 --- a/gen/OpenIddict.Client.WebIntegration.Generators/OpenIddictClientWebIntegrationConfiguration.liquid +++ b/gen/OpenIddict.Client.WebIntegration.Generators/OpenIddictClientWebIntegrationConfiguration.liquid @@ -241,12 +241,12 @@ public sealed partial class OpenIddictClientWebIntegrationConfiguration } // Note: ECDSA algorithms are bound to specific curves and must be treated separately. - else if (key.IsSupportedAlgorithm(SecurityAlgorithms.EcdsaSha256)) + else if (key.KeySize is 256 && key.IsSupportedAlgorithm(SecurityAlgorithms.EcdsaSha256)) { registration.SigningCredentials.Add(new SigningCredentials(key, SecurityAlgorithms.EcdsaSha256)); } - else if (key.IsSupportedAlgorithm(SecurityAlgorithms.EcdsaSha384)) + else if (key.KeySize is 384 && key.IsSupportedAlgorithm(SecurityAlgorithms.EcdsaSha384)) { registration.SigningCredentials.Add(new SigningCredentials(key, SecurityAlgorithms.EcdsaSha384)); } @@ -274,12 +274,12 @@ public sealed partial class OpenIddictClientWebIntegrationConfiguration } // Note: ECDSA algorithms are bound to specific curves and must be treated separately. - else if (settings.{{ setting.property_name }}.IsSupportedAlgorithm(SecurityAlgorithms.EcdsaSha256)) + else if (settings.{{ setting.property_name }}.KeySize is 256 && settings.{{ setting.property_name }}.IsSupportedAlgorithm(SecurityAlgorithms.EcdsaSha256)) { registration.SigningCredentials.Add(new SigningCredentials(settings.{{ setting.property_name }}, SecurityAlgorithms.EcdsaSha256)); } - else if (settings.{{ setting.property_name }}.IsSupportedAlgorithm(SecurityAlgorithms.EcdsaSha384)) + else if (settings.{{ setting.property_name }}.KeySize is 384 && settings.{{ setting.property_name }}.IsSupportedAlgorithm(SecurityAlgorithms.EcdsaSha384)) { registration.SigningCredentials.Add(new SigningCredentials(settings.{{ setting.property_name }}, SecurityAlgorithms.EcdsaSha384)); } diff --git a/src/OpenIddict.Client/OpenIddictClientBuilder.cs b/src/OpenIddict.Client/OpenIddictClientBuilder.cs index b9134263..7a0cd2c6 100644 --- a/src/OpenIddict.Client/OpenIddictClientBuilder.cs +++ b/src/OpenIddict.Client/OpenIddictClientBuilder.cs @@ -497,12 +497,12 @@ public sealed class OpenIddictClientBuilder } // Note: ECDSA algorithms are bound to specific curves and must be treated separately. - if (key.IsSupportedAlgorithm(SecurityAlgorithms.EcdsaSha256)) + if (key.KeySize is 256 && key.IsSupportedAlgorithm(SecurityAlgorithms.EcdsaSha256)) { return AddSigningCredentials(new SigningCredentials(key, SecurityAlgorithms.EcdsaSha256)); } - if (key.IsSupportedAlgorithm(SecurityAlgorithms.EcdsaSha384)) + if (key.KeySize is 384 && key.IsSupportedAlgorithm(SecurityAlgorithms.EcdsaSha384)) { return AddSigningCredentials(new SigningCredentials(key, SecurityAlgorithms.EcdsaSha384)); } diff --git a/src/OpenIddict.Server/OpenIddictServerBuilder.cs b/src/OpenIddict.Server/OpenIddictServerBuilder.cs index b728be24..35c37dc8 100644 --- a/src/OpenIddict.Server/OpenIddictServerBuilder.cs +++ b/src/OpenIddict.Server/OpenIddictServerBuilder.cs @@ -508,12 +508,12 @@ public sealed class OpenIddictServerBuilder } // Note: ECDSA algorithms are bound to specific curves and must be treated separately. - if (key.IsSupportedAlgorithm(SecurityAlgorithms.EcdsaSha256)) + if (key.KeySize is 256 && key.IsSupportedAlgorithm(SecurityAlgorithms.EcdsaSha256)) { return AddSigningCredentials(new SigningCredentials(key, SecurityAlgorithms.EcdsaSha256)); } - if (key.IsSupportedAlgorithm(SecurityAlgorithms.EcdsaSha384)) + if (key.KeySize is 384 && key.IsSupportedAlgorithm(SecurityAlgorithms.EcdsaSha384)) { return AddSigningCredentials(new SigningCredentials(key, SecurityAlgorithms.EcdsaSha384)); } diff --git a/src/OpenIddict.Validation/OpenIddictValidationBuilder.cs b/src/OpenIddict.Validation/OpenIddictValidationBuilder.cs index 95611c29..f5f5cc84 100644 --- a/src/OpenIddict.Validation/OpenIddictValidationBuilder.cs +++ b/src/OpenIddict.Validation/OpenIddictValidationBuilder.cs @@ -377,12 +377,12 @@ public sealed class OpenIddictValidationBuilder } // Note: ECDSA algorithms are bound to specific curves and must be treated separately. - if (key.IsSupportedAlgorithm(SecurityAlgorithms.EcdsaSha256)) + if (key.KeySize is 256 && key.IsSupportedAlgorithm(SecurityAlgorithms.EcdsaSha256)) { return AddSigningCredentials(new SigningCredentials(key, SecurityAlgorithms.EcdsaSha256)); } - if (key.IsSupportedAlgorithm(SecurityAlgorithms.EcdsaSha384)) + if (key.KeySize is 384 && key.IsSupportedAlgorithm(SecurityAlgorithms.EcdsaSha384)) { return AddSigningCredentials(new SigningCredentials(key, SecurityAlgorithms.EcdsaSha384)); }