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

◆ ImportParameters()

override void System.Security.Cryptography.ECDiffieHellmanCng.ImportParameters ( ECParameters parameters)
inlinevirtual

Reimplemented from System.Security.Cryptography.ECDiffieHellman.

Definition at line 476 of file ECDiffieHellmanCng.cs.

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 {
505 throw new PlatformNotSupportedException(System.SR.Format(System.SR.Cryptography_InvalidCurveOid, curve.Oid.Value));
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 }
523 throw new PlatformNotSupportedException(System.SR.Format(System.SR.Cryptography_CurveNotSupported, curve.CurveType.ToString()));
524 }
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
Definition SR.cs:7
static unsafe byte[] GetPrimeCurveBlob(ref ECParameters parameters, bool ecdh)
Definition ECCng.cs:88
static unsafe byte[] GetNamedCurveBlob(ref ECParameters parameters, bool ecdh)
Definition ECCng.cs:63
void ImportFullKeyBlob(byte[] ecfullKeyBlob, bool includePrivateParameters)
void ImportKeyBlob(byte[] ecfullKeyBlob, string curveName, bool includePrivateParameters)

References System.array, System.SR.Cryptography_CurveNotSupported, System.SR.Cryptography_InvalidCurveOid, System.Security.Cryptography.ECParameters.Curve, System.Security.Cryptography.ECCurve.CurveType, System.Security.Cryptography.ECParameters.D, System.SR.Format(), System.Security.Cryptography.Oid.FriendlyName, System.Security.Cryptography.ECCng.GetNamedCurveBlob(), System.Security.Cryptography.ECCng.GetPrimeCurveBlob(), System.Security.Cryptography.ECDiffieHellmanCng.ImportFullKeyBlob(), System.Security.Cryptography.ECDiffieHellmanCng.ImportKeyBlob(), System.Security.Cryptography.ECCurve.IsNamed, System.Security.Cryptography.ECCurve.IsPrime, System.Security.Cryptography.ECCurve.Oid, System.Security.Cryptography.ECDiffieHellmanCng.ThrowIfDisposed(), System.Security.Cryptography.ECParameters.Validate(), and System.Security.Cryptography.Oid.Value.

Referenced by Internal.Cryptography.Pal.X509Pal.DecodeECDiffieHellmanPublicKey().