CspProviderFlags 枚举


指定修改加密服务提供程序 (CSP) 行为的标志。Specifies flags that modify the behavior of the cryptographic service providers (CSP).

此枚举有一个 FlagsAttribute 属性,允许按位组合成员值。

public enum class CspProviderFlags
public enum CspProviderFlags
type CspProviderFlags = 
Public Enum CspProviderFlags


CreateEphemeralKey 128

创建一个在关闭关联的 Rivest-Shamir-Adleman (RSA) 对象时释放的临时密钥。Create a temporary key that is released when the associated Rivest-Shamir-Adleman (RSA) object is closed. 如果希望密钥与 RSA 对象无关,则不要使用此标志。Do not use this flag if you want your key to be independent of the RSA object.

NoFlags 0

不指定任何设置。Do not specify any settings.

NoPrompt 64

防止 CSP 显示此上下文的任何用户界面 (UI)。Prevent the CSP from displaying any user interface (UI) for this context.

UseArchivableKey 16

允许导出密钥以便存档或恢复。Allow a key to be exported for archival or recovery.

UseDefaultKeyContainer 2

使用默认密钥容器中的密钥信息。Use key information from the default key container.

UseExistingKey 8

使用当前密钥中的密钥信息。Use key information from the current key.

UseMachineKeyStore 1

使用计算机的密钥存储区中的密钥信息。Use key information from the computer's key store.

UseNonExportableKey 4

使用无法导出的密钥信息。Use key information that cannot be exported.

UseUserProtectedKey 32

当某些操作尝试使用密钥时,通过对话框或另一种方法通知用户。Notify the user through a dialog box or another method when certain actions are attempting to use a key. 此标志与 NoPrompt 标志不兼容。This flag is not compatible with the NoPrompt flag.



CreateEphemeralKey标志提供具有更可靠清理的临时密钥。The CreateEphemeralKey flag provides temporary keys with more reliable cleanup. 如果未使用此标志, 公共语言运行时 (CLR) 将在创建 RSA 对象时生成一个随机命名的键。If this flag is not used, the common language runtime (CLR) generates a randomly named key when an RSA object is created. 完成或处置对象后, 将删除该密钥。When the object is finalized or disposed of, the key is deleted. 当模拟有效时, 未显式调用Dispose可能会产生问题。When impersonation is in effect, not explicitly calling Dispose can potentially create a problem. 例如, 如果使用模拟, 创建一个 RSA 对象, 但不释放它, 则终结器线程 (未模拟) 可能无法删除该密钥, 然后引发异常。For example, if you use impersonation, create an RSA object, and do not dispose of it, the finalizer thread (which is not impersonating) can fail to delete the key, and then throws an exception. 此异常未经处理, 可以终止进程。This exception is unhandled and can terminate the process. 不会恢复分配给密钥的资源, 从而导致内存泄露。The resources allocated to the key are not recovered, resulting in a memory leak. KeyContainerPermission标志禁止该需求。The KeyContainerPermission demand is suppressed by this flag.