Edit

Share via


AsymmetricAlgorithm.TryExportEncryptedPkcs8PrivateKeyPem Method

Definition

Overloads

TryExportEncryptedPkcs8PrivateKeyPem(ReadOnlySpan<Byte>, PbeParameters, Span<Char>, Int32)

Attempts to export the current key in the PKCS#8 EncryptedPrivateKeyInfo format with a byte-based password, PEM encoded.

TryExportEncryptedPkcs8PrivateKeyPem(ReadOnlySpan<Char>, PbeParameters, Span<Char>, Int32)

Exports the current key in the PKCS#8 EncryptedPrivateKeyInfo format with a char-based password, PEM encoded.

TryExportEncryptedPkcs8PrivateKeyPem(ReadOnlySpan<Byte>, PbeParameters, Span<Char>, Int32)

Source:
AsymmetricAlgorithm.cs
Source:
AsymmetricAlgorithm.cs

Attempts to export the current key in the PKCS#8 EncryptedPrivateKeyInfo format with a byte-based password, PEM encoded.

public:
 bool TryExportEncryptedPkcs8PrivateKeyPem(ReadOnlySpan<System::Byte> passwordBytes, System::Security::Cryptography::PbeParameters ^ pbeParameters, Span<char> destination, [Runtime::InteropServices::Out] int % charsWritten);
public bool TryExportEncryptedPkcs8PrivateKeyPem (ReadOnlySpan<byte> passwordBytes, System.Security.Cryptography.PbeParameters pbeParameters, Span<char> destination, out int charsWritten);
member this.TryExportEncryptedPkcs8PrivateKeyPem : ReadOnlySpan<byte> * System.Security.Cryptography.PbeParameters * Span<char> * int -> bool
Public Function TryExportEncryptedPkcs8PrivateKeyPem (passwordBytes As ReadOnlySpan(Of Byte), pbeParameters As PbeParameters, destination As Span(Of Char), ByRef charsWritten As Integer) As Boolean

Parameters

passwordBytes
ReadOnlySpan<Byte>

The bytes to use as a password when encrypting the key material.

pbeParameters
PbeParameters

The password-based encryption (PBE) parameters to use when encrypting the key material.

destination
Span<Char>

The character span to receive the PEM-encoded PKCS#8 EncryptedPrivateKeyInfo data.

charsWritten
Int32

When this method returns, contains a value that indicates the number of characters written to destination. This parameter is treated as uninitialized.

Returns

true if destination is big enough to receive the output; otherwise, false.

Exceptions

The key could not be exported.

Remarks

A PEM-encoded PKCS#8 EncryptedPrivateKeyInfo will begin with -----BEGIN ENCRYPTED PRIVATE KEY----- and end with -----END ENCRYPTED PRIVATE KEY-----, with the base64 encoded DER contents of the key between the PEM boundaries.

The PEM is encoded according to the IETF RFC 7468 "strict" encoding rules.

Applies to

TryExportEncryptedPkcs8PrivateKeyPem(ReadOnlySpan<Char>, PbeParameters, Span<Char>, Int32)

Source:
AsymmetricAlgorithm.cs
Source:
AsymmetricAlgorithm.cs
Source:
AsymmetricAlgorithm.cs

Exports the current key in the PKCS#8 EncryptedPrivateKeyInfo format with a char-based password, PEM encoded.

public:
 bool TryExportEncryptedPkcs8PrivateKeyPem(ReadOnlySpan<char> password, System::Security::Cryptography::PbeParameters ^ pbeParameters, Span<char> destination, [Runtime::InteropServices::Out] int % charsWritten);
public bool TryExportEncryptedPkcs8PrivateKeyPem (ReadOnlySpan<char> password, System.Security.Cryptography.PbeParameters pbeParameters, Span<char> destination, out int charsWritten);
member this.TryExportEncryptedPkcs8PrivateKeyPem : ReadOnlySpan<char> * System.Security.Cryptography.PbeParameters * Span<char> * int -> bool
Public Function TryExportEncryptedPkcs8PrivateKeyPem (password As ReadOnlySpan(Of Char), pbeParameters As PbeParameters, destination As Span(Of Char), ByRef charsWritten As Integer) As Boolean

Parameters

password
ReadOnlySpan<Char>

The password to use when encrypting the key material.

pbeParameters
PbeParameters

The password-based encryption (PBE) parameters to use when encrypting the key material.

destination
Span<Char>

The character span to receive the PEM-encoded PKCS#8 EncryptedPrivateKeyInfo data.

charsWritten
Int32

When this method returns, contains a value that indicates the number of characters written to destination. This parameter is treated as uninitialized.

Returns

true if destination is big enough to receive the output; otherwise, false.

Exceptions

The key could not be exported.

Remarks

When pbeParameters indicates an algorithm that uses PBKDF2 (Password-Based Key Derivation Function 2), the password is converted to bytes via the UTF-8 encoding.

          A PEM-encoded PKCS#8 EncryptedPrivateKeyInfo will begin with
        `-----BEGIN ENCRYPTED PRIVATE KEY-----` and end with
        `-----END ENCRYPTED PRIVATE KEY-----`, with the base64 encoded DER
          contents of the key between the PEM boundaries.

          The PEM is encoded according to the IETF RFC 7468 "strict"
          encoding rules.

Applies to