本文整理汇总了C#中System.Security.Permissions.KeyContainerPermissionAccessEntry类的典型用法代码示例。如果您正苦于以下问题:C# KeyContainerPermissionAccessEntry类的具体用法?C# KeyContainerPermissionAccessEntry怎么用?C# KeyContainerPermissionAccessEntry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
KeyContainerPermissionAccessEntry类属于System.Security.Permissions命名空间,在下文中一共展示了KeyContainerPermissionAccessEntry类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Create
public static CngKey Create(CngAlgorithm algorithm, string keyName, CngKeyCreationParameters creationParameters)
{
if (algorithm == null)
{
throw new ArgumentNullException("algorithm");
}
if (creationParameters == null)
{
creationParameters = new CngKeyCreationParameters();
}
if (!NCryptNative.NCryptSupported)
{
throw new PlatformNotSupportedException(System.SR.GetString("Cryptography_PlatformNotSupported"));
}
if (keyName != null)
{
KeyContainerPermissionAccessEntry accessEntry = new KeyContainerPermissionAccessEntry(keyName, KeyContainerPermissionFlags.Create) {
ProviderName = creationParameters.Provider.Provider
};
KeyContainerPermission permission = new KeyContainerPermission(KeyContainerPermissionFlags.NoFlags);
permission.AccessEntries.Add(accessEntry);
permission.Demand();
}
SafeNCryptProviderHandle provider = NCryptNative.OpenStorageProvider(creationParameters.Provider.Provider);
SafeNCryptKeyHandle keyHandle = NCryptNative.CreatePersistedKey(provider, algorithm.Algorithm, keyName, creationParameters.KeyCreationOptions);
SetKeyProperties(keyHandle, creationParameters);
NCryptNative.FinalizeKey(keyHandle);
CngKey key = new CngKey(provider, keyHandle);
if (keyName == null)
{
key.IsEphemeral = true;
}
return key;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:34,代码来源:CngKey.cs
示例2: BuildKeyContainerPermission
internal KeyContainerPermission BuildKeyContainerPermission(KeyContainerPermissionFlags flags)
{
KeyContainerPermission permission = null;
if (this.IsEphemeral)
{
return permission;
}
string keyContainerName = null;
string str2 = null;
try
{
keyContainerName = this.KeyName;
str2 = NCryptNative.GetPropertyAsString(this.m_kspHandle, "Name", CngPropertyOptions.None);
}
catch (CryptographicException)
{
}
if (keyContainerName != null)
{
KeyContainerPermissionAccessEntry accessEntry = new KeyContainerPermissionAccessEntry(keyContainerName, flags) {
ProviderName = str2
};
permission = new KeyContainerPermission(KeyContainerPermissionFlags.NoFlags);
permission.AccessEntries.Add(accessEntry);
return permission;
}
return new KeyContainerPermission(flags);
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:28,代码来源:CngKey.cs
示例3: Remove
public void Remove(KeyContainerPermissionAccessEntry accessEntry)
{
if (accessEntry == null)
{
throw new ArgumentNullException("accessEntry");
}
this.m_list.Remove(accessEntry);
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:KeyContainerPermissionAccessEntryCollection.cs
示例4: KeyContainerPermission
public KeyContainerPermission (KeyContainerPermissionFlags flags, KeyContainerPermissionAccessEntry[] accessList)
{
SetFlags (flags);
if (accessList != null) {
foreach (KeyContainerPermissionAccessEntry kcpae in accessList) {
_accessEntries.Add (kcpae);
}
}
}
开发者ID:runefs,项目名称:Marvin,代码行数:9,代码来源:KeyContainerPermission.cs
示例5: Copy
// Methods
public override IPermission Copy ()
{
if (_accessEntries.Count == 0)
return new KeyContainerPermission (_flags);
KeyContainerPermissionAccessEntry[] list = new KeyContainerPermissionAccessEntry [_accessEntries.Count];
_accessEntries.CopyTo (list, 0);
return new KeyContainerPermission (_flags, list);
}
开发者ID:runefs,项目名称:Marvin,代码行数:11,代码来源:KeyContainerPermission.cs
示例6: KeyContainerPermissionAccessEntryCollection
internal KeyContainerPermissionAccessEntryCollection (KeyContainerPermissionAccessEntry[] entries)
: base ()
{
if (entries != null) {
foreach (KeyContainerPermissionAccessEntry kcpae in entries) {
Add (kcpae);
}
}
}
开发者ID:runefs,项目名称:Marvin,代码行数:9,代码来源:KeyContainerPermissionAccessEntryCollection.cs
示例7: KeyContainerPermission
public KeyContainerPermission(KeyContainerPermissionFlags flags, KeyContainerPermissionAccessEntry[] accessList)
{
if (accessList == null)
{
throw new ArgumentNullException("accessList");
}
VerifyFlags(flags);
this.m_flags = flags;
this.m_accessEntries = new KeyContainerPermissionAccessEntryCollection(this.m_flags);
for (int i = 0; i < accessList.Length; i++)
{
this.m_accessEntries.Add(accessList[i]);
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:14,代码来源:KeyContainerPermission.cs
示例8: CreatePermission
public override IPermission CreatePermission()
{
if (base.m_unrestricted)
{
return new KeyContainerPermission(PermissionState.Unrestricted);
}
if (KeyContainerPermissionAccessEntry.IsUnrestrictedEntry(this.m_keyStore, this.m_providerName, this.m_providerType, this.m_keyContainerName, this.m_keySpec))
{
return new KeyContainerPermission(this.m_flags);
}
KeyContainerPermission permission = new KeyContainerPermission(KeyContainerPermissionFlags.NoFlags);
KeyContainerPermissionAccessEntry accessEntry = new KeyContainerPermissionAccessEntry(this.m_keyStore, this.m_providerName, this.m_providerType, this.m_keyContainerName, this.m_keySpec, this.m_flags);
permission.AccessEntries.Add(accessEntry);
return permission;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:15,代码来源:KeyContainerPermissionAttribute.cs
示例9: CspKeyContainerInfo
[System.Security.SecurityCritical] // auto-generated
internal CspKeyContainerInfo (CspParameters parameters, bool randomKeyContainer) {
KeyContainerPermission kp = new KeyContainerPermission(KeyContainerPermissionFlags.NoFlags);
KeyContainerPermissionAccessEntry entry = new KeyContainerPermissionAccessEntry(parameters, KeyContainerPermissionFlags.Open);
kp.AccessEntries.Add(entry);
kp.Demand();
m_parameters = new CspParameters(parameters);
if (m_parameters.KeyNumber == -1) {
if (m_parameters.ProviderType == Constants.PROV_RSA_FULL || m_parameters.ProviderType == Constants.PROV_RSA_AES)
m_parameters.KeyNumber = Constants.AT_KEYEXCHANGE;
else if (m_parameters.ProviderType == Constants.PROV_DSS_DH)
m_parameters.KeyNumber = Constants.AT_SIGNATURE;
}
m_randomKeyContainer = randomKeyContainer;
}
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:16,代码来源:ICspAsymmetricAlgorithm.cs
示例10: Add
public int Add(KeyContainerPermissionAccessEntry accessEntry)
{
if (accessEntry == null)
{
throw new ArgumentNullException("accessEntry");
}
int index = this.m_list.IndexOf(accessEntry);
if (index == -1)
{
if (accessEntry.Flags != this.m_globalFlags)
{
return this.m_list.Add(accessEntry);
}
return -1;
}
KeyContainerPermissionAccessEntry entry1 = (KeyContainerPermissionAccessEntry) this.m_list[index];
entry1.Flags &= accessEntry.Flags;
return index;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:19,代码来源:KeyContainerPermissionAccessEntryCollection.cs
示例11: CspKeyContainerInfo
internal CspKeyContainerInfo(CspParameters parameters, bool randomKeyContainer)
{
KeyContainerPermission permission = new KeyContainerPermission(KeyContainerPermissionFlags.NoFlags);
KeyContainerPermissionAccessEntry accessEntry = new KeyContainerPermissionAccessEntry(parameters, KeyContainerPermissionFlags.Open);
permission.AccessEntries.Add(accessEntry);
permission.Demand();
this.m_parameters = new CspParameters(parameters);
if (this.m_parameters.KeyNumber == -1)
{
if ((this.m_parameters.ProviderType == 1) || (this.m_parameters.ProviderType == 0x18))
{
this.m_parameters.KeyNumber = 1;
}
else if (this.m_parameters.ProviderType == 13)
{
this.m_parameters.KeyNumber = 2;
}
}
this.m_randomKeyContainer = randomKeyContainer;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:20,代码来源:CspKeyContainerInfo.cs
示例12: Decrypt
public byte[] Decrypt(byte[] rgb, bool fOAEP)
{
if (rgb == null)
{
throw new ArgumentNullException("rgb");
}
this.GetKeyPair();
if (rgb.Length > (this.KeySize / 8))
{
throw new CryptographicException(Environment.GetResourceString("Cryptography_Padding_DecDataTooBig", new object[] { this.KeySize / 8 }));
}
if (!this.CspKeyContainerInfo.RandomlyGenerated)
{
KeyContainerPermission permission = new KeyContainerPermission(KeyContainerPermissionFlags.NoFlags);
KeyContainerPermissionAccessEntry accessEntry = new KeyContainerPermissionAccessEntry(this._parameters, KeyContainerPermissionFlags.Decrypt);
permission.AccessEntries.Add(accessEntry);
permission.Demand();
}
byte[] o = null;
DecryptKey(this._safeKeyHandle, rgb, rgb.Length, fOAEP, JitHelpers.GetObjectHandleOnStack<byte[]>(ref o));
return o;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:22,代码来源:RSACryptoServiceProvider.cs
示例13: IsSubsetOf
internal bool IsSubsetOf(KeyContainerPermissionAccessEntry target)
{
if ((target.m_keyStore != "*") && (this.m_keyStore != target.m_keyStore))
{
return false;
}
if ((target.m_providerName != "*") && (this.m_providerName != target.m_providerName))
{
return false;
}
if ((target.m_providerType != -1) && (this.m_providerType != target.m_providerType))
{
return false;
}
if ((target.m_keyContainerName != "*") && (this.m_keyContainerName != target.m_keyContainerName))
{
return false;
}
if ((target.m_keySpec != -1) && (this.m_keySpec != target.m_keySpec))
{
return false;
}
return true;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:24,代码来源:KeyContainerPermissionAccessEntry.cs
示例14: CryptAcquireContext
bool CryptAcquireContext(
[In,Out] ref SafeCryptProvHandle hCryptProv,
[In] [MarshalAs(UnmanagedType.LPStr)] string pwszContainer,
[In] [MarshalAs(UnmanagedType.LPStr)] string pwszProvider,
[In] uint dwProvType,
[In] uint dwFlags) {
CspParameters parameters = new CspParameters();
parameters.ProviderName = pwszProvider;
parameters.KeyContainerName = pwszContainer;
parameters.ProviderType = (int) dwProvType;
parameters.KeyNumber = -1;
parameters.Flags = (CspProviderFlags) ((dwFlags & CAPI.CRYPT_MACHINE_KEYSET) == CAPI.CRYPT_MACHINE_KEYSET ? CspProviderFlags.UseMachineKeyStore : 0);
#if !FEATURE_CORESYSTEM
if (!CompatibilitySwitches.IsAppEarlierThanWindowsPhone8) {
KeyContainerPermission kp = new KeyContainerPermission(KeyContainerPermissionFlags.NoFlags);
KeyContainerPermissionAccessEntry entry = new KeyContainerPermissionAccessEntry(parameters, KeyContainerPermissionFlags.Open);
kp.AccessEntries.Add(entry);
kp.Demand();
}
#endif
bool rc = CAPIMethods.CryptAcquireContext(ref hCryptProv,
pwszContainer,
pwszProvider,
dwProvType,
dwFlags);
if (!rc && Marshal.GetLastWin32Error() == CAPI.NTE_BAD_KEYSET) {
rc = CAPIMethods.CryptAcquireContext(ref hCryptProv,
pwszContainer,
pwszProvider,
dwProvType,
dwFlags | CAPI.CRYPT_NEWKEYSET);
}
return rc;
}
开发者ID:REALTOBIZ,项目名称:mono,代码行数:39,代码来源:cryptoapi.cs
示例15: GetApplicableFlags
private static KeyContainerPermissionFlags GetApplicableFlags (KeyContainerPermissionAccessEntry accessEntry, KeyContainerPermission target) {
KeyContainerPermissionFlags flags = KeyContainerPermissionFlags.NoFlags;
bool applyDefaultFlags = true;
// If the entry exists in the target, return the flag of the target entry.
int index = target.AccessEntries.IndexOf(accessEntry);
if (index != -1) {
flags = ((KeyContainerPermissionAccessEntry)target.AccessEntries[index]).Flags;
return flags;
}
// Intersect the flags in all the target entries that apply to the current access entry,
foreach (KeyContainerPermissionAccessEntry targetAccessEntry in target.AccessEntries) {
if (accessEntry.IsSubsetOf(targetAccessEntry)) {
if (applyDefaultFlags == false) {
flags &= targetAccessEntry.Flags;
} else {
flags = targetAccessEntry.Flags;
applyDefaultFlags = false;
}
}
}
// If no target entry applies to the current entry, the default global flag applies.
if (applyDefaultFlags)
flags = target.Flags;
return flags;
}
开发者ID:uQr,项目名称:referencesource,代码行数:29,代码来源:keycontainerpermission.cs
示例16: AddAccessEntryAndIntersect
private void AddAccessEntryAndIntersect (KeyContainerPermissionAccessEntry accessEntry, KeyContainerPermission target) {
KeyContainerPermissionAccessEntry newAccessEntry = new KeyContainerPermissionAccessEntry(accessEntry);
newAccessEntry.Flags &= GetApplicableFlags(accessEntry, target);
AccessEntries.Add(newAccessEntry);
}
开发者ID:uQr,项目名称:referencesource,代码行数:5,代码来源:keycontainerpermission.cs
示例17: AddAccessEntries
//
// private methods
//
private void AddAccessEntries(SecurityElement securityElement) {
if (securityElement.InternalChildren != null && securityElement.InternalChildren.Count != 0) {
IEnumerator elemEnumerator = securityElement.Children.GetEnumerator();
while (elemEnumerator.MoveNext()) {
SecurityElement current = (SecurityElement) elemEnumerator.Current;
if (current != null) {
if (String.Equals(current.Tag, "AccessEntry")) {
int iMax = current.m_lAttributes.Count;
Contract.Assert(iMax % 2 == 0, "Odd number of strings means the attr/value pairs were not added correctly");
string keyStore = null;
string providerName = null;
int providerType = -1;
string keyContainerName = null;
int keySpec = -1;
KeyContainerPermissionFlags flags = KeyContainerPermissionFlags.NoFlags;
for (int i = 0; i < iMax; i += 2) {
String strAttrName = (String) current.m_lAttributes[i];
String strAttrValue = (String) current.m_lAttributes[i+1];
if (String.Equals(strAttrName, "KeyStore"))
keyStore = strAttrValue;
if (String.Equals(strAttrName, "ProviderName"))
providerName = strAttrValue;
else if (String.Equals(strAttrName, "ProviderType"))
providerType = Convert.ToInt32(strAttrValue, null);
else if (String.Equals(strAttrName, "KeyContainerName"))
keyContainerName = strAttrValue;
else if (String.Equals(strAttrName, "KeySpec"))
keySpec = Convert.ToInt32(strAttrValue, null);
else if (String.Equals(strAttrName, "Flags")) {
flags = (KeyContainerPermissionFlags) Enum.Parse(typeof(KeyContainerPermissionFlags), strAttrValue);
}
}
KeyContainerPermissionAccessEntry accessEntry = new KeyContainerPermissionAccessEntry(keyStore, providerName, providerType, keyContainerName, keySpec, flags);
AccessEntries.Add(accessEntry);
}
}
}
}
}
开发者ID:uQr,项目名称:referencesource,代码行数:43,代码来源:keycontainerpermission.cs
示例18: KeyContainerPermissionAccessEntry
internal KeyContainerPermissionAccessEntry(KeyContainerPermissionAccessEntry accessEntry) :
this (accessEntry.KeyStore, accessEntry.ProviderName, accessEntry.ProviderType, accessEntry.KeyContainerName,
accessEntry.KeySpec, accessEntry.Flags) {
}
开发者ID:uQr,项目名称:referencesource,代码行数:4,代码来源:keycontainerpermission.cs
示例19: Remove
public void Remove (KeyContainerPermissionAccessEntry accessEntry)
{
if (accessEntry == null)
throw new ArgumentNullException ("accessEntry");
for (int i=0; i < _list.Count; i++) {
if (accessEntry.Equals (_list [i]))
_list.RemoveAt (i);
}
}
开发者ID:runefs,项目名称:Marvin,代码行数:10,代码来源:KeyContainerPermissionAccessEntryCollection.cs
示例20: Remove
public void Remove (KeyContainerPermissionAccessEntry accessEntry) {
if (accessEntry == null)
throw new ArgumentNullException("accessEntry");
Contract.EndContractBlock();
m_list.Remove(accessEntry);
}
开发者ID:uQr,项目名称:referencesource,代码行数:6,代码来源:keycontainerpermission.cs
注:本文中的System.Security.Permissions.KeyContainerPermissionAccessEntry类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论