diff options
Diffstat (limited to 'src/libraries/Common/src/System/Security/Cryptography/ECCng.ImportExport.cs')
-rw-r--r-- | src/libraries/Common/src/System/Security/Cryptography/ECCng.ImportExport.cs | 57 |
1 files changed, 2 insertions, 55 deletions
diff --git a/src/libraries/Common/src/System/Security/Cryptography/ECCng.ImportExport.cs b/src/libraries/Common/src/System/Security/Cryptography/ECCng.ImportExport.cs index 8e8726fb3cd..dcd36ca435c 100644 --- a/src/libraries/Common/src/System/Security/Cryptography/ECCng.ImportExport.cs +++ b/src/libraries/Common/src/System/Security/Cryptography/ECCng.ImportExport.cs @@ -384,7 +384,7 @@ namespace System.Security.Cryptography /// that don't have the named curve functionality. /// </summary> private static KeyBlobMagicNumber EcdsaCurveNameToMagicNumber(string? name, bool includePrivateParameters) => - EcdsaCurveNameToAlgorithm(name) switch + CngKey.EcdsaCurveNameToAlgorithm(name).Algorithm switch { AlgorithmName.ECDsaP256 => includePrivateParameters ? KeyBlobMagicNumber.BCRYPT_ECDSA_PRIVATE_P256_MAGIC : @@ -409,7 +409,7 @@ namespace System.Security.Cryptography /// that don't have the named curve functionality. /// </summary> private static KeyBlobMagicNumber EcdhCurveNameToMagicNumber(string? name, bool includePrivateParameters) => - EcdhCurveNameToAlgorithm(name) switch + CngKey.EcdhCurveNameToAlgorithm(name).Algorithm switch { AlgorithmName.ECDHP256 => includePrivateParameters ? KeyBlobMagicNumber.BCRYPT_ECDH_PRIVATE_P256_MAGIC : @@ -513,58 +513,5 @@ namespace System.Security.Cryptography return keyHandle; } - - /// <summary> - /// Map a curve name to algorithm. This enables curves that worked pre-Win10 - /// to work with newer APIs for import and export. - /// </summary> - internal static string EcdsaCurveNameToAlgorithm(string? algorithm) - { - switch (algorithm) - { - case "nistP256": - case "ECDSA_P256": - return AlgorithmName.ECDsaP256; - - case "nistP384": - case "ECDSA_P384": - return AlgorithmName.ECDsaP384; - - case "nistP521": - case "ECDSA_P521": - return AlgorithmName.ECDsaP521; - } - - // All other curves are new in Win10 so use generic algorithm - return AlgorithmName.ECDsa; - } - - /// <summary> - /// Map a curve name to algorithm. This enables curves that worked pre-Win10 - /// to work with newer APIs for import and export. - /// </summary> - internal static string EcdhCurveNameToAlgorithm(string? algorithm) - { - switch (algorithm) - { - case "nistP256": - case "ECDH_P256": - case "ECDSA_P256": - return AlgorithmName.ECDHP256; - - case "nistP384": - case "ECDH_P384": - case "ECDSA_P384": - return AlgorithmName.ECDHP384; - - case "nistP521": - case "ECDH_P521": - case "ECDSA_P521": - return AlgorithmName.ECDHP521; - } - - // All other curves are new in Win10 so use generic algorithm - return AlgorithmName.ECDH; - } } } |