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.

583 lines
16 KiB

  1. /*
  2. * password.h
  3. *
  4. * Copyright (c) 1995 by DataBeam Corporation, Lexington, KY
  5. *
  6. * Abstract:
  7. * This is the interface file for the class CPassword. This class
  8. * manages the data associated with a Password. Passwords are used to
  9. * restrict access to conferences. A password can be one of two basic
  10. * types. The simple type consists of either a simple numeric password or
  11. * a simple textual password, or both. The "PDU" type "Password" is a
  12. * structure which must contain the numeric form of the password and may
  13. * optionally contain the textual part as well. The "PDU" type
  14. * "PasswordSelector" is a union of the numeric and textual forms of a
  15. * password and is therefore always one or the other but not both. When
  16. * the password is not the simple type it assumes the form of a
  17. * "PasswordChallengeRequestResponse". This complex structure allows a
  18. * challenge-response scheme to be used to control access to conferences.
  19. *
  20. * Caveats:
  21. * None.
  22. *
  23. * Author:
  24. * blp/jbo
  25. */
  26. #ifndef _PASSWORD_DATA_
  27. #define _PASSWORD_DATA_
  28. #include "userdata.h"
  29. class CPassword;
  30. /*
  31. * This is the typedef for the structure used to maintain the challenge
  32. * response algorithms internally.
  33. */
  34. typedef struct
  35. {
  36. GCCPasswordAlgorithmType algorithm_type;
  37. CObjectKeyContainer *object_key;
  38. LPOSTR poszOctetString;
  39. } ResponseAlgorithmInfo;
  40. typedef ResponseAlgorithmInfo * PResponseAlgorithmInfo;
  41. /*
  42. * This is the typedef for the structure used to maintain the challenge items
  43. * associated with a challenge request.
  44. */
  45. typedef struct
  46. {
  47. ResponseAlgorithmInfo algorithm;
  48. CUserDataListContainer *challenge_data_list;
  49. } ChallengeItemInfo;
  50. typedef ChallengeItemInfo * PChallengeItemInfo;
  51. /*
  52. * This is the typedef for the structure used to maintain the memory used
  53. * to hold the user data and object key data associated with a challenge
  54. * request item.
  55. */
  56. typedef struct
  57. {
  58. LPBYTE user_data_list_memory;
  59. LPBYTE object_key_memory;
  60. } ChallengeItemMemoryInfo;
  61. typedef ChallengeItemMemoryInfo * PChallengeItemMemoryInfo;
  62. /*
  63. * This is the typedef for the structure used to maintain the
  64. * challenge-reponse items internally.
  65. */
  66. typedef struct
  67. {
  68. CPassword *password;
  69. CUserDataListContainer *response_data_list;
  70. } ChallengeResponseItemInfo;
  71. typedef ChallengeResponseItemInfo * PChallengeResponseItemInfo;
  72. /*
  73. * The set of challenge items is maintained internally in a linked List.
  74. */
  75. class CChallengeItemList : public CList
  76. {
  77. DEFINE_CLIST(CChallengeItemList, PChallengeItemInfo)
  78. };
  79. /*
  80. * The memory associated with each challenge item is maintained internally in
  81. * linked List.
  82. */
  83. class CChallengeItemMemoryList : public CList
  84. {
  85. DEFINE_CLIST(CChallengeItemMemoryList, PChallengeItemMemoryInfo)
  86. };
  87. /*
  88. * This is the typedef for the structure used to maintain the "Request"
  89. * data internally.
  90. */
  91. typedef struct
  92. {
  93. GCCResponseTag challenge_tag;
  94. CChallengeItemList ChallengeItemList;
  95. }
  96. RequestInfo, *PRequestInfo;
  97. /*
  98. * This is the typedef for the structure used to maintain the "Response"
  99. * data internally.
  100. */
  101. typedef struct
  102. {
  103. GCCResponseTag challenge_tag;
  104. ResponseAlgorithmInfo algorithm;
  105. ChallengeResponseItemInfo challenge_response_item;
  106. }
  107. ResponseInfo, *PResponseInfo;
  108. /*
  109. * Class definition:
  110. */
  111. class CPassword : public CRefCount
  112. {
  113. public:
  114. CPassword(PGCCPassword, PGCCError);
  115. CPassword(PGCCChallengeRequestResponse, PGCCError);
  116. CPassword(PPassword, PGCCError);
  117. CPassword(PPasswordSelector, PGCCError);
  118. CPassword(PPasswordChallengeRequestResponse, PGCCError);
  119. ~CPassword(void);
  120. GCCError LockPasswordData(void);
  121. void UnLockPasswordData(void);
  122. GCCError GetPasswordData(PGCCPassword *);
  123. GCCError GetPasswordChallengeData(PGCCChallengeRequestResponse *);
  124. GCCError GetPasswordPDU(PPassword);
  125. GCCError GetPasswordSelectorPDU(PPasswordSelector);
  126. GCCError GetPasswordChallengeResponsePDU(PPasswordChallengeRequestResponse);
  127. void FreePasswordChallengeResponsePDU(void);
  128. protected:
  129. BOOL m_fSimplePassword;
  130. BOOL m_fClearPassword;
  131. /*
  132. * Variables and structures used to hold the password data internally.
  133. */
  134. LPSTR m_pszNumeric;
  135. LPWSTR m_pwszText;
  136. PRequestInfo m_pInternalRequest;
  137. PResponseInfo m_pInternalResponse;
  138. /*
  139. * Structures used to hold the password data in "API" form.
  140. */
  141. PGCCChallengeRequestResponse m_pChallengeResponse;
  142. PGCCPassword m_pPassword;
  143. LPBYTE m_pUserDataMemory;
  144. LPBYTE m_pChallengeItemListMemory;
  145. LPBYTE m_pObjectKeyMemory;
  146. CChallengeItemMemoryList m_ChallengeItemMemoryList;
  147. /*
  148. * Structure used to hold the password data in "PDU" form.
  149. */
  150. PasswordChallengeRequestResponse m_ChallengeResponsePDU;
  151. BOOL m_fValidChallengeResponsePDU;
  152. private:
  153. GCCError ConvertAPIChallengeRequest(PGCCChallengeRequest);
  154. GCCError ConvertAPIChallengeResponse(PGCCChallengeResponse);
  155. GCCError CopyResponseAlgorithm(PGCCChallengeResponseAlgorithm, PResponseAlgorithmInfo);
  156. GCCError ConvertPDUChallengeRequest(PChallengeRequest);
  157. GCCError ConvertPDUChallengeItem(PChallengeItem);
  158. GCCError ConvertPDUChallengeResponse(PChallengeResponse);
  159. GCCError ConvertPDUResponseAlgorithm(PChallengeResponseAlgorithm, PResponseAlgorithmInfo);
  160. GCCError GetGCCChallengeRequest(PGCCChallengeRequest);
  161. GCCError GetGCCChallengeResponse(PGCCChallengeResponse);
  162. GCCError GetChallengeRequestPDU(PChallengeRequest);
  163. GCCError ConvertInternalChallengeItemToPDU(PChallengeItemInfo, PChallengeItem);
  164. GCCError GetChallengeResponsePDU(PChallengeResponse);
  165. void FreeChallengeRequestPDU(void);
  166. void FreeChallengeResponsePDU(void);
  167. void FreeAPIPasswordData(void);
  168. };
  169. /*
  170. * Comments explaining the public and protected class member functions
  171. */
  172. /*
  173. * CPassword ( PGCCPassword password,
  174. * PGCCError return_value);
  175. *
  176. * Public member function of CPassword.
  177. *
  178. * Function Description:
  179. * This is the constructor for the CPassword class which takes as
  180. * input the "API" version of password data, GCCPassword.
  181. *
  182. * Formal Parameters:
  183. * password (i) The password data to store.
  184. * return_value (o) The output parameter used to indicate errors.
  185. *
  186. * Return Value:
  187. * GCC_NO_ERROR - No error.
  188. * GCC_ALLOCATION_FAILURE - Error creating an object using the
  189. * "new" operator.
  190. * GCC_INVALID_PASSWORD - An invalid password passed in.
  191. *
  192. * Side Effects:
  193. * None.
  194. *
  195. * Caveats:
  196. * None.
  197. */
  198. /*
  199. * CPassword ( PGCCChallengeRequestResponse challenge_response_data,
  200. * PGCCError return_value)
  201. *
  202. * Public member function of CPassword.
  203. *
  204. * Function Description:
  205. * This is the constructor for the CPassword class which takes as
  206. * input the "API" version of password challenge data,
  207. * GCCChallengeRequestResponse.
  208. *
  209. * Formal Parameters:
  210. * challenge_response_data (i) The password challenge data to store.
  211. * return_value (o) The output parameter used to indicate errors.
  212. *
  213. * Return Value:
  214. * GCC_NO_ERROR - No error.
  215. * GCC_ALLOCATION_FAILURE - Error creating an object using the
  216. * "new" operator.
  217. * GCC_INVALID_PASSWORD - An invalid password passed in.
  218. *
  219. * Side Effects:
  220. * None.
  221. *
  222. * Caveats:
  223. * None.
  224. */
  225. /*
  226. * CPassword ( PPassword password_pdu,
  227. * PGCCError return_value)
  228. *
  229. * Public member function of CPassword.
  230. *
  231. * Function Description:
  232. * This is the constructor for the CPassword class which takes as
  233. * input the "PDU" version of password data, Password.
  234. *
  235. * Formal Parameters:
  236. * password_pdu (i) The password data to store.
  237. * return_value (o) The output parameter used to indicate errors.
  238. *
  239. * Return Value:
  240. * GCC_NO_ERROR - No error.
  241. * GCC_ALLOCATION_FAILURE - Error creating an object using the
  242. * "new" operator.
  243. * GCC_INVALID_PASSWORD - An invalid password passed in.
  244. *
  245. * Side Effects:
  246. * None.
  247. *
  248. * Caveats:
  249. * None.
  250. */
  251. /*
  252. * CPassword( PPasswordSelector password_selector_pdu,
  253. * PGCCError return_value)
  254. *
  255. * Public member function of CPassword.
  256. *
  257. * Function Description:
  258. * This is the constructor for the CPassword class which takes as
  259. * input the "PDU" version of password data, PasswordSelector.
  260. *
  261. * Formal Parameters:
  262. * password_selector_pdu (i) The password selector data to store.
  263. * return_value (o) The output parameter used to indicate errors.
  264. *
  265. * Return Value:
  266. * GCC_NO_ERROR - No error.
  267. * GCC_ALLOCATION_FAILURE - Error creating an object using the
  268. * "new" operator.
  269. * GCC_INVALID_PASSWORD - An invalid password passed in.
  270. *
  271. * Side Effects:
  272. * None.
  273. *
  274. * Caveats:
  275. * None.
  276. */
  277. /*
  278. * CPassword ( PPasswordChallengeRequestResponse pdu_challenge_data,
  279. * PGCCError return_value)
  280. *
  281. * Public member function of CPassword.
  282. *
  283. * Function Description:
  284. * This is the constructor for the CPassword class which takes as
  285. * input the "PDU" version of password challenge data,
  286. * PasswordChallengeRequestResponse.
  287. *
  288. * Formal Parameters:
  289. * pdu_challenge_data (i) The password challenge data to store.
  290. * return_value (o) The output parameter used to indicate errors.
  291. *
  292. * Return Value:
  293. * GCC_NO_ERROR - No error.
  294. * GCC_ALLOCATION_FAILURE - Error creating an object using the
  295. * "new" operator.
  296. * GCC_INVALID_PASSWORD - An invalid password passed in.
  297. *
  298. * Side Effects:
  299. * None.
  300. *
  301. * Caveats:
  302. * None.
  303. */
  304. /*
  305. * ~CPassword();
  306. *
  307. * Public member function of CPassword.
  308. *
  309. * Function Description:
  310. * This is the destructor for the CPassword class. It is used to
  311. * clean up any memory allocated during the life of this object.
  312. *
  313. * Formal Parameters:
  314. * None.
  315. *
  316. * Return Value:
  317. * None.
  318. *
  319. * Side Effects:
  320. * None.
  321. *
  322. * Caveats:
  323. * None.
  324. */
  325. /*
  326. * GCCError LockPasswordData ();
  327. *
  328. * Public member function of CPassword.
  329. *
  330. * Function Description:
  331. * This routine is used to "lock" the "API" data for this object. This
  332. * results in the appropriate form of the "API" password being stored
  333. * internally in preparation for a call to "GetGCCPasswordData" which will
  334. * return that data.
  335. *
  336. * Formal Parameters:
  337. * None.
  338. *
  339. * Return Value:
  340. * GCC_NO_ERROR - No error.
  341. * GCC_ALLOCATION_FAILURE - Error creating an object using the
  342. * "new" operator.
  343. *
  344. * Side Effects:
  345. * The internal lock count is incremented.
  346. *
  347. * Caveats:
  348. * The internal lock count is used in conjuction with an internal "free"
  349. * flag as a mechanism for ensuring that this object remains in existance
  350. * until all interested parties are through with it. The object remains
  351. * valid (unless explicity deleted) until the lock count is zero and the
  352. * "free" flag is set through a call to FreePasswordData. This allows
  353. * other objects to lock this object and be sure that it remains valid
  354. * until they call UnLock which will decrement the internal lock count. A
  355. * typical usage scenerio for this object would be: A CPassword
  356. * object is constructed and then passed off to any interested parties
  357. * through a function call. On return from the function call, the
  358. * FreePasswordData call is made which will set the internal "free"
  359. * flag. If no other parties have locked the object with a Lock call,
  360. * then the CPassword object will automatically delete itself when
  361. * the FreePasswordData call is made. If, however, any number of
  362. * other parties has locked the object, it will remain in existence until
  363. * each of them has unlocked the object through a call to UnLock.
  364. */
  365. /*
  366. * GCCError GetPasswordData ( PGCCPassword * gcc_password)
  367. *
  368. * Public member function of CPassword.
  369. *
  370. * Function Description:
  371. * This routine is used to retrieve the password data from the
  372. * CPassword object in the "API" form of a GCCPassword.
  373. *
  374. * Formal Parameters:
  375. * gcc_password (o) The GCCPassword structure to fill in.
  376. *
  377. * Return Value:
  378. * GCC_NO_ERROR - No error.
  379. * GCC_ALLOCATION_FAILURE - The object was not properly locked
  380. * prior to this call.
  381. *
  382. * Side Effects:
  383. * None.
  384. *
  385. * Caveats:
  386. * None.
  387. */
  388. /*
  389. * GCCError GetPasswordChallengeData (
  390. * PGCCChallengeRequestResponse * gcc_challenge_password)
  391. *
  392. * Public member function of CPassword.
  393. *
  394. * Function Description:
  395. * This routine is used to retrieve the password challenge data from the
  396. * CPassword object in the "API" form of a GCCChallengeRequestResponse.
  397. *
  398. * Formal Parameters:
  399. * gcc_challenge_password (o) The GCCChallengeRequestResponse
  400. * structure to fill in.
  401. *
  402. * Return Value:
  403. * GCC_NO_ERROR - No error.
  404. * GCC_ALLOCATION_FAILURE - The object was not properly locked
  405. * prior to this call.
  406. *
  407. * Side Effects:
  408. * None.
  409. *
  410. * Caveats:
  411. * None.
  412. */
  413. /*
  414. * void UnLockPasswordData ();
  415. *
  416. * Public member function of CPassword.
  417. *
  418. * Function Description:
  419. * This routine is used to "unlock" the "API" data for this object. This
  420. * results in the lock count for this object being decremented. When the
  421. * lock count transitions from 1 to 0, a check is made to determine
  422. * whether the object has been freed through a call to FreePasswordData.
  423. * If so, the object will automatically delete itself.
  424. *
  425. * Formal Parameters:
  426. * None.
  427. *
  428. * Return Value:
  429. * None.
  430. *
  431. * Side Effects:
  432. * The internal lock count is decremented.
  433. *
  434. * Caveats:
  435. * It is the responsibility of any party which locks a CPassword
  436. * object by calling Lock to also unlock the object with a call to UnLock.
  437. * If the party calling UnLock did not construct the CPassword
  438. * object, it should assume the object to be invalid thereafter.
  439. */
  440. /*
  441. * GCCError GetPasswordPDU (PPassword pdu_password)
  442. *
  443. * Public member function of CPassword.
  444. *
  445. * Function Description:
  446. * This routine is used to retrieve the password data from the
  447. * CPassword object in the "PDU" form of a Password.
  448. *
  449. * Formal Parameters:
  450. * pdu_password (o) The Password structure to fill in.
  451. *
  452. * Return Value:
  453. * GCC_NO_ERROR - No error.
  454. * GCC_ALLOCATION_FAILURE - The required numeric portion of the
  455. * password does not exist.
  456. *
  457. * Side Effects:
  458. * None.
  459. *
  460. * Caveats:
  461. * None.
  462. */
  463. /*
  464. * GCCError GetPasswordSelectorPDU(
  465. * PPasswordSelector password_selector_pdu)
  466. *
  467. * Public member function of CPassword.
  468. *
  469. * Function Description:
  470. * This routine is used to retrieve the password data from the
  471. * CPassword object in the "PDU" form of a PasswordSelector.
  472. *
  473. * Formal Parameters:
  474. * password_selector_pdu (o) The PasswordSelector structure to fill in.
  475. *
  476. * Return Value:
  477. * GCC_NO_ERROR - No error.
  478. * GCC_INVALID_PASSWORD - Neither the numeric nor the textual
  479. * form of the password are valid.
  480. *
  481. * Side Effects:
  482. * None.
  483. *
  484. * Caveats:
  485. * None.
  486. */
  487. /*
  488. * GCCError GetPasswordChallengeResponsePDU(
  489. * PPasswordChallengeRequestResponse challenge_pdu)
  490. *
  491. * Public member function of CPassword.
  492. *
  493. * Function Description:
  494. * This routine is used to retrieve the password challenge data from the
  495. * CPassword object in the "PDU" form of a
  496. * PasswordChallengeRequestResponse.
  497. *
  498. * Formal Parameters:
  499. * challenge_pdu (o) The PasswordChallengeRequestResponse
  500. * structure to fill in.
  501. *
  502. * Return Value:
  503. * GCC_NO_ERROR - No error.
  504. * GCC_INVALID_PARAMETER - Invalid attempt to retrieve
  505. * challenge data from a simple
  506. * password.
  507. * GCC_INVALID_PASSWORD - The challenge password is "clear"
  508. * but no valid data exists.
  509. * GCC_ALLOCATION_FAILURE - Neither the numeric nor the textual
  510. * form of the password are valid.
  511. *
  512. * Side Effects:
  513. * None.
  514. *
  515. * Caveats:
  516. * None.
  517. */
  518. /*
  519. * void FreePasswordChallengeResponsePDU ()
  520. *
  521. * Public member function of CPassword.
  522. *
  523. * Function Description:
  524. * This routine is used to "free" the "PDU" data allocated for this object
  525. * which is held internally in a GCCChallengeRequestResponse structure.
  526. *
  527. * Formal Parameters:
  528. * None.
  529. *
  530. * Return Value:
  531. * None.
  532. *
  533. * Side Effects:
  534. * The internal "free" flag is set.
  535. *
  536. * Caveats:
  537. * This object should be assumed invalid after a call to
  538. * FreePasswordChallengeResponsePDU has been made.
  539. */
  540. #endif