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.

782 lines
30 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1996 - 1999
  6. //
  7. // File: mscat.h
  8. //
  9. // Contents: Microsoft Internet Security Catalog API
  10. //
  11. // History: 29-Apr-1997 pberkman created
  12. // 09-Sep-1997 pberkman add CATAdmin functions
  13. //
  14. //--------------------------------------------------------------------------
  15. #ifndef MSCAT_H
  16. #define MSCAT_H
  17. #if _MSC_VER > 1000
  18. #pragma once
  19. #endif
  20. #include "mssip.h"
  21. #ifdef __cplusplus
  22. extern "C"
  23. {
  24. #endif
  25. /////////////////////////////////////////////////////////////////////////////
  26. //
  27. // defines:
  28. //
  29. /////////////////////////////////////////////////////////////////////////////
  30. #define szOID_CATALOG_LIST "1.3.6.1.4.1.311.12.1.1"
  31. #define szOID_CATALOG_LIST_MEMBER "1.3.6.1.4.1.311.12.1.2"
  32. #define CRYPTCAT_FILEEXT L"CAT"
  33. #define CRYPTCAT_MAX_MEMBERTAG 64
  34. //
  35. // fdwOpenFlags
  36. //
  37. #define CRYPTCAT_OPEN_CREATENEW 0x00000001 // creates/overwrites
  38. #define CRYPTCAT_OPEN_ALWAYS 0x00000002 // opens/creates
  39. #define CRYPTCAT_OPEN_EXISTING 0x00000004 // opens only
  40. #define CRYPTCAT_OPEN_VERIFYSIGHASH 0x10000000 // verifies the signature (not the certs!)
  41. //
  42. // fdwMemberFlags (used internal -- do not fill)
  43. //
  44. //
  45. // dwAttrTypeAndAction
  46. //
  47. #define CRYPTCAT_ATTR_AUTHENTICATED 0x10000000
  48. #define CRYPTCAT_ATTR_UNAUTHENTICATED 0x20000000
  49. #define CRYPTCAT_ATTR_NAMEASCII 0x00000001 // ascii string
  50. #define CRYPTCAT_ATTR_NAMEOBJID 0x00000002 // crypt obj id
  51. #define CRYPTCAT_ATTR_DATAASCII 0x00010000 // do not decode simple ascii chars
  52. #define CRYPTCAT_ATTR_DATABASE64 0x00020000 // base 64
  53. #define CRYPTCAT_ATTR_DATAREPLACE 0x00040000 // this data is a replacment for an existing attr
  54. //
  55. // dwLocalError - CDF Parse
  56. //
  57. #define CRYPTCAT_E_AREA_HEADER 0x00000000
  58. #define CRYPTCAT_E_AREA_MEMBER 0x00010000
  59. #define CRYPTCAT_E_AREA_ATTRIBUTE 0x00020000
  60. #define CRYPTCAT_E_CDF_UNSUPPORTED 0x00000001
  61. #define CRYPTCAT_E_CDF_DUPLICATE 0x00000002
  62. #define CRYPTCAT_E_CDF_TAGNOTFOUND 0x00000004
  63. #define CRYPTCAT_E_CDF_MEMBER_FILE_PATH 0x00010001
  64. #define CRYPTCAT_E_CDF_MEMBER_INDIRECTDATA 0x00010002
  65. #define CRYPTCAT_E_CDF_MEMBER_FILENOTFOUND 0x00010004
  66. #define CRYPTCAT_E_CDF_BAD_GUID_CONV 0x00020001
  67. #define CRYPTCAT_E_CDF_ATTR_TOOFEWVALUES 0x00020002
  68. #define CRYPTCAT_E_CDF_ATTR_TYPECOMBO 0x00020004
  69. /////////////////////////////////////////////////////////////////////////////
  70. //
  71. // structures:
  72. //
  73. /////////////////////////////////////////////////////////////////////////////
  74. #include <pshpack8.h>
  75. typedef struct CRYPTCATSTORE_
  76. {
  77. DWORD cbStruct; // = sizeof(CRYPTCATSTORE)
  78. DWORD dwPublicVersion;
  79. LPWSTR pwszP7File;
  80. HCRYPTPROV hProv;
  81. DWORD dwEncodingType;
  82. DWORD fdwStoreFlags;
  83. HANDLE hReserved; // pStack(members) (null if init/pbData) INTERNAL!
  84. // 18-Sep-1997 pberkman: added
  85. HANDLE hAttrs; // pStack(Catalog attrs) INTERNAL!
  86. } CRYPTCATSTORE;
  87. typedef struct CRYPTCATMEMBER_
  88. {
  89. DWORD cbStruct; // = sizeof(CRYPTCATMEMBER)
  90. LPWSTR pwszReferenceTag;
  91. LPWSTR pwszFileName; // used only by the CDF APIs
  92. GUID gSubjectType; // may be zeros -- see sEncodedMemberInfo
  93. DWORD fdwMemberFlags;
  94. struct SIP_INDIRECT_DATA_ *pIndirectData; // may be null -- see sEncodedIndirectData
  95. DWORD dwCertVersion; // may be zero -- see sEncodedMemberInfo
  96. DWORD dwReserved; // used by enum -- DO NOT USE!
  97. HANDLE hReserved; // pStack(attrs) (null if init) INTERNAL!
  98. // 30-Sep-1997 pberkman: added
  99. CRYPT_ATTR_BLOB sEncodedIndirectData; // lazy decode
  100. CRYPT_ATTR_BLOB sEncodedMemberInfo; // lazy decode
  101. } CRYPTCATMEMBER;
  102. typedef struct CRYPTCATATTRIBUTE_
  103. {
  104. DWORD cbStruct; // = sizeof(CRYPTCATATTRIBUTE)
  105. LPWSTR pwszReferenceTag;
  106. DWORD dwAttrTypeAndAction;
  107. DWORD cbValue;
  108. BYTE *pbValue; // encoded CAT_NAMEVALUE struct
  109. DWORD dwReserved; // used by enum -- DO NOT USE!
  110. } CRYPTCATATTRIBUTE;
  111. typedef struct CRYPTCATCDF_
  112. {
  113. DWORD cbStruct; // = sizeof(CRYPTCATCDF)
  114. HANDLE hFile;
  115. DWORD dwCurFilePos;
  116. DWORD dwLastMemberOffset;
  117. BOOL fEOF;
  118. LPWSTR pwszResultDir;
  119. HANDLE hCATStore;
  120. } CRYPTCATCDF;
  121. typedef struct CATALOG_INFO_
  122. {
  123. DWORD cbStruct; // set to sizeof(CATALOG_INFO)
  124. WCHAR wszCatalogFile[MAX_PATH];
  125. } CATALOG_INFO;
  126. typedef HANDLE HCATADMIN;
  127. typedef HANDLE HCATINFO;
  128. #include <poppack.h>
  129. typedef void (WINAPI *PFN_CDF_PARSE_ERROR_CALLBACK)(IN DWORD dwErrorArea,
  130. IN DWORD dwLocalError,
  131. IN WCHAR *pwszLine);
  132. /////////////////////////////////////////////////////////////////////////////
  133. //
  134. // Prototypes:
  135. //
  136. /////////////////////////////////////////////////////////////////////////////
  137. /////////////////////////////////////////////////////////////////////////////
  138. //
  139. // Open:
  140. // --------------------------------------------------------------------------
  141. // Usage:
  142. // open the catalog for Get/Put operations.
  143. //
  144. // Return:
  145. // INVALID_HANDLE_VALUE: an error occured while opening Catalog
  146. //
  147. // Errors:
  148. // ERROR_INVALID_PARAMETER: an input parameter is incorrect
  149. //
  150. extern HANDLE WINAPI CryptCATOpen(IN LPWSTR pwszFileName,
  151. IN DWORD fdwOpenFlags,
  152. IN OPTIONAL HCRYPTPROV hProv,
  153. IN OPTIONAL DWORD dwPublicVersion,
  154. IN OPTIONAL DWORD dwEncodingType);
  155. /////////////////////////////////////////////////////////////////////////////
  156. //
  157. // Close:
  158. // --------------------------------------------------------------------------
  159. // Usage:
  160. // close the catalog handle.
  161. //
  162. // Errors:
  163. // ERROR_INVALID_PARAMETER: an input parameter is incorrect
  164. //
  165. extern BOOL WINAPI CryptCATClose(IN HANDLE hCatalog);
  166. /////////////////////////////////////////////////////////////////////////////
  167. //
  168. // StoreFromHandle:
  169. // --------------------------------------------------------------------------
  170. // Usage:
  171. // retrieve the CRYPTCATSTORE from the store handle.
  172. //
  173. // *** DO NOT FREE THE POINTER OR ANY OF ITS MEMBERS! ***
  174. //
  175. // Errors:
  176. // ERROR_INVALID_PARAMETER: an input parameter is incorrect
  177. //
  178. extern CRYPTCATSTORE * WINAPI CryptCATStoreFromHandle(IN HANDLE hCatalog);
  179. /////////////////////////////////////////////////////////////////////////////
  180. //
  181. // HandleFromStore:
  182. // --------------------------------------------------------------------------
  183. // Usage:
  184. // retrieve the handle from a CRYPTCATSTORE pointer.
  185. //
  186. // Errors:
  187. // ERROR_INVALID_PARAMETER: an input parameter is incorrect
  188. //
  189. extern HANDLE WINAPI CryptCATHandleFromStore(IN CRYPTCATSTORE *pCatStore);
  190. /////////////////////////////////////////////////////////////////////////////
  191. //
  192. // PersistStore
  193. // --------------------------------------------------------------------------
  194. // Usage:
  195. // Persist the information in the current Catalog Store to an unsigned
  196. // Catalog File. It is REQUIRED to fill in the pwszP7File member
  197. // of CRYPTCATSTORE prior to this call!
  198. //
  199. // Errors:
  200. // ERROR_INVALID_PARAMETER: an input parameter is incorrect
  201. //
  202. extern BOOL WINAPI CryptCATPersistStore(IN HANDLE hCatalog);
  203. /////////////////////////////////////////////////////////////////////////////
  204. //
  205. // CryptCATGetCatAttrInfo
  206. // --------------------------------------------------------------------------
  207. // Usage:
  208. //
  209. // *** DO NOT FREE THE POINTER OR ANY OF ITS MEMBERS! ***
  210. //
  211. // Errors:
  212. // ERROR_INVALID_PARAMETER: an input parameter is incorrect
  213. //
  214. extern CRYPTCATATTRIBUTE * WINAPI CryptCATGetCatAttrInfo(IN HANDLE hCatalog,
  215. IN LPWSTR pwszReferenceTag);
  216. /////////////////////////////////////////////////////////////////////////////
  217. //
  218. // CryptCATPutCatAttrInfo
  219. // --------------------------------------------------------------------------
  220. // Usage:
  221. // Allocates and adds the attribute to the catalog. Returns a pointer
  222. // to the allocated attribute.
  223. //
  224. // *** DO NOT FREE THE POINTER OR ANY OF ITS MEMBERS! ***
  225. //
  226. // Errors:
  227. // ERROR_INVALID_PARAMETER: an input parameter is incorrect
  228. //
  229. extern CRYPTCATATTRIBUTE * WINAPI CryptCATPutCatAttrInfo(IN HANDLE hCatalog,
  230. IN LPWSTR pwszReferenceTag,
  231. IN DWORD dwAttrTypeAndAction,
  232. IN DWORD cbData,
  233. IN BYTE *pbData);
  234. /////////////////////////////////////////////////////////////////////////////
  235. //
  236. // CryptCATEnumerateCatAttr
  237. // --------------------------------------------------------------------------
  238. // Usage:
  239. // Enumerates through the list of attributes associated with the catalog.
  240. // Returns a pointer to the attribute. This return should be passed in
  241. // as the 'PrevAttr' to continue the enumeration. On the first call,
  242. // the 'PrevAttr' should be set to NULL.
  243. //
  244. // *** DO NOT FREE THE POINTER OR ANY OF ITS MEMBERS! ***
  245. //
  246. // Errors:
  247. // ERROR_INVALID_PARAMETER: an input parameter is incorrect
  248. //
  249. extern CRYPTCATATTRIBUTE * WINAPI CryptCATEnumerateCatAttr(IN HANDLE hCatalog,
  250. IN CRYPTCATATTRIBUTE *pPrevAttr);
  251. /////////////////////////////////////////////////////////////////////////////
  252. //
  253. // CryptCATGetMemberInfo
  254. // --------------------------------------------------------------------------
  255. // Usage:
  256. // Retrieve the Tag info (member info) structure from the catalog
  257. // PKCS#7, fill the CRYPTCATMEMBER structure, and return. -- Opens a
  258. // member context.
  259. //
  260. // *** DO NOT FREE THE POINTER OR ANY OF ITS MEMBERS! ***
  261. //
  262. // Errors:
  263. // ERROR_INVALID_PARAMETER: an input parameter is incorrect
  264. //
  265. extern CRYPTCATMEMBER * WINAPI CryptCATGetMemberInfo(IN HANDLE hCatalog,
  266. IN LPWSTR pwszReferenceTag);
  267. /////////////////////////////////////////////////////////////////////////////
  268. //
  269. // CryptCATGetAttr:
  270. // --------------------------------------------------------------------------
  271. // Usage:
  272. // get pwszReferenceTag attribute information for a member.
  273. //
  274. // Errors:
  275. // ERROR_INVALID_PARAMETER: an input parameter is incorrect
  276. //
  277. extern CRYPTCATATTRIBUTE * WINAPI CryptCATGetAttrInfo(IN HANDLE hCatalog,
  278. IN CRYPTCATMEMBER *pCatMember,
  279. IN LPWSTR pwszReferenceTag);
  280. /////////////////////////////////////////////////////////////////////////////
  281. //
  282. // CryptCATPutMemberInfo
  283. // --------------------------------------------------------------------------
  284. // Usage:
  285. // Allocates and adds the member to the catalog. Returns a pointer
  286. // to the allocated member.
  287. //
  288. // *** DO NOT FREE THE POINTER OR ANY OF ITS MEMBERS! ***
  289. //
  290. // Errors:
  291. // ERROR_INVALID_PARAMETER: an input parameter is incorrect
  292. // CRYPT_E_EXISTS: the reference tag already exists
  293. // CRYPT_E_NOT_FOUND: the attr was not found
  294. //
  295. extern CRYPTCATMEMBER * WINAPI CryptCATPutMemberInfo(IN HANDLE hCatalog,
  296. IN OPTIONAL LPWSTR pwszFileName,
  297. IN LPWSTR pwszReferenceTag,
  298. IN GUID *pgSubjectType,
  299. IN DWORD dwCertVersion,
  300. IN DWORD cbSIPIndirectData,
  301. IN BYTE *pbSIPIndirectData);
  302. /////////////////////////////////////////////////////////////////////////////
  303. //
  304. // CryptCATPutAttrInfo
  305. // --------------------------------------------------------------------------
  306. // Usage:
  307. // Allocates and adds the attribute to the member. Returns a pointer
  308. // to the allocated attribute.
  309. //
  310. // *** DO NOT FREE THE POINTER OR ANY OF ITS MEMBERS! ***
  311. //
  312. // Errors:
  313. // ERROR_INVALID_PARAMETER: an input parameter is incorrect
  314. //
  315. extern CRYPTCATATTRIBUTE * WINAPI CryptCATPutAttrInfo(IN HANDLE hCatalog,
  316. IN CRYPTCATMEMBER *pCatMember,
  317. IN LPWSTR pwszReferenceTag,
  318. IN DWORD dwAttrTypeAndAction,
  319. IN DWORD cbData,
  320. IN BYTE *pbData);
  321. /////////////////////////////////////////////////////////////////////////////
  322. //
  323. // CryptCATEnumerateMember
  324. // --------------------------------------------------------------------------
  325. // Usage:
  326. // Enumerates through the list of members in the store. Returns a pointer
  327. // to the member. This return should be passed in as the 'PrevMember' to
  328. // continue the enumeration. On the first call, the 'PrevMember' should
  329. // be set to NULL.
  330. //
  331. // *** DO NOT FREE THE POINTER OR ANY OF ITS MEMBERS! ***
  332. //
  333. // Errors:
  334. // ERROR_INVALID_PARAMETER: an input parameter is incorrect
  335. //
  336. extern CRYPTCATMEMBER * WINAPI CryptCATEnumerateMember(IN HANDLE hCatalog,
  337. IN CRYPTCATMEMBER *pPrevMember);
  338. /////////////////////////////////////////////////////////////////////////////
  339. //
  340. // CryptCATEnumerateAttr
  341. // --------------------------------------------------------------------------
  342. // Usage:
  343. // Enumerates through the list of attributes associated with the member.
  344. // Returns a pointer to the attribute. This return should be passed in
  345. // as the 'PrevAttr' to continue the enumeration. On the first call,
  346. // the 'PrevAttr' should be set to NULL.
  347. //
  348. // *** DO NOT FREE THE POINTER OR ANY OF ITS MEMBERS! ***
  349. //
  350. // Errors:
  351. // ERROR_INVALID_PARAMETER: an input parameter is incorrect
  352. //
  353. extern CRYPTCATATTRIBUTE * WINAPI CryptCATEnumerateAttr(IN HANDLE hCatalog,
  354. IN CRYPTCATMEMBER *pCatMember,
  355. IN CRYPTCATATTRIBUTE *pPrevAttr);
  356. /////////////////////////////////////////////////////////////////////////////
  357. //
  358. // CryptCATCDFOpen
  359. // --------------------------------------------------------------------------
  360. // Usage:
  361. // Opens the specified CDF file and initialized the structure
  362. //
  363. // Errors:
  364. // ERROR_INVALID_PARAMETER: an input parameter is incorrect
  365. // ERROR_FILE_NOT_FOUND: the CDF file was not found
  366. //
  367. extern CRYPTCATCDF * WINAPI CryptCATCDFOpen(IN LPWSTR pwszFilePath,
  368. IN OPTIONAL PFN_CDF_PARSE_ERROR_CALLBACK pfnParseError);
  369. /////////////////////////////////////////////////////////////////////////////
  370. //
  371. // CryptCATCDFClose
  372. // --------------------------------------------------------------------------
  373. // Usage:
  374. // Closes the CDF file and deallocates the structure
  375. //
  376. // Errors:
  377. // ERROR_INVALID_PARAMETER: an input parameter is incorrect
  378. //
  379. extern BOOL WINAPI CryptCATCDFClose(IN CRYPTCATCDF *pCDF);
  380. /////////////////////////////////////////////////////////////////////////////
  381. //
  382. // CryptCATCDFEnumCatAttributes
  383. // --------------------------------------------------------------------------
  384. // Usage:
  385. // Enumerates Catalog level attributes within the "[CatalogFiles]"
  386. // section of the CDF.
  387. //
  388. // Errors:
  389. // ERROR_INVALID_PARAMETER: an input parameter is incorrect
  390. //
  391. extern CRYPTCATATTRIBUTE * WINAPI CryptCATCDFEnumCatAttributes(CRYPTCATCDF *pCDF,
  392. CRYPTCATATTRIBUTE *pPrevAttr,
  393. PFN_CDF_PARSE_ERROR_CALLBACK pfnParseError);
  394. /////////////////////////////////////////////////////////////////////////////
  395. //
  396. // CryptCATCDFEnumMembers
  397. // --------------------------------------------------------------------------
  398. // Usage:
  399. // Enumerates files within the "[CatalogFiles]" section of the CDF.
  400. //
  401. // Errors:
  402. // ERROR_INVALID_PARAMETER: an input parameter is incorrect
  403. //
  404. extern CRYPTCATMEMBER * WINAPI CryptCATCDFEnumMembers(IN CRYPTCATCDF *pCDF,
  405. IN CRYPTCATMEMBER *pPrevMember,
  406. IN OPTIONAL PFN_CDF_PARSE_ERROR_CALLBACK pfnParseError);
  407. /////////////////////////////////////////////////////////////////////////////
  408. //
  409. // CryptCATCDFEnumAttributes
  410. // --------------------------------------------------------------------------
  411. // Usage:
  412. // Enumerates the files attributes within the "[CatalogFiles]" section
  413. // of the CDF.
  414. //
  415. // Errors:
  416. // ERROR_INVALID_PARAMETER: an input parameter is incorrect
  417. //
  418. extern CRYPTCATATTRIBUTE *WINAPI CryptCATCDFEnumAttributes(IN CRYPTCATCDF *pCDF,
  419. IN CRYPTCATMEMBER *pMember,
  420. IN CRYPTCATATTRIBUTE *pPrevAttr,
  421. IN OPTIONAL PFN_CDF_PARSE_ERROR_CALLBACK pfnParseError);
  422. //////////////////////////////////////////////////////////////////////////
  423. //
  424. // IsCatalogFile
  425. // --------------------------------------------------------------------------
  426. // Usage:
  427. // Call this function to determine if the file is a Catalog File. Both
  428. // parameters are optional. HOWEVER, one of them MUST be passed!
  429. //
  430. // Return:
  431. // TRUE if it is.
  432. // FALSE if it isn't or an error occured.
  433. //
  434. //
  435. // Errors:
  436. // ERROR_INVALID_PARAMETER: an input parameter is incorrect
  437. // ERROR_NOT_ENOUGH_MEMORY: a memory allocation failed
  438. // {file errors} a file error occured
  439. //
  440. extern BOOL WINAPI IsCatalogFile(IN OPTIONAL HANDLE hFile,
  441. IN OPTIONAL WCHAR *pwszFileName);
  442. //////////////////////////////////////////////////////////////////////////
  443. //
  444. // CryptCATAdminAcquireContext
  445. // --------------------------------------------------------------------------
  446. // Usage:
  447. // Opens a new Admin Context based on the pgSubsystem Id.
  448. //
  449. // the Guid passed in will be converted to a string and used as the
  450. // sub-directory under %SystemRoot%\CatRoot to store all Catalog files
  451. // for this app/sub-system.
  452. //
  453. // if a NULL is passed in to the pgSubsystem parameter, all finds will be
  454. // "global" and any Adds will be under the "default" Subsystem.
  455. //
  456. // Return:
  457. // TRUE if phCatAdmin points to a valid context.
  458. // FALSE if an error occurs.
  459. //
  460. // Errors:
  461. // ERROR_INVALID_PARAMETER: an input parameter is incorrect
  462. // ERROR_NOT_ENOUGH_MEMORY: a memory allocation failed
  463. // ERROR_DATABASE_FAILURE: an error occured while processing
  464. // the database.
  465. //
  466. // Comments:
  467. // The dwFlags parameter is reserved for future use. Must
  468. // be set to NULL.
  469. //
  470. //
  471. extern BOOL WINAPI CryptCATAdminAcquireContext(OUT HCATADMIN *phCatAdmin,
  472. IN const GUID *pgSubsystem,
  473. IN DWORD dwFlags);
  474. //////////////////////////////////////////////////////////////////////////
  475. //
  476. // CryptCATAdminReleaseContext
  477. // --------------------------------------------------------------------------
  478. // Usage:
  479. // Releases (frees) all information related to the Admin Context
  480. //
  481. // Errors:
  482. // ERROR_INVALID_PARAMETER: an input parameter is incorrect
  483. //
  484. // Comments:
  485. // The dwFlags parameter is reserved for future use. Must
  486. // be set to NULL.
  487. //
  488. extern BOOL WINAPI CryptCATAdminReleaseContext(IN HCATADMIN hCatAdmin,
  489. IN DWORD dwFlags);
  490. //////////////////////////////////////////////////////////////////////////
  491. //
  492. // CryptCATAdminReleaseCatalogContext
  493. // -----------------------------------------------------------------------
  494. // Usage:
  495. // Call this function to release memory associated with the Catalog
  496. // Info Context.
  497. //
  498. // Errors:
  499. // ERROR_INVALID_PARAMETER: an input parameter is incorrect
  500. //
  501. // Comments:
  502. // the dwFlags parameter is reserved for future use and must be assigned
  503. // to NULL.
  504. //
  505. extern BOOL WINAPI CryptCATAdminReleaseCatalogContext(IN HCATADMIN hCatAdmin,
  506. IN HCATINFO hCatInfo,
  507. IN DWORD dwFlags);
  508. //////////////////////////////////////////////////////////////////////////
  509. //
  510. // CryptCATAdminEnumCatalogFromHash
  511. // --------------------------------------------------------------------------
  512. // Usage:
  513. // Call this function to retrieve the Catalog Info handle of the Catalog
  514. // file that currently "points" to the specified Member Hash.
  515. //
  516. // if hCatInfo is NULL, the first catalog found that contains the
  517. // hash will be returned.
  518. //
  519. // if hCatInfo is not NULL, the content must be initialized to NULL prior
  520. // to going into the enum loop -- this starts the first/next search.
  521. // This function uses this parameter to determine the last catalog returned.
  522. //
  523. // if hCatInfo is not NULL, and the loop is terminated prior to this
  524. // function returning NULL, the application must call
  525. // CryptCATAdminReleaseCatalogContext to free all memory associated with
  526. // ppPrevContext.
  527. //
  528. // Errors:
  529. // ERROR_INVALID_PARAMETER: an input parameter is incorrect
  530. // ERROR_NOT_ENOUGH_MEMORY: a memory allocation failed
  531. // ERROR_DATABASE_FAILURE: an error occurred while processing
  532. // the database.
  533. //
  534. extern HCATINFO WINAPI CryptCATAdminEnumCatalogFromHash(IN HCATADMIN hCatAdmin,
  535. IN BYTE *pbHash,
  536. IN DWORD cbHash,
  537. IN DWORD dwFlags,
  538. IN OUT HCATINFO *phPrevCatInfo);
  539. //////////////////////////////////////////////////////////////////////////
  540. //
  541. // CryptCATAdminCalcHashFromFileHandle
  542. // --------------------------------------------------------------------------
  543. // Usage:
  544. // Call this function to calculate the has based on an open file handle.
  545. //
  546. // Return:
  547. // TRUE if the pbHash was filled with the calculated hash.
  548. // FALSE if an error occured
  549. //
  550. // To obtain the size required for pbHash, set pbHash to NULL. The
  551. // correct size will be returned in pcbHash, the return value will
  552. // be TRUE and a call to GetLastError() will equal ERROR_INSUFFICIENT_BUFFER.
  553. //
  554. // Errors:
  555. // ERROR_INVALID_PARAMETER: an input parameter is incorrect
  556. // ERROR_INSUFFICIENT_BUFFER: the *pbHash was not big enough.
  557. // ERROR_NOT_ENOUGH_MEMORY: a memory allocation failed
  558. //
  559. // Comments:
  560. // the dwFlags parameter is reserved for future use and must be assigned
  561. // to NULL.
  562. //
  563. extern BOOL WINAPI CryptCATAdminCalcHashFromFileHandle(IN HANDLE hFile,
  564. IN OUT DWORD *pcbHash,
  565. OUT OPTIONAL BYTE *pbHash,
  566. IN DWORD dwFlags);
  567. //////////////////////////////////////////////////////////////////////////
  568. //
  569. // CryptCATAdminAddCatalog
  570. // --------------------------------------------------------------------------
  571. // Usage:
  572. // Call this function to add a catalog file to the CAT Maintenance
  573. // subsystem.
  574. //
  575. // if the pwszSelectedBaseName is NULL, the Catalog Admin system will
  576. // generate a file base name for you. Otherwise, this parameter is
  577. // used as the file name (base & extension only) of the copied Catalog
  578. // file.
  579. //
  580. // Call CryptCATAdminReleaseCatalogContext to free the memory associated
  581. // with the Catalog Context returned if not NULL.
  582. //
  583. // Return:
  584. // On success, the HCATINFO of the catalog that was successfully added
  585. // is returned. On failure, NULL is returned.
  586. //
  587. // Errors:
  588. // ERROR_INVALID_PARAMETER: an input parameter is incorrect
  589. // ERROR_NOT_ENOUGH_MEMORY: a memory allocation failed
  590. // ERROR_BAD_FORMAT: the file is not a catalog file.
  591. // ERROR_DATABASE_FAILURE: an error occurred while processing
  592. // the database.
  593. //
  594. // Comments:
  595. // the dwFlags parameter is reserved for future use and must be assigned
  596. // to NULL.
  597. //
  598. extern HCATINFO WINAPI CryptCATAdminAddCatalog(IN HCATADMIN hCatAdmin,
  599. IN WCHAR *pwszCatalogFile,
  600. IN OPTIONAL WCHAR *pwszSelectBaseName,
  601. IN DWORD dwFlags);
  602. //////////////////////////////////////////////////////////////////////////
  603. //
  604. // CryptCATAdminRemoveCatalog
  605. // --------------------------------------------------------------------------
  606. // Usage:
  607. // Call this function to remove a catalog file from the CAT Maintenance
  608. // subsystem.
  609. //
  610. // Return:
  611. // On success, TRUE is returned. FALSE if an error occurs.
  612. //
  613. // Errors:
  614. // ERROR_INVALID_PARAMETER: an input parameter is incorrect
  615. //
  616. // Comments:
  617. // pwszCatalogFile must point to a string that contains only the name
  618. // of the catalog file, ex. "foo.cat", and not a fully qualified path
  619. // name
  620. //
  621. extern BOOL WINAPI CryptCATAdminRemoveCatalog(IN HCATADMIN hCatAdmin,
  622. IN LPCWSTR pwszCatalogFile,
  623. IN DWORD dwFlags);
  624. //////////////////////////////////////////////////////////////////////////
  625. //
  626. // CryptCATCatalogInfoFromContext
  627. // --------------------------------------------------------------------------
  628. // Usage:
  629. // call this function to retrieve information relating to the
  630. // Catalog info handle passed from the Add Catalog function.
  631. //
  632. // Return:
  633. // On success, TRUE is returned and the CATALOG_INFO structure
  634. // is filled in.
  635. // FALSE if an error occurs.
  636. //
  637. // Errors:
  638. // ERROR_INVALID_PARAMETER: an input parameter is incorrect
  639. //
  640. // Comments:
  641. // the dwFlags parameter is reserved for future use and must be assigned
  642. // to NULL.
  643. //
  644. extern BOOL WINAPI CryptCATCatalogInfoFromContext(IN HCATINFO hCatInfo,
  645. IN OUT CATALOG_INFO *psCatInfo,
  646. IN DWORD dwFlags);
  647. //////////////////////////////////////////////////////////////////////////
  648. //
  649. // CryptCATAdminResolveCatalogPath
  650. // --------------------------------------------------------------------------
  651. // Usage:
  652. // call this function to retrieve the fully qualified path to the
  653. // catalog specified by pwszCatalogFile
  654. //
  655. // Return:
  656. // On success, TRUE is returned and the CATALOG_INFO structure
  657. // is filled in.
  658. // FALSE if an error occurs.
  659. //
  660. // Errors:
  661. // ERROR_INVALID_PARAMETER: an input parameter is incorrect
  662. // ERROR_NOT_ENOUGH_MEMORY: if the fully qualified path is longer
  663. // than MAX_PATH
  664. //
  665. // Comments:
  666. // the dwFlags parameter is reserved for future use and must be assigned
  667. // to NULL.
  668. //
  669. extern BOOL WINAPI CryptCATAdminResolveCatalogPath(IN HCATADMIN hCatAdmin,
  670. IN WCHAR *pwszCatalogFile,
  671. IN OUT CATALOG_INFO *psCatInfo,
  672. IN DWORD dwFlags);
  673. //////////////////////////////////////////////////////////////////////////
  674. //
  675. // CryptCATAdminPauseServiceForBackup
  676. // --------------------------------------------------------------------------
  677. // Usage:
  678. // call this function to pause the catalog sub-system in preparation
  679. // for backing up the catalog sub-systems files.
  680. //
  681. // Return:
  682. // On success, TRUE is returned. FALSE if an error occurs.
  683. //
  684. // Errors:
  685. // ERROR_INVALID_PARAMETER: an input parameter is incorrect
  686. // ERROR_TIMEOUT: if clients are accessing database files
  687. // and fail to relinquish them in a timely
  688. // manner.
  689. //
  690. // Comments:
  691. // the dwFlags parameter is reserved for future use and must be assigned
  692. // to NULL. Set fResume to FALSE when pausing the catalog service, and
  693. // set it to TRUE to resume service.
  694. //
  695. extern BOOL WINAPI CryptCATAdminPauseServiceForBackup(IN DWORD dwFlags,
  696. IN BOOL fResume);
  697. #ifdef __cplusplus
  698. }
  699. #endif
  700. #endif // MSCAT_H