10Duke Enterprise C++ SDK
Toggle main menu visibility
Loading...
Searching...
No Matches
NCryptHandle.h
1
#ifndef TENDUKE_CRYPT_WIN_CNG_NCRYPTHANDLE_H
2
#define TENDUKE_CRYPT_WIN_CNG_NCRYPTHANDLE_H
3
4
#include "log/log.h"
5
#include "../WinCNG_utils.h"
6
#include <windows.h>
7
#include <ncrypt.h>
8
9
namespace
tenduke
{
namespace
crypto
{
namespace
win {
namespace
cng {
10
11
template
<
class
H>
12
class
NCryptHandle
13
{
14
public
:
15
explicit
NCryptHandle(
const
H handle)
16
: handle(handle)
17
{
18
}
19
20
virtual
~NCryptHandle()
21
{
22
if
(handle != 0) {
23
auto
status = ::NCryptFreeObject(handle);
24
25
if
(status != ERROR_SUCCESS) {
26
::tenduke::log::warning
(
27
std::string(
"NCryptFreeObject failed. Ignored. Error code: "
)
28
+ std::to_string(status)
29
+
", message: "
30
+ ::tenduke::crypto::win::cng::getNCryptErrorMessage(status)
31
);
32
}
33
}
34
}
35
36
// The instance owns the handle: not copyable
37
NCryptHandle(
const
NCryptHandle &) =
delete
;
38
NCryptHandle &operator=(
const
NCryptHandle &) =
delete
;
39
40
virtual
H getHandle()
const
41
{
42
return
handle;
43
}
44
45
protected
:
46
H handle;
47
};
48
49
50
}}}}
51
52
#endif
//TENDUKE_CRYPT_WIN_CNG_NCRYPTHANDLE_H
tenduke::crypto
Cryptography services.
Definition
AbstractCiphers.h:18
tenduke::log::warning
void warning(const char *message)
Write message to global logger at WARNING-level.
Definition
log.cpp:106
tenduke
Root for classes, functions and globals of 10Duke C++ Client.
Definition
APIRequest.h:4
core
services
windows
src
crypto
ncrypt
NCryptHandle.h
Generated by
1.17.0