Add project
Basic formatting applied. Unnecessary comments have been removed. Suspicious code is covered by TODO.
This commit is contained in:
36
Hcs.Client/GostCryptography/Native/SafeKeyHandleImpl.cs
Normal file
36
Hcs.Client/GostCryptography/Native/SafeKeyHandleImpl.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using Microsoft.Win32.SafeHandles;
|
||||
using System;
|
||||
using System.Security;
|
||||
|
||||
namespace GostCryptography.Native
|
||||
{
|
||||
/// <summary>
|
||||
/// Дескриптор ключа криптографического провайдера
|
||||
/// </summary>
|
||||
[SecurityCritical]
|
||||
public sealed class SafeKeyHandleImpl : SafeHandleZeroOrMinusOneIsInvalid
|
||||
{
|
||||
public SafeKeyHandleImpl()
|
||||
: base(true)
|
||||
{
|
||||
}
|
||||
|
||||
public SafeKeyHandleImpl(IntPtr handle)
|
||||
: base(true)
|
||||
{
|
||||
SetHandle(handle);
|
||||
}
|
||||
|
||||
public static SafeKeyHandleImpl InvalidHandle
|
||||
{
|
||||
get { return new SafeKeyHandleImpl(IntPtr.Zero); }
|
||||
}
|
||||
|
||||
[SecurityCritical]
|
||||
protected override bool ReleaseHandle()
|
||||
{
|
||||
CryptoApi.CryptDestroyKey(handle);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user