CngKey.Exists 方法

定义

检查特定密钥存储提供程序 (KSP) 中是否存在已命名的密钥。Checks for a named key in a specific key storage provider(KSP).

重载

Exists(String, CngProvider, CngKeyOpenOptions)

根据指定的选项,检查指定的密钥存储提供程序 (KSP) 中是否存在已命名的密钥。Checks to see whether a named key exists in the specified key storage provider (KSP), according to the specified options.

Exists(String)

检查默认的密钥存储提供程序 (KSP) 中是否存在已命名的密钥。Checks to see whether a named key exists in the default key storage provider (KSP).

Exists(String, CngProvider)

检查指定的密钥存储提供程序 (KSP) 中是否存在已命名的密钥。Checks to see whether a named key exists in the specified key storage provider (KSP).

Exists(String, CngProvider, CngKeyOpenOptions)

根据指定的选项,检查指定的密钥存储提供程序 (KSP) 中是否存在已命名的密钥。Checks to see whether a named key exists in the specified key storage provider (KSP), according to the specified options.

public:
 static bool Exists(System::String ^ keyName, System::Security::Cryptography::CngProvider ^ provider, System::Security::Cryptography::CngKeyOpenOptions options);
public static bool Exists (string keyName, System.Security.Cryptography.CngProvider provider, System.Security.Cryptography.CngKeyOpenOptions options);
[System.Security.SecurityCritical]
public static bool Exists (string keyName, System.Security.Cryptography.CngProvider provider, System.Security.Cryptography.CngKeyOpenOptions options);
static member Exists : string * System.Security.Cryptography.CngProvider * System.Security.Cryptography.CngKeyOpenOptions -> bool
[<System.Security.SecurityCritical>]
static member Exists : string * System.Security.Cryptography.CngProvider * System.Security.Cryptography.CngKeyOpenOptions -> bool
Public Shared Function Exists (keyName As String, provider As CngProvider, options As CngKeyOpenOptions) As Boolean

参数

keyName
String

键名称。The key name.

provider
CngProvider

用于搜索密钥的 KSP。The KSP to search for the key.

options
CngKeyOpenOptions

指定密钥打开选项的枚举值的按位组合。A bitwise combination of the enumeration values that specify options for opening a key.

返回

Boolean

如果指定的提供程序中存在该已命名的密钥,则为 true;否则为 falsetrue if the named key exists in the specified provider; otherwise, false.

属性

例外

keyNameprovidernullkeyName or provider is null.

此系统上不支持下一代加密技术 (CNG)。Cryptography Next Generation (CNG) is not supported on this system.

所有其他错误。All other errors.

注解

使用此重载检查默认情况下的 KSP 中是否存在密钥 MicrosoftSoftwareKeyStorageProvider ,并指定密钥打开选项。Use this overload to check for the existence of a key in a KSP other than the default MicrosoftSoftwareKeyStorageProvider, and to specify key open options.

适用于

Exists(String)

检查默认的密钥存储提供程序 (KSP) 中是否存在已命名的密钥。Checks to see whether a named key exists in the default key storage provider (KSP).

public:
 static bool Exists(System::String ^ keyName);
public static bool Exists (string keyName);
static member Exists : string -> bool
Public Shared Function Exists (keyName As String) As Boolean

参数

keyName
String

键名称。The key name.

返回

Boolean

如果默认的 KSP 中存在该已命名的密钥,则为 true;否则为 falsetrue if the named key exists in the default KSP; otherwise, false.

例外

keyNamenullkeyName is null.

此系统上不支持下一代加密技术 (CNG)。Cryptography Next Generation (CNG) is not supported on this system.

所有其他错误。All other errors.

注解

默认 KSP 是 MicrosoftSoftwareKeyStorageProviderThe default KSP is MicrosoftSoftwareKeyStorageProvider.

适用于

Exists(String, CngProvider)

检查指定的密钥存储提供程序 (KSP) 中是否存在已命名的密钥。Checks to see whether a named key exists in the specified key storage provider (KSP).

public:
 static bool Exists(System::String ^ keyName, System::Security::Cryptography::CngProvider ^ provider);
public static bool Exists (string keyName, System.Security.Cryptography.CngProvider provider);
static member Exists : string * System.Security.Cryptography.CngProvider -> bool
Public Shared Function Exists (keyName As String, provider As CngProvider) As Boolean

参数

keyName
String

键名称。The key name.

provider
CngProvider

用于检查密钥的 KSP。The KSP to check for the key.

返回

Boolean

如果指定的提供程序中存在该已命名的密钥,则为 true;否则为 falsetrue if the named key exists in the specified provider; otherwise, false.

例外

keyNameprovidernullkeyName or provider is null.

此系统上不支持下一代加密技术 (CNG)。Cryptography Next Generation (CNG) is not supported on this system.

所有其他错误。All other errors.

注解

使用此重载检查默认 KSP (即)中是否存在密钥 MicrosoftSoftwareKeyStorageProviderUse this overload to check for the existence of a key in a KSP other than the default KSP, which is MicrosoftSoftwareKeyStorageProvider.

适用于