Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ECCng.cs
Go to the documentation of this file.
4
6
7internal static class ECCng
8{
9 internal static global::Interop.BCrypt.ECC_CURVE_ALG_ID_ENUM GetHashAlgorithmId(HashAlgorithmName? name)
10 {
11 if (!name.HasValue || string.IsNullOrEmpty(name.Value.Name))
12 {
13 return global::Interop.BCrypt.ECC_CURVE_ALG_ID_ENUM.BCRYPT_NO_CURVE_GENERATION_ALG_ID;
14 }
15 global::Interop.Crypt32.CRYPT_OID_INFO cRYPT_OID_INFO = global::Interop.Crypt32.FindOidInfo(global::Interop.Crypt32.CryptOidInfoKeyType.CRYPT_OID_INFO_NAME_KEY, name.Value.Name, OidGroup.HashAlgorithm, fallBackToAllGroups: false);
16 if (cRYPT_OID_INFO.AlgId == -1)
17 {
19 }
20 return (global::Interop.BCrypt.ECC_CURVE_ALG_ID_ENUM)cRYPT_OID_INFO.AlgId;
21 }
22
23 internal static HashAlgorithmName? GetHashAlgorithmName(global::Interop.BCrypt.ECC_CURVE_ALG_ID_ENUM hashId)
24 {
25 global::Interop.Crypt32.CRYPT_OID_INFO cRYPT_OID_INFO = global::Interop.Crypt32.FindAlgIdOidInfo(hashId);
26 if (cRYPT_OID_INFO.AlgId == -1)
27 {
28 return null;
29 }
30 return new HashAlgorithmName(cRYPT_OID_INFO.Name);
31 }
32
33 internal static bool IsECNamedCurve(string algorithm)
34 {
35 if (!(algorithm == "ECDH"))
36 {
37 return algorithm == "ECDSA";
38 }
39 return true;
40 }
41
42 internal static string SpecialNistAlgorithmToCurveName(string algorithm, out string oidValue)
43 {
44 switch (algorithm)
45 {
46 case "ECDH_P256":
47 case "ECDSA_P256":
48 oidValue = "1.2.840.10045.3.1.7";
49 return "nistP256";
50 case "ECDH_P384":
51 case "ECDSA_P384":
52 oidValue = "1.3.132.0.34";
53 return "nistP384";
54 case "ECDH_P521":
55 case "ECDSA_P521":
56 oidValue = "1.3.132.0.35";
57 return "nistP521";
58 default:
60 }
61 }
62
63 internal unsafe static byte[] GetNamedCurveBlob(ref ECParameters parameters, bool ecdh)
64 {
65 bool flag = parameters.D != null;
66 int num = sizeof(global::Interop.BCrypt.BCRYPT_ECCKEY_BLOB) + parameters.Q.X.Length + parameters.Q.Y.Length;
67 if (flag)
68 {
69 num += parameters.D.Length;
70 }
71 byte[] array = new byte[num];
72 fixed (byte* ptr = &array[0])
73 {
74 global::Interop.BCrypt.BCRYPT_ECCKEY_BLOB* ptr2 = (global::Interop.BCrypt.BCRYPT_ECCKEY_BLOB*)ptr;
75 ptr2->Magic = (ecdh ? EcdhCurveNameToMagicNumber(parameters.Curve.Oid.FriendlyName, flag) : EcdsaCurveNameToMagicNumber(parameters.Curve.Oid.FriendlyName, flag));
76 ptr2->cbKey = parameters.Q.X.Length;
77 int offset = sizeof(global::Interop.BCrypt.BCRYPT_ECCKEY_BLOB);
78 global::Interop.BCrypt.Emit(array, ref offset, parameters.Q.X);
79 global::Interop.BCrypt.Emit(array, ref offset, parameters.Q.Y);
80 if (flag)
81 {
82 global::Interop.BCrypt.Emit(array, ref offset, parameters.D);
83 }
84 }
85 return array;
86 }
87
88 internal unsafe static byte[] GetPrimeCurveBlob(ref ECParameters parameters, bool ecdh)
89 {
90 bool flag = parameters.D != null;
91 ECCurve curve = parameters.Curve;
92 int num = sizeof(global::Interop.BCrypt.BCRYPT_ECCFULLKEY_BLOB) + curve.Prime.Length + curve.A.Length + curve.B.Length + curve.G.X.Length + curve.G.Y.Length + curve.Order.Length + curve.Cofactor.Length + ((curve.Seed != null) ? curve.Seed.Length : 0) + parameters.Q.X.Length + parameters.Q.Y.Length;
93 if (flag)
94 {
95 num += parameters.D.Length;
96 }
97 byte[] array = new byte[num];
98 fixed (byte* ptr = &array[0])
99 {
100 global::Interop.BCrypt.BCRYPT_ECCFULLKEY_BLOB* ptr2 = (global::Interop.BCrypt.BCRYPT_ECCFULLKEY_BLOB*)ptr;
101 ptr2->Version = 1;
102 ptr2->Magic = ((!flag) ? (ecdh ? global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_ECDH_PUBLIC_GENERIC_MAGIC : global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_ECDSA_PUBLIC_GENERIC_MAGIC) : (ecdh ? global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_ECDH_PRIVATE_GENERIC_MAGIC : global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_ECDSA_PRIVATE_GENERIC_MAGIC));
103 ptr2->cbCofactor = curve.Cofactor.Length;
104 ptr2->cbFieldLength = parameters.Q.X.Length;
105 ptr2->cbSeed = ((curve.Seed != null) ? curve.Seed.Length : 0);
106 ptr2->cbSubgroupOrder = curve.Order.Length;
107 ptr2->CurveGenerationAlgId = GetHashAlgorithmId(curve.Hash);
108 ptr2->CurveType = ConvertToCurveTypeEnum(curve.CurveType);
109 int offset = sizeof(global::Interop.BCrypt.BCRYPT_ECCFULLKEY_BLOB);
110 global::Interop.BCrypt.Emit(array, ref offset, curve.Prime);
111 global::Interop.BCrypt.Emit(array, ref offset, curve.A);
112 global::Interop.BCrypt.Emit(array, ref offset, curve.B);
113 global::Interop.BCrypt.Emit(array, ref offset, curve.G.X);
114 global::Interop.BCrypt.Emit(array, ref offset, curve.G.Y);
115 global::Interop.BCrypt.Emit(array, ref offset, curve.Order);
116 global::Interop.BCrypt.Emit(array, ref offset, curve.Cofactor);
117 if (curve.Seed != null)
118 {
119 global::Interop.BCrypt.Emit(array, ref offset, curve.Seed);
120 }
121 global::Interop.BCrypt.Emit(array, ref offset, parameters.Q.X);
122 global::Interop.BCrypt.Emit(array, ref offset, parameters.Q.Y);
123 if (flag)
124 {
125 global::Interop.BCrypt.Emit(array, ref offset, parameters.D);
126 }
127 }
128 return array;
129 }
130
131 internal unsafe static void ExportNamedCurveParameters(ref ECParameters ecParams, byte[] ecBlob, bool includePrivateParameters)
132 {
133 global::Interop.BCrypt.KeyBlobMagicNumber magic = (global::Interop.BCrypt.KeyBlobMagicNumber)BitConverter.ToInt32(ecBlob, 0);
134 CheckMagicValueOfKey(magic, includePrivateParameters);
135 if (ecBlob.Length < sizeof(global::Interop.BCrypt.BCRYPT_ECCKEY_BLOB))
136 {
137 throw global::Interop.NCrypt.ErrorCode.E_FAIL.ToCryptographicException();
138 }
139 fixed (byte* ptr = &ecBlob[0])
140 {
141 global::Interop.BCrypt.BCRYPT_ECCKEY_BLOB* ptr2 = (global::Interop.BCrypt.BCRYPT_ECCKEY_BLOB*)ptr;
142 int offset = sizeof(global::Interop.BCrypt.BCRYPT_ECCKEY_BLOB);
143 ecParams.Q = new ECPoint
144 {
145 X = global::Interop.BCrypt.Consume(ecBlob, ref offset, ptr2->cbKey),
146 Y = global::Interop.BCrypt.Consume(ecBlob, ref offset, ptr2->cbKey)
147 };
148 if (includePrivateParameters)
149 {
150 ecParams.D = global::Interop.BCrypt.Consume(ecBlob, ref offset, ptr2->cbKey);
151 }
152 }
153 }
154
155 internal unsafe static void ExportPrimeCurveParameters(ref ECParameters ecParams, byte[] ecBlob, bool includePrivateParameters)
156 {
157 global::Interop.BCrypt.KeyBlobMagicNumber magic = (global::Interop.BCrypt.KeyBlobMagicNumber)BitConverter.ToInt32(ecBlob, 0);
158 CheckMagicValueOfKey(magic, includePrivateParameters);
159 if (ecBlob.Length < sizeof(global::Interop.BCrypt.BCRYPT_ECCFULLKEY_BLOB))
160 {
161 throw global::Interop.NCrypt.ErrorCode.E_FAIL.ToCryptographicException();
162 }
163 fixed (byte* ptr = &ecBlob[0])
164 {
165 global::Interop.BCrypt.BCRYPT_ECCFULLKEY_BLOB* ptr2 = (global::Interop.BCrypt.BCRYPT_ECCFULLKEY_BLOB*)ptr;
166 ECCurve curve = default(ECCurve);
167 curve.CurveType = ConvertToCurveTypeEnum(ptr2->CurveType);
168 curve.Hash = GetHashAlgorithmName(ptr2->CurveGenerationAlgId);
169 int offset = sizeof(global::Interop.BCrypt.BCRYPT_ECCFULLKEY_BLOB);
170 curve.Prime = global::Interop.BCrypt.Consume(ecBlob, ref offset, ptr2->cbFieldLength);
171 curve.A = global::Interop.BCrypt.Consume(ecBlob, ref offset, ptr2->cbFieldLength);
172 curve.B = global::Interop.BCrypt.Consume(ecBlob, ref offset, ptr2->cbFieldLength);
173 curve.G = new ECPoint
174 {
175 X = global::Interop.BCrypt.Consume(ecBlob, ref offset, ptr2->cbFieldLength),
176 Y = global::Interop.BCrypt.Consume(ecBlob, ref offset, ptr2->cbFieldLength)
177 };
178 curve.Order = global::Interop.BCrypt.Consume(ecBlob, ref offset, ptr2->cbSubgroupOrder);
179 curve.Cofactor = global::Interop.BCrypt.Consume(ecBlob, ref offset, ptr2->cbCofactor);
180 curve.Seed = ((ptr2->cbSeed == 0) ? null : global::Interop.BCrypt.Consume(ecBlob, ref offset, ptr2->cbSeed));
181 ecParams.Q = new ECPoint
182 {
183 X = global::Interop.BCrypt.Consume(ecBlob, ref offset, ptr2->cbFieldLength),
184 Y = global::Interop.BCrypt.Consume(ecBlob, ref offset, ptr2->cbFieldLength)
185 };
186 if (includePrivateParameters)
187 {
188 ecParams.D = global::Interop.BCrypt.Consume(ecBlob, ref offset, ptr2->cbSubgroupOrder);
189 }
190 ecParams.Curve = curve;
191 }
192 }
193
194 internal unsafe static byte[] GetPrimeCurveParameterBlob(ref ECCurve curve)
195 {
196 int num = sizeof(global::Interop.BCrypt.BCRYPT_ECC_PARAMETER_HEADER) + curve.Prime.Length + curve.A.Length + curve.B.Length + curve.G.X.Length + curve.G.Y.Length + curve.Order.Length + curve.Cofactor.Length + ((curve.Seed != null) ? curve.Seed.Length : 0);
197 byte[] array = new byte[num];
198 fixed (byte* ptr = &array[0])
199 {
200 global::Interop.BCrypt.BCRYPT_ECC_PARAMETER_HEADER* ptr2 = (global::Interop.BCrypt.BCRYPT_ECC_PARAMETER_HEADER*)ptr;
201 ptr2->Version = 1;
202 ptr2->cbCofactor = curve.Cofactor.Length;
203 ptr2->cbFieldLength = curve.A.Length;
204 ptr2->cbSeed = ((curve.Seed != null) ? curve.Seed.Length : 0);
205 ptr2->cbSubgroupOrder = curve.Order.Length;
206 ptr2->CurveGenerationAlgId = GetHashAlgorithmId(curve.Hash);
207 ptr2->CurveType = ConvertToCurveTypeEnum(curve.CurveType);
208 int offset = sizeof(global::Interop.BCrypt.BCRYPT_ECC_PARAMETER_HEADER);
209 global::Interop.BCrypt.Emit(array, ref offset, curve.Prime);
210 global::Interop.BCrypt.Emit(array, ref offset, curve.A);
211 global::Interop.BCrypt.Emit(array, ref offset, curve.B);
212 global::Interop.BCrypt.Emit(array, ref offset, curve.G.X);
213 global::Interop.BCrypt.Emit(array, ref offset, curve.G.Y);
214 global::Interop.BCrypt.Emit(array, ref offset, curve.Order);
215 global::Interop.BCrypt.Emit(array, ref offset, curve.Cofactor);
216 if (curve.Seed != null)
217 {
218 global::Interop.BCrypt.Emit(array, ref offset, curve.Seed);
219 }
220 }
221 return array;
222 }
223
224 private static void CheckMagicValueOfKey(global::Interop.BCrypt.KeyBlobMagicNumber magic, bool includePrivateParameters)
225 {
226 if (includePrivateParameters)
227 {
228 if (!IsMagicValueOfKeyPrivate(magic))
229 {
231 }
232 }
233 else if (!IsMagicValueOfKeyPublic(magic))
234 {
236 }
237 }
238
239 private static bool IsMagicValueOfKeyPrivate(global::Interop.BCrypt.KeyBlobMagicNumber magic)
240 {
241 switch (magic)
242 {
243 case global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_ECDH_PRIVATE_P256_MAGIC:
244 case global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_ECDSA_PRIVATE_P256_MAGIC:
245 case global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_ECDH_PRIVATE_P384_MAGIC:
246 case global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_ECDSA_PRIVATE_P384_MAGIC:
247 case global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_ECDH_PRIVATE_P521_MAGIC:
248 case global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_ECDSA_PRIVATE_P521_MAGIC:
249 case global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_ECDSA_PRIVATE_GENERIC_MAGIC:
250 case global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_ECDH_PRIVATE_GENERIC_MAGIC:
251 return true;
252 default:
253 return false;
254 }
255 }
256
257 private static bool IsMagicValueOfKeyPublic(global::Interop.BCrypt.KeyBlobMagicNumber magic)
258 {
259 switch (magic)
260 {
261 case global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_ECDH_PUBLIC_P256_MAGIC:
262 case global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_ECDSA_PUBLIC_P256_MAGIC:
263 case global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_ECDH_PUBLIC_P384_MAGIC:
264 case global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_ECDSA_PUBLIC_P384_MAGIC:
265 case global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_ECDH_PUBLIC_P521_MAGIC:
266 case global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_ECDSA_PUBLIC_P521_MAGIC:
267 case global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_ECDSA_PUBLIC_GENERIC_MAGIC:
268 case global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_ECDH_PUBLIC_GENERIC_MAGIC:
269 return true;
270 default:
271 return IsMagicValueOfKeyPrivate(magic);
272 }
273 }
274
275 private static global::Interop.BCrypt.KeyBlobMagicNumber EcdsaCurveNameToMagicNumber(string name, bool includePrivateParameters)
276 {
277 return EcdsaCurveNameToAlgorithm(name) switch
278 {
279 "ECDSA_P256" => includePrivateParameters ? global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_ECDSA_PRIVATE_P256_MAGIC : global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_ECDSA_PUBLIC_P256_MAGIC,
280 "ECDSA_P384" => includePrivateParameters ? global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_ECDSA_PRIVATE_P384_MAGIC : global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_ECDSA_PUBLIC_P384_MAGIC,
281 "ECDSA_P521" => includePrivateParameters ? global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_ECDSA_PRIVATE_P521_MAGIC : global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_ECDSA_PUBLIC_P521_MAGIC,
282 _ => includePrivateParameters ? global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_ECDSA_PRIVATE_GENERIC_MAGIC : global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_ECDSA_PUBLIC_GENERIC_MAGIC,
283 };
284 }
285
286 private static global::Interop.BCrypt.KeyBlobMagicNumber EcdhCurveNameToMagicNumber(string name, bool includePrivateParameters)
287 {
288 return EcdhCurveNameToAlgorithm(name) switch
289 {
290 "ECDH_P256" => includePrivateParameters ? global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_ECDH_PRIVATE_P256_MAGIC : global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_ECDH_PUBLIC_P256_MAGIC,
291 "ECDH_P384" => includePrivateParameters ? global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_ECDH_PRIVATE_P384_MAGIC : global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_ECDH_PUBLIC_P384_MAGIC,
292 "ECDH_P521" => includePrivateParameters ? global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_ECDH_PRIVATE_P521_MAGIC : global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_ECDH_PUBLIC_P521_MAGIC,
293 _ => includePrivateParameters ? global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_ECDH_PRIVATE_GENERIC_MAGIC : global::Interop.BCrypt.KeyBlobMagicNumber.BCRYPT_ECDH_PUBLIC_GENERIC_MAGIC,
294 };
295 }
296
297 private static global::Interop.BCrypt.ECC_CURVE_TYPE_ENUM ConvertToCurveTypeEnum(ECCurve.ECCurveType value)
298 {
299 return (global::Interop.BCrypt.ECC_CURVE_TYPE_ENUM)value;
300 }
301
302 private static ECCurve.ECCurveType ConvertToCurveTypeEnum(global::Interop.BCrypt.ECC_CURVE_TYPE_ENUM value)
303 {
304 return (ECCurve.ECCurveType)value;
305 }
306
307 internal static SafeNCryptKeyHandle ImportKeyBlob(string blobType, ReadOnlySpan<byte> keyBlob, string curveName, SafeNCryptProviderHandle provider)
308 {
309 global::Interop.NCrypt.ErrorCode errorCode;
311 using (SafeUnicodeStringHandle safeUnicodeStringHandle = new SafeUnicodeStringHandle(curveName))
312 {
313 global::Interop.BCrypt.BCryptBufferDesc structure = default(global::Interop.BCrypt.BCryptBufferDesc);
314 global::Interop.BCrypt.BCryptBuffer structure2 = default(global::Interop.BCrypt.BCryptBuffer);
315 IntPtr intPtr = IntPtr.Zero;
316 IntPtr intPtr2 = IntPtr.Zero;
317 try
318 {
319 intPtr = Marshal.AllocHGlobal(Marshal.SizeOf(structure));
320 intPtr2 = Marshal.AllocHGlobal(Marshal.SizeOf(structure2));
321 structure2.cbBuffer = (curveName.Length + 1) * 2;
322 structure2.BufferType = global::Interop.BCrypt.CngBufferDescriptors.NCRYPTBUFFER_ECC_CURVE_NAME;
323 structure2.pvBuffer = safeUnicodeStringHandle.DangerousGetHandle();
324 Marshal.StructureToPtr(structure2, intPtr2, fDeleteOld: false);
325 structure.cBuffers = 1;
326 structure.pBuffers = intPtr2;
327 structure.ulVersion = 0;
328 Marshal.StructureToPtr(structure, intPtr, fDeleteOld: false);
329 errorCode = global::Interop.NCrypt.NCryptImportKey(provider, IntPtr.Zero, blobType, intPtr, out phKey, ref MemoryMarshal.GetReference(keyBlob), keyBlob.Length, 0);
330 }
331 finally
332 {
333 Marshal.FreeHGlobal(intPtr);
334 Marshal.FreeHGlobal(intPtr2);
335 }
336 }
337 if (errorCode != 0)
338 {
339 Exception ex = errorCode.ToCryptographicException();
340 if (errorCode == global::Interop.NCrypt.ErrorCode.NTE_INVALID_PARAMETER)
341 {
343 }
344 throw ex;
345 }
346 return phKey;
347 }
348
349 internal static string EcdsaCurveNameToAlgorithm(string algorithm)
350 {
351 switch (algorithm)
352 {
353 case "nistP256":
354 case "ECDSA_P256":
355 return "ECDSA_P256";
356 case "nistP384":
357 case "ECDSA_P384":
358 return "ECDSA_P384";
359 case "nistP521":
360 case "ECDSA_P521":
361 return "ECDSA_P521";
362 default:
363 return "ECDSA";
364 }
365 }
366
367 internal static string EcdhCurveNameToAlgorithm(string algorithm)
368 {
369 switch (algorithm)
370 {
371 case "nistP256":
372 case "ECDH_P256":
373 case "ECDSA_P256":
374 return "ECDH_P256";
375 case "nistP384":
376 case "ECDH_P384":
377 case "ECDSA_P384":
378 return "ECDH_P384";
379 case "nistP521":
380 case "ECDH_P521":
381 case "ECDSA_P521":
382 return "ECDH_P521";
383 default:
384 return "ECDH";
385 }
386 }
387}
static int ToInt32(byte[] value, int startIndex)
static void StructureToPtr(object structure, IntPtr ptr, bool fDeleteOld)
static void FreeHGlobal(IntPtr hglobal)
Definition Marshal.cs:1680
static int SizeOf(object structure)
Definition Marshal.cs:697
static IntPtr AllocHGlobal(int cb)
Definition Marshal.cs:625
static string Cryptography_NotValidPrivateKey
Definition SR.cs:120
static string Cryptography_UnknownHashAlgorithm
Definition SR.cs:152
static string Cryptography_CurveNotSupported
Definition SR.cs:64
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string Cryptography_NotValidPublicOrPrivateKey
Definition SR.cs:122
Definition SR.cs:7
static SafeNCryptKeyHandle ImportKeyBlob(string blobType, ReadOnlySpan< byte > keyBlob, string curveName, SafeNCryptProviderHandle provider)
Definition ECCng.cs:307
static string EcdhCurveNameToAlgorithm(string algorithm)
Definition ECCng.cs:367
static ? HashAlgorithmName GetHashAlgorithmName(global::Interop.BCrypt.ECC_CURVE_ALG_ID_ENUM hashId)
Definition ECCng.cs:23
static global::Interop.BCrypt.KeyBlobMagicNumber EcdsaCurveNameToMagicNumber(string name, bool includePrivateParameters)
Definition ECCng.cs:275
static unsafe byte[] GetPrimeCurveParameterBlob(ref ECCurve curve)
Definition ECCng.cs:194
static unsafe byte[] GetPrimeCurveBlob(ref ECParameters parameters, bool ecdh)
Definition ECCng.cs:88
static unsafe void ExportNamedCurveParameters(ref ECParameters ecParams, byte[] ecBlob, bool includePrivateParameters)
Definition ECCng.cs:131
static global::Interop.BCrypt.KeyBlobMagicNumber EcdhCurveNameToMagicNumber(string name, bool includePrivateParameters)
Definition ECCng.cs:286
static bool IsMagicValueOfKeyPrivate(global::Interop.BCrypt.KeyBlobMagicNumber magic)
Definition ECCng.cs:239
static string EcdsaCurveNameToAlgorithm(string algorithm)
Definition ECCng.cs:349
static ECCurve.ECCurveType ConvertToCurveTypeEnum(global::Interop.BCrypt.ECC_CURVE_TYPE_ENUM value)
Definition ECCng.cs:302
static global::Interop.BCrypt.ECC_CURVE_ALG_ID_ENUM GetHashAlgorithmId(HashAlgorithmName? name)
Definition ECCng.cs:9
static void CheckMagicValueOfKey(global::Interop.BCrypt.KeyBlobMagicNumber magic, bool includePrivateParameters)
Definition ECCng.cs:224
static bool IsMagicValueOfKeyPublic(global::Interop.BCrypt.KeyBlobMagicNumber magic)
Definition ECCng.cs:257
static unsafe byte[] GetNamedCurveBlob(ref ECParameters parameters, bool ecdh)
Definition ECCng.cs:63
static bool IsECNamedCurve(string algorithm)
Definition ECCng.cs:33
static global::Interop.BCrypt.ECC_CURVE_TYPE_ENUM ConvertToCurveTypeEnum(ECCurve.ECCurveType value)
Definition ECCng.cs:297
static unsafe void ExportPrimeCurveParameters(ref ECParameters ecParams, byte[] ecBlob, bool includePrivateParameters)
Definition ECCng.cs:155
static string SpecialNistAlgorithmToCurveName(string algorithm, out string oidValue)
Definition ECCng.cs:42
static readonly IntPtr Zero
Definition IntPtr.cs:18