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

◆ FromPkcs1PrivateKey()

static void System.Security.Cryptography.RSAKeyFormatHelper.FromPkcs1PrivateKey ( ReadOnlyMemory< byte > keyData,
in AlgorithmIdentifierAsn algId,
out RSAParameters ret )
inlinestaticpackage

Definition at line 10 of file RSAKeyFormatHelper.cs.

11 {
12 RSAPrivateKeyAsn rSAPrivateKeyAsn = RSAPrivateKeyAsn.Decode(keyData, AsnEncodingRules.BER);
13 if (!algId.HasNullEquivalentParameters())
14 {
15 throw new CryptographicException(System.SR.Cryptography_Der_Invalid_Encoding);
16 }
17 if (rSAPrivateKeyAsn.Version > 0)
18 {
19 throw new CryptographicException(System.SR.Format(System.SR.Cryptography_RSAPrivateKey_VersionTooNew, rSAPrivateKeyAsn.Version, 0));
20 }
21 byte[] array = rSAPrivateKeyAsn.Modulus.ToByteArray(isUnsigned: true, isBigEndian: true);
22 int length = (array.Length + 1) / 2;
23 ret = new RSAParameters
24 {
25 Modulus = array,
26 Exponent = rSAPrivateKeyAsn.PublicExponent.ToByteArray(isUnsigned: true, isBigEndian: true),
27 D = rSAPrivateKeyAsn.PrivateExponent.ExportKeyParameter(array.Length),
28 P = rSAPrivateKeyAsn.Prime1.ExportKeyParameter(length),
29 Q = rSAPrivateKeyAsn.Prime2.ExportKeyParameter(length),
30 DP = rSAPrivateKeyAsn.Exponent1.ExportKeyParameter(length),
31 DQ = rSAPrivateKeyAsn.Exponent2.ExportKeyParameter(length),
32 InverseQ = rSAPrivateKeyAsn.Coefficient.ExportKeyParameter(length)
33 };
34 }
static string Cryptography_Der_Invalid_Encoding
Definition SR.cs:50
static string Cryptography_RSAPrivateKey_VersionTooNew
Definition SR.cs:140
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
Definition SR.cs:7
static RSAPrivateKeyAsn Decode(ReadOnlyMemory< byte > encoded, AsnEncodingRules ruleSet)

References System.array, System.Security.Cryptography.Asn1.RSAPrivateKeyAsn.Coefficient, System.SR.Cryptography_Der_Invalid_Encoding, System.SR.Cryptography_RSAPrivateKey_VersionTooNew, System.D, System.Security.Cryptography.Asn1.RSAPrivateKeyAsn.Decode(), System.Security.Cryptography.Asn1.RSAPrivateKeyAsn.Exponent1, System.Security.Cryptography.Asn1.RSAPrivateKeyAsn.Exponent2, System.SR.Format(), System.length, System.Security.Cryptography.Asn1.RSAPrivateKeyAsn.Modulus, System.P, System.Security.Cryptography.Asn1.RSAPrivateKeyAsn.Prime1, System.Security.Cryptography.Asn1.RSAPrivateKeyAsn.Prime2, System.Security.Cryptography.Asn1.RSAPrivateKeyAsn.PrivateExponent, System.Security.Cryptography.Asn1.RSAPrivateKeyAsn.PublicExponent, System.Q, and System.Security.Cryptography.Asn1.RSAPrivateKeyAsn.Version.

Referenced by System.Security.Cryptography.RSA.ImportRSAPrivateKey(), System.Security.Cryptography.RSAKeyFormatHelper.ReadEncryptedPkcs8(), and System.Security.Cryptography.RSAKeyFormatHelper.ReadEncryptedPkcs8().