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

◆ TryExportEncryptedPkcs8PrivateKey() [1/2]

unsafe override bool System.Security.Cryptography.ECDiffieHellman.TryExportEncryptedPkcs8PrivateKey ( ReadOnlySpan< byte > passwordBytes,
PbeParameters pbeParameters,
Span< byte > destination,
out int bytesWritten )
inlinevirtualinherited

Reimplemented from System.Security.Cryptography.AsymmetricAlgorithm.

Reimplemented in System.Security.Cryptography.ECDiffieHellmanImplementation.ECDiffieHellmanCng, and System.Security.Cryptography.ECDiffieHellmanCng.

Definition at line 84 of file ECDiffieHellman.cs.

85 {
86 if (pbeParameters == null)
87 {
88 throw new ArgumentNullException("pbeParameters");
89 }
90 PasswordBasedEncryption.ValidatePbeParameters(pbeParameters, ReadOnlySpan<char>.Empty, passwordBytes);
91 ECParameters ecParameters = ExportParameters(includePrivateParameters: true);
92 fixed (byte* ptr = ecParameters.D)
93 {
94 try
95 {
96 AsnWriter pkcs8Writer = EccKeyFormatHelper.WritePkcs8PrivateKey(ecParameters);
97 AsnWriter asnWriter = KeyFormatHelper.WriteEncryptedPkcs8(passwordBytes, pkcs8Writer, pbeParameters);
98 return asnWriter.TryEncode(destination, out bytesWritten);
99 }
100 finally
101 {
102 CryptographicOperations.ZeroMemory(ecParameters.D);
103 }
104 }
105 }
bool TryEncode(Span< byte > destination, out int bytesWritten)
Definition AsnWriter.cs:173
virtual ECParameters ExportParameters(bool includePrivateParameters)

References System.Security.Cryptography.ECParameters.D, System.destination, System.Security.Cryptography.ECDiffieHellman.ExportParameters(), System.Formats.Asn1.AsnWriter.TryEncode(), System.Security.Cryptography.PasswordBasedEncryption.ValidatePbeParameters(), System.Security.Cryptography.KeyFormatHelper.WriteEncryptedPkcs8(), System.Security.Cryptography.EccKeyFormatHelper.WritePkcs8PrivateKey(), and System.Security.Cryptography.CryptographicOperations.ZeroMemory().