aboutsummaryrefslogtreecommitdiff
path: root/src/dutil/inc/cryputil.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/dutil/inc/cryputil.h')
-rw-r--r--src/dutil/inc/cryputil.h103
1 files changed, 103 insertions, 0 deletions
diff --git a/src/dutil/inc/cryputil.h b/src/dutil/inc/cryputil.h
new file mode 100644
index 00000000..88aa784d
--- /dev/null
+++ b/src/dutil/inc/cryputil.h
@@ -0,0 +1,103 @@
1#pragma once
2// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
3
4
5#define ReleaseCryptMsg(p) if (p) { ::CryptMsgClose(p); p = NULL; }
6
7#ifdef __cplusplus
8extern "C" {
9#endif
10
11
12// Use CRYPTPROTECTMEMORY_BLOCK_SIZE, because it's larger and thus more restrictive than RTL_ENCRYPT_MEMORY_SIZE.
13#define CRYP_ENCRYPT_MEMORY_SIZE CRYPTPROTECTMEMORY_BLOCK_SIZE
14#define SHA1_HASH_LEN 20
15
16typedef NTSTATUS (APIENTRY *PFN_RTLENCRYPTMEMORY)(
17 __inout PVOID Memory,
18 __in ULONG MemoryLength,
19 __in ULONG OptionFlags
20 );
21
22typedef NTSTATUS (APIENTRY *PFN_RTLDECRYPTMEMORY)(
23 __inout PVOID Memory,
24 __in ULONG MemoryLength,
25 __in ULONG OptionFlags
26 );
27
28typedef BOOL (APIENTRY *PFN_CRYPTPROTECTMEMORY)(
29 __inout LPVOID pData,
30 __in DWORD cbData,
31 __in DWORD dwFlags
32 );
33
34typedef BOOL (APIENTRY *PFN_CRYPTUNPROTECTMEMORY)(
35 __inout LPVOID pData,
36 __in DWORD cbData,
37 __in DWORD dwFlags
38 );
39
40// function declarations
41
42HRESULT DAPI CrypInitialize();
43void DAPI CrypUninitialize();
44
45HRESULT DAPI CrypDecodeObject(
46 __in_z LPCSTR szStructType,
47 __in_ecount(cbData) const BYTE* pbData,
48 __in DWORD cbData,
49 __in DWORD dwFlags,
50 __out LPVOID* ppvObject,
51 __out_opt DWORD* pcbObject
52 );
53
54HRESULT DAPI CrypMsgGetParam(
55 __in HCRYPTMSG hCryptMsg,
56 __in DWORD dwType,
57 __in DWORD dwIndex,
58 __out LPVOID* ppvData,
59 __out_opt DWORD* pcbData
60 );
61
62HRESULT DAPI CrypHashFile(
63 __in_z LPCWSTR wzFilePath,
64 __in DWORD dwProvType,
65 __in ALG_ID algid,
66 __out_bcount(cbHash) BYTE* pbHash,
67 __in DWORD cbHash,
68 __out_opt DWORD64* pqwBytesHashed
69 );
70
71HRESULT DAPI CrypHashFileHandle(
72 __in HANDLE hFile,
73 __in DWORD dwProvType,
74 __in ALG_ID algid,
75 __out_bcount(cbHash) BYTE* pbHash,
76 __in DWORD cbHash,
77 __out_opt DWORD64* pqwBytesHashed
78 );
79
80HRESULT DAPI CrypHashBuffer(
81 __in_bcount(cbBuffer) const BYTE* pbBuffer,
82 __in SIZE_T cbBuffer,
83 __in DWORD dwProvType,
84 __in ALG_ID algid,
85 __out_bcount(cbHash) BYTE* pbHash,
86 __in DWORD cbHash
87 );
88
89HRESULT DAPI CrypEncryptMemory(
90 __inout LPVOID pData,
91 __in DWORD cbData,
92 __in DWORD dwFlags
93 );
94
95HRESULT DAPI CrypDecryptMemory(
96 __inout LPVOID pData,
97 __in DWORD cbData,
98 __in DWORD dwFlags
99 );
100
101#ifdef __cplusplus
102}
103#endif