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.

346 lines
11 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // Copyright (C) 1996, Microsoft Corporation
  4. //
  5. // File: cacheapi.h
  6. //
  7. // Contents: The definitions of functions and structures which are used
  8. // external to the core of this library.
  9. //
  10. // Functions:
  11. //
  12. // History: 8/28/96 JayH created
  13. //
  14. // Todo:
  15. //
  16. // Bugs:
  17. //
  18. //-----------------------------------------------------------------------------
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif //__cplusplus
  22. typedef DWORD HCACHE;
  23. typedef HCACHE FAR * LPHCACHE;
  24. typedef DWORD HFORMAT;
  25. //
  26. // CACHE_TYPE is used to identify the type of cache entry being stored. Currently
  27. // the only cache entry type is USERNAME_PASSWORD. This type uses a secret blob
  28. // to hold the password, and does not store anything in the nonsecret blob.
  29. //
  30. typedef enum _CACHE_TYPE {
  31. CT_NONE,
  32. CT_USERNAME_PASSWORD
  33. } CACHE_TYPE;
  34. //
  35. // HFORMAT's for hashes are derived by concating two words which represent the
  36. // authentication algorithm they are used for and the version of the hash algorithm
  37. //
  38. #define HFORMAT_DPA_HASH_1 0x00010001
  39. #define HFORMAT_RPA_HASH_1 0x00020001
  40. #define CR_SAVE_SECRET 0x00000001
  41. #define CR_DELETE_PEERS 0x00000002
  42. #define CL_STORED_CACHE 0x00000010
  43. #define CL_CONFIRMED_CACHE 0x00000020
  44. //+------------------------------------------------------------
  45. //
  46. // Function: OpenCommonCache
  47. //
  48. // Synopsis: This function opens the common cache and performs
  49. // everything necessary to get it to work. That means if this
  50. // is the first time it is being called, it will call
  51. // InitCacheLibrary. This keeps a ref count.
  52. //
  53. // Arguments: szUserName -- Presently unused. This can be used to support
  54. // the sharing of the cache between users.
  55. // phCache -- The handle to the opened common cache is
  56. // returned here.
  57. // Returns: Nothing.
  58. //
  59. // History: Jayhoo Created 8/28/1996
  60. //
  61. //-------------------------------------------------------------
  62. HRESULT OpenCommonCache(LPTSTR szUserName,
  63. LPHCACHE phCache);
  64. //+------------------------------------------------------------
  65. //
  66. // Function: CloseCommonCache
  67. //
  68. // Synopsis: This function closes the cache and decrements the ref count on
  69. // it. If the reference count reaches zero, the library will be
  70. // closed.
  71. //
  72. // Arguments: szUserName -- Presently unused. This can be used to support
  73. // the sharing of the commmon cache between users.
  74. // phCache -- The handle to the opened common cache is
  75. // returned here.
  76. // Returns: Nothing.
  77. //
  78. // History: Jayhoo Created 8/28/1996
  79. //
  80. //-------------------------------------------------------------
  81. HRESULT CloseCommonCache(HCACHE hCache);
  82. //+------------------------------------------------------------
  83. //
  84. // Function: SetCacheEntry
  85. //
  86. // Synopsis: This function sets an entry in the cache. If the entry does
  87. // not already exist, it will create the entry. It sets the entry
  88. // in the persistent cache and the non-persistent cache, and it
  89. // creates hashed versions of the secret for every hash secret
  90. // format that it knows about.
  91. //
  92. // Arguments: hCache Handle of a valid, opened cache
  93. //
  94. // szEntryName The name of the entry, currently this must be
  95. // this must be the username since that is the
  96. // only supported form of cache entry.
  97. //
  98. // szListName This list of entries which that entry is valid
  99. // within. Currently this must be the domain name
  100. //
  101. // ctCacheType The type of cache entry being used. This must
  102. // be CT_USERNAME_PASSWORD.
  103. //
  104. // lpbSecretOpaque The secret information to be hashed before
  105. // it is stored (Sssshhh!)
  106. //
  107. // dwSizeSecretOpaque The size of the secret information
  108. //
  109. // lpbOpaque The information which doesn't need to be hashed
  110. //
  111. // dwSizeOpaque The size of the opaque info
  112. //
  113. // fCacheReq The flags about how this should be cached. The
  114. // only defined flag currently is CR_SAVE_SECRET
  115. //
  116. // fCacheLoc Allows the caller to specify where the cache
  117. // should be saved to. It is a bitmask of
  118. // CL_PERSISTENT and CL_NONPERSISTENT
  119. //
  120. // History: Jayhoo Created 8/28/1996
  121. //
  122. //-------------------------------------------------------------
  123. HRESULT SetCacheEntry(HCACHE hCache,
  124. LPTSTR szEntryName,
  125. LPTSTR szListName,
  126. CACHE_TYPE ctCacheType,
  127. LPBYTE lpbSecretOpaque,
  128. DWORD dwSizeSecretOpaque,
  129. LPBYTE lpbOpaque,
  130. DWORD dwSizeOpaque,
  131. DWORD fCacheReq,
  132. DWORD fCacheLoc);
  133. //+------------------------------------------------------------
  134. //
  135. // Function: DeleteCacheEntry
  136. //
  137. // Synopsis: This function gets an entry in the cache. If the entry does
  138. // not already exist, it returns failure. If the username
  139. // entered into the function is null, the default user will be
  140. // returned. Currently the default user is the only one in the
  141. // cache. You can only get secret information in the hashed
  142. // format.
  143. //
  144. // Arguments: hCache Handle of a valid, opened cache
  145. //
  146. // szEntryName The name of the entry to delete
  147. //
  148. // szListName The name of the list that entry is in
  149. //
  150. // ctCacheType The type of the entry
  151. //
  152. // fCacheLoc Allows the caller to specify where the cache
  153. // should be deleted from. It is a bitmask of
  154. // CL_PERSISTENT and CL_NONPERSISTENT
  155. //
  156. // History: Jayhoo Created 8/28/1996
  157. //
  158. //-------------------------------------------------------------
  159. HRESULT DeleteCacheEntry(HCACHE hCache,
  160. LPTSTR szEntryName,
  161. LPTSTR szListName,
  162. CACHE_TYPE ctCacheType,
  163. DWORD fCacheLoc);
  164. //+------------------------------------------------------------
  165. //
  166. // Function: GetCacheEntry
  167. //
  168. // Synopsis: This function gets an entry in the cache. If the entry does
  169. // not already exist, it returns failure. If the username
  170. // entered into the function is null, the default user will be
  171. // returned. Currently the default user is the only one in the
  172. // cache. You can only get secret information in the hashed
  173. // format.
  174. //
  175. // Arguments: hCache Handle of a valid, opened cache
  176. //
  177. // hFormat Handle of the format we wish to use
  178. //
  179. // szEntryName The name of the entry, currently this must be
  180. // this must be the username since that is the
  181. // only supported form of cache entry.
  182. //
  183. // szListName This list of entries which that entry is valid
  184. // within. Currently this must be the domain name
  185. //
  186. // ctCacheType The type of cache entry being used. This must
  187. // be CT_USERNAME_PASSWORD.
  188. //
  189. // lppbSecretOpaque Used to return the hashed secret. The
  190. // caller must free this by calling the
  191. // ReleaseBuffer function.
  192. //
  193. // lpdwSizeSecretOpaque returns he size of the secret data
  194. //
  195. // lppbOpaque Used to return the insecure information. The
  196. // caller must free this by calling the
  197. // ReleaseBuffer fucntion
  198. //
  199. // lpdwSizeOpaque Returns the size of the opaque info
  200. //
  201. // pfCacheReq Returns the flags about how this should be
  202. // cached. The only defined flag currently is
  203. // CR_SAVE_SECRET
  204. //
  205. // fCacheLoc Allows the caller to specify where the cache
  206. // should be loaded from. It is a bitmask of
  207. // CL_PERSISTENT and CL_NONPERSISTENT
  208. //
  209. // History: Jayhoo Created 8/28/1996
  210. //
  211. //-------------------------------------------------------------
  212. HRESULT GetCacheEntry(HCACHE hCache,
  213. HFORMAT hFormat,
  214. LPTSTR szEntryName,
  215. LPTSTR szListName,
  216. CACHE_TYPE ctCacheType,
  217. LPBYTE FAR *lppbSecretOpaque,
  218. LPDWORD lpdwSizeSecretOpaque,
  219. LPBYTE FAR *lppbOpaque,
  220. LPDWORD lpdwSizeOpaque,
  221. LPTSTR FAR *lpszEntryName,
  222. LPDWORD pfCacheReq,
  223. DWORD fCacheLoc);
  224. //+------------------------------------------------------------
  225. //
  226. // Function: AllocateBuffer
  227. //
  228. // Synopsis: This function is used to allocate all memory in the cache
  229. // library. This gives us a centralized way to optimize memory
  230. // allocation. Note that classes might use a cpool.
  231. //
  232. // Arguments: dwSizeBuffer The size of the buffer to be allocated
  233. //
  234. // History: Jayhoo Created 8/28/1996
  235. //
  236. //-------------------------------------------------------------
  237. LPBYTE AllocateBuffer(DWORD dwSizeBuffer);
  238. //+------------------------------------------------------------
  239. //
  240. // Function: ReleaseBuffer
  241. //
  242. // Synopsis: This function will release the buffer. This API is exposed
  243. // to the world so that we can allocate and return buffers and
  244. // have some way to be rid of them.
  245. //
  246. // Arguments: lpbBuffer The buffer to be released
  247. //
  248. // History: Jayhoo Created 8/28/1996
  249. //
  250. //-------------------------------------------------------------
  251. HRESULT ReleaseBuffer(LPBYTE lpbBuffer);
  252. //+------------------------------------------------------------
  253. //
  254. // Function: HashSecret
  255. //
  256. // Synopsis: This function will hash the secret for the caller. This
  257. // is done so that the hashing funciton will not be implemented
  258. // in multiple files.
  259. //
  260. // Arguments: lpbBuffer The buffer to be released
  261. //
  262. // History: Jayhoo Created 8/28/1996
  263. //
  264. //-------------------------------------------------------------
  265. HRESULT HashSecret(HFORMAT hFormat,
  266. CACHE_TYPE ctCacheType,
  267. LPBYTE lpbSecretBlob,
  268. DWORD dwSizeSecret,
  269. LPBYTE FAR * lppbHashedBlob,
  270. LPDWORD lpdwSizeHashedBlob);
  271. //+------------------------------------------------------------
  272. //
  273. // Function: ChangeEntryName
  274. //
  275. // Synopsis: This function will change the name of an entry in a given
  276. // list of a given cache type, for all formats in which it exists
  277. //
  278. // Arguments: lpbBuffer The buffer to be released
  279. //
  280. // History: Jayhoo Created 8/28/1996
  281. //
  282. //-------------------------------------------------------------
  283. HRESULT ChangeEntryName(HCACHE hCache,
  284. CACHE_TYPE ctCacheType,
  285. LPTSTR szStartEntryName,
  286. LPTSTR szEndEntryName,
  287. LPTSTR szListName,
  288. DWORD fCacheReq);
  289. //+------------------------------------------------------------
  290. //
  291. // Function: ConfirmCacheEntry
  292. //
  293. // Synopsis: This function will copy an entry in the stored cache to
  294. // the confirmed cache, for all hashed secret formats that
  295. // the cache type supports.
  296. //
  297. // Arguments: hCache Handle of a valid, opened cache
  298. //
  299. // szEntryName The name of the entry, currently this must be
  300. // this must be the username since that is the
  301. // only supported form of cache entry.
  302. //
  303. // szListName This list of entries which that entry is valid
  304. // within. Currently this must be the domain name
  305. //
  306. // ctCacheType The type of cache entry being used. This must
  307. // be CT_USERNAME_PASSWORD.
  308. //
  309. // History: Jayhoo Created 8/28/1996
  310. //
  311. //-------------------------------------------------------------
  312. HRESULT ConfirmCacheEntry(HCACHE hCache,
  313. LPTSTR szEntryName,
  314. LPTSTR szListName,
  315. CACHE_TYPE ctCacheType,
  316. DWORD fCacheReq);
  317. #ifdef __cplusplus
  318. }
  319. #endif //__cplusplus