AsymmetricAlgorithm.TryExportEncryptedPkcs8PrivateKey 方法

定义

重载

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

在派生的类中替代时,尝试使用基于字节的密码以 PKCS#8 EncryptedPrivateKeyInfo 格式将当前密钥导出到所提供的缓冲区。

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

在派生的类中替代时,尝试使用基于字符的密码以 PKCS#8 EncryptedPrivateKeyInfo 格式将当前密钥导出到所提供的缓冲区。

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

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

在派生的类中替代时,尝试使用基于字节的密码以 PKCS#8 EncryptedPrivateKeyInfo 格式将当前密钥导出到所提供的缓冲区。

C#
public virtual bool TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan<byte> passwordBytes, System.Security.Cryptography.PbeParameters pbeParameters, Span<byte> destination, out int bytesWritten);

参数

passwordBytes
ReadOnlySpan<Byte>

加密密钥材料时用作密码的字节。

pbeParameters
PbeParameters

加密密钥材料时使用的基于密码加密 (PBE) 参数。

destination
Span<Byte>

接收 PKCS#8 EncryptedPrivateKeyInfo 数据的字节范围。

bytesWritten
Int32

此方法返回时,包含一个指示写入 destination 的字节数的值。 该参数未经初始化即被处理。

返回

如果 destination 具有足够的大小以接收输出,则为 true;否则为 false

例外

未能导出密钥。

pbeParameters 指示应使用需要基于 Char 密码的 TripleDes3KeyPkcs12

派生的类型未替代此成员。

注解

密码字节直接传递到由 指示 pbeParameters的算法使用的密钥派生函数 (KDF) 。 当使用 PBKDF2 (基于密码的密钥派生函数 2) 处理密码时,这样可以与使用 UTF-8 以外的文本编码的其他系统兼容。

由于生成此数据格式需要特定于算法的支持, TryExportEncryptedPkcs8PrivateKey 默认情况下会 NotImplementedException 引发 。

另请参阅

适用于

.NET 10 和其他版本
产品 版本
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Standard 2.1

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

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

在派生的类中替代时,尝试使用基于字符的密码以 PKCS#8 EncryptedPrivateKeyInfo 格式将当前密钥导出到所提供的缓冲区。

C#
public virtual bool TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan<char> password, System.Security.Cryptography.PbeParameters pbeParameters, Span<byte> destination, out int bytesWritten);

参数

password
ReadOnlySpan<Char>

加密密钥材料时使用的密码。

pbeParameters
PbeParameters

加密密钥材料时使用的基于密码加密 (PBE) 参数。

destination
Span<Byte>

接收 PKCS#8 EncryptedPrivateKeyInfo 数据的字节范围。

bytesWritten
Int32

此方法返回时,包含一个指示写入 destination 的字节数的值。 该参数未经初始化即被处理。

返回

如果 destination 具有足够的大小以接收输出,则为 true;否则为 false

例外

未能导出密钥。

派生的类型未替代此成员。

注解

pbeParameters 指示使用 PBKDF2 (基于密码的密钥派生函数 2) 的算法时,密码将通过 UTF-8 编码转换为字节。

由于生成此数据格式需要特定于算法的支持, TryExportEncryptedPkcs8PrivateKey 默认情况下会 NotImplementedException 引发 。

另请参阅

适用于

.NET 10 和其他版本
产品 版本
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Standard 2.1