Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

522 lines
10 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1996 - 1999
  3. Module Name:
  4. cspDirect
  5. Abstract:
  6. This header file provides direct linkage to a CSP, so it does not have to be
  7. in a separate DLL. This facilitates code generation and debugging.
  8. Author:
  9. Doug Barlow (dbarlow) 5/8/1996
  10. Environment:
  11. Win32
  12. Notes:
  13. ?Notes?
  14. --*/
  15. #ifdef CSP_DIRECT
  16. #ifndef _CSPDIRECT_H_
  17. #define _CSPDIRECT_H_
  18. #pragma message("WARNING: building with direct CSP access enabled!")
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22. #define CSPBOOL BOOL WINAPI
  23. #undef CryptAcquireContext
  24. #ifdef UNICODE
  25. #define CryptAcquireContext CSPAcquireContextW
  26. #else
  27. #define CryptAcquireContext CSPAcquireContextA
  28. #endif
  29. #define CryptReleaseContext CSPReleaseContext
  30. #define CryptGenKey CSPGenKey
  31. #define CryptDeriveKey CSPDeriveKey
  32. #define CryptDestroyKey CSPDestroyKey
  33. #define CryptSetKeyParam CSPSetKeyParam
  34. #define CryptGetKeyParam CSPGetKeyParam
  35. #define CryptSetHashParam CSPSetHashParam
  36. #define CryptGetHashParam CSPGetHashParam
  37. #define CryptSetProvParam CSPSetProvParam
  38. #define CryptGetProvParam CSPGetProvParam
  39. #define CryptGenRandom CSPGenRandom
  40. #define CryptGetUserKey CSPGetUserKey
  41. #define CryptExportKey CSPExportKey
  42. #define CryptImportKey CSPImportKey
  43. #define CryptEncrypt CSPEncrypt
  44. #define CryptDecrypt CSPDecrypt
  45. #define CryptCreateHash CSPCreateHash
  46. #define CryptHashData CSPHashData
  47. #define CryptHashSessionKey CSPHashSessionKey
  48. // #define CryptGetHashValue CSPGetHashValue
  49. #define CryptDestroyHash CSPDestroyHash
  50. #undef CryptSignHash
  51. #ifdef UNICODE
  52. #define CryptSignHash CSPSignHashW
  53. #else
  54. #define CryptSignHash CSPSignHashA
  55. #endif
  56. #undef CryptVerifySignature
  57. #ifdef UNICODE
  58. #define CryptVerifySignature CSPVerifySignatureW
  59. #else
  60. #define CryptVerifySignature CSPVerifySignatureA
  61. #endif
  62. #undef CryptSetProvider
  63. #ifdef UNICODE
  64. #define CryptSetProvider CSPSetProviderW
  65. #else
  66. #define CryptSetProvider CSPSetProviderA
  67. #endif
  68. extern CSPBOOL
  69. CSPAcquireContextA(
  70. HCRYPTPROV *phProv,
  71. LPCSTR pszContainer,
  72. LPCSTR pszProvider,
  73. DWORD dwProvType,
  74. DWORD dwFlags);
  75. extern CSPBOOL
  76. CSPAcquireContextW(
  77. HCRYPTPROV *phProv,
  78. LPCWSTR pszContainer,
  79. LPCWSTR pszProvider,
  80. DWORD dwProvType,
  81. DWORD dwFlags);
  82. extern CSPBOOL
  83. CSPReleaseContext(
  84. HCRYPTPROV hProv,
  85. DWORD dwFlags);
  86. extern CSPBOOL
  87. CSPGenKey(
  88. HCRYPTPROV hProv,
  89. ALG_ID Algid,
  90. DWORD dwFlags,
  91. HCRYPTKEY *phKey);
  92. extern CSPBOOL
  93. CSPDeriveKey(
  94. HCRYPTPROV hProv,
  95. ALG_ID Algid,
  96. HCRYPTHASH hBaseData,
  97. DWORD dwFlags,
  98. HCRYPTKEY *phKey);
  99. extern CSPBOOL
  100. CSPDestroyKey(
  101. HCRYPTKEY hKey);
  102. extern CSPBOOL
  103. CSPSetKeyParam(
  104. HCRYPTKEY hKey,
  105. DWORD dwParam,
  106. BYTE *pbData,
  107. DWORD dwFlags);
  108. extern CSPBOOL
  109. CSPGetKeyParam(
  110. HCRYPTKEY hKey,
  111. DWORD dwParam,
  112. BYTE *pbData,
  113. DWORD *pdwDataLen,
  114. DWORD dwFlags);
  115. extern CSPBOOL
  116. CSPSetHashParam(
  117. HCRYPTHASH hHash,
  118. DWORD dwParam,
  119. BYTE *pbData,
  120. DWORD dwFlags);
  121. extern CSPBOOL
  122. CSPGetHashParam(
  123. HCRYPTHASH hHash,
  124. DWORD dwParam,
  125. BYTE *pbData,
  126. DWORD *pdwDataLen,
  127. DWORD dwFlags);
  128. extern CSPBOOL
  129. CSPSetProvParam(
  130. HCRYPTPROV hProv,
  131. DWORD dwParam,
  132. BYTE *pbData,
  133. DWORD dwFlags);
  134. extern CSPBOOL
  135. CSPGetProvParam(
  136. HCRYPTPROV hProv,
  137. DWORD dwParam,
  138. BYTE *pbData,
  139. DWORD *pdwDataLen,
  140. DWORD dwFlags);
  141. extern CSPBOOL
  142. CSPGenRandom(
  143. HCRYPTPROV hProv,
  144. DWORD dwLen,
  145. BYTE *pbBuffer);
  146. extern CSPBOOL
  147. CSPGetUserKey(
  148. HCRYPTPROV hProv,
  149. DWORD dwKeySpec,
  150. HCRYPTKEY *phUserKey);
  151. extern CSPBOOL
  152. CSPExportKey(
  153. HCRYPTKEY hKey,
  154. HCRYPTKEY hExpKey,
  155. DWORD dwBlobType,
  156. DWORD dwFlags,
  157. BYTE *pbData,
  158. DWORD *pdwDataLen);
  159. extern CSPBOOL
  160. CSPImportKey(
  161. HCRYPTPROV hProv,
  162. CONST BYTE *pbData,
  163. DWORD dwDataLen,
  164. HCRYPTKEY hPubKey,
  165. DWORD dwFlags,
  166. HCRYPTKEY *phKey);
  167. extern CSPBOOL
  168. CSPEncrypt(
  169. HCRYPTKEY hKey,
  170. HCRYPTHASH hHash,
  171. BOOL Final,
  172. DWORD dwFlags,
  173. BYTE *pbData,
  174. DWORD *pdwDataLen,
  175. DWORD dwBufLen);
  176. extern CSPBOOL
  177. CSPDecrypt(
  178. HCRYPTKEY hKey,
  179. HCRYPTHASH hHash,
  180. BOOL Final,
  181. DWORD dwFlags,
  182. BYTE *pbData,
  183. DWORD *pdwDataLen);
  184. extern CSPBOOL
  185. CSPCreateHash(
  186. HCRYPTPROV hProv,
  187. ALG_ID Algid,
  188. HCRYPTKEY hKey,
  189. DWORD dwFlags,
  190. HCRYPTHASH *phHash);
  191. extern CSPBOOL
  192. CSPHashData(
  193. HCRYPTHASH hHash,
  194. CONST BYTE *pbData,
  195. DWORD dwDataLen,
  196. DWORD dwFlags);
  197. extern CSPBOOL
  198. CSPHashSessionKey(
  199. HCRYPTHASH hHash,
  200. HCRYPTKEY hKey,
  201. DWORD dwFlags);
  202. /*
  203. extern CSPBOOL
  204. CSPGetHashValue(
  205. HCRYPTHASH hHash,
  206. DWORD dwFlags,
  207. BYTE *pbHash,
  208. DWORD *pdwHashLen);
  209. */
  210. extern CSPBOOL
  211. CSPDestroyHash(
  212. HCRYPTHASH hHash);
  213. extern CSPBOOL
  214. CSPSignHashA(
  215. HCRYPTHASH hHash,
  216. DWORD dwKeySpec,
  217. LPCSTR sDescription,
  218. DWORD dwFlags,
  219. BYTE *pbSignature,
  220. DWORD *pdwSigLen);
  221. extern CSPBOOL
  222. CSPSignHashW(
  223. HCRYPTHASH hHash,
  224. DWORD dwKeySpec,
  225. LPCWSTR sDescription,
  226. DWORD dwFlags,
  227. BYTE *pbSignature,
  228. DWORD *pdwSigLen);
  229. extern CSPBOOL
  230. CSPVerifySignatureA(
  231. HCRYPTHASH hHash,
  232. CONST BYTE *pbSignature,
  233. DWORD dwSigLen,
  234. HCRYPTKEY hPubKey,
  235. LPCSTR sDescription,
  236. DWORD dwFlags);
  237. extern CSPBOOL
  238. CSPVerifySignatureW(
  239. HCRYPTHASH hHash,
  240. CONST BYTE *pbSignature,
  241. DWORD dwSigLen,
  242. HCRYPTKEY hPubKey,
  243. LPCWSTR sDescription,
  244. DWORD dwFlags);
  245. extern CSPBOOL
  246. CSPSetProviderA(
  247. LPCSTR pszProvName,
  248. DWORD dwProvType);
  249. extern CSPBOOL
  250. CSPSetProviderW(
  251. LPCWSTR pszProvName,
  252. DWORD dwProvType);
  253. //
  254. // CSP Entry points.
  255. //
  256. extern BOOL WINAPI
  257. CPAcquireContext(
  258. OUT HCRYPTPROV *phProv,
  259. LPCTSTR pszContainer,
  260. IN DWORD dwFlags,
  261. IN PVTableProvStruc pVTable);
  262. extern BOOL WINAPI
  263. CPAcquireContextEx(
  264. OUT HCRYPTPROV *phProv,
  265. LPCTSTR pszContainer,
  266. IN DWORD dwFlags,
  267. IN LPCVOID pvParams,
  268. IN PVTableProvStruc pVTable);
  269. extern BOOL WINAPI
  270. CPReleaseContext(
  271. IN HCRYPTPROV hProv,
  272. IN DWORD dwFlags);
  273. extern BOOL WINAPI
  274. CPGenKey(
  275. IN HCRYPTPROV hProv,
  276. IN ALG_ID Algid,
  277. IN DWORD dwFlags,
  278. OUT HCRYPTKEY *phKey);
  279. extern BOOL WINAPI
  280. CPDeriveKey(
  281. IN HCRYPTPROV hProv,
  282. IN ALG_ID Algid,
  283. IN HCRYPTHASH hHash,
  284. IN DWORD dwFlags,
  285. OUT HCRYPTKEY * phKey);
  286. extern BOOL WINAPI
  287. CPDestroyKey(
  288. IN HCRYPTPROV hProv,
  289. IN HCRYPTKEY hKey);
  290. extern BOOL WINAPI
  291. CPSetKeyParam(
  292. IN HCRYPTPROV hProv,
  293. IN HCRYPTKEY hKey,
  294. IN DWORD dwParam,
  295. IN BYTE *pbData,
  296. IN DWORD dwFlags);
  297. extern BOOL WINAPI
  298. CPGetKeyParam(
  299. IN HCRYPTPROV hProv,
  300. IN HCRYPTKEY hKey,
  301. IN DWORD dwParam,
  302. OUT BYTE *pbData,
  303. IN DWORD *pdwDataLen,
  304. IN DWORD dwFlags);
  305. extern BOOL WINAPI
  306. CPSetProvParam(
  307. IN HCRYPTPROV hProv,
  308. IN DWORD dwParam,
  309. IN BYTE *pbData,
  310. IN DWORD dwFlags);
  311. extern BOOL WINAPI
  312. CPGetProvParam(
  313. IN HCRYPTPROV hProv,
  314. IN DWORD dwParam,
  315. IN BYTE *pbData,
  316. IN OUT DWORD *pdwDataLen,
  317. IN DWORD dwFlags);
  318. extern BOOL WINAPI
  319. CPSetHashParam(
  320. IN HCRYPTPROV hProv,
  321. IN HCRYPTHASH hHash,
  322. IN DWORD dwParam,
  323. IN BYTE *pbData,
  324. IN DWORD dwFlags);
  325. extern BOOL WINAPI
  326. CPGetHashParam(
  327. IN HCRYPTPROV hProv,
  328. IN HCRYPTHASH hHash,
  329. IN DWORD dwParam,
  330. OUT BYTE *pbData,
  331. IN DWORD *pdwDataLen,
  332. IN DWORD dwFlags);
  333. extern BOOL WINAPI
  334. CPExportKey(
  335. IN HCRYPTPROV hProv,
  336. IN HCRYPTKEY hKey,
  337. IN HCRYPTKEY hPubKey,
  338. IN DWORD dwBlobType,
  339. IN DWORD dwFlags,
  340. OUT BYTE *pbData,
  341. IN OUT DWORD *pdwDataLen);
  342. extern BOOL WINAPI
  343. CPImportKey(
  344. IN HCRYPTPROV hProv,
  345. IN CONST BYTE *pbData,
  346. IN DWORD dwDataLen,
  347. IN HCRYPTKEY hPubKey,
  348. IN DWORD dwFlags,
  349. OUT HCRYPTKEY *phKey);
  350. extern BOOL WINAPI
  351. CPEncrypt(
  352. IN HCRYPTPROV hProv,
  353. IN HCRYPTKEY hKey,
  354. IN HCRYPTHASH hHash,
  355. IN BOOL Final,
  356. IN DWORD dwFlags,
  357. IN OUT BYTE *pbData,
  358. IN OUT DWORD *pdwDataLen,
  359. IN DWORD dwBufLen);
  360. extern BOOL WINAPI
  361. CPDecrypt(
  362. IN HCRYPTPROV hProv,
  363. IN HCRYPTKEY hKey,
  364. IN HCRYPTHASH hHash,
  365. IN BOOL Final,
  366. IN DWORD dwFlags,
  367. IN OUT BYTE *pbData,
  368. IN OUT DWORD *pdwDataLen);
  369. extern BOOL WINAPI
  370. CPCreateHash(
  371. IN HCRYPTPROV hProv,
  372. IN ALG_ID Algid,
  373. IN HCRYPTKEY hKey,
  374. IN DWORD dwFlags,
  375. OUT HCRYPTHASH *phHash);
  376. extern BOOL WINAPI
  377. CPHashData(
  378. IN HCRYPTPROV hProv,
  379. IN HCRYPTHASH hHash,
  380. IN CONST BYTE *pbData,
  381. IN DWORD dwDataLen,
  382. IN DWORD dwFlags);
  383. extern BOOL WINAPI
  384. CPHashSessionKey(
  385. IN HCRYPTPROV hProv,
  386. IN HCRYPTHASH hHash,
  387. IN HCRYPTKEY hKey,
  388. IN DWORD dwFlags);
  389. extern BOOL WINAPI
  390. CPSignHash(
  391. IN HCRYPTPROV hProv,
  392. IN HCRYPTHASH hHash,
  393. IN DWORD dwKeySpec,
  394. IN LPCTSTR sDescription,
  395. IN DWORD dwFlags,
  396. OUT BYTE *pbSignature,
  397. IN OUT DWORD *pdwSigLen);
  398. /*
  399. extern BOOL WINAPI
  400. CPGetHashValue(
  401. IN HCRYPTPROV g_hProv,
  402. IN HCRYPTHASH hHash,
  403. IN DWORD dwFlags,
  404. OUT BYTE *pbHash,
  405. IN OUT DWORD *pdwHashLen);
  406. */
  407. extern BOOL WINAPI
  408. CPDestroyHash(
  409. IN HCRYPTPROV hProv,
  410. IN HCRYPTHASH hHash);
  411. extern BOOL WINAPI
  412. CPSignHash(
  413. IN HCRYPTPROV hProv,
  414. IN HCRYPTHASH hHash,
  415. IN DWORD dwKeySpec,
  416. IN LPCTSTR sDescription,
  417. IN DWORD dwFlags,
  418. OUT BYTE *pbSignature,
  419. IN OUT DWORD *pdwSigLen);
  420. extern BOOL WINAPI
  421. CPVerifySignature(
  422. IN HCRYPTPROV hProv,
  423. IN HCRYPTHASH hHash,
  424. IN CONST BYTE *pbSignature,
  425. IN DWORD dwSigLen,
  426. IN HCRYPTKEY hPubKey,
  427. IN LPCTSTR sDescription,
  428. IN DWORD dwFlags);
  429. extern BOOL WINAPI
  430. CPGenRandom(
  431. IN HCRYPTPROV hProv,
  432. IN DWORD dwLen,
  433. IN OUT BYTE *pbBuffer);
  434. extern BOOL WINAPI
  435. CPGetUserKey(
  436. IN HCRYPTPROV hProv,
  437. IN DWORD dwKeySpec,
  438. OUT HCRYPTKEY *phUserKey);
  439. #ifdef __cplusplus
  440. }
  441. #endif
  442. #endif
  443. #endif // _CSPDIRECT_H_