Edit

Share via


SlhDsa.TryExportEncryptedPkcs8PrivateKey Method

Definition

Overloads

TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan<Byte>, PbeParameters, Span<Byte>, Int32)

Attempts to export the current key in the PKCS#8 EncryptedPrivateKeyInfo format into a provided buffer, using a byte-based password.

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

Attempts to export the current key in the PKCS#8 EncryptedPrivateKeyInfo format into a provided buffer, using a char-based password.

TryExportEncryptedPkcs8PrivateKey(String, PbeParameters, Span<Byte>, Int32)

Attempts to export the current key in the PKCS#8 EncryptedPrivateKeyInfo format into a provided buffer, using a char-based password.

TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan<Byte>, PbeParameters, Span<Byte>, Int32)

Source:
SlhDsa.cs
Source:
SlhDsa.cs

Attempts to export the current key in the PKCS#8 EncryptedPrivateKeyInfo format into a provided buffer, using a byte-based password.

public:
 bool TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan<System::Byte> passwordBytes, System::Security::Cryptography::PbeParameters ^ pbeParameters, Span<System::Byte> destination, [Runtime::InteropServices::Out] int % bytesWritten);
public bool TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan<byte> passwordBytes, System.Security.Cryptography.PbeParameters pbeParameters, Span<byte> destination, out int bytesWritten);
member this.TryExportEncryptedPkcs8PrivateKey : ReadOnlySpan<byte> * System.Security.Cryptography.PbeParameters * Span<byte> * int -> bool
Public Function TryExportEncryptedPkcs8PrivateKey (passwordBytes As ReadOnlySpan(Of Byte), pbeParameters As PbeParameters, destination As Span(Of Byte), ByRef bytesWritten 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<Byte>

The buffer to receive the PKCS#8 EncryptedPrivateKeyInfo value.

bytesWritten
Int32

When this method returns, contains the number of bytes written to the destination buffer.

This parameter is treated as uninitialized.

Returns

true if destination was large enough to hold the result; otherwise, false.

Exceptions

pbeParameters is null.

This instance has been disposed.

pbeParameters specifies a KDF that requires a char-based password.

-or-

pbeParameters does not represent a valid password-based encryption algorithm.

-or-

This instance only represents a public key.

-or-

The private key is not exportable.

-or-

An error occurred while exporting the key.

Applies to

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

Source:
SlhDsa.cs
Source:
SlhDsa.cs

Attempts to export the current key in the PKCS#8 EncryptedPrivateKeyInfo format into a provided buffer, using a char-based password.

public:
 bool TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan<char> password, System::Security::Cryptography::PbeParameters ^ pbeParameters, Span<System::Byte> destination, [Runtime::InteropServices::Out] int % bytesWritten);
public bool TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan<char> password, System.Security.Cryptography.PbeParameters pbeParameters, Span<byte> destination, out int bytesWritten);
member this.TryExportEncryptedPkcs8PrivateKey : ReadOnlySpan<char> * System.Security.Cryptography.PbeParameters * Span<byte> * int -> bool
Public Function TryExportEncryptedPkcs8PrivateKey (password As ReadOnlySpan(Of Char), pbeParameters As PbeParameters, destination As Span(Of Byte), ByRef bytesWritten 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<Byte>

The buffer to receive the PKCS#8 EncryptedPrivateKeyInfo value.

bytesWritten
Int32

When this method returns, contains the number of bytes written to the destination buffer.

This parameter is treated as uninitialized.

Returns

true if destination was large enough to hold the result; otherwise, false.

Exceptions

pbeParameters is null.

This instance has been disposed.

pbeParameters does not represent a valid password-based encryption algorithm.

-or-

This instance only represents a public key.

-or-

The private key is not exportable.

-or-

An error occurred while exporting the key.

Applies to

TryExportEncryptedPkcs8PrivateKey(String, PbeParameters, Span<Byte>, Int32)

Source:
SlhDsa.cs

Attempts to export the current key in the PKCS#8 EncryptedPrivateKeyInfo format into a provided buffer, using a char-based password.

public:
 bool TryExportEncryptedPkcs8PrivateKey(System::String ^ password, System::Security::Cryptography::PbeParameters ^ pbeParameters, Span<System::Byte> destination, [Runtime::InteropServices::Out] int % bytesWritten);
public bool TryExportEncryptedPkcs8PrivateKey(string password, System.Security.Cryptography.PbeParameters pbeParameters, Span<byte> destination, out int bytesWritten);
member this.TryExportEncryptedPkcs8PrivateKey : string * System.Security.Cryptography.PbeParameters * Span<byte> * int -> bool
Public Function TryExportEncryptedPkcs8PrivateKey (password As String, pbeParameters As PbeParameters, destination As Span(Of Byte), ByRef bytesWritten As Integer) As Boolean

Parameters

password
String

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<Byte>

The buffer to receive the PKCS#8 EncryptedPrivateKeyInfo value.

bytesWritten
Int32

When this method returns, contains the number of bytes written to the destination buffer.

This parameter is treated as uninitialized.

Returns

true if destination was large enough to hold the result; otherwise, false.

Exceptions

password or pbeParameters is null.

Applies to