Merge commit 'origin/master' into msys
[msysgit.git] / include / wincrypt.h
blob0feba96309d16d0587586706f246b94f96111414
1 #ifndef _WINCRYPT_H
2 #define _WINCRYPT_H
3 #ifdef __cplusplus
4 extern "C" {
5 #endif
6 #define MS_DEF_PROV_A "Microsoft Base Cryptographic Provider v1.0"
7 #define MS_DEF_PROV_W L"Microsoft Base Cryptographic Provider v1.0"
8 #define GET_ALG_CLASS(x) (x&57344)
9 #define GET_ALG_TYPE(x) (x&7680)
10 #define GET_ALG_SID(x) (x&511)
11 #define ALG_CLASS_ANY 0
12 #define ALG_CLASS_SIGNATURE 8192
13 #define ALG_CLASS_MSG_ENCRYPT 16384
14 #define ALG_CLASS_DATA_ENCRYPT 24576
15 #define ALG_CLASS_HASH 32768
16 #define ALG_CLASS_KEY_EXCHANGE 40960
17 #define ALG_TYPE_ANY 0
18 #define ALG_TYPE_DSS 512
19 #define ALG_TYPE_RSA 1024
20 #define ALG_TYPE_BLOCK 1536
21 #define ALG_TYPE_STREAM 2048
22 #define ALG_SID_ANY 0
23 #define ALG_SID_RSA_ANY 0
24 #define ALG_SID_RSA_PKCS 1
25 #define ALG_SID_RSA_MSATWORK 2
26 #define ALG_SID_RSA_ENTRUST 3
27 #define ALG_SID_RSA_PGP 4
28 #define ALG_SID_DSS_ANY 0
29 #define ALG_SID_DSS_PKCS 1
30 #define ALG_SID_DSS_DMS 2
31 #define ALG_SID_DES 1
32 #define ALG_SID_RC2 2
33 #define ALG_SID_RC4 1
34 #define ALG_SID_SEAL 2
35 #define ALG_SID_MD2 1
36 #define ALG_SID_MD4 2
37 #define ALG_SID_MD5 3
38 #define ALG_SID_SHA 4
39 #define ALG_SID_MAC 5
40 #define ALG_SID_EXAMPLE 80
41 #define CALG_MD2 (ALG_CLASS_HASH|ALG_TYPE_ANY|ALG_SID_MD2)
42 #define CALG_MD4 (ALG_CLASS_HASH|ALG_TYPE_ANY|ALG_SID_MD4)
43 #define CALG_MD5 (ALG_CLASS_HASH|ALG_TYPE_ANY|ALG_SID_MD5)
44 #define CALG_SHA (ALG_CLASS_HASH|ALG_TYPE_ANY|ALG_SID_SHA)
45 #define CALG_MAC (ALG_CLASS_HASH|ALG_TYPE_ANY|ALG_SID_MAC)
46 #define CALG_RSA_SIGN (ALG_CLASS_SIGNATURE|ALG_TYPE_RSA|ALG_SID_RSA_ANY)
47 #define CALG_DSS_SIGN (ALG_CLASS_SIGNATURE|ALG_TYPE_DSS|ALG_SID_DSS_ANY)
48 #define CALG_RSA_KEYX (ALG_CLASS_KEY_EXCHANGE|ALG_TYPE_RSA|ALG_SID_RSA_ANY)
49 #define CALG_DES (ALG_CLASS_DATA_ENCRYPT|ALG_TYPE_BLOCK|ALG_SID_DES)
50 #define CALG_RC2 (ALG_CLASS_DATA_ENCRYPT|ALG_TYPE_BLOCK|ALG_SID_RC2)
51 #define CALG_RC4 (ALG_CLASS_DATA_ENCRYPT|ALG_TYPE_STREAM|ALG_SID_RC4)
52 #define CALG_SEAL (ALG_CLASS_DATA_ENCRYPT|ALG_TYPE_STREAM|ALG_SID_SEAL)
53 #define CRYPT_VERIFYCONTEXT 0xF0000000
54 #define CRYPT_NEWKEYSET 8
55 #define CRYPT_DELETEKEYSET 16
56 #define CRYPT_MACHINE_KEYSET 32
57 #define CRYPT_EXPORTABLE 1
58 #define CRYPT_USER_PROTECTED 2
59 #define CRYPT_CREATE_SALT 4
60 #define CRYPT_UPDATE_KEY 8
61 #define SIMPLEBLOB 1
62 #define PUBLICKEYBLOB 6
63 #define AT_KEYEXCHANGE 1
64 #define AT_SIGNATURE 2
65 #define CRYPT_USERDATA 1
66 #define KP_IV 1
67 #define KP_SALT 2
68 #define KP_PADDING 3
69 #define KP_MODE 4
70 #define KP_MODE_BITS 5
71 #define KP_PERMISSIONS 6
72 #define KP_ALGID 7
73 #define KP_BLOCKLEN 8
74 #define PKCS5_PADDING 1
75 #define CRYPT_MODE_CBC 1
76 #define CRYPT_MODE_ECB 2
77 #define CRYPT_MODE_OFB 3
78 #define CRYPT_MODE_CFB 4
79 #define CRYPT_MODE_CTS 5
80 #define CRYPT_ENCRYPT 1
81 #define CRYPT_DECRYPT 2
82 #define CRYPT_EXPORT 4
83 #define CRYPT_READ 8
84 #define CRYPT_WRITE 16
85 #define CRYPT_MAC 32
86 #define HP_ALGID 1
87 #define HP_HASHVAL 2
88 #define HP_HASHSIZE 4
89 #define CRYPT_FAILED FALSE
90 #define CRYPT_SUCCEED TRUE
91 #define RCRYPT_SUCCEEDED(r) ((r)==CRYPT_SUCCEED)
92 #define RCRYPT_FAILED(r) ((r)==CRYPT_FAILED)
93 #define PP_ENUMALGS 1
94 #define PP_ENUMCONTAINERS 2
95 #define PP_IMPTYPE 3
96 #define PP_NAME 4
97 #define PP_VERSION 5
98 #define PP_CONTAINER 6
99 #define CRYPT_FIRST 1
100 #define CRYPT_NEXT 2
101 #define CRYPT_IMPL_HARDWARE 1
102 #define CRYPT_IMPL_SOFTWARE 2
103 #define CRYPT_IMPL_MIXED 3
104 #define CRYPT_IMPL_UNKNOWN 4
105 #define PROV_RSA_FULL 1
106 #define PROV_RSA_SIG 2
107 #define PROV_DSS 3
108 #define PROV_FORTEZZA 4
109 #define PROV_MS_MAIL 5
110 #define PROV_SSL 6
111 #define PROV_STT_MER 7
112 #define PROV_STT_ACQ 8
113 #define PROV_STT_BRND 9
114 #define PROV_STT_ROOT 10
115 #define PROV_STT_ISS 11
116 #define MAXUIDLEN 64
117 #define CUR_BLOB_VERSION 2
118 typedef UINT ALG_ID;
119 typedef struct _VTableProvStruc {FARPROC FuncVerifyImage;} VTableProvStruc,*PVTableProvStruc;
120 typedef ULONG HCRYPTPROV;
121 typedef ULONG HCRYPTKEY;
122 typedef ULONG HCRYPTHASH;
123 typedef struct _PROV_ENUMALGS {
124 ALG_ID aiAlgid;
125 DWORD dwBitLen;
126 DWORD dwNameLen;
127 CHAR szName[20];
128 } PROV_ENUMALGS;
129 typedef struct _PUBLICKEYSTRUC {
130 BYTE bType;
131 BYTE bVersion;
132 WORD reserved;
133 ALG_ID aiKeyAlg;
134 } PUBLICKEYSTRUC;
135 typedef struct _RSAPUBKEY {
136 DWORD magic;
137 DWORD bitlen;
138 DWORD pubexp;
139 } RSAPUBKEY;
140 BOOL WINAPI CryptAcquireContextA(HCRYPTPROV*,LPCSTR,LPCSTR,DWORD,DWORD);
141 BOOL WINAPI CryptAcquireContextW(HCRYPTPROV*,LPCWSTR,LPCWSTR,DWORD,DWORD);
142 BOOL WINAPI CryptReleaseContext(HCRYPTPROV,DWORD);
143 BOOL WINAPI CryptGenKey(HCRYPTPROV,ALG_ID,DWORD,HCRYPTKEY*);
144 BOOL WINAPI CryptDeriveKey(HCRYPTPROV,ALG_ID,HCRYPTHASH,DWORD,HCRYPTKEY*);
145 BOOL WINAPI CryptDestroyKey(HCRYPTKEY);
146 BOOL WINAPI CryptSetKeyParam(HCRYPTKEY,DWORD,PBYTE,DWORD);
147 BOOL WINAPI CryptGetKeyParam(HCRYPTKEY,DWORD,PBYTE,PDWORD,DWORD);
148 BOOL WINAPI CryptSetHashParam(HCRYPTHASH,DWORD,PBYTE,DWORD);
149 BOOL WINAPI CryptGetHashParam(HCRYPTHASH,DWORD,PBYTE,PDWORD,DWORD);
150 BOOL WINAPI CryptSetProvParam(HCRYPTPROV,DWORD,PBYTE,DWORD);
151 BOOL WINAPI CryptGetProvParam(HCRYPTPROV,DWORD,PBYTE,PDWORD,DWORD);
152 BOOL WINAPI CryptGenRandom(HCRYPTPROV,DWORD,PBYTE);
153 BOOL WINAPI CryptGetUserKey(HCRYPTPROV,DWORD,HCRYPTKEY*);
154 BOOL WINAPI CryptExportKey(HCRYPTKEY,HCRYPTKEY,DWORD,DWORD,PBYTE,PDWORD);
155 BOOL WINAPI CryptImportKey(HCRYPTPROV,PBYTE,DWORD,HCRYPTKEY,DWORD,HCRYPTKEY*);
156 BOOL WINAPI CryptEncrypt(HCRYPTKEY,HCRYPTHASH,BOOL,DWORD,PBYTE,PDWORD,DWORD);
157 BOOL WINAPI CryptDecrypt(HCRYPTKEY,HCRYPTHASH,BOOL,DWORD,PBYTE,PDWORD);
158 BOOL WINAPI CryptCreateHash(HCRYPTPROV,ALG_ID,HCRYPTKEY,DWORD,HCRYPTHASH*);
159 BOOL WINAPI CryptHashData(HCRYPTHASH,PBYTE,DWORD,DWORD);
160 BOOL WINAPI CryptHashSessionKey(HCRYPTHASH,HCRYPTKEY,DWORD);
161 BOOL WINAPI CryptGetHashValue(HCRYPTHASH,DWORD,PBYTE,PDWORD);
162 BOOL WINAPI CryptDestroyHash(HCRYPTHASH);
163 BOOL WINAPI CryptSignHashA(HCRYPTHASH,DWORD,LPCSTR,DWORD,PBYTE,PDWORD);
164 BOOL WINAPI CryptSignHashW(HCRYPTHASH,DWORD,LPCWSTR,DWORD,PBYTE,PDWORD);
165 BOOL WINAPI CryptVerifySignatureA(HCRYPTHASH,PBYTE,DWORD,HCRYPTKEY,LPCSTR,DWORD);
166 BOOL WINAPI CryptVerifySignatureW(HCRYPTHASH,PBYTE,DWORD,HCRYPTKEY,LPCWSTR,DWORD);
167 BOOL WINAPI CryptSetProviderA(LPCSTR,DWORD);
168 BOOL WINAPI CryptSetProviderW(LPCWSTR,DWORD);
169 #ifdef UNICODE
170 #define CryptAcquireContext CryptAcquireContextW
171 #define CryptSignHash CryptSignHashW
172 #define CryptVerifySignature CryptVerifySignatureW
173 #define CryptSetProvider CryptSetProviderW
174 #define MS_DEF_PROV MS_DEF_PROV_W
175 #else
176 #define CryptAcquireContext CryptAcquireContextA
177 #define CryptSignHash CryptSignHashA
178 #define CryptVerifySignature CryptVerifySignatureA
179 #define CryptSetProvider CryptSetProviderA
180 #define MS_DEF_PROV MS_DEF_PROV_A
181 #endif
182 #ifdef __cplusplus
184 #endif
185 #endif