Edit

Share via


Pkcs8PrivateKeyInfo.DecryptAndDecode Method

Definition

Overloads

DecryptAndDecode(ReadOnlySpan<Byte>, ReadOnlyMemory<Byte>, Int32)

Decrypts the provided data using the provided byte-based password and decodes the output into an object view of the PKCS#8 PrivateKeyInfo.

DecryptAndDecode(ReadOnlySpan<Char>, ReadOnlyMemory<Byte>, Int32)

Decrypts the provided data using the provided character-based password and decodes the output into an object view of the PKCS#8 PrivateKeyInfo.

DecryptAndDecode(ReadOnlySpan<Byte>, ReadOnlyMemory<Byte>, Int32)

Source:
Pkcs8PrivateKeyInfo.cs
Source:
Pkcs8PrivateKeyInfo.cs
Source:
Pkcs8PrivateKeyInfo.cs
Source:
Pkcs8PrivateKeyInfo.cs
Source:
Pkcs8PrivateKeyInfo.cs

Decrypts the provided data using the provided byte-based password and decodes the output into an object view of the PKCS#8 PrivateKeyInfo.

public:
 static System::Security::Cryptography::Pkcs::Pkcs8PrivateKeyInfo ^ DecryptAndDecode(ReadOnlySpan<System::Byte> passwordBytes, ReadOnlyMemory<System::Byte> source, [Runtime::InteropServices::Out] int % bytesRead);
public static System.Security.Cryptography.Pkcs.Pkcs8PrivateKeyInfo DecryptAndDecode (ReadOnlySpan<byte> passwordBytes, ReadOnlyMemory<byte> source, out int bytesRead);
static member DecryptAndDecode : ReadOnlySpan<byte> * ReadOnlyMemory<byte> * int -> System.Security.Cryptography.Pkcs.Pkcs8PrivateKeyInfo
Public Shared Function DecryptAndDecode (passwordBytes As ReadOnlySpan(Of Byte), source As ReadOnlyMemory(Of Byte), ByRef bytesRead As Integer) As Pkcs8PrivateKeyInfo

Parameters

passwordBytes
ReadOnlySpan<Byte>

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

source
ReadOnlyMemory<Byte>

The data to read as a PKCS#8 EncryptedPrivateKeyInfo structure in the ASN.1-BER encoding.

bytesRead
Int32

When this method returns, contains a value that indicates the number of bytes read from source. This parameter is treated as uninitialized.

Returns

An object view of the contents decrypted decoded as a PKCS#8 PrivateKeyInfo.

Exceptions

The password is incorrect.

-or-

The contents of source indicate the Key Derivation Function (KDF) to apply is the legacy PKCS#12 KDF, which requires Char-based passwords.

-or-

The contents of source do not represent an ASN.1-BER-encoded PKCS#8 EncryptedPrivateKeyInfo structure.

Remarks

The password bytes are passed directly into the Key Derivation Function (KDF) used by the algorithm indicated by pbeParameters. This enables compatibility with other systems which use a text encoding other than UTF-8 when processing passwords with PBKDF2 (Password-Based Key Derivation Function 2).

This method only supports the binary (BER/CER/DER) encoding of EncryptedPrivateKeyInfo. If the value is Base64-encoded or in the PEM text format, the caller must Base64-decode the contents before calling this method.

Applies to

DecryptAndDecode(ReadOnlySpan<Char>, ReadOnlyMemory<Byte>, Int32)

Source:
Pkcs8PrivateKeyInfo.cs
Source:
Pkcs8PrivateKeyInfo.cs
Source:
Pkcs8PrivateKeyInfo.cs
Source:
Pkcs8PrivateKeyInfo.cs
Source:
Pkcs8PrivateKeyInfo.cs

Decrypts the provided data using the provided character-based password and decodes the output into an object view of the PKCS#8 PrivateKeyInfo.

public:
 static System::Security::Cryptography::Pkcs::Pkcs8PrivateKeyInfo ^ DecryptAndDecode(ReadOnlySpan<char> password, ReadOnlyMemory<System::Byte> source, [Runtime::InteropServices::Out] int % bytesRead);
public static System.Security.Cryptography.Pkcs.Pkcs8PrivateKeyInfo DecryptAndDecode (ReadOnlySpan<char> password, ReadOnlyMemory<byte> source, out int bytesRead);
static member DecryptAndDecode : ReadOnlySpan<char> * ReadOnlyMemory<byte> * int -> System.Security.Cryptography.Pkcs.Pkcs8PrivateKeyInfo
Public Shared Function DecryptAndDecode (password As ReadOnlySpan(Of Char), source As ReadOnlyMemory(Of Byte), ByRef bytesRead As Integer) As Pkcs8PrivateKeyInfo

Parameters

password
ReadOnlySpan<Char>

The password to use when decrypting the key material.

source
ReadOnlyMemory<Byte>

The bytes of a PKCS#8 EncryptedPrivateKeyInfo structure in the ASN.1-BER encoding.

bytesRead
Int32

When this method returns, contains a value that indicates the number of bytes read from source. This parameter is treated as uninitialized.

Returns

An object view of the contents decrypted decoded as a PKCS#8 PrivateKeyInfo.

Remarks

When the contents of source indicate an algorithm that uses PBKDF1 (Password-Based Key Derivation Function 1) or PBKDF2 (Password-Based Key Derivation Function 2), the password is converted to bytes via the UTF-8 encoding.

This method only supports the binary (BER/CER/DER) encoding of EncryptedPrivateKeyInfo. If the value is Base64-encoded or in the PEM text format, the caller must Base64-decode the contents before calling this method.

See also

Applies to