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)

注解

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

适用于