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.

471 lines
6.9 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. iiscrypt.h
  5. Abstract:
  6. This include file contains public constants, type definitions, and
  7. function prototypes for the IIS cryptographic routines.
  8. Author:
  9. Keith Moore (keithmo) 02-Dec-1996
  10. Revision History:
  11. --*/
  12. #ifndef _IISCRYPT_H_
  13. #define _IISCRYPT_H_
  14. //
  15. // Get the dependent include files.
  16. //
  17. #include <windows.h>
  18. #include <wincrypt.h>
  19. #include <iiscblob.h>
  20. //
  21. // Define API decoration, should we ever move these routines into a DLL.
  22. //
  23. #define IIS_CRYPTO_API
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif // __cplusplus
  27. //
  28. // A NULL crypto handle, mysteriously absent from wincrypt.h.
  29. //
  30. #define CRYPT_NULL 0
  31. //
  32. // Initialization/termination functions.
  33. //
  34. IIS_CRYPTO_API
  35. HRESULT
  36. WINAPI
  37. IISCryptoInitialize(
  38. VOID
  39. );
  40. IIS_CRYPTO_API
  41. HRESULT
  42. WINAPI
  43. IISCryptoTerminate(
  44. VOID
  45. );
  46. // special function for programatically disabling encryption for French case
  47. VOID
  48. WINAPI
  49. IISCryptoInitializeOverride(
  50. BOOL flag
  51. );
  52. //
  53. // Memory allocation functions. Clients may provide their own
  54. // definitions of these routines if necessary.
  55. //
  56. PVOID
  57. WINAPI
  58. IISCryptoAllocMemory(
  59. IN DWORD Size
  60. );
  61. VOID
  62. WINAPI
  63. IISCryptoFreeMemory(
  64. IN PVOID Buffer
  65. );
  66. //
  67. // Container functions.
  68. //
  69. IIS_CRYPTO_API
  70. HRESULT
  71. WINAPI
  72. IISCryptoGetStandardContainer(
  73. OUT HCRYPTPROV * phProv,
  74. IN DWORD dwAdditionalFlags
  75. );
  76. IIS_CRYPTO_API
  77. HRESULT
  78. WINAPI
  79. IISCryptoGetStandardContainer2(
  80. OUT HCRYPTPROV * phProv
  81. );
  82. IIS_CRYPTO_API
  83. HRESULT
  84. WINAPI
  85. IISCryptoGetContainerByName(
  86. OUT HCRYPTPROV * phProv,
  87. IN LPTSTR pszContainerName,
  88. IN DWORD dwAdditionalFlags,
  89. IN BOOL fApplyAcl
  90. );
  91. IIS_CRYPTO_API
  92. HRESULT
  93. WINAPI
  94. IISCryptoDeleteStandardContainer(
  95. IN DWORD dwAdditionalFlags
  96. );
  97. IIS_CRYPTO_API
  98. HRESULT
  99. WINAPI
  100. IISCryptoDeleteContainerByName(
  101. IN LPTSTR pszContainerName,
  102. IN DWORD dwAdditionalFlags
  103. );
  104. IIS_CRYPTO_API
  105. HRESULT
  106. WINAPI
  107. IISCryptoCloseContainer(
  108. IN HCRYPTPROV hProv
  109. );
  110. //
  111. // Key manipulation functions.
  112. //
  113. IIS_CRYPTO_API
  114. HRESULT
  115. WINAPI
  116. IISCryptoGetKeyDeriveKey2(
  117. OUT HCRYPTKEY * phKey,
  118. IN HCRYPTPROV hProv,
  119. IN HCRYPTHASH hHash
  120. );
  121. IIS_CRYPTO_API
  122. HRESULT
  123. WINAPI
  124. IISCryptoGetKeyExchangeKey(
  125. OUT HCRYPTKEY * phKey,
  126. IN HCRYPTPROV hProv
  127. );
  128. IIS_CRYPTO_API
  129. HRESULT
  130. WINAPI
  131. IISCryptoGetSignatureKey(
  132. OUT HCRYPTKEY * phKey,
  133. IN HCRYPTPROV hProv
  134. );
  135. IIS_CRYPTO_API
  136. HRESULT
  137. WINAPI
  138. IISCryptoGenerateSessionKey(
  139. OUT HCRYPTKEY * phKey,
  140. IN HCRYPTPROV hProv
  141. );
  142. IIS_CRYPTO_API
  143. HRESULT
  144. WINAPI
  145. IISCryptoCloseKey(
  146. IN HCRYPTKEY hKey
  147. );
  148. //
  149. // Hash manipulation functions.
  150. //
  151. IIS_CRYPTO_API
  152. HRESULT
  153. WINAPI
  154. IISCryptoCreateHash(
  155. OUT HCRYPTHASH * phHash,
  156. IN HCRYPTPROV hProv
  157. );
  158. IIS_CRYPTO_API
  159. HRESULT
  160. WINAPI
  161. IISCryptoDestroyHash(
  162. IN HCRYPTHASH hHash
  163. );
  164. IIS_CRYPTO_API
  165. HRESULT
  166. WINAPI
  167. IISCryptoHashData(
  168. IN HCRYPTHASH hHash,
  169. IN PVOID pBuffer,
  170. IN DWORD dwBufferLength
  171. );
  172. IIS_CRYPTO_API
  173. HRESULT
  174. WINAPI
  175. IISCryptoHashSessionKey(
  176. IN HCRYPTHASH hHash,
  177. IN HCRYPTKEY hSessionKey
  178. );
  179. //
  180. // Generic blob manipulators.
  181. //
  182. #define IISCryptoGetBlobLength(p) (((p)->BlobDataLength) + sizeof(*(p)))
  183. IIS_CRYPTO_API
  184. HRESULT
  185. WINAPI
  186. IISCryptoReadBlobFromRegistry(
  187. OUT PIIS_CRYPTO_BLOB * ppBlob,
  188. IN HKEY hRegistryKey,
  189. IN LPCTSTR pszRegistryValueName
  190. );
  191. IIS_CRYPTO_API
  192. HRESULT
  193. WINAPI
  194. IISCryptoWriteBlobToRegistry(
  195. IN PIIS_CRYPTO_BLOB pBlob,
  196. IN HKEY hRegistryKey,
  197. IN LPCTSTR pszRegistryValueName
  198. );
  199. IIS_CRYPTO_API
  200. BOOL
  201. WINAPI
  202. IISCryptoIsValidBlob(
  203. IN PIIS_CRYPTO_BLOB pBlob
  204. );
  205. IIS_CRYPTO_API
  206. BOOL
  207. WINAPI
  208. IISCryptoIsValidBlob2(
  209. IN PIIS_CRYPTO_BLOB pBlob
  210. );
  211. IIS_CRYPTO_API
  212. HRESULT
  213. WINAPI
  214. IISCryptoFreeBlob(
  215. IN PIIS_CRYPTO_BLOB pBlob
  216. );
  217. IIS_CRYPTO_API
  218. HRESULT
  219. WINAPI
  220. IISCryptoFreeBlob2(
  221. IN PIIS_CRYPTO_BLOB pBlob
  222. );
  223. IIS_CRYPTO_API
  224. BOOL
  225. WINAPI
  226. IISCryptoCompareBlobs(
  227. IN PIIS_CRYPTO_BLOB pBlob1,
  228. IN PIIS_CRYPTO_BLOB pBlob2
  229. );
  230. IIS_CRYPTO_API
  231. HRESULT
  232. WINAPI
  233. IISCryptoCloneBlobFromRawData(
  234. OUT PIIS_CRYPTO_BLOB * ppBlob,
  235. IN PBYTE pRawBlob,
  236. IN DWORD dwRawBlobLength
  237. );
  238. IIS_CRYPTO_API
  239. HRESULT
  240. WINAPI
  241. IISCryptoCloneBlobFromRawData2(
  242. OUT PIIS_CRYPTO_BLOB * ppBlob,
  243. IN PBYTE pRawBlob,
  244. IN DWORD dwRawBlobLength
  245. );
  246. IIS_CRYPTO_API
  247. HRESULT
  248. WINAPI
  249. IISCryptoCreateCleartextBlob(
  250. OUT PIIS_CRYPTO_BLOB * ppBlob,
  251. IN PVOID pBlobData,
  252. IN DWORD dwBlobDataLength
  253. );
  254. //
  255. // Key blob functions.
  256. //
  257. IIS_CRYPTO_API
  258. HRESULT
  259. WINAPI
  260. IISCryptoExportSessionKeyBlob(
  261. OUT PIIS_CRYPTO_BLOB * ppSessionKeyBlob,
  262. IN HCRYPTPROV hProv,
  263. IN HCRYPTKEY hSessionKey,
  264. IN HCRYPTKEY hKeyExchangeKey
  265. );
  266. IIS_CRYPTO_API
  267. HRESULT
  268. WINAPI
  269. IISCryptoExportSessionKeyBlob2(
  270. OUT PIIS_CRYPTO_BLOB * ppSessionKeyBlob,
  271. IN HCRYPTPROV hProv,
  272. IN HCRYPTKEY hSessionKey,
  273. IN LPSTR pszPasswd
  274. );
  275. IIS_CRYPTO_API
  276. HRESULT
  277. WINAPI
  278. IISCryptoImportSessionKeyBlob(
  279. OUT HCRYPTKEY * phSessionKey,
  280. IN PIIS_CRYPTO_BLOB pSessionKeyBlob,
  281. IN HCRYPTPROV hProv,
  282. IN HCRYPTKEY hSignatureKey
  283. );
  284. IIS_CRYPTO_API
  285. HRESULT
  286. WINAPI
  287. IISCryptoImportSessionKeyBlob2(
  288. OUT HCRYPTKEY * phSessionKey,
  289. IN PIIS_CRYPTO_BLOB pSessionKeyBlob,
  290. IN HCRYPTPROV hProv,
  291. IN LPSTR pszPasswd
  292. );
  293. IIS_CRYPTO_API
  294. HRESULT
  295. WINAPI
  296. IISCryptoExportPublicKeyBlob(
  297. OUT PIIS_CRYPTO_BLOB * ppPublicKeyBlob,
  298. IN HCRYPTPROV hProv,
  299. IN HCRYPTKEY hPublicKey
  300. );
  301. IIS_CRYPTO_API
  302. HRESULT
  303. WINAPI
  304. IISCryptoImportPublicKeyBlob(
  305. OUT HCRYPTKEY * phPublicKey,
  306. IN PIIS_CRYPTO_BLOB pPublicKeyBlob,
  307. IN HCRYPTPROV hProv
  308. );
  309. //
  310. // Data blob functions.
  311. //
  312. IIS_CRYPTO_API
  313. HRESULT
  314. WINAPI
  315. IISCryptoEncryptDataBlob(
  316. OUT PIIS_CRYPTO_BLOB * ppDataBlob,
  317. IN PVOID pBuffer,
  318. IN DWORD dwBufferLength,
  319. IN DWORD dwRegType,
  320. IN HCRYPTPROV hProv,
  321. IN HCRYPTKEY hSessionKey
  322. );
  323. IIS_CRYPTO_API
  324. HRESULT
  325. WINAPI
  326. IISCryptoEncryptDataBlob2(
  327. OUT PIIS_CRYPTO_BLOB * ppDataBlob,
  328. IN PVOID pBuffer,
  329. IN DWORD dwBufferLength,
  330. IN DWORD dwRegType,
  331. IN HCRYPTPROV hProv,
  332. IN HCRYPTKEY hSessionKey
  333. );
  334. IIS_CRYPTO_API
  335. HRESULT
  336. WINAPI
  337. IISCryptoDecryptDataBlob(
  338. OUT PVOID * ppBuffer,
  339. OUT LPDWORD pdwBufferLength,
  340. OUT LPDWORD pdwRegType,
  341. IN PIIS_CRYPTO_BLOB pDataBlob,
  342. IN HCRYPTPROV hProv,
  343. IN HCRYPTKEY hSessionKey,
  344. IN HCRYPTKEY hSignatureKey
  345. );
  346. IIS_CRYPTO_API
  347. HRESULT
  348. WINAPI
  349. IISCryptoDecryptDataBlob2(
  350. OUT PVOID * ppBuffer,
  351. OUT LPDWORD pdwBufferLength,
  352. OUT LPDWORD pdwRegType,
  353. IN PIIS_CRYPTO_BLOB pDataBlob,
  354. IN HCRYPTPROV hProv,
  355. IN HCRYPTKEY hSessionKey
  356. );
  357. //
  358. // Hash blob functions.
  359. //
  360. IIS_CRYPTO_API
  361. HRESULT
  362. WINAPI
  363. IISCryptoExportHashBlob(
  364. OUT PIIS_CRYPTO_BLOB * ppHashBlob,
  365. IN HCRYPTHASH hHash
  366. );
  367. //
  368. // Simple check function for some special French case
  369. //
  370. BOOL
  371. WINAPI
  372. IISCryptoIsClearTextSignature (
  373. IIS_CRYPTO_BLOB UNALIGNED *pBlob
  374. );
  375. #ifdef __cplusplus
  376. } // extern "C"
  377. #endif // __cplusplus
  378. #endif // _IISCRYPT_H_