本文整理汇总了C#中CspProviderFlags类的典型用法代码示例。如果您正苦于以下问题:C# CspProviderFlags类的具体用法?C# CspProviderFlags怎么用?C# CspProviderFlags使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CspProviderFlags类属于命名空间,在下文中一共展示了CspProviderFlags类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CspParameters
internal CspParameters(int providerType, string providerName, string keyContainerName, CspProviderFlags flags)
{
this.ProviderType = providerType;
this.ProviderName = providerName;
this.KeyContainerName = keyContainerName;
this.KeyNumber = -1;
this.Flags = flags;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:CspParameters.cs
示例2: CspParameters
private CspParameters(int providerType, string providerName, string keyContainerName, CspProviderFlags flags)
{
ProviderType = providerType;
ProviderName = providerName;
KeyContainerName = keyContainerName;
KeyNumber = -1;
Flags = flags;
}
开发者ID:noahfalk,项目名称:corefx,代码行数:8,代码来源:CertificatePal.CspParametersStub.cs
示例3: KeyContainerStore
public KeyContainerStore(string storeType)
{
flags = "machine".Equals(storeType)
? CspProviderFlags.UseMachineKeyStore
: CspProviderFlags.UseUserProtectedKey;
Log.Verbose($"using key container, flags: {flags}");
}
开发者ID:Xamarui,项目名称:acme.net,代码行数:8,代码来源:KeyContainerStore.cs
示例4: GetKey
extern public static byte[] GetKey(int algorithm, String name,
CspProviderFlags flag,
out int result);
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:3,代码来源:CryptoMethods.cs
示例5: ValidateCspFlags
/// <summary>
/// Validates the CSP flags are expected
/// </summary>
/// <param name="flags">CSP provider flags</param>
private static void ValidateCspFlags(CspProviderFlags flags)
{
// check that the flags are consistent.
if (IsFlagBitSet((uint)flags, (uint)CspProviderFlags.UseExistingKey))
{
CspProviderFlags keyFlags = (CspProviderFlags.UseNonExportableKey |
CspProviderFlags.UseArchivableKey |
CspProviderFlags.UseUserProtectedKey);
if ((flags & keyFlags) != CspProviderFlags.NoFlags)
{
throw new ArgumentException(SR.Format(SR.Argument_InvalidValue, Convert.ToString(flags)));
}
}
}
开发者ID:chcosta,项目名称:corefx,代码行数:18,代码来源:CapiHelper.cs
示例6: SaveCspParameters
internal static CspParameters SaveCspParameters (CspAlgorithmType keyType, CspParameters userParameters, CspProviderFlags defaultFlags, ref bool randomKeyContainer) {
CspParameters parameters;
if (userParameters == null) {
parameters = new CspParameters(keyType == CspAlgorithmType.Dss ? Constants.PROV_DSS_DH : DefaultRsaProviderType, null, null, defaultFlags);
} else {
ValidateCspFlags(userParameters.Flags);
parameters = new CspParameters(userParameters);
}
if (parameters.KeyNumber == -1)
parameters.KeyNumber = keyType == CspAlgorithmType.Dss ? Constants.AT_SIGNATURE : Constants.AT_KEYEXCHANGE;
else if (parameters.KeyNumber == Constants.CALG_DSS_SIGN || parameters.KeyNumber == Constants.CALG_RSA_SIGN)
parameters.KeyNumber = Constants.AT_SIGNATURE;
else if (parameters.KeyNumber == Constants.CALG_RSA_KEYX)
parameters.KeyNumber = Constants.AT_KEYEXCHANGE;
// If no key container was specified and UseDefaultKeyContainer is not used, then use CRYPT_VERIFYCONTEXT
// to generate an ephemeral key
randomKeyContainer = (parameters.Flags & CspProviderFlags.CreateEphemeralKey) == CspProviderFlags.CreateEphemeralKey;
if (parameters.KeyContainerName == null && (parameters.Flags & CspProviderFlags.UseDefaultKeyContainer) == 0) {
parameters.Flags |= CspProviderFlags.CreateEphemeralKey;
randomKeyContainer = true;
}
return parameters;
}
开发者ID:peterdocter,项目名称:referencesource,代码行数:27,代码来源:utils.cs
示例7: ValidateCspFlags
[System.Security.SecurityCritical] // auto-generated
private static void ValidateCspFlags (CspProviderFlags flags) {
// check that the flags are consistent.
if ((flags & CspProviderFlags.UseExistingKey) != 0) {
CspProviderFlags keyFlags = (CspProviderFlags.UseNonExportableKey | CspProviderFlags.UseArchivableKey | CspProviderFlags.UseUserProtectedKey);
if ((flags & keyFlags) != CspProviderFlags.NoFlags)
throw new ArgumentException(Environment.GetResourceString("Argument_InvalidFlag"));
}
// make sure we are allowed to display the key protection UI if a user protected key is requested.
if ((flags & CspProviderFlags.UseUserProtectedKey) != 0) {
// UI only allowed in interactive session.
if (!System.Environment.UserInteractive)
throw new InvalidOperationException(Environment.GetResourceString("Cryptography_NotInteractive"));
// we need to demand UI permission here.
UIPermission uiPermission = new UIPermission(UIPermissionWindow.SafeTopLevelWindows);
uiPermission.Demand();
}
}
开发者ID:peterdocter,项目名称:referencesource,代码行数:20,代码来源:utils.cs
示例8: _ImportCspBlob
internal static extern int _ImportCspBlob(byte[] keyBlob, SafeProvHandle hProv, CspProviderFlags flags, ref SafeKeyHandle hKey);
开发者ID:peterdocter,项目名称:referencesource,代码行数:1,代码来源:utils.cs
示例9: _ImportKey
internal static extern void _ImportKey(SafeProvHandle hCSP, int keyNumber, CspProviderFlags flags, object cspObject, ref SafeKeyHandle hKey);
开发者ID:peterdocter,项目名称:referencesource,代码行数:1,代码来源:utils.cs
示例10: ImportKeyBlob
/// <summary>
/// Helper for Import CSP
/// </summary>
internal static void ImportKeyBlob(SafeProvHandle saveProvHandle, CspProviderFlags flags, byte[] keyBlob, out SafeKeyHandle safeKeyHandle)
{
// Compat note: This isn't the same check as the one done by the CLR _ImportCspBlob QCall,
// but this does match the desktop CLR behavior and the only scenarios it
// affects are cases where a corrupt blob is passed in.
bool isPublic = keyBlob.Length > 0 && keyBlob[0] == CapiHelper.PUBLICKEYBLOB;
int dwCapiFlags = MapCspKeyFlags((int)flags);
if (isPublic)
{
dwCapiFlags &= ~(int)(CryptGenKeyFlags.CRYPT_EXPORTABLE);
}
SafeKeyHandle hKey;
if (!Interop.CryptImportKey(saveProvHandle, keyBlob, keyBlob.Length, SafeKeyHandle.InvalidHandle, dwCapiFlags, out hKey))
{
int hr = Marshal.GetHRForLastWin32Error();
hKey.Dispose();
throw hr.ToCryptographicException();
}
hKey.PublicOnly = isPublic;
safeKeyHandle = hKey;
return;
}
开发者ID:SGuyGe,项目名称:corefx,代码行数:31,代码来源:CapiHelper.cs
示例11: ValidateCspFlags
private static void ValidateCspFlags(CspProviderFlags flags)
{
if ((flags & CspProviderFlags.UseExistingKey) != CspProviderFlags.NoFlags)
{
CspProviderFlags flags2 = CspProviderFlags.UseUserProtectedKey | CspProviderFlags.UseArchivableKey | CspProviderFlags.UseNonExportableKey;
if ((flags & flags2) != CspProviderFlags.NoFlags)
{
throw new ArgumentException(Environment.GetResourceString("Argument_InvalidFlag"));
}
}
if ((flags & CspProviderFlags.UseUserProtectedKey) != CspProviderFlags.NoFlags)
{
if (!Environment.UserInteractive)
{
throw new InvalidOperationException(Environment.GetResourceString("Cryptography_NotInteractive"));
}
new UIPermission(UIPermissionWindow.SafeTopLevelWindows).Demand();
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:19,代码来源:Utils.cs
示例12: SaveCspParameters
/// <summary>
/// Helper method to save the CSP parameters.
/// </summary>
/// <param name="keyType">CSP algorithm type</param>
/// <param name="userParameters">CSP Parameters passed by user</param>
/// <param name="defaultFlags">flags </param>
/// <param name="randomKeyContainer">identifies if it is random key container</param>
/// <returns></returns>
internal static CspParameters SaveCspParameters(
CspAlgorithmType keyType,
CspParameters userParameters,
CspProviderFlags defaultFlags,
out bool randomKeyContainer)
{
CspParameters parameters;
if (userParameters == null)
{
parameters = new CspParameters(keyType == CspAlgorithmType.Dss ?
(int)ProviderType.PROV_DSS_DH : DefaultRsaProviderType,
null, null, defaultFlags);
}
else
{
ValidateCspFlags(userParameters.Flags);
parameters = new CspParameters(userParameters);
}
if (parameters.KeyNumber == -1)
{
parameters.KeyNumber = keyType == CapiHelper.CspAlgorithmType.Dss ? (int)KeyNumber.Signature : (int)KeyNumber.Exchange;
}
else if (parameters.KeyNumber == CALG_DSS_SIGN || parameters.KeyNumber == CALG_RSA_SIGN)
{
parameters.KeyNumber = (int)KeyNumber.Signature;
}
else if (parameters.KeyNumber == CALG_RSA_KEYX)
{
parameters.KeyNumber = (int)KeyNumber.Exchange;
}
// If no key container was specified and UseDefaultKeyContainer is not used, then use CRYPT_VERIFYCONTEXT
// to generate an ephemeral key
randomKeyContainer = IsFlagBitSet((uint)parameters.Flags, (uint)CspProviderFlags.CreateEphemeralKey);
if (parameters.KeyContainerName == null && !IsFlagBitSet((uint)parameters.Flags,
(uint)CspProviderFlags.UseDefaultKeyContainer))
{
parameters.Flags |= CspProviderFlags.CreateEphemeralKey;
randomKeyContainer = true;
}
return parameters;
}
开发者ID:SGuyGe,项目名称:corefx,代码行数:52,代码来源:CapiHelper.cs
示例13: CreateProviderParameters
private static CspParameters CreateProviderParameters(CspParameters providerParameters, CspProviderFlags defaultFlags, out bool randomKeyContainer)
{
CspParameters parameters;
if (providerParameters == null)
{
parameters = new CspParameters(GostCryptoConfig.ProviderType) { Flags = defaultFlags };
}
else
{
ValidateProviderParameters(providerParameters.Flags);
parameters = new CspParameters(providerParameters.ProviderType, providerParameters.ProviderName, providerParameters.KeyContainerName) { Flags = providerParameters.Flags, KeyNumber = providerParameters.KeyNumber };
}
// Установка типа ключа
if (parameters.KeyNumber == -1)
{
parameters.KeyNumber = (int)KeyNumber.Exchange;
}
else if (parameters.KeyNumber == Constants.CALG_GR3410EL)
{
parameters.KeyNumber = (int)KeyNumber.Signature;
}
else if (parameters.KeyNumber == Constants.CALG_DH_EL_SF)
{
parameters.KeyNumber = (int)KeyNumber.Exchange;
}
// Использовать автогенерированный контейнер
randomKeyContainer = ((parameters.KeyContainerName == null) && ((parameters.Flags & CspProviderFlags.UseDefaultKeyContainer) == CspProviderFlags.NoFlags));
if (randomKeyContainer)
{
parameters.KeyContainerName = Guid.NewGuid().ToString();
}
return parameters;
}
开发者ID:kapitanov,项目名称:GostCryptography,代码行数:39,代码来源:Gost3410AsymmetricAlgorithm.cs
示例14: WriteToStore
/// <summary>
/// Writes a copy of this key into the local Csp store with the given options
/// </summary>
public void WriteToStore(string name, CspProviderFlags flags)
{
CspParameters cp = new CspParameters();
cp.KeyContainerName = name;
cp.Flags = flags;
RSACryptoServiceProvider csp = new RSACryptoServiceProvider(cp);
csp.ImportCspBlob(RSAKey.ExportCspBlob(IsPrivateKey));
csp.PersistKeyInCsp = true;
csp.Clear();
}
开发者ID:hivie7510,项目名称:csharptest-net,代码行数:13,代码来源:RSAPublicKey.cs
示例15: ValidateProviderParameters
private static void ValidateProviderParameters(CspProviderFlags flags)
{
// Ели информацию о провайдере нужно взять из текущего ключа
if ((flags & CspProviderFlags.UseExistingKey) != CspProviderFlags.NoFlags)
{
const CspProviderFlags notExpectedFlags = CspProviderFlags.UseUserProtectedKey
| CspProviderFlags.UseArchivableKey
| CspProviderFlags.UseNonExportableKey;
if ((flags & notExpectedFlags) != CspProviderFlags.NoFlags)
{
throw ExceptionUtility.Argument("flags", Resources.InvalidCspProviderFlags);
}
}
// Если пользователь должен сам выбрать ключ (например, в диалоге)
if ((flags & CspProviderFlags.UseUserProtectedKey) != CspProviderFlags.NoFlags)
{
if (!Environment.UserInteractive)
{
throw ExceptionUtility.CryptographicException(Resources.UserInteractiveNotSupported);
}
new UIPermission(UIPermissionWindow.SafeTopLevelWindows).Demand();
}
}
开发者ID:kapitanov,项目名称:GostCryptography,代码行数:26,代码来源:Gost3410AsymmetricAlgorithm.cs
示例16: ValidateCspFlags
/// <summary>
/// Validates the CSP flags are expected
/// </summary>
/// <param name="flags">CSP provider flags</param>
private static void ValidateCspFlags(CspProviderFlags flags)
{
// check that the flags are consistent.
if (IsFlagBitSet((uint)flags, (uint)CspProviderFlags.UseExistingKey))
{
CspProviderFlags keyFlags = (CspProviderFlags.UseNonExportableKey |
CspProviderFlags.UseArchivableKey |
CspProviderFlags.UseUserProtectedKey);
if ((flags & keyFlags) != CspProviderFlags.NoFlags)
{
throw new ArgumentException(SR.Format(SR.Argument_InvalidValue, Convert.ToString(flags)));
}
}
//TODO : I don't think we need following commented code. Leaving it now for confirming the same
// during code review. Reviewers please let me kn know?
// make sure we are allowed to display the key protection UI if a user protected key is requested.
//if ((flags & CspProviderFlags.UseUserProtectedKey) != 0)
//{
// // UI only allowed in interactive session.
// if (!System.Environment.UserInteractive)
// {
// throw new InvalidOperationException(("Cryptography_NotInteractive"));
// }
// // we need to demand UI permission here.
// UIPermission uiPermission = new UIPermission(UIPermissionWindow.SafeTopLevelWindows);
// uiPermission.Demand();
//}
}
开发者ID:SGuyGe,项目名称:corefx,代码行数:34,代码来源:CapiHelper.cs
示例17: SaveCspParameters
internal static CspParameters SaveCspParameters (CspAlgorithmType keyType, CspParameters userParameters, CspProviderFlags defaultFlags, ref bool randomKeyContainer) {
#if SILVERLIGHT
Contract.Assert(keyType == CspAlgorithmType.Rsa, "Only RSA is supported in Silverlight");
#endif // SILVERLIGHT
CspParameters parameters;
if (userParameters == null) {
#if !SILVERLIGHT
parameters = new CspParameters(keyType == CspAlgorithmType.Dss ? Constants.PROV_DSS_DH : DefaultRsaProviderType, null, null, defaultFlags);
#else // !SILVERLIGHT
parameters = new CspParameters();
#endif // !SILVERLIGHT
} else {
ValidateCspFlags(userParameters.Flags);
parameters = new CspParameters(userParameters);
}
#if !SILVERLIGHT
if (parameters.KeyNumber == -1)
parameters.KeyNumber = keyType == CspAlgorithmType.Dss ? Constants.AT_SIGNATURE : Constants.AT_KEYEXCHANGE;
else if (parameters.KeyNumber == Constants.CALG_DSS_SIGN || parameters.KeyNumber == Constants.CALG_RSA_SIGN)
parameters.KeyNumber = Constants.AT_SIGNATURE;
else if (parameters.KeyNumber == Constants.CALG_RSA_KEYX)
parameters.KeyNumber = Constants.AT_KEYEXCHANGE;
#else // !SILVERLIGHT
if (parameters.KeyNumber == -1) {
parameters.KeyNumber = (int)CapiNative.KeySpec.Signature;
}
#endif // !SILVERLIGHT
// If no key container was specified and UseDefaultKeyContainer is not used, then use CRYPT_VERIFYCONTEXT
// to generate an ephemeral key
randomKeyContainer = (parameters.Flags & CspProviderFlags.CreateEphemeralKey) == CspProviderFlags.CreateEphemeralKey;
if (parameters.KeyContainerName == null && (parameters.Flags & CspProviderFlags.UseDefaultKeyContainer) == 0) {
parameters.Flags |= CspProviderFlags.CreateEphemeralKey;
randomKeyContainer = true;
}
return parameters;
}
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:40,代码来源:Utils.cs
示例18: _GenerateKey
internal static extern void _GenerateKey(SafeProvHandle hProv, int algid, CspProviderFlags flags, int keySize, ref SafeKeyHandle hKey);
开发者ID:peterdocter,项目名称:referencesource,代码行数:1,代码来源:utils.cs
示例19: SaveCspParameters
internal static CspParameters SaveCspParameters(CspAlgorithmType keyType, CspParameters userParameters, CspProviderFlags defaultFlags, ref bool randomKeyContainer)
{
CspParameters parameters;
if (userParameters == null)
{
parameters = new CspParameters((keyType == CspAlgorithmType.Dss) ? 13 : DefaultRsaProviderType, null, null, defaultFlags);
}
else
{
ValidateCspFlags(userParameters.Flags);
parameters = new CspParameters(userParameters);
}
if (parameters.KeyNumber == -1)
{
parameters.KeyNumber = (keyType == CspAlgorithmType.Dss) ? 2 : 1;
}
else if ((parameters.KeyNumber == 0x2200) || (parameters.KeyNumber == 0x2400))
{
parameters.KeyNumber = 2;
}
else if (parameters.KeyNumber == 0xa400)
{
parameters.KeyNumber = 1;
}
randomKeyContainer = (parameters.Flags & CspProviderFlags.CreateEphemeralKey) == CspProviderFlags.CreateEphemeralKey;
if ((parameters.KeyContainerName == null) && ((parameters.Flags & CspProviderFlags.UseDefaultKeyContainer) == CspProviderFlags.NoFlags))
{
parameters.Flags |= CspProviderFlags.CreateEphemeralKey;
randomKeyContainer = true;
}
return parameters;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:32,代码来源:Utils.cs
示例20: CspParameters
//Copy constructor
internal CspParameters(CspParameters parameters)
{
ProviderType = parameters.ProviderType;
ProviderName = parameters.ProviderName;
KeyContainerName = parameters.KeyContainerName;
KeyNumber = parameters.KeyNumber;
Flags = parameters.Flags;
_parentWindowHandle = parameters._parentWindowHandle;
}
开发者ID:johnhhm,项目名称:corefx,代码行数:10,代码来源:CspParameters.cs
注:本文中的CspProviderFlags类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论