1 // Licensed to the .NET Foundation under one or more agreements. 2 // The .NET Foundation licenses this file to you under the MIT license. 3 // See the LICENSE file in the project root for more information. 4 5 using System.Diagnostics; 6 7 namespace System.Security.Cryptography 8 { 9 public partial struct ECCurve 10 { 11 /// <summary> 12 /// Factory class for creating named curves. 13 /// </summary> 14 public static class NamedCurves 15 { 16 private const string ECDSA_P256_OID_VALUE = "1.2.840.10045.3.1.7"; // nistP256 or secP256r1 17 private const string ECDSA_P384_OID_VALUE = "1.3.132.0.34"; // nistP384 or secP384r1 18 private const string ECDSA_P521_OID_VALUE = "1.3.132.0.35"; // nistP521 or secP521r1 19 20 public static ECCurve brainpoolP160r1 21 { 22 get 23 { 24 return ECCurve.CreateFromFriendlyName(nameof(brainpoolP160r1)); 25 } 26 } 27 28 public static ECCurve brainpoolP160t1 29 { 30 get 31 { 32 return ECCurve.CreateFromFriendlyName(nameof(brainpoolP160t1)); 33 } 34 } 35 36 public static ECCurve brainpoolP192r1 37 { 38 get 39 { 40 return ECCurve.CreateFromFriendlyName(nameof(brainpoolP192r1)); 41 } 42 } 43 44 public static ECCurve brainpoolP192t1 45 { 46 get 47 { 48 return ECCurve.CreateFromFriendlyName(nameof(brainpoolP192t1)); 49 } 50 } 51 52 public static ECCurve brainpoolP224r1 53 { 54 get 55 { 56 return ECCurve.CreateFromFriendlyName(nameof(brainpoolP224r1)); 57 } 58 } 59 60 public static ECCurve brainpoolP224t1 61 { 62 get 63 { 64 return ECCurve.CreateFromFriendlyName(nameof(brainpoolP224t1)); 65 } 66 } 67 68 public static ECCurve brainpoolP256r1 69 { 70 get 71 { 72 return ECCurve.CreateFromFriendlyName(nameof(brainpoolP256r1)); 73 } 74 } 75 76 public static ECCurve brainpoolP256t1 77 { 78 get 79 { 80 return ECCurve.CreateFromFriendlyName(nameof(brainpoolP256t1)); 81 } 82 } 83 84 public static ECCurve brainpoolP320r1 85 { 86 get 87 { 88 return ECCurve.CreateFromFriendlyName(nameof(brainpoolP320r1)); 89 } 90 } 91 92 public static ECCurve brainpoolP320t1 93 { 94 get 95 { 96 return ECCurve.CreateFromFriendlyName(nameof(brainpoolP320t1)); 97 } 98 } 99 100 public static ECCurve brainpoolP384r1 101 { 102 get 103 { 104 return ECCurve.CreateFromFriendlyName(nameof(brainpoolP384r1)); 105 } 106 } 107 108 public static ECCurve brainpoolP384t1 109 { 110 get 111 { 112 return ECCurve.CreateFromFriendlyName(nameof(brainpoolP384t1)); 113 } 114 } 115 116 public static ECCurve brainpoolP512r1 117 { 118 get 119 { 120 return ECCurve.CreateFromFriendlyName(nameof(brainpoolP512r1)); 121 } 122 } 123 124 public static ECCurve brainpoolP512t1 125 { 126 get 127 { 128 return ECCurve.CreateFromFriendlyName(nameof(brainpoolP512t1)); 129 } 130 } 131 132 public static ECCurve nistP256 133 { 134 get 135 { 136 // Hard-code nist curve as friendly name is not consistent with algorithm name 137 return ECCurve.CreateFromValueAndName(ECDSA_P256_OID_VALUE, nameof(nistP256)); 138 } 139 } 140 141 public static ECCurve nistP384 142 { 143 get 144 { 145 // Hard-code nist curve as friendly name is not consistent with algorithm name 146 return ECCurve.CreateFromValueAndName(ECDSA_P384_OID_VALUE, nameof(nistP384)); 147 } 148 } 149 150 public static ECCurve nistP521 151 { 152 get 153 { 154 // Hard-code nist curve as friendly name is not consistent with algorithm name 155 return ECCurve.CreateFromValueAndName(ECDSA_P521_OID_VALUE, nameof(nistP521)); 156 } 157 } 158 } 159 } 160 } 161