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

◆ WritePkcs1PrivateKey()

static AsnWriter System.Security.Cryptography.RSAKeyFormatHelper.WritePkcs1PrivateKey ( in RSAParameters rsaParameters)
inlinestaticpackage

Definition at line 110 of file RSAKeyFormatHelper.cs.

111 {
112 if (rsaParameters.Modulus == null || rsaParameters.Exponent == null)
113 {
114 throw new CryptographicException(System.SR.Cryptography_InvalidRsaParameters);
115 }
116 if (rsaParameters.D == null || rsaParameters.P == null || rsaParameters.Q == null || rsaParameters.DP == null || rsaParameters.DQ == null || rsaParameters.InverseQ == null)
117 {
118 throw new CryptographicException(System.SR.Cryptography_NotValidPrivateKey);
119 }
120 AsnWriter asnWriter = new AsnWriter(AsnEncodingRules.DER);
121 asnWriter.PushSequence();
122 asnWriter.WriteInteger(0L);
123 asnWriter.WriteKeyParameterInteger(rsaParameters.Modulus);
124 asnWriter.WriteKeyParameterInteger(rsaParameters.Exponent);
125 asnWriter.WriteKeyParameterInteger(rsaParameters.D);
126 asnWriter.WriteKeyParameterInteger(rsaParameters.P);
127 asnWriter.WriteKeyParameterInteger(rsaParameters.Q);
128 asnWriter.WriteKeyParameterInteger(rsaParameters.DP);
129 asnWriter.WriteKeyParameterInteger(rsaParameters.DQ);
130 asnWriter.WriteKeyParameterInteger(rsaParameters.InverseQ);
131 asnWriter.PopSequence();
132 return asnWriter;
133 }
Scope PushSequence(Asn1Tag? tag=null)
void WriteInteger(long value, Asn1Tag? tag=null)
Definition AsnWriter.cs:665
void PopSequence(Asn1Tag? tag=null)
static string Cryptography_NotValidPrivateKey
Definition SR.cs:120
static string Cryptography_InvalidRsaParameters
Definition SR.cs:108
Definition SR.cs:7

References System.SR.Cryptography_InvalidRsaParameters, System.SR.Cryptography_NotValidPrivateKey, System.L, System.Formats.Asn1.AsnWriter.PopSequence(), System.Formats.Asn1.AsnWriter.PushSequence(), and System.Formats.Asn1.AsnWriter.WriteInteger().

Referenced by System.Security.Cryptography.RSA.WritePkcs1PrivateKey().