Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ GenerateKey()

override void System.Security.Cryptography.ECDiffieHellmanCng.GenerateKey ( ECCurve curve)
inlinevirtual

Reimplemented from System.Security.Cryptography.ECDiffieHellman.

Definition at line 333 of file ECDiffieHellmanCng.cs.

334 {
335 curve.Validate();
337 if (curve.IsNamed)
338 {
339 if (string.IsNullOrEmpty(curve.Oid.FriendlyName))
340 {
341 throw new PlatformNotSupportedException(System.SR.Format(System.SR.Cryptography_InvalidCurveOid, curve.Oid.Value));
342 }
343 CngAlgorithm cngAlgorithm = CngKey.EcdhCurveNameToAlgorithm(curve.Oid.FriendlyName);
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 {
374 throw new PlatformNotSupportedException(System.SR.Format(System.SR.Cryptography_CurveNotSupported, curve.CurveType.ToString()));
375 }
376 CngKey orGenerateKey2 = _core.GetOrGenerateKey(curve);
377 ForceSetKeySize(orGenerateKey2.KeySize);
378 }
379 }
static string Cryptography_CurveNotSupported
Definition SR.cs:64
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string Cryptography_InvalidCurveOid
Definition SR.cs:66
static string Cryptography_InvalidKeySize
Definition SR.cs:92
Definition SR.cs:7
CngKey GetOrGenerateKey(int keySize, CngAlgorithm algorithm)

References System.Security.Cryptography.ECDiffieHellmanCng._core, System.Security.Cryptography.CngAlgorithm.Algorithm, System.SR.Cryptography_CurveNotSupported, System.SR.Cryptography_InvalidCurveOid, System.SR.Cryptography_InvalidKeySize, System.Security.Cryptography.ECCurve.CurveType, Internal.Cryptography.CngAlgorithmCore.DisposeKey(), System.Security.Cryptography.CngKey.EcdhCurveNameToAlgorithm(), System.Security.Cryptography.CngAlgorithm.ECDiffieHellmanP256, System.Security.Cryptography.CngAlgorithm.ECDiffieHellmanP384, System.Security.Cryptography.CngAlgorithm.ECDiffieHellmanP521, System.Security.Cryptography.ECDiffieHellmanCng.ForceSetKeySize(), System.SR.Format(), System.Security.Cryptography.Oid.FriendlyName, Internal.Cryptography.CngAlgorithmCore.GetOrGenerateKey(), System.Security.Cryptography.CngKey.IsECNamedCurve(), System.Security.Cryptography.ECCurve.IsExplicit, System.Security.Cryptography.ECCurve.IsNamed, System.Security.Cryptography.CngKey.KeySize, System.Security.Cryptography.ECCurve.Oid, System.Security.Cryptography.ECCurve.Validate(), and System.Security.Cryptography.Oid.Value.

Referenced by System.Security.Cryptography.ECDiffieHellmanCng.ECDiffieHellmanCng().