MLKem.ImportFromEncryptedPem Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
| ImportFromEncryptedPem(ReadOnlySpan<Char>, ReadOnlySpan<Byte>) |
Imports an ML-KEM key from an encrypted RFC 7468 PEM-encoded string. |
| ImportFromEncryptedPem(ReadOnlySpan<Char>, ReadOnlySpan<Char>) |
Imports an ML-KEM key from an encrypted RFC 7468 PEM-encoded string. |
| ImportFromEncryptedPem(String, Byte[]) |
Imports an ML-KEM key from an encrypted RFC 7468 PEM-encoded string. |
| ImportFromEncryptedPem(String, String) |
Imports an ML-KEM key from an encrypted RFC 7468 PEM-encoded string. |
ImportFromEncryptedPem(ReadOnlySpan<Char>, ReadOnlySpan<Byte>)
- Source:
- MLKem.cs
- Source:
- MLKem.cs
Imports an ML-KEM key from an encrypted RFC 7468 PEM-encoded string.
public:
static System::Security::Cryptography::MLKem ^ ImportFromEncryptedPem(ReadOnlySpan<char> source, ReadOnlySpan<System::Byte> passwordBytes);
[System.Diagnostics.CodeAnalysis.Experimental("SYSLIB5006", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public static System.Security.Cryptography.MLKem ImportFromEncryptedPem(ReadOnlySpan<char> source, ReadOnlySpan<byte> passwordBytes);
public static System.Security.Cryptography.MLKem ImportFromEncryptedPem(ReadOnlySpan<char> source, ReadOnlySpan<byte> passwordBytes);
[<System.Diagnostics.CodeAnalysis.Experimental("SYSLIB5006", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
static member ImportFromEncryptedPem : ReadOnlySpan<char> * ReadOnlySpan<byte> -> System.Security.Cryptography.MLKem
static member ImportFromEncryptedPem : ReadOnlySpan<char> * ReadOnlySpan<byte> -> System.Security.Cryptography.MLKem
Public Shared Function ImportFromEncryptedPem (source As ReadOnlySpan(Of Char), passwordBytes As ReadOnlySpan(Of Byte)) As MLKem
Parameters
- source
- ReadOnlySpan<Char>
The PEM text of the encrypted key to import.
- passwordBytes
- ReadOnlySpan<Byte>
The password to use for decrypting the key material.
Returns
- Attributes
Exceptions
source does not contain a PEM-encoded key with a recognized label.
-or-
source contains multiple PEM-encoded keys with a recognized label.
The password is incorrect.
-or-
The base-64 decoded contents of the PEM text from source do not represent an ASN.1-BER-encoded PKCS#8 EncryptedPrivateKeyInfo structure.
-or-
The base-64 decoded contents of the PEM text from source indicate the key is for an algorithm other than the algorithm represented by this instance.
-or-
The base-64 decoded contents of the PEM text from source represent the key in a format that is not supported.
-or-
An error occurred while importing the key.
Remarks
Unsupported or malformed PEM-encoded objects will be ignored. If multiple supported PEM labels are found, an exception is thrown to prevent importing a key when the key is ambiguous.
This method supports the ENCRYPTED PRIVATE KEY PEM label.
Applies to
ImportFromEncryptedPem(ReadOnlySpan<Char>, ReadOnlySpan<Char>)
- Source:
- MLKem.cs
- Source:
- MLKem.cs
Imports an ML-KEM key from an encrypted RFC 7468 PEM-encoded string.
public:
static System::Security::Cryptography::MLKem ^ ImportFromEncryptedPem(ReadOnlySpan<char> source, ReadOnlySpan<char> password);
[System.Diagnostics.CodeAnalysis.Experimental("SYSLIB5006", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public static System.Security.Cryptography.MLKem ImportFromEncryptedPem(ReadOnlySpan<char> source, ReadOnlySpan<char> password);
public static System.Security.Cryptography.MLKem ImportFromEncryptedPem(ReadOnlySpan<char> source, ReadOnlySpan<char> password);
[<System.Diagnostics.CodeAnalysis.Experimental("SYSLIB5006", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
static member ImportFromEncryptedPem : ReadOnlySpan<char> * ReadOnlySpan<char> -> System.Security.Cryptography.MLKem
static member ImportFromEncryptedPem : ReadOnlySpan<char> * ReadOnlySpan<char> -> System.Security.Cryptography.MLKem
Public Shared Function ImportFromEncryptedPem (source As ReadOnlySpan(Of Char), password As ReadOnlySpan(Of Char)) As MLKem
Parameters
- source
- ReadOnlySpan<Char>
The PEM text of the encrypted key to import.
- password
- ReadOnlySpan<Char>
The password to use for decrypting the key material.
Returns
- Attributes
Exceptions
source does not contain a PEM-encoded key with a recognized label.
-or-
source contains multiple PEM-encoded keys with a recognized label.
The password is incorrect.
-or-
The base-64 decoded contents of the PEM text from source do not represent an ASN.1-BER-encoded PKCS#8 EncryptedPrivateKeyInfo structure.
-or-
The base-64 decoded contents of the PEM text from source indicate the key is for an algorithm other than the algorithm represented by this instance.
-or-
The base-64 decoded contents of the PEM text from source represent the key in a format that is not supported.
-or-
An error occurred while importing the key.
Remarks
When the base-64 decoded 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.
Unsupported or malformed PEM-encoded objects will be ignored. If multiple supported PEM labels are found, an exception is thrown to prevent importing a key when the key is ambiguous.
This method supports the ENCRYPTED PRIVATE KEY PEM label.
Applies to
ImportFromEncryptedPem(String, Byte[])
- Source:
- MLKem.cs
- Source:
- MLKem.cs
Imports an ML-KEM key from an encrypted RFC 7468 PEM-encoded string.
public:
static System::Security::Cryptography::MLKem ^ ImportFromEncryptedPem(System::String ^ source, cli::array <System::Byte> ^ passwordBytes);
[System.Diagnostics.CodeAnalysis.Experimental("SYSLIB5006", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public static System.Security.Cryptography.MLKem ImportFromEncryptedPem(string source, byte[] passwordBytes);
public static System.Security.Cryptography.MLKem ImportFromEncryptedPem(string source, byte[] passwordBytes);
[<System.Diagnostics.CodeAnalysis.Experimental("SYSLIB5006", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
static member ImportFromEncryptedPem : string * byte[] -> System.Security.Cryptography.MLKem
static member ImportFromEncryptedPem : string * byte[] -> System.Security.Cryptography.MLKem
Public Shared Function ImportFromEncryptedPem (source As String, passwordBytes As Byte()) As MLKem
Parameters
- source
- String
The PEM text of the encrypted key to import.
- passwordBytes
- Byte[]
The password to use for decrypting the key material.
Returns
- Attributes
Exceptions
source or passwordBytes is null
Applies to
ImportFromEncryptedPem(String, String)
- Source:
- MLKem.cs
- Source:
- MLKem.cs
Imports an ML-KEM key from an encrypted RFC 7468 PEM-encoded string.
public:
static System::Security::Cryptography::MLKem ^ ImportFromEncryptedPem(System::String ^ source, System::String ^ password);
[System.Diagnostics.CodeAnalysis.Experimental("SYSLIB5006", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public static System.Security.Cryptography.MLKem ImportFromEncryptedPem(string source, string password);
public static System.Security.Cryptography.MLKem ImportFromEncryptedPem(string source, string password);
[<System.Diagnostics.CodeAnalysis.Experimental("SYSLIB5006", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
static member ImportFromEncryptedPem : string * string -> System.Security.Cryptography.MLKem
static member ImportFromEncryptedPem : string * string -> System.Security.Cryptography.MLKem
Public Shared Function ImportFromEncryptedPem (source As String, password As String) As MLKem
Parameters
- source
- String
The PEM text of the encrypted key to import.
- password
- String
The password to use for decrypting the key material.
Returns
- Attributes
Exceptions
source or password is null