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.

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