Source code of Windows XP (NT5)
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.

341 lines
6.1 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1995.
  5. //
  6. // File: capi.c
  7. //
  8. // Contents: Traffic cop routines that allow schannel to switch between
  9. // calling an actual CSP and calling a statically linked
  10. // (domestic) CSP.
  11. //
  12. // Functions:
  13. //
  14. // History: 11-04-97 jbanes Created.
  15. // 03-31-99 jbanes Removed support for static CSP.
  16. //
  17. //----------------------------------------------------------------------------
  18. #include <spbase.h>
  19. BOOL
  20. WINAPI
  21. SchCryptAcquireContextA(
  22. HCRYPTPROV *phProv,
  23. LPCSTR pszContainer,
  24. LPCSTR pszProvider,
  25. DWORD dwProvType,
  26. DWORD dwFlags,
  27. DWORD dwSchFlags)
  28. {
  29. return CryptAcquireContextA(phProv, pszContainer, pszProvider, dwProvType, dwFlags);
  30. }
  31. BOOL
  32. WINAPI
  33. SchCryptAcquireContextW(
  34. HCRYPTPROV *phProv,
  35. LPCWSTR pszContainer,
  36. LPCWSTR pszProvider,
  37. DWORD dwProvType,
  38. DWORD dwFlags,
  39. DWORD dwSchFlags)
  40. {
  41. return CryptAcquireContextW(phProv, pszContainer, pszProvider, dwProvType, dwFlags);
  42. }
  43. BOOL
  44. WINAPI
  45. SchCryptCreateHash(
  46. HCRYPTPROV hProv,
  47. ALG_ID Algid,
  48. HCRYPTKEY hKey,
  49. DWORD dwFlags,
  50. HCRYPTHASH *phHash,
  51. DWORD dwSchFlags)
  52. {
  53. return CryptCreateHash(hProv, Algid, hKey, dwFlags, phHash);
  54. }
  55. BOOL
  56. WINAPI
  57. SchCryptDecrypt(
  58. HCRYPTKEY hKey,
  59. HCRYPTHASH hHash,
  60. BOOL Final,
  61. DWORD dwFlags,
  62. BYTE *pbData,
  63. DWORD *pdwDataLen,
  64. DWORD dwSchFlags)
  65. {
  66. return CryptDecrypt(hKey, hHash, Final, dwFlags, pbData, pdwDataLen);
  67. }
  68. BOOL
  69. WINAPI
  70. SchCryptDeriveKey(
  71. HCRYPTPROV hProv,
  72. ALG_ID Algid,
  73. HCRYPTHASH hBaseData,
  74. DWORD dwFlags,
  75. HCRYPTKEY *phKey,
  76. DWORD dwSchFlags)
  77. {
  78. return CryptDeriveKey(hProv, Algid, hBaseData, dwFlags, phKey);
  79. }
  80. BOOL
  81. WINAPI
  82. SchCryptDestroyHash(
  83. HCRYPTHASH hHash,
  84. DWORD dwSchFlags)
  85. {
  86. return CryptDestroyHash(hHash);
  87. }
  88. BOOL
  89. WINAPI
  90. SchCryptDestroyKey(
  91. HCRYPTKEY hKey,
  92. DWORD dwSchFlags)
  93. {
  94. return CryptDestroyKey(hKey);
  95. }
  96. BOOL
  97. WINAPI
  98. SchCryptDuplicateHash(
  99. HCRYPTHASH hHash,
  100. DWORD *pdwReserved,
  101. DWORD dwFlags,
  102. HCRYPTHASH * phHash,
  103. DWORD dwSchFlags)
  104. {
  105. return CryptDuplicateHash(hHash, pdwReserved, dwFlags, phHash);
  106. }
  107. BOOL
  108. WINAPI
  109. SchCryptDuplicateKey(
  110. HCRYPTKEY hKey,
  111. DWORD *pdwReserved,
  112. DWORD dwFlags,
  113. HCRYPTKEY * phKey,
  114. DWORD dwSchFlags)
  115. {
  116. return CryptDuplicateKey(hKey, pdwReserved, dwFlags, phKey);
  117. }
  118. BOOL
  119. WINAPI
  120. SchCryptEncrypt(
  121. HCRYPTKEY hKey,
  122. HCRYPTHASH hHash,
  123. BOOL Final,
  124. DWORD dwFlags,
  125. BYTE *pbData,
  126. DWORD *pdwDataLen,
  127. DWORD dwBufLen,
  128. DWORD dwSchFlags)
  129. {
  130. return CryptEncrypt(hKey, hHash, Final, dwFlags, pbData, pdwDataLen, dwBufLen);
  131. }
  132. BOOL
  133. WINAPI
  134. SchCryptExportKey(
  135. HCRYPTKEY hKey,
  136. HCRYPTKEY hExpKey,
  137. DWORD dwBlobType,
  138. DWORD dwFlags,
  139. BYTE *pbData,
  140. DWORD *pdwDataLen,
  141. DWORD dwSchFlags)
  142. {
  143. return CryptExportKey(hKey, hExpKey, dwBlobType, dwFlags, pbData, pdwDataLen);
  144. }
  145. BOOL
  146. WINAPI
  147. SchCryptGenKey(
  148. HCRYPTPROV hProv,
  149. ALG_ID Algid,
  150. DWORD dwFlags,
  151. HCRYPTKEY *phKey,
  152. DWORD dwSchFlags)
  153. {
  154. return CryptGenKey(hProv, Algid, dwFlags, phKey);
  155. }
  156. BOOL
  157. WINAPI
  158. SchCryptGenRandom(
  159. HCRYPTPROV hProv,
  160. DWORD dwLen,
  161. BYTE *pbBuffer,
  162. DWORD dwSchFlags)
  163. {
  164. return CryptGenRandom(hProv, dwLen, pbBuffer);
  165. }
  166. BOOL
  167. WINAPI
  168. SchCryptGetHashParam(
  169. HCRYPTHASH hHash,
  170. DWORD dwParam,
  171. BYTE *pbData,
  172. DWORD *pdwDataLen,
  173. DWORD dwFlags,
  174. DWORD dwSchFlags)
  175. {
  176. return CryptGetHashParam(hHash, dwParam, pbData, pdwDataLen, dwFlags);
  177. }
  178. BOOL
  179. WINAPI
  180. SchCryptGetKeyParam(
  181. HCRYPTKEY hKey,
  182. DWORD dwParam,
  183. BYTE *pbData,
  184. DWORD *pdwDataLen,
  185. DWORD dwFlags,
  186. DWORD dwSchFlags)
  187. {
  188. return CryptGetKeyParam(hKey, dwParam, pbData, pdwDataLen, dwFlags);
  189. }
  190. BOOL
  191. WINAPI
  192. SchCryptGetProvParam(
  193. HCRYPTPROV hProv,
  194. DWORD dwParam,
  195. BYTE *pbData,
  196. DWORD *pdwDataLen,
  197. DWORD dwFlags,
  198. DWORD dwSchFlags)
  199. {
  200. return CryptGetProvParam(hProv, dwParam, pbData, pdwDataLen, dwFlags);
  201. }
  202. BOOL
  203. WINAPI
  204. SchCryptGetUserKey(
  205. HCRYPTPROV hProv,
  206. DWORD dwKeySpec,
  207. HCRYPTKEY *phUserKey,
  208. DWORD dwSchFlags)
  209. {
  210. return CryptGetUserKey(hProv, dwKeySpec, phUserKey);
  211. }
  212. BOOL
  213. WINAPI
  214. SchCryptHashData(
  215. HCRYPTHASH hHash,
  216. CONST BYTE *pbData,
  217. DWORD dwDataLen,
  218. DWORD dwFlags,
  219. DWORD dwSchFlags)
  220. {
  221. return CryptHashData(hHash, pbData, dwDataLen, dwFlags);
  222. }
  223. BOOL
  224. WINAPI
  225. SchCryptHashSessionKey(
  226. HCRYPTHASH hHash,
  227. HCRYPTKEY hKey,
  228. DWORD dwFlags,
  229. DWORD dwSchFlags)
  230. {
  231. return CryptHashSessionKey(hHash, hKey, dwFlags);
  232. }
  233. BOOL
  234. WINAPI
  235. SchCryptImportKey(
  236. HCRYPTPROV hProv,
  237. CONST BYTE *pbData,
  238. DWORD dwDataLen,
  239. HCRYPTKEY hPubKey,
  240. DWORD dwFlags,
  241. HCRYPTKEY *phKey,
  242. DWORD dwSchFlags)
  243. {
  244. return CryptImportKey(hProv, pbData, dwDataLen, hPubKey, dwFlags, phKey);
  245. }
  246. BOOL
  247. WINAPI
  248. SchCryptReleaseContext(
  249. HCRYPTPROV hProv,
  250. DWORD dwFlags,
  251. DWORD dwSchFlags)
  252. {
  253. return CryptReleaseContext(hProv, dwFlags);
  254. }
  255. BOOL
  256. WINAPI
  257. SchCryptSetHashParam(
  258. HCRYPTHASH hHash,
  259. DWORD dwParam,
  260. BYTE *pbData,
  261. DWORD dwFlags,
  262. DWORD dwSchFlags)
  263. {
  264. return CryptSetHashParam(hHash, dwParam, pbData, dwFlags);
  265. }
  266. BOOL
  267. WINAPI
  268. SchCryptSetKeyParam(
  269. HCRYPTKEY hKey,
  270. DWORD dwParam,
  271. BYTE *pbData,
  272. DWORD dwFlags,
  273. DWORD dwSchFlags)
  274. {
  275. return CryptSetKeyParam(hKey, dwParam, pbData, dwFlags);
  276. }
  277. BOOL
  278. WINAPI
  279. SchCryptSetProvParam(
  280. HCRYPTPROV hProv,
  281. DWORD dwParam,
  282. BYTE *pbData,
  283. DWORD dwFlags,
  284. DWORD dwSchFlags)
  285. {
  286. return CryptSetProvParam(hProv, dwParam, pbData, dwFlags);
  287. }
  288. BOOL
  289. WINAPI
  290. SchCryptSignHash(
  291. HCRYPTHASH hHash,
  292. DWORD dwKeySpec,
  293. LPCSTR sDescription,
  294. DWORD dwFlags,
  295. BYTE *pbSignature,
  296. DWORD *pdwSigLen,
  297. DWORD dwSchFlags)
  298. {
  299. return CryptSignHash(hHash, dwKeySpec, sDescription, dwFlags, pbSignature, pdwSigLen);
  300. }
  301. BOOL
  302. WINAPI
  303. SchCryptVerifySignature(
  304. HCRYPTHASH hHash,
  305. CONST BYTE *pbSignature,
  306. DWORD dwSigLen,
  307. HCRYPTKEY hPubKey,
  308. LPCSTR sDescription,
  309. DWORD dwFlags,
  310. DWORD dwSchFlags)
  311. {
  312. return CryptVerifySignature(hHash, pbSignature, dwSigLen, hPubKey, sDescription, dwFlags);
  313. }