Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SafeProvHandle.cs
Go to the documentation of this file.
1
using
Microsoft.Win32.SafeHandles
;
2
3
namespace
System.Security.Cryptography
;
4
5
internal
sealed
class
SafeProvHandle
:
SafeHandleZeroOrMinusOneIsInvalid
6
{
7
private
string
_containerName
;
8
9
private
string
_providerName
;
10
11
private
int
_type
;
12
13
private
uint
_flags
;
14
15
private
bool
_fPersistKeyInCsp
;
16
17
internal
string
ContainerName
18
{
19
set
20
{
21
_containerName
=
value
;
22
}
23
}
24
25
internal
string
ProviderName
26
{
27
set
28
{
29
_providerName
=
value
;
30
}
31
}
32
33
internal
int
Types
34
{
35
set
36
{
37
_type
=
value
;
38
}
39
}
40
41
internal
uint Flags
42
{
43
set
44
{
45
_flags
=
value
;
46
}
47
}
48
49
internal
bool
PersistKeyInCsp
50
{
51
get
52
{
53
return
_fPersistKeyInCsp
;
54
}
55
set
56
{
57
_fPersistKeyInCsp
=
value
;
58
}
59
}
60
61
internal
static
SafeProvHandle
InvalidHandle
=>
SafeHandleCache<SafeProvHandle>
.
GetInvalidHandle
(() =>
new
SafeProvHandle
());
62
63
public
SafeProvHandle
()
64
: base(ownsHandle: true)
65
{
66
SetHandle
(
IntPtr
.
Zero
);
67
_containerName
=
null
;
68
_providerName
=
null
;
69
_type
= 0;
70
_flags
= 0u;
71
_fPersistKeyInCsp
=
true
;
72
}
73
74
protected
override
void
Dispose
(
bool
disposing)
75
{
76
if
(!
SafeHandleCache<SafeProvHandle>
.IsCachedInvalidHandle(
this
))
77
{
78
base.Dispose(disposing);
79
}
80
}
81
82
protected
override
bool
ReleaseHandle
()
83
{
84
if
(!
_fPersistKeyInCsp
&& (
_flags
& 0xF0000000u) == 0)
85
{
86
uint dwFlags = (
_flags
& 0x20u) | 0x10u;
87
global::Interop.Advapi32.CryptAcquireContext(out var phProv,
_containerName
,
_providerName
,
_type
, dwFlags);
88
phProv.Dispose();
89
}
90
bool
result = global::Interop.Advapi32.CryptReleaseContext(
handle
, 0);
91
SetHandle
(
IntPtr
.
Zero
);
92
return
result;
93
}
94
}
Microsoft.Win32.SafeHandles.SafeHandleCache.GetInvalidHandle
static T GetInvalidHandle(Func< T > invalidHandleFactory)
Definition
SafeHandleCache.cs:11
Microsoft.Win32.SafeHandles.SafeHandleCache
Definition
SafeHandleCache.cs:8
Microsoft.Win32.SafeHandles.SafeHandleZeroOrMinusOneIsInvalid
Definition
SafeHandleZeroOrMinusOneIsInvalid.cs:7
System.Runtime.InteropServices.SafeHandle.SetHandle
void SetHandle(IntPtr handle)
Definition
SafeHandle.cs:42
System.Runtime.InteropServices.SafeHandle.handle
IntPtr handle
Definition
SafeHandle.cs:8
System.Security.Cryptography.SafeProvHandle.ReleaseHandle
override bool ReleaseHandle()
Definition
SafeProvHandle.cs:82
System.Security.Cryptography.SafeProvHandle._providerName
string _providerName
Definition
SafeProvHandle.cs:9
System.Security.Cryptography.SafeProvHandle.ProviderName
string ProviderName
Definition
SafeProvHandle.cs:26
System.Security.Cryptography.SafeProvHandle.PersistKeyInCsp
bool PersistKeyInCsp
Definition
SafeProvHandle.cs:50
System.Security.Cryptography.SafeProvHandle.Types
int Types
Definition
SafeProvHandle.cs:34
System.Security.Cryptography.SafeProvHandle._fPersistKeyInCsp
bool _fPersistKeyInCsp
Definition
SafeProvHandle.cs:15
System.Security.Cryptography.SafeProvHandle._containerName
string _containerName
Definition
SafeProvHandle.cs:7
System.Security.Cryptography.SafeProvHandle.Dispose
override void Dispose(bool disposing)
Definition
SafeProvHandle.cs:74
System.Security.Cryptography.SafeProvHandle.InvalidHandle
static SafeProvHandle InvalidHandle
Definition
SafeProvHandle.cs:61
System.Security.Cryptography.SafeProvHandle.SafeProvHandle
SafeProvHandle()
Definition
SafeProvHandle.cs:63
System.Security.Cryptography.SafeProvHandle._flags
uint _flags
Definition
SafeProvHandle.cs:13
System.Security.Cryptography.SafeProvHandle.ContainerName
string ContainerName
Definition
SafeProvHandle.cs:18
System.Security.Cryptography.SafeProvHandle._type
int _type
Definition
SafeProvHandle.cs:11
System.Security.Cryptography.SafeProvHandle
Definition
SafeProvHandle.cs:6
Microsoft.Win32.SafeHandles
Definition
SafeProcessHandle.cs:3
System.Security.Cryptography
Definition
CryptoPool.cs:3
System.ExceptionArgument.value
@ value
System.IntPtr.Zero
static readonly IntPtr Zero
Definition
IntPtr.cs:18
System.IntPtr
Definition
IntPtr.cs:14
source
System.Security.Cryptography.Csp
System.Security.Cryptography
SafeProvHandle.cs
Generated by
1.10.0