-
Notifications
You must be signed in to change notification settings - Fork 41
/
ProviderType.cs
85 lines (70 loc) · 2.18 KB
/
ProviderType.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
using System.Collections.Generic;
namespace GostCryptography.Base
{
/// <summary>
/// Типы криптографических провайдеров.
/// </summary>
public enum ProviderType
{
/// <summary>
/// Infotecs Cryptographic Service Provider.
/// </summary>
VipNet = 2,
/// <summary>
/// Infotecs GOST 2012/512 Cryptographic Service Provider.
/// </summary>
VipNet_2012_512 = 77,
/// <summary>
/// Infotecs GOST 2012/1024 Cryptographic Service Provider.
/// </summary>
VipNet_2012_1024 = 78,
/// <summary>
/// Crypto-Pro GOST R 34.10-2001 Cryptographic Service Provider.
/// </summary>
CryptoPro = 75,
/// <summary>
/// Crypto-Pro GOST R 34.10-2012 Cryptographic Service Provider.
/// </summary>
CryptoPro_2012_512 = 80,
/// <summary>
/// Crypto-Pro GOST R 34.10-2012 Strong Cryptographic Service Provider.
/// </summary>
CryptoPro_2012_1024 = 81
}
/// <summary>
/// Методы расширения <see cref="ProviderType"/>.
/// </summary>
public static class ProviderTypesExtensions
{
/// <summary>
/// Набор провайдеров VipNet.
/// </summary>
public static readonly HashSet<ProviderType> VipNetProviders = new HashSet<ProviderType>
{
ProviderType.VipNet,
ProviderType.VipNet_2012_512,
ProviderType.VipNet_2012_1024
};
/// <summary>
/// Набор провайдеров CryptoPro.
/// </summary>
public static readonly HashSet<ProviderType> CryptoProProviders = new HashSet<ProviderType>
{
ProviderType.CryptoPro,
ProviderType.CryptoPro_2012_512,
ProviderType.CryptoPro_2012_1024
};
/// <summary>
/// Возвращает <see langword="true"/> для VipNet.
/// </summary>
public static bool IsVipNet(this ProviderType providerType) => VipNetProviders.Contains(providerType);
/// <summary>
/// Возвращает <see langword="true"/> для CryptoPro.
/// </summary>
public static bool IsCryptoPro(this ProviderType providerType) => CryptoProProviders.Contains(providerType);
/// <summary>
/// Преобразует значение в <see cref="int"/>.
/// </summary>
public static int ToInt(this ProviderType providerType) => (int)providerType;
}
}