main
h 106 lines 2.47 KB
Raw
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
8 extern "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 MD5_HASH_LEN 16
15 #define SHA1_HASH_LEN 20
16 #define SHA256_HASH_LEN 32
17 #define SHA512_HASH_LEN 64
18
19 typedef NTSTATUS (APIENTRY *PFN_RTLENCRYPTMEMORY)(
20 __inout PVOID Memory,
21 __in ULONG MemoryLength,
22 __in ULONG OptionFlags
23 );
24
25 typedef NTSTATUS (APIENTRY *PFN_RTLDECRYPTMEMORY)(
26 __inout PVOID Memory,
27 __in ULONG MemoryLength,
28 __in ULONG OptionFlags
29 );
30
31 typedef BOOL (APIENTRY *PFN_CRYPTPROTECTMEMORY)(
32 __inout LPVOID pData,
33 __in DWORD cbData,
34 __in DWORD dwFlags
35 );
36
37 typedef BOOL (APIENTRY *PFN_CRYPTUNPROTECTMEMORY)(
38 __inout LPVOID pData,
39 __in DWORD cbData,
40 __in DWORD dwFlags
41 );
42
43 // function declarations
44
45 HRESULT DAPI CrypInitialize();
46 void DAPI CrypUninitialize();
47
48 HRESULT DAPI CrypDecodeObject(
49 __in_z LPCSTR szStructType,
50 __in_ecount(cbData) const BYTE* pbData,
51 __in DWORD cbData,
52 __in DWORD dwFlags,
53 __out LPVOID* ppvObject,
54 __out_opt DWORD* pcbObject
55 );
56
57 HRESULT DAPI CrypMsgGetParam(
58 __in HCRYPTMSG hCryptMsg,
59 __in DWORD dwType,
60 __in DWORD dwIndex,
61 __out LPVOID* ppvData,
62 __out_opt DWORD* pcbData
63 );
64
65 HRESULT DAPI CrypHashFile(
66 __in_z LPCWSTR wzFilePath,
67 __in DWORD dwProvType,
68 __in ALG_ID algid,
69 __out_bcount(cbHash) BYTE* pbHash,
70 __in DWORD cbHash,
71 __out_opt DWORD64* pqwBytesHashed
72 );
73
74 HRESULT DAPI CrypHashFileHandle(
75 __in HANDLE hFile,
76 __in DWORD dwProvType,
77 __in ALG_ID algid,
78 __out_bcount(cbHash) BYTE* pbHash,
79 __in DWORD cbHash,
80 __out_opt DWORD64* pqwBytesHashed
81 );
82
83 HRESULT DAPI CrypHashBuffer(
84 __in_bcount(cbBuffer) const BYTE* pbBuffer,
85 __in SIZE_T cbBuffer,
86 __in DWORD dwProvType,
87 __in ALG_ID algid,
88 __out_bcount(cbHash) BYTE* pbHash,
89 __in DWORD cbHash
90 );
91
92 HRESULT DAPI CrypEncryptMemory(
93 __inout LPVOID pData,
94 __in DWORD cbData,
95 __in DWORD dwFlags
96 );
97
98 HRESULT DAPI CrypDecryptMemory(
99 __inout LPVOID pData,
100 __in DWORD cbData,
101 __in DWORD dwFlags
102 );
103
104 #ifdef __cplusplus
105 }
106 #endif