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

◆ FromECPublicKey()

static void System.Security.Cryptography.EccKeyFormatHelper.FromECPublicKey ( ReadOnlyMemory< byte > key,
in AlgorithmIdentifierAsn algId,
out ECParameters ret )
inlinestaticpackage

Definition at line 79 of file EccKeyFormatHelper.cs.

80 {
81 if (!algId.Parameters.HasValue)
82 {
83 throw new CryptographicException(System.SR.Cryptography_Der_Invalid_Encoding);
84 }
85 ReadOnlySpan<byte> span = key.Span;
86 if (span.Length == 0)
87 {
88 throw new CryptographicException(System.SR.Cryptography_Der_Invalid_Encoding);
89 }
90 if (span[0] != 4)
91 {
92 throw new CryptographicException(System.SR.Cryptography_NotValidPublicOrPrivateKey);
93 }
94 if ((span.Length & 1) != 1)
95 {
96 throw new CryptographicException(System.SR.Cryptography_Der_Invalid_Encoding);
97 }
98 int num = span.Length / 2;
99 ECDomainParameters domainParameters = ECDomainParameters.Decode(algId.Parameters.Value, AsnEncodingRules.DER);
100 ret = new ECParameters
101 {
102 Curve = GetCurve(domainParameters),
103 Q =
104 {
105 X = span.Slice(1, num).ToArray(),
106 Y = span.Slice(1 + num).ToArray()
107 }
108 };
109 ret.Validate();
110 }
static string Cryptography_Der_Invalid_Encoding
Definition SR.cs:50
static string Cryptography_NotValidPublicOrPrivateKey
Definition SR.cs:122
Definition SR.cs:7
static ECCurve GetCurve(ECDomainParameters domainParameters)
static ECDomainParameters Decode(ReadOnlyMemory< byte > encoded, AsnEncodingRules ruleSet)

References System.SR.Cryptography_Der_Invalid_Encoding, System.SR.Cryptography_NotValidPublicOrPrivateKey, System.Security.Cryptography.Asn1.ECDomainParameters.Decode(), System.Security.Cryptography.EccKeyFormatHelper.GetCurve(), System.key, System.ReadOnlySpan< T >.Length, System.Q, System.ReadOnlySpan< T >.Slice(), System.X, and System.Y.

Referenced by System.Security.Cryptography.ECDiffieHellman.ImportSubjectPublicKeyInfo(), and System.Security.Cryptography.ECDsa.ImportSubjectPublicKeyInfo().