using Microsoft.IdentityModel.Tokens; using System.Security.Cryptography; namespace StellaOps.Cryptography.Kms; public sealed partial class KmsCryptoProvider { private static string ResolveCurveName(ECCurve curve) { if (!string.IsNullOrWhiteSpace(curve.Oid.FriendlyName)) { return curve.Oid.FriendlyName switch { "nistP256" => JsonWebKeyECTypes.P256, "nistP384" => JsonWebKeyECTypes.P384, "nistP521" => JsonWebKeyECTypes.P521, _ => JsonWebKeyECTypes.P256 }; } return JsonWebKeyECTypes.P256; } private static string ResolveCurveName(int coordinateLength) => coordinateLength switch { 32 => JsonWebKeyECTypes.P256, 48 => JsonWebKeyECTypes.P384, 66 => JsonWebKeyECTypes.P521, _ => JsonWebKeyECTypes.P256 }; private static ECCurve ResolveCurve(string curve) => curve switch { JsonWebKeyECTypes.P256 or "P-256" => ECCurve.NamedCurves.nistP256, JsonWebKeyECTypes.P384 or "P-384" => ECCurve.NamedCurves.nistP384, JsonWebKeyECTypes.P521 or "P-521" => ECCurve.NamedCurves.nistP521, _ => ECCurve.NamedCurves.nistP256 }; }