* Sync up to trunk head (r64921).
[reactos.git] / dll / win32 / advapi32 / crypt / crypt.h
1 /*
2 * Driver routines
3 *
4 * Copyright 2001 - Travis Michielsen
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21 #ifndef __WINE_CRYPT_H
22 #define __WINE_CRYPT_H
23
24 //#include <stdarg.h>
25
26 //#include "windef.h"
27 //#include "winbase.h"
28 //#include "wincrypt.h"
29
30 typedef struct tagPROVFUNCS
31 {
32 BOOL (WINAPI *pCPAcquireContext)(HCRYPTPROV *phProv, LPSTR pszContainer, DWORD dwFlags, PVTableProvStruc pVTable);
33 BOOL (WINAPI *pCPCreateHash)(HCRYPTPROV hProv, ALG_ID Algid, HCRYPTKEY hKey, DWORD dwFlags, HCRYPTHASH *phHash);
34 BOOL (WINAPI *pCPDecrypt)(HCRYPTPROV hProv, HCRYPTKEY hKey, HCRYPTHASH hHash, BOOL Final, DWORD dwFlags, BYTE *pbData, DWORD *pdwDataLen);
35 BOOL (WINAPI *pCPDeriveKey)(HCRYPTPROV hProv, ALG_ID Algid, HCRYPTHASH hBaseData, DWORD dwFlags, HCRYPTKEY *phKey);
36 BOOL (WINAPI *pCPDestroyHash)(HCRYPTPROV hProv, HCRYPTHASH hHash);
37 BOOL (WINAPI *pCPDestroyKey)(HCRYPTPROV hProv, HCRYPTKEY hKey);
38 BOOL (WINAPI *pCPDuplicateHash)(HCRYPTPROV hUID, HCRYPTHASH hHash, DWORD *pdwReserved, DWORD dwFlags, HCRYPTHASH *phHash);
39 BOOL (WINAPI *pCPDuplicateKey)(HCRYPTPROV hUID, HCRYPTKEY hKey, DWORD *pdwReserved, DWORD dwFlags, HCRYPTKEY *phKey);
40 BOOL (WINAPI *pCPEncrypt)(HCRYPTPROV hProv, HCRYPTKEY hKey, HCRYPTHASH hHash, BOOL Final, DWORD dwFlags, BYTE *pbData, DWORD *pdwDataLen, DWORD dwBufLen);
41 BOOL (WINAPI *pCPExportKey)(HCRYPTPROV hProv, HCRYPTKEY hKey, HCRYPTKEY hPubKey, DWORD dwBlobType, DWORD dwFlags, BYTE *pbData, DWORD *pdwDataLen);
42 BOOL (WINAPI *pCPGenKey)(HCRYPTPROV hProv, ALG_ID Algid, DWORD dwFlags, HCRYPTKEY *phKey);
43 BOOL (WINAPI *pCPGenRandom)(HCRYPTPROV hProv, DWORD dwLen, BYTE *pbBuffer);
44 BOOL (WINAPI *pCPGetHashParam)(HCRYPTPROV hProv, HCRYPTHASH hHash, DWORD dwParam, BYTE *pbData, DWORD *pdwDataLen, DWORD dwFlags);
45 BOOL (WINAPI *pCPGetKeyParam)(HCRYPTPROV hProv, HCRYPTKEY hKey, DWORD dwParam, BYTE *pbData, DWORD *pdwDataLen, DWORD dwFlags);
46 BOOL (WINAPI *pCPGetProvParam)(HCRYPTPROV hProv, DWORD dwParam, BYTE *pbData, DWORD *pdwDataLen, DWORD dwFlags);
47 BOOL (WINAPI *pCPGetUserKey)(HCRYPTPROV hProv, DWORD dwKeySpec, HCRYPTKEY *phUserKey);
48 BOOL (WINAPI *pCPHashData)(HCRYPTPROV hProv, HCRYPTHASH hHash, const BYTE *pbData, DWORD dwDataLen, DWORD dwFlags);
49 BOOL (WINAPI *pCPHashSessionKey)(HCRYPTPROV hProv, HCRYPTHASH hHash, HCRYPTKEY hKey, DWORD dwFlags);
50 BOOL (WINAPI *pCPImportKey)(HCRYPTPROV hProv, const BYTE *pbData, DWORD dwDataLen, HCRYPTKEY hPubKey, DWORD dwFlags, HCRYPTKEY *phKey);
51 BOOL (WINAPI *pCPReleaseContext)(HCRYPTPROV hProv, DWORD dwFlags);
52 BOOL (WINAPI *pCPSetHashParam)(HCRYPTPROV hProv, HCRYPTHASH hHash, DWORD dwParam, const BYTE *pbData, DWORD dwFlags);
53 BOOL (WINAPI *pCPSetKeyParam)(HCRYPTPROV hProv, HCRYPTKEY hKey, DWORD dwParam, const BYTE *pbData, DWORD dwFlags);
54 BOOL (WINAPI *pCPSetProvParam)(HCRYPTPROV hProv, DWORD dwParam, const BYTE *pbData, DWORD dwFlags);
55 BOOL (WINAPI *pCPSignHash)(HCRYPTPROV hProv, HCRYPTHASH hHash, DWORD dwKeySpec, LPCWSTR sDescription, DWORD dwFlags, BYTE *pbSignature, DWORD *pdwSigLen);
56 BOOL (WINAPI *pCPVerifySignature)(HCRYPTPROV hProv, HCRYPTHASH hHash, const BYTE *pbSignature, DWORD dwSigLen, HCRYPTKEY hPubKey, LPCWSTR sDescription, DWORD dwFlags);
57 } PROVFUNCS, *PPROVFUNCS;
58
59 #define MAGIC_CRYPTPROV 0xA39E741F
60 #define MAGIC_CRYPTKEY 0xA39E741E
61 #define MAGIC_CRYPTHASH 0xA39E741D
62
63 typedef struct tagCRYPTPROV
64 {
65 DWORD dwMagic;
66 UINT refcount;
67 HMODULE hModule;
68 PPROVFUNCS pFuncs;
69 HCRYPTPROV hPrivate; /*CSP's handle - Should not be given to application under any circumstances!*/
70 PVTableProvStruc pVTable;
71 } CRYPTPROV, *PCRYPTPROV;
72
73 typedef struct tagCRYPTKEY
74 {
75 DWORD dwMagic;
76 PCRYPTPROV pProvider;
77 HCRYPTKEY hPrivate; /*CSP's handle - Should not be given to application under any circumstances!*/
78 } CRYPTKEY, *PCRYPTKEY;
79
80 typedef struct tagCRYPTHASH
81 {
82 DWORD dwMagic;
83 PCRYPTPROV pProvider;
84 HCRYPTHASH hPrivate; /*CSP's handle - Should not be given to application under any circumstances!*/
85 } CRYPTHASH, *PCRYPTHASH;
86
87 #define MAXPROVTYPES 999
88
89 extern unsigned char *CRYPT_DEShash( unsigned char *dst, const unsigned char *key,
90 const unsigned char *src ) DECLSPEC_HIDDEN;
91 extern unsigned char *CRYPT_DESunhash( unsigned char *dst, const unsigned char *key,
92 const unsigned char *src ) DECLSPEC_HIDDEN;
93
94 struct ustring {
95 DWORD Length;
96 DWORD MaximumLength;
97 unsigned char *Buffer;
98 };
99
100 NTSTATUS WINAPI SystemFunction032(struct ustring *data, const struct ustring *key);
101
102 #endif /* __WINE_CRYPT_H_ */