Terraria v1.4.4.9
Terraria source code documentation
All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Macros
CspKeyContainerInfo.cs
Go to the documentation of this file.
3
5
6[SupportedOSPlatform("windows")]
7public sealed class CspKeyContainerInfo
8{
9 private readonly CspParameters _parameters;
10
11 private readonly bool _randomKeyContainer;
12
13 public bool Accessible
14 {
15 get
16 {
17 object obj = ReadKeyParameterSilent(6, throwOnNotFound: false);
18 if (obj == null)
19 {
20 return false;
21 }
22 return (bool)obj;
23 }
24 }
25
26 public bool Exportable
27 {
28 get
29 {
31 {
32 return false;
33 }
34 return (bool)ReadKeyParameterSilent(3);
35 }
36 }
37
39
41
43
45
46 public bool Protected
47 {
48 get
49 {
51 {
52 return true;
53 }
54 return (bool)ReadKeyParameterSilent(7);
55 }
56 }
57
59
61
63
65
67
69 : this(parameters, randomKeyContainer: false)
70 {
71 }
72
73 internal CspKeyContainerInfo(CspParameters parameters, bool randomKeyContainer)
74 {
75 _parameters = new CspParameters(parameters);
76 if (_parameters.KeyNumber == -1)
77 {
79 {
80 _parameters.KeyNumber = 1;
81 }
82 else if (_parameters.ProviderType == 13)
83 {
84 _parameters.KeyNumber = 2;
85 }
86 }
87 _randomKeyContainer = randomKeyContainer;
88 }
89
90 private object ReadKeyParameterSilent(int keyParam, bool throwOnNotFound = true)
91 {
92 SafeProvHandle safeProvHandle;
93 int num = CapiHelper.OpenCSP(_parameters, 64u, out safeProvHandle);
94 using (safeProvHandle)
95 {
96 if (num != 0)
97 {
98 if (throwOnNotFound)
99 {
101 }
102 return null;
103 }
104 return CapiHelper.GetProviderParameter(safeProvHandle, _parameters.KeyNumber, keyParam);
105 }
106 }
107
108 private object ReadDeviceParameterVerifyContext(int keyParam)
109 {
110 CspParameters cspParameters = new CspParameters(_parameters);
111 cspParameters.Flags &= CspProviderFlags.UseMachineKeyStore;
112 cspParameters.KeyContainerName = null;
113 SafeProvHandle safeProvHandle;
114 int num = CapiHelper.OpenCSP(cspParameters, 4026531840u, out safeProvHandle);
115 using (safeProvHandle)
116 {
117 if (num != 0)
118 {
120 }
121 return CapiHelper.GetProviderParameter(safeProvHandle, cspParameters.KeyNumber, keyParam);
122 }
123 }
124}
static object GetProviderParameter(SafeProvHandle safeProvHandle, int keyNumber, int keyParam)
static int OpenCSP(CspParameters cspParameters, uint flags, out SafeProvHandle safeProvHandle)
static bool IsFlagBitSet(uint dwImp, uint flag)
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string Cryptography_CSP_NotFound
Definition SR.cs:24
Definition SR.cs:7
CspKeyContainerInfo(CspParameters parameters, bool randomKeyContainer)
object ReadKeyParameterSilent(int keyParam, bool throwOnNotFound=true)