Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ECDiffieHellmanCng.cs
Go to the documentation of this file.
3
5
7{
8 private CngAlgorithmCore _core = new CngAlgorithmCore("ECDiffieHellmanCng")
9 {
10 DefaultKeyType = CngAlgorithm.ECDiffieHellman
11 };
12
14
16
17 private byte[] _hmacKey;
18
19 private byte[] _label;
20
21 private byte[] _secretAppend;
22
23 private byte[] _secretPrepend;
24
25 private byte[] _seed;
26
28 {
29 get
30 {
31 return _hashAlgorithm;
32 }
33 set
34 {
35 if (_hashAlgorithm == null)
36 {
37 throw new ArgumentNullException("value");
38 }
40 }
41 }
42
44 {
45 get
46 {
47 return _kdf;
48 }
49 set
50 {
51 if (value < ECDiffieHellmanKeyDerivationFunction.Hash || value > ECDiffieHellmanKeyDerivationFunction.Tls)
52 {
53 throw new ArgumentOutOfRangeException("value");
54 }
55 _kdf = value;
56 }
57 }
58
59 public byte[]? HmacKey
60 {
61 get
62 {
63 return _hmacKey;
64 }
65 set
66 {
68 }
69 }
70
71 public byte[]? Label
72 {
73 get
74 {
75 return _label;
76 }
77 set
78 {
79 _label = value;
80 }
81 }
82
83 public byte[]? SecretAppend
84 {
85 get
86 {
87 return _secretAppend;
88 }
89 set
90 {
92 }
93 }
94
95 public byte[]? SecretPrepend
96 {
97 get
98 {
99 return _secretPrepend;
100 }
101 set
102 {
104 }
105 }
106
107 public byte[]? Seed
108 {
109 get
110 {
111 return _seed;
112 }
113 set
114 {
115 _seed = value;
116 }
117 }
118
119 public bool UseSecretAgreementAsHmacKey => HmacKey == null;
120
122
123 public CngKey Key
124 {
125 get
126 {
127 return GetKey();
128 }
129 private set
130 {
131 if (value == null)
132 {
133 throw new ArgumentNullException("value");
134 }
135 if (value.AlgorithmGroup != CngAlgorithmGroup.ECDiffieHellman)
136 {
138 }
140 ForceSetKeySize(value.KeySize);
141 }
142 }
143
144 public override int KeySize
145 {
146 get
147 {
148 return base.KeySize;
149 }
150 set
151 {
152 if (KeySize != value)
153 {
154 base.KeySize = value;
155 DisposeKey();
156 }
157 }
158 }
159
160 public override KeySizes[] LegalKeySizes => new KeySizes[2]
161 {
162 new KeySizes(256, 384, 128),
163 new KeySizes(521, 521, 0)
164 };
165
167 {
168 if (key == null)
169 {
170 throw new ArgumentNullException("key");
171 }
172 if (key.AlgorithmGroup != CngAlgorithmGroup.ECDiffieHellman)
173 {
175 }
177 }
178
179 protected override void Dispose(bool disposing)
180 {
181 _core.Dispose();
182 }
183
184 private void ThrowIfDisposed()
185 {
187 }
188
189 private void DisposeKey()
190 {
192 }
193
194 internal string GetCurveName(out string oidValue)
195 {
196 return Key.GetCurveName(out oidValue);
197 }
198
199 private void ImportFullKeyBlob(byte[] ecfullKeyBlob, bool includePrivateParameters)
200 {
201 Key = System.Security.Cryptography.ECCng.ImportFullKeyBlob(ecfullKeyBlob, includePrivateParameters);
202 }
203
204 private void ImportKeyBlob(byte[] ecfullKeyBlob, string curveName, bool includePrivateParameters)
205 {
206 Key = System.Security.Cryptography.ECCng.ImportKeyBlob(ecfullKeyBlob, curveName, includePrivateParameters);
207 }
208
209 private byte[] ExportKeyBlob(bool includePrivateParameters)
210 {
211 return System.Security.Cryptography.ECCng.ExportKeyBlob(Key, includePrivateParameters);
212 }
213
214 private byte[] ExportFullKeyBlob(bool includePrivateParameters)
215 {
216 return System.Security.Cryptography.ECCng.ExportFullKeyBlob(Key, includePrivateParameters);
217 }
218
220 {
221 Key = response.Key;
222 }
223
224 public override bool TryExportPkcs8PrivateKey(Span<byte> destination, out int bytesWritten)
225 {
226 return Key.TryExportKeyBlob("PKCS8_PRIVATEKEY", destination, out bytesWritten);
227 }
228
229 private byte[] ExportEncryptedPkcs8(ReadOnlySpan<char> pkcs8Password, int kdfCount)
230 {
231 return Key.ExportPkcs8KeyBlob(pkcs8Password, kdfCount);
232 }
233
234 private bool TryExportEncryptedPkcs8(ReadOnlySpan<char> pkcs8Password, int kdfCount, Span<byte> destination, out int bytesWritten)
235 {
236 return Key.TryExportPkcs8KeyBlob(pkcs8Password, kdfCount, destination, out bytesWritten);
237 }
238
239 public override byte[] DeriveKeyMaterial(ECDiffieHellmanPublicKey otherPartyPublicKey)
240 {
241 if (otherPartyPublicKey == null)
242 {
243 throw new ArgumentNullException("otherPartyPublicKey");
244 }
245 if (otherPartyPublicKey is ECDiffieHellmanCngPublicKey eCDiffieHellmanCngPublicKey)
246 {
247 using CngKey otherPartyPublicKey2 = eCDiffieHellmanCngPublicKey.Import();
248 return DeriveKeyMaterial(otherPartyPublicKey2);
249 }
250 ECParameters parameters = otherPartyPublicKey.ExportParameters();
251 using ECDiffieHellmanCng eCDiffieHellmanCng = new ECDiffieHellmanCng();
252 eCDiffieHellmanCng.ImportParameters(parameters);
253 ECDiffieHellmanCngPublicKey eCDiffieHellmanCngPublicKey2;
254 using (eCDiffieHellmanCngPublicKey2 = (ECDiffieHellmanCngPublicKey)eCDiffieHellmanCng.PublicKey)
255 {
256 using CngKey otherPartyPublicKey3 = eCDiffieHellmanCngPublicKey2.Import();
257 return DeriveKeyMaterial(otherPartyPublicKey3);
258 }
259 }
260
261 public byte[] DeriveKeyMaterial(CngKey otherPartyPublicKey)
262 {
263 if (otherPartyPublicKey == null)
264 {
265 throw new ArgumentNullException("otherPartyPublicKey");
266 }
267 if (otherPartyPublicKey.AlgorithmGroup != CngAlgorithmGroup.ECDiffieHellman)
268 {
269 throw new ArgumentException(System.SR.Cryptography_ArgECDHRequiresECDHKey, "otherPartyPublicKey");
270 }
271 if (otherPartyPublicKey.KeySize != KeySize)
272 {
273 throw new ArgumentException(System.SR.Cryptography_ArgECDHKeySizeMismatch, "otherPartyPublicKey");
274 }
275 global::Interop.NCrypt.SecretAgreementFlags flags = (UseSecretAgreementAsHmacKey ? global::Interop.NCrypt.SecretAgreementFlags.UseSecretAsHmacKey : global::Interop.NCrypt.SecretAgreementFlags.None);
276 using SafeNCryptSecretHandle secretAgreement = DeriveSecretAgreementHandle(otherPartyPublicKey);
277 switch (KeyDerivationFunction)
278 {
280 return global::Interop.NCrypt.DeriveKeyMaterialHash(secretAgreement, HashAlgorithm.Algorithm, _secretPrepend, _secretAppend, flags);
282 return global::Interop.NCrypt.DeriveKeyMaterialHmac(secretAgreement, HashAlgorithm.Algorithm, _hmacKey, _secretPrepend, _secretAppend, flags);
283 default:
284 if (_label == null || _seed == null)
285 {
287 }
288 return global::Interop.NCrypt.DeriveKeyMaterialTls(secretAgreement, _label, _seed, flags);
289 }
290 }
291
293 {
294 if (otherPartyPublicKey == null)
295 {
296 throw new ArgumentNullException("otherPartyPublicKey");
297 }
298 if (otherPartyPublicKey is ECDiffieHellmanCngPublicKey eCDiffieHellmanCngPublicKey)
299 {
300 using CngKey otherPartyPublicKey2 = eCDiffieHellmanCngPublicKey.Import();
301 return DeriveSecretAgreementHandle(otherPartyPublicKey2);
302 }
303 ECParameters parameters = otherPartyPublicKey.ExportParameters();
304 using ECDiffieHellmanCng eCDiffieHellmanCng = new ECDiffieHellmanCng();
305 eCDiffieHellmanCng.ImportParameters(parameters);
306 ECDiffieHellmanCngPublicKey eCDiffieHellmanCngPublicKey2;
307 using (eCDiffieHellmanCngPublicKey2 = (ECDiffieHellmanCngPublicKey)eCDiffieHellmanCng.PublicKey)
308 {
309 using CngKey otherPartyPublicKey3 = eCDiffieHellmanCngPublicKey2.Import();
310 return DeriveSecretAgreementHandle(otherPartyPublicKey3);
311 }
312 }
313
315 {
316 if (otherPartyPublicKey == null)
317 {
318 throw new ArgumentNullException("otherPartyPublicKey");
319 }
320 if (otherPartyPublicKey.AlgorithmGroup != CngAlgorithmGroup.ECDiffieHellman)
321 {
322 throw new ArgumentException(System.SR.Cryptography_ArgECDHRequiresECDHKey, "otherPartyPublicKey");
323 }
324 if (otherPartyPublicKey.KeySize != KeySize)
325 {
326 throw new ArgumentException(System.SR.Cryptography_ArgECDHKeySizeMismatch, "otherPartyPublicKey");
327 }
328 using SafeNCryptKeyHandle privateKey = Key.Handle;
329 using SafeNCryptKeyHandle otherPartyPublicKey2 = otherPartyPublicKey.Handle;
330 return global::Interop.NCrypt.DeriveSecretAgreement(privateKey, otherPartyPublicKey2);
331 }
332
333 public override void GenerateKey(ECCurve curve)
334 {
335 curve.Validate();
337 if (curve.IsNamed)
338 {
339 if (string.IsNullOrEmpty(curve.Oid.FriendlyName))
340 {
342 }
344 if (CngKey.IsECNamedCurve(cngAlgorithm.Algorithm))
345 {
346 CngKey orGenerateKey = _core.GetOrGenerateKey(curve);
347 ForceSetKeySize(orGenerateKey.KeySize);
348 return;
349 }
350 int num = 0;
351 if (cngAlgorithm == CngAlgorithm.ECDiffieHellmanP256)
352 {
353 num = 256;
354 }
355 else if (cngAlgorithm == CngAlgorithm.ECDiffieHellmanP384)
356 {
357 num = 384;
358 }
359 else
360 {
361 if (!(cngAlgorithm == CngAlgorithm.ECDiffieHellmanP521))
362 {
364 }
365 num = 521;
366 }
367 _core.GetOrGenerateKey(num, cngAlgorithm);
368 ForceSetKeySize(num);
369 }
370 else
371 {
372 if (!curve.IsExplicit)
373 {
375 }
376 CngKey orGenerateKey2 = _core.GetOrGenerateKey(curve);
377 ForceSetKeySize(orGenerateKey2.KeySize);
378 }
379 }
380
381 private CngKey GetKey()
382 {
384 {
385 return _core.GetOrGenerateKey(null);
386 }
387 int num = 0;
388 num = KeySize;
389 CngAlgorithm algorithm = num switch
390 {
395 };
396 return _core.GetOrGenerateKey(num, algorithm);
397 }
398
399 public void FromXmlString(string xml, ECKeyXmlFormat format)
400 {
402 }
403
405 {
407 }
408
410 : this(521)
411 {
412 }
413
414 public ECDiffieHellmanCng(int keySize)
415 {
416 KeySize = keySize;
417 }
418
420 {
421 GenerateKey(curve);
422 }
423
424 private void ForceSetKeySize(int newKeySize)
425 {
426 KeySizeValue = newKeySize;
427 }
428
429 public override byte[] DeriveKeyFromHash(ECDiffieHellmanPublicKey otherPartyPublicKey, HashAlgorithmName hashAlgorithm, byte[]? secretPrepend, byte[]? secretAppend)
430 {
431 if (otherPartyPublicKey == null)
432 {
433 throw new ArgumentNullException("otherPartyPublicKey");
434 }
435 if (string.IsNullOrEmpty(hashAlgorithm.Name))
436 {
438 }
439 using SafeNCryptSecretHandle secretAgreement = DeriveSecretAgreementHandle(otherPartyPublicKey);
440 return global::Interop.NCrypt.DeriveKeyMaterialHash(secretAgreement, hashAlgorithm.Name, secretPrepend, secretAppend, global::Interop.NCrypt.SecretAgreementFlags.None);
441 }
442
443 public override byte[] DeriveKeyFromHmac(ECDiffieHellmanPublicKey otherPartyPublicKey, HashAlgorithmName hashAlgorithm, byte[]? hmacKey, byte[]? secretPrepend, byte[]? secretAppend)
444 {
445 if (otherPartyPublicKey == null)
446 {
447 throw new ArgumentNullException("otherPartyPublicKey");
448 }
449 if (string.IsNullOrEmpty(hashAlgorithm.Name))
450 {
452 }
453 using SafeNCryptSecretHandle secretAgreement = DeriveSecretAgreementHandle(otherPartyPublicKey);
454 global::Interop.NCrypt.SecretAgreementFlags flags = ((hmacKey == null) ? global::Interop.NCrypt.SecretAgreementFlags.UseSecretAsHmacKey : global::Interop.NCrypt.SecretAgreementFlags.None);
455 return global::Interop.NCrypt.DeriveKeyMaterialHmac(secretAgreement, hashAlgorithm.Name, hmacKey, secretPrepend, secretAppend, flags);
456 }
457
458 public override byte[] DeriveKeyTls(ECDiffieHellmanPublicKey otherPartyPublicKey, byte[] prfLabel, byte[] prfSeed)
459 {
460 if (otherPartyPublicKey == null)
461 {
462 throw new ArgumentNullException("otherPartyPublicKey");
463 }
464 if (prfLabel == null)
465 {
466 throw new ArgumentNullException("prfLabel");
467 }
468 if (prfSeed == null)
469 {
470 throw new ArgumentNullException("prfSeed");
471 }
472 using SafeNCryptSecretHandle secretAgreement = DeriveSecretAgreementHandle(otherPartyPublicKey);
473 return global::Interop.NCrypt.DeriveKeyMaterialTls(secretAgreement, prfLabel, prfSeed, global::Interop.NCrypt.SecretAgreementFlags.None);
474 }
475
476 public override void ImportParameters(ECParameters parameters)
477 {
478 parameters.Validate();
480 ECCurve curve = parameters.Curve;
481 bool flag = parameters.D != null;
482 bool flag2 = parameters.Q.X != null && parameters.Q.Y != null;
483 if (curve.IsPrime)
484 {
485 if (!flag2 && flag)
486 {
487 byte[] array = new byte[parameters.D.Length];
488 ECParameters parameters2 = parameters;
489 parameters2.Q.X = array;
490 parameters2.Q.Y = array;
491 byte[] primeCurveBlob = System.Security.Cryptography.ECCng.GetPrimeCurveBlob(ref parameters2, ecdh: true);
492 ImportFullKeyBlob(primeCurveBlob, includePrivateParameters: true);
493 }
494 else
495 {
496 byte[] primeCurveBlob2 = System.Security.Cryptography.ECCng.GetPrimeCurveBlob(ref parameters, ecdh: true);
497 ImportFullKeyBlob(primeCurveBlob2, flag);
498 }
499 return;
500 }
501 if (curve.IsNamed)
502 {
503 if (string.IsNullOrEmpty(curve.Oid.FriendlyName))
504 {
506 }
507 if (!flag2 && flag)
508 {
509 byte[] array2 = new byte[parameters.D.Length];
510 ECParameters parameters3 = parameters;
511 parameters3.Q.X = array2;
512 parameters3.Q.Y = array2;
513 byte[] namedCurveBlob = System.Security.Cryptography.ECCng.GetNamedCurveBlob(ref parameters3, ecdh: true);
514 ImportKeyBlob(namedCurveBlob, curve.Oid.FriendlyName, includePrivateParameters: true);
515 }
516 else
517 {
518 byte[] namedCurveBlob2 = System.Security.Cryptography.ECCng.GetNamedCurveBlob(ref parameters, ecdh: true);
519 ImportKeyBlob(namedCurveBlob2, curve.Oid.FriendlyName, flag);
520 }
521 return;
522 }
524 }
525
526 public override ECParameters ExportExplicitParameters(bool includePrivateParameters)
527 {
528 byte[] array = ExportFullKeyBlob(includePrivateParameters);
529 try
530 {
531 ECParameters ecParams = default(ECParameters);
532 System.Security.Cryptography.ECCng.ExportPrimeCurveParameters(ref ecParams, array, includePrivateParameters);
533 return ecParams;
534 }
535 finally
536 {
538 }
539 }
540
541 public override ECParameters ExportParameters(bool includePrivateParameters)
542 {
543 ECParameters ecParams = default(ECParameters);
544 string oidValue;
545 string curveName = GetCurveName(out oidValue);
546 byte[] array = null;
547 try
548 {
549 if (string.IsNullOrEmpty(curveName))
550 {
551 array = ExportFullKeyBlob(includePrivateParameters);
552 System.Security.Cryptography.ECCng.ExportPrimeCurveParameters(ref ecParams, array, includePrivateParameters);
553 }
554 else
555 {
556 array = ExportKeyBlob(includePrivateParameters);
557 System.Security.Cryptography.ECCng.ExportNamedCurveParameters(ref ecParams, array, includePrivateParameters);
558 ecParams.Curve = ECCurve.CreateFromOid(new Oid(oidValue, curveName));
559 }
560 return ecParams;
561 }
562 finally
563 {
564 if (array != null)
565 {
567 }
568 }
569 }
570
571 public override void ImportPkcs8PrivateKey(ReadOnlySpan<byte> source, out int bytesRead)
572 {
574 int bytesRead2;
576 ProcessPkcs8Response(response);
577 bytesRead = bytesRead2;
578 }
579
580 public override void ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<byte> passwordBytes, ReadOnlySpan<byte> source, out int bytesRead)
581 {
583 int bytesRead2;
585 ProcessPkcs8Response(response);
586 bytesRead = bytesRead2;
587 }
588
589 public override void ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<char> password, ReadOnlySpan<byte> source, out int bytesRead)
590 {
592 int bytesRead2;
594 ProcessPkcs8Response(response);
595 bytesRead = bytesRead2;
596 }
597
599 {
600 if (response.GetAlgorithmGroup() != "ECDH")
601 {
602 response.FreeKey();
604 }
605 AcceptImport(response);
606 }
607
608 public override byte[] ExportEncryptedPkcs8PrivateKey(ReadOnlySpan<byte> passwordBytes, PbeParameters pbeParameters)
609 {
610 if (pbeParameters == null)
611 {
612 throw new ArgumentNullException("pbeParameters");
613 }
614 return System.Security.Cryptography.CngPkcs8.ExportEncryptedPkcs8PrivateKey(this, passwordBytes, pbeParameters);
615 }
616
617 public override byte[] ExportEncryptedPkcs8PrivateKey(ReadOnlySpan<char> password, PbeParameters pbeParameters)
618 {
619 if (pbeParameters == null)
620 {
621 throw new ArgumentNullException("pbeParameters");
622 }
625 {
626 return ExportEncryptedPkcs8(password, pbeParameters.IterationCount);
627 }
628 return System.Security.Cryptography.CngPkcs8.ExportEncryptedPkcs8PrivateKey(this, password, pbeParameters);
629 }
630
631 public override bool TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan<byte> passwordBytes, PbeParameters pbeParameters, Span<byte> destination, out int bytesWritten)
632 {
633 if (pbeParameters == null)
634 {
635 throw new ArgumentNullException("pbeParameters");
636 }
638 return System.Security.Cryptography.CngPkcs8.TryExportEncryptedPkcs8PrivateKey(this, passwordBytes, pbeParameters, destination, out bytesWritten);
639 }
640
641 public override bool TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan<char> password, PbeParameters pbeParameters, Span<byte> destination, out int bytesWritten)
642 {
643 if (pbeParameters == null)
644 {
645 throw new ArgumentNullException("pbeParameters");
646 }
649 {
650 return TryExportEncryptedPkcs8(password, pbeParameters.IterationCount, destination, out bytesWritten);
651 }
652 return System.Security.Cryptography.CngPkcs8.TryExportEncryptedPkcs8PrivateKey(this, password, pbeParameters, destination, out bytesWritten);
653 }
654}
static unsafe void Clear(Array array)
Definition Array.cs:755
static string Cryptography_TlsRequiresLabelAndSeed
Definition SR.cs:32
static string Cryptography_CurveNotSupported
Definition SR.cs:64
static string Cryptography_ArgECDHRequiresECDHKey
Definition SR.cs:42
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string Cryptography_NotValidPublicOrPrivateKey
Definition SR.cs:122
static string Cryptography_ArgECDHKeySizeMismatch
Definition SR.cs:40
static string Cryptography_InvalidCurveOid
Definition SR.cs:66
static string Cryptography_InvalidKeySize
Definition SR.cs:92
static string Cryptography_HashAlgorithmNameNullOrEmpty
Definition SR.cs:60
Definition SR.cs:7
bool TryExportKeyBlob(string blobType, Span< byte > destination, out int bytesWritten)
Definition CngKey.cs:643
static CngAlgorithm EcdhCurveNameToAlgorithm(string name)
Definition CngKey.cs:507
string GetCurveName(out string oidValue)
Definition CngKey.cs:450
byte[] ExportPkcs8KeyBlob(ReadOnlySpan< char > password, int kdfCount)
Definition CngKey.cs:665
static CngKey Import(ReadOnlySpan< byte > keyBlob, CngKeyBlobFormat format)
Definition CngKey.cs:525
bool TryExportPkcs8KeyBlob(ReadOnlySpan< char > password, int kdfCount, Span< byte > destination, out int bytesWritten)
Definition CngKey.cs:673
SafeNCryptKeyHandle Handle
Definition CngKey.cs:51
CngAlgorithmGroup? AlgorithmGroup
Definition CngKey.cs:27
static bool IsPlatformScheme(PbeParameters pbeParameters)
Definition CngPkcs8.cs:44
static unsafe Pkcs8Response ImportEncryptedPkcs8PrivateKey(ReadOnlySpan< byte > passwordBytes, ReadOnlySpan< byte > source, out int bytesRead)
Definition CngPkcs8.cs:134
static byte[] ExportEncryptedPkcs8PrivateKey(AsymmetricAlgorithm key, ReadOnlySpan< byte > passwordBytes, PbeParameters pbeParameters)
Definition CngPkcs8.cs:53
static Pkcs8Response ImportPkcs8PrivateKey(ReadOnlySpan< byte > source, out int bytesRead)
Definition CngPkcs8.cs:90
static bool TryExportEncryptedPkcs8PrivateKey(AsymmetricAlgorithm key, ReadOnlySpan< byte > passwordBytes, PbeParameters pbeParameters, Span< byte > destination, out int bytesWritten)
Definition CngPkcs8.cs:68
static SafeNCryptKeyHandle ImportKeyBlob(string blobType, ReadOnlySpan< byte > keyBlob, string curveName, SafeNCryptProviderHandle provider)
Definition ECCng.cs:307
static unsafe byte[] GetPrimeCurveBlob(ref ECParameters parameters, bool ecdh)
Definition ECCng.cs:88
static CngKey ImportFullKeyBlob(byte[] ecBlob, bool includePrivateParameters)
Definition ECCng.cs:17
static unsafe void ExportNamedCurveParameters(ref ECParameters ecParams, byte[] ecBlob, bool includePrivateParameters)
Definition ECCng.cs:131
static byte[] ExportKeyBlob(CngKey key, bool includePrivateParameters)
Definition ECCng.cs:25
static unsafe byte[] GetNamedCurveBlob(ref ECParameters parameters, bool ecdh)
Definition ECCng.cs:63
static unsafe void ExportPrimeCurveParameters(ref ECParameters ecParams, byte[] ecBlob, bool includePrivateParameters)
Definition ECCng.cs:155
static byte[] ExportFullKeyBlob(CngKey key, bool includePrivateParameters)
Definition ECCng.cs:31
static ECDiffieHellmanCngPublicKey FromKey(CngKey key)
override void ImportParameters(ECParameters parameters)
byte[] ExportKeyBlob(bool includePrivateParameters)
override bool TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan< char > password, PbeParameters pbeParameters, Span< byte > destination, out int bytesWritten)
override ECParameters ExportParameters(bool includePrivateParameters)
SafeNCryptSecretHandle DeriveSecretAgreementHandle(ECDiffieHellmanPublicKey otherPartyPublicKey)
ECDiffieHellmanKeyDerivationFunction KeyDerivationFunction
override void ImportEncryptedPkcs8PrivateKey(ReadOnlySpan< byte > passwordBytes, ReadOnlySpan< byte > source, out int bytesRead)
override byte[] DeriveKeyFromHash(ECDiffieHellmanPublicKey otherPartyPublicKey, HashAlgorithmName hashAlgorithm, byte[]? secretPrepend, byte[]? secretAppend)
override byte[] DeriveKeyTls(ECDiffieHellmanPublicKey otherPartyPublicKey, byte[] prfLabel, byte[] prfSeed)
override ECParameters ExportExplicitParameters(bool includePrivateParameters)
byte[] ExportEncryptedPkcs8(ReadOnlySpan< char > pkcs8Password, int kdfCount)
byte[] DeriveKeyMaterial(CngKey otherPartyPublicKey)
void ImportFullKeyBlob(byte[] ecfullKeyBlob, bool includePrivateParameters)
void ImportKeyBlob(byte[] ecfullKeyBlob, string curveName, bool includePrivateParameters)
void ProcessPkcs8Response(System.Security.Cryptography.CngPkcs8.Pkcs8Response response)
override byte[] DeriveKeyMaterial(ECDiffieHellmanPublicKey otherPartyPublicKey)
SafeNCryptSecretHandle DeriveSecretAgreementHandle(CngKey otherPartyPublicKey)
override bool TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan< byte > passwordBytes, PbeParameters pbeParameters, Span< byte > destination, out int bytesWritten)
override byte[] ExportEncryptedPkcs8PrivateKey(ReadOnlySpan< byte > passwordBytes, PbeParameters pbeParameters)
override void ImportPkcs8PrivateKey(ReadOnlySpan< byte > source, out int bytesRead)
override byte[] DeriveKeyFromHmac(ECDiffieHellmanPublicKey otherPartyPublicKey, HashAlgorithmName hashAlgorithm, byte[]? hmacKey, byte[]? secretPrepend, byte[]? secretAppend)
override bool TryExportPkcs8PrivateKey(Span< byte > destination, out int bytesWritten)
bool TryExportEncryptedPkcs8(ReadOnlySpan< char > pkcs8Password, int kdfCount, Span< byte > destination, out int bytesWritten)
byte[] ExportFullKeyBlob(bool includePrivateParameters)
void AcceptImport(System.Security.Cryptography.CngPkcs8.Pkcs8Response response)
override byte[] ExportEncryptedPkcs8PrivateKey(ReadOnlySpan< char > password, PbeParameters pbeParameters)
ECDiffieHellmanKeyDerivationFunction _kdf
override void ImportEncryptedPkcs8PrivateKey(ReadOnlySpan< char > password, ReadOnlySpan< byte > source, out int bytesRead)
void FromXmlString(string xml, ECKeyXmlFormat format)
static void ValidatePbeParameters(PbeParameters pbeParameters, ReadOnlySpan< char > password, ReadOnlySpan< byte > passwordBytes)
CngKey GetOrGenerateKey(int keySize, CngAlgorithm algorithm)
static ECCurve CreateFromOid(Oid curveOid)
Definition ECCurve.cs:127