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

◆ ReadDsaPublicKey()

static void System.Security.Cryptography.DSAKeyFormatHelper.ReadDsaPublicKey ( ReadOnlyMemory< byte > yBytes,
in AlgorithmIdentifierAsn algId,
out DSAParameters ret )
inlinestaticpackage

Definition at line 44 of file DSAKeyFormatHelper.cs.

45 {
47 try
48 {
49 value = AsnDecoder.ReadInteger(yBytes.Span, AsnEncodingRules.DER, out var bytesConsumed);
50 if (bytesConsumed != yBytes.Length)
51 {
52 throw new CryptographicException(System.SR.Cryptography_Der_Invalid_Encoding);
53 }
54 }
55 catch (AsnContentException inner)
56 {
57 throw new CryptographicException(System.SR.Cryptography_Der_Invalid_Encoding, inner);
58 }
59 if (!algId.Parameters.HasValue)
60 {
61 throw new CryptographicException(System.SR.Cryptography_Der_Invalid_Encoding);
62 }
63 DssParms dssParms = DssParms.Decode(algId.Parameters.Value, AsnEncodingRules.BER);
64 ret = new DSAParameters
65 {
66 P = dssParms.P.ToByteArray(isUnsigned: true, isBigEndian: true),
67 Q = dssParms.Q.ToByteArray(isUnsigned: true, isBigEndian: true)
68 };
69 ret.G = dssParms.G.ExportKeyParameter(ret.P.Length);
70 ret.Y = value.ExportKeyParameter(ret.P.Length);
71 }
static BigInteger ReadInteger(ReadOnlySpan< byte > source, AsnEncodingRules ruleSet, out int bytesConsumed, Asn1Tag? expectedTag=null)
static string Cryptography_Der_Invalid_Encoding
Definition SR.cs:50
Definition SR.cs:7
unsafe ReadOnlySpan< T > Span
static DssParms Decode(ReadOnlyMemory< byte > encoded, AsnEncodingRules ruleSet)
Definition DssParms.cs:14

References System.SR.Cryptography_Der_Invalid_Encoding, System.Security.Cryptography.Asn1.DssParms.Decode(), System.Security.Cryptography.Asn1.DssParms.G, System.ReadOnlyMemory< T >.Length, System.P, System.Security.Cryptography.Asn1.DssParms.P, System.Q, System.Security.Cryptography.Asn1.DssParms.Q, System.Formats.Asn1.AsnDecoder.ReadInteger(), System.ReadOnlyMemory< T >.Span, System.Numerics.BigInteger.ToByteArray(), and System.value.

Referenced by System.Security.Cryptography.DSAKeyFormatHelper.ReadSubjectPublicKeyInfo().