Files
hcs/Hcs.Client/GostCryptography/Native/SafeKeyHandleImpl.cs
HOME-LAPTOP\kshkulev 33ab055b43 Add project
Basic formatting applied. Unnecessary comments have been removed. Suspicious code is covered by TODO.
2025-08-12 11:21:10 +09:00

37 lines
873 B
C#

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;
}
}
}