KeyNumber 枚举

定义

指定是创建非对称签名密钥还是非对称交换密钥。Specifies whether to create an asymmetric signature key or an asymmetric exchange key.

public enum class KeyNumber
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public enum KeyNumber
type KeyNumber = 
Public Enum KeyNumber
继承
KeyNumber
属性

字段

Exchange 1

一个交换密钥对,用于加密会话密钥,以便可以安全地存储以及与其他用户交换会话密钥。An exchange key pair used to encrypt session keys so that they can be safely stored and exchanged with other users. 此值对应于非托管 Microsoft 加密 API (CAPI) 中使用的 AT_KEYEXCHANGE 值。This value corresponds to the AT_KEYEXCHANGE value used in the unmanaged Microsoft Cryptographic API (CAPI).

Signature 2

一个签名密钥对,用于对数字签名的消息或文件进行身份验证。A signature key pair used for authenticating digitally signed messages or files. 此值对应于非托管 Microsoft 加密 API (CAPI) 中使用的 AT_SIGNATURE 值。This value corresponds to the AT_SIGNATURE value used in the unmanaged Microsoft Cryptographic API (CAPI).

示例

下面的代码示例演示如何使用 KeyNumber 枚举为 RSACryptoServiceProvider 对象指定密钥类型。The following code example demonstrates how to use the KeyNumber enumeration to specify a key type for an RSACryptoServiceProvider object.

// Create a new CspParameters object.
CspParameters^ cspParams = gcnew CspParameters();

// Specify an exchange key.
cspParams->KeyNumber = (int) KeyNumber::Exchange;

// Initialize the RSACryptoServiceProvider
// with the CspParameters object.
RSACryptoServiceProvider^ RSACSP = gcnew RSACryptoServiceProvider(cspParams);
// Create a new CspParameters object.
CspParameters cspParams = new CspParameters();

// Specify an exchange key.
cspParams.KeyNumber = (int) KeyNumber.Exchange;

// Initialize the RSACryptoServiceProvider  
// with the CspParameters object.
RSACryptoServiceProvider RSACSP = new RSACryptoServiceProvider(cspParams);
' Create a new CspParameters object.
Dim cspParams As New CspParameters()

' Specify an exchange key.
cspParams.KeyNumber = Fix(KeyNumber.Exchange)

' Initialize the RSACryptoServiceProvider  
' with the CspParameters object.
Dim RSACSP As New RSACryptoServiceProvider(cspParams)

注解

使用带有 CspKeyContainerInfo.KeyNumber 属性的 KeyNumber 枚举来检查键类型或使用 CspParameters.KeyNumber 字段来指定密钥类型。Use the KeyNumber enumeration with the CspKeyContainerInfo.KeyNumber property to inspect a key type or with the CspParameters.KeyNumber field to specify a key type.

适用于