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.

781 lines
19 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. owdcrypt.c
  5. Abstract:
  6. Contains functions that reversibly encrypt OwfPasswords
  7. RtlEncryptLmOwfPwdWithLmOwfPwd
  8. RtlDecryptLmOwfPwdWithLmOwfPwd
  9. RtlEncryptLmOwfPwdWithLmSesKey
  10. RtlDecryptLmOwfPwdWithLmSesKey
  11. RtlEncryptLmOwfPwdWithUserKey
  12. RtlDecryptLmOwfPwdWithUserKey
  13. RtlEncryptLmOwfPwdWithIndex
  14. RtlDecryptLmOwfPwdWithIndex
  15. RtlEncryptNtOwfPwdWithNtOwfPwd
  16. RtlDecryptNtOwfPwdWithNtOwfPwd
  17. RtlEncryptNtOwfPwdWithNtSesKey
  18. RtlDecryptNtOwfPwdWithNtSesKey
  19. RtlEncryptNtOwfPwdWithUserKey
  20. RtlDecryptNtOwfPwdWithUserKey
  21. RtlEncryptNtOwfPwdWithIndex
  22. RtlDecryptNtOwfPwdWithIndex
  23. Author:
  24. David Chalmers (Davidc) 10-21-91
  25. Revision History:
  26. --*/
  27. #include <nt.h>
  28. #include <ntrtl.h>
  29. #include <crypt.h>
  30. NTSTATUS
  31. RtlEncryptLmOwfPwdWithLmOwfPwd(
  32. IN PLM_OWF_PASSWORD DataLmOwfPassword,
  33. IN PLM_OWF_PASSWORD KeyLmOwfPassword,
  34. OUT PENCRYPTED_LM_OWF_PASSWORD EncryptedLmOwfPassword
  35. )
  36. /*++
  37. Routine Description:
  38. Encrypts one OwfPassword with another
  39. Arguments:
  40. DataLmOwfPassword - OwfPassword to be encrypted
  41. KeyLmOwfPassword - OwfPassword to be used as a key to the encryption
  42. EncryptedLmOwfPassword - The encrypted OwfPassword is returned here.
  43. Return Values:
  44. STATUS_SUCCESS - The function completed successfully. The encrypted
  45. OwfPassword is in EncryptedLmOwfPassword
  46. STATUS_UNSUCCESSFUL - Something failed. The EncryptedLmOwfPassword is undefined.
  47. --*/
  48. {
  49. NTSTATUS Status;
  50. Status = RtlEncryptBlock((PCLEAR_BLOCK)&(DataLmOwfPassword->data[0]),
  51. &(((PBLOCK_KEY)(KeyLmOwfPassword->data))[0]),
  52. &(EncryptedLmOwfPassword->data[0]));
  53. if (!NT_SUCCESS(Status)) {
  54. return(Status);
  55. }
  56. Status = RtlEncryptBlock((PCLEAR_BLOCK)&(DataLmOwfPassword->data[1]),
  57. &(((PBLOCK_KEY)(KeyLmOwfPassword->data))[1]),
  58. &(EncryptedLmOwfPassword->data[1]));
  59. return(Status);
  60. }
  61. NTSTATUS
  62. RtlDecryptLmOwfPwdWithLmOwfPwd(
  63. IN PENCRYPTED_LM_OWF_PASSWORD EncryptedLmOwfPassword,
  64. IN PLM_OWF_PASSWORD KeyLmOwfPassword,
  65. OUT PLM_OWF_PASSWORD DataLmOwfPassword
  66. )
  67. /*++
  68. Routine Description:
  69. Decrypts one OwfPassword with another
  70. Arguments:
  71. EncryptedLmOwfPassword - The ecnrypted OwfPassword to be decrypted
  72. KeyLmOwfPassword - OwfPassword to be used as a key to the encryption
  73. DataLmOwfPassword - The decrpted OwfPassword is returned here.
  74. Return Values:
  75. STATUS_SUCCESS - The function completed successfully. The decrypted
  76. OwfPassword is in DataLmOwfPassword
  77. STATUS_UNSUCCESSFUL - Something failed. The DataLmOwfPassword is undefined.
  78. --*/
  79. {
  80. NTSTATUS Status;
  81. Status = RtlDecryptBlock(&(EncryptedLmOwfPassword->data[0]),
  82. &(((PBLOCK_KEY)(KeyLmOwfPassword->data))[0]),
  83. (PCLEAR_BLOCK)&(DataLmOwfPassword->data[0]));
  84. if (!NT_SUCCESS(Status)) {
  85. return(Status);
  86. }
  87. Status = RtlDecryptBlock(&(EncryptedLmOwfPassword->data[1]),
  88. &(((PBLOCK_KEY)(KeyLmOwfPassword->data))[1]),
  89. (PCLEAR_BLOCK)&(DataLmOwfPassword->data[1]));
  90. return(Status);
  91. }
  92. NTSTATUS
  93. RtlEncryptNtOwfPwdWithNtOwfPwd(
  94. IN PNT_OWF_PASSWORD DataNtOwfPassword,
  95. IN PNT_OWF_PASSWORD KeyNtOwfPassword,
  96. OUT PENCRYPTED_NT_OWF_PASSWORD EncryptedNtOwfPassword
  97. )
  98. /*++
  99. Routine Description:
  100. Encrypts one OwfPassword with another
  101. Arguments:
  102. DataLmOwfPassword - OwfPassword to be encrypted
  103. KeyLmOwfPassword - OwfPassword to be used as a key to the encryption
  104. EncryptedLmOwfPassword - The encrypted OwfPassword is returned here.
  105. Return Values:
  106. STATUS_SUCCESS - The function completed successfully. The encrypted
  107. OwfPassword is in EncryptedLmOwfPassword
  108. STATUS_UNSUCCESSFUL - Something failed. The EncryptedLmOwfPassword is undefined.
  109. --*/
  110. {
  111. return(RtlEncryptLmOwfPwdWithLmOwfPwd(
  112. (PLM_OWF_PASSWORD)DataNtOwfPassword,
  113. (PLM_OWF_PASSWORD)KeyNtOwfPassword,
  114. (PENCRYPTED_LM_OWF_PASSWORD)EncryptedNtOwfPassword));
  115. }
  116. NTSTATUS
  117. RtlDecryptNtOwfPwdWithNtOwfPwd(
  118. IN PENCRYPTED_NT_OWF_PASSWORD EncryptedNtOwfPassword,
  119. IN PNT_OWF_PASSWORD KeyNtOwfPassword,
  120. OUT PNT_OWF_PASSWORD DataNtOwfPassword
  121. )
  122. /*++
  123. Routine Description:
  124. Decrypts one OwfPassword with another
  125. Arguments:
  126. EncryptedLmOwfPassword - The ecnrypted OwfPassword to be decrypted
  127. KeyLmOwfPassword - OwfPassword to be used as a key to the encryption
  128. DataLmOwfPassword - The decrpted OwfPassword is returned here.
  129. Return Values:
  130. STATUS_SUCCESS - The function completed successfully. The decrypted
  131. OwfPassword is in DataLmOwfPassword
  132. STATUS_UNSUCCESSFUL - Something failed. The DataLmOwfPassword is undefined.
  133. --*/
  134. {
  135. return(RtlDecryptLmOwfPwdWithLmOwfPwd(
  136. (PENCRYPTED_LM_OWF_PASSWORD)EncryptedNtOwfPassword,
  137. (PLM_OWF_PASSWORD)KeyNtOwfPassword,
  138. (PLM_OWF_PASSWORD)DataNtOwfPassword));
  139. }
  140. NTSTATUS
  141. RtlEncryptLmOwfPwdWithLmSesKey(
  142. IN PLM_OWF_PASSWORD LmOwfPassword,
  143. IN PLM_SESSION_KEY LmSessionKey,
  144. OUT PENCRYPTED_LM_OWF_PASSWORD EncryptedLmOwfPassword
  145. )
  146. /*++
  147. Routine Description:
  148. Encrypts an OwfPassword with a session key
  149. Arguments:
  150. LmOwfPassword - OwfPassword to be encrypted
  151. LmSessionKey - key to the encryption
  152. EncryptedLmOwfPassword - The ecnrypted OwfPassword is returned here.
  153. Return Values:
  154. STATUS_SUCCESS - The function completed successfully. The encrypted
  155. OwfPassword is in EncryptedLmOwfPassword
  156. STATUS_UNSUCCESSFUL - Something failed. The LMEncryptedLmOwfPassword is undefined.
  157. --*/
  158. {
  159. NTSTATUS Status;
  160. Status = RtlEncryptBlock((PCLEAR_BLOCK)&(LmOwfPassword->data[0]),
  161. (PBLOCK_KEY)LmSessionKey,
  162. &(EncryptedLmOwfPassword->data[0]));
  163. if (!NT_SUCCESS(Status)) {
  164. return(Status);
  165. }
  166. Status = RtlEncryptBlock((PCLEAR_BLOCK)&(LmOwfPassword->data[1]),
  167. (PBLOCK_KEY)LmSessionKey,
  168. &(EncryptedLmOwfPassword->data[1]));
  169. return(Status);
  170. }
  171. NTSTATUS
  172. RtlDecryptLmOwfPwdWithLmSesKey(
  173. IN PENCRYPTED_LM_OWF_PASSWORD EncryptedLmOwfPassword,
  174. IN PLM_SESSION_KEY LmSessionKey,
  175. OUT PLM_OWF_PASSWORD LmOwfPassword
  176. )
  177. /*++
  178. Routine Description:
  179. Decrypts one OwfPassword with a session key
  180. Arguments:
  181. EncryptedLmOwfPassword - The ecnrypted OwfPassword to be decrypted
  182. LmSessionKey - key to the encryption
  183. LmOwfPassword - The decrypted OwfPassword is returned here.
  184. Return Values:
  185. STATUS_SUCCESS - The function completed successfully. The decrypted
  186. OwfPassword is in LmOwfPassword
  187. STATUS_UNSUCCESSFUL - Something failed. The LmOwfPassword is undefined.
  188. --*/
  189. {
  190. NTSTATUS Status;
  191. Status = RtlDecryptBlock(&(EncryptedLmOwfPassword->data[0]),
  192. (PBLOCK_KEY)LmSessionKey,
  193. (PCLEAR_BLOCK)&(LmOwfPassword->data[0]));
  194. if (!NT_SUCCESS(Status)) {
  195. return(Status);
  196. }
  197. Status = RtlDecryptBlock(&(EncryptedLmOwfPassword->data[1]),
  198. (PBLOCK_KEY)LmSessionKey,
  199. (PCLEAR_BLOCK)&(LmOwfPassword->data[1]));
  200. return(Status);
  201. }
  202. NTSTATUS
  203. RtlEncryptNtOwfPwdWithNtSesKey(
  204. IN PNT_OWF_PASSWORD NtOwfPassword,
  205. IN PNT_SESSION_KEY NtSessionKey,
  206. OUT PENCRYPTED_NT_OWF_PASSWORD EncryptedNtOwfPassword
  207. )
  208. /*++
  209. Routine Description:
  210. Encrypts an OwfPassword with a session key
  211. Arguments:
  212. NtOwfPassword - OwfPassword to be encrypted
  213. NtSessionKey - key to the encryption
  214. EncryptedNtOwfPassword - The encrypted OwfPassword is returned here.
  215. Return Values:
  216. STATUS_SUCCESS - The function completed successfully. The encrypted
  217. OwfPassword is in EncryptedNtOwfPassword
  218. STATUS_UNSUCCESSFUL - Something failed. The EncryptedNtOwfPassword is undefined.
  219. --*/
  220. {
  221. ASSERT(sizeof(LM_OWF_PASSWORD) == sizeof(NT_OWF_PASSWORD));
  222. ASSERT(sizeof(LM_SESSION_KEY) == sizeof(NT_SESSION_KEY));
  223. ASSERT(sizeof(ENCRYPTED_LM_OWF_PASSWORD) == sizeof(ENCRYPTED_NT_OWF_PASSWORD));
  224. return(RtlEncryptLmOwfPwdWithLmSesKey(
  225. (PLM_OWF_PASSWORD)NtOwfPassword,
  226. (PLM_SESSION_KEY)NtSessionKey,
  227. (PENCRYPTED_LM_OWF_PASSWORD)EncryptedNtOwfPassword));
  228. }
  229. NTSTATUS
  230. RtlDecryptNtOwfPwdWithNtSesKey(
  231. IN PENCRYPTED_NT_OWF_PASSWORD EncryptedNtOwfPassword,
  232. IN PNT_SESSION_KEY NtSessionKey,
  233. OUT PNT_OWF_PASSWORD NtOwfPassword
  234. )
  235. /*++
  236. Routine Description:
  237. Decrypts one OwfPassword with a session key
  238. Arguments:
  239. EncryptedNtOwfPassword - The ecnrypted OwfPassword to be decrypted
  240. NtSessionKey - key to the encryption
  241. NtOwfPassword - The decrypted OwfPassword is returned here.
  242. Return Values:
  243. STATUS_SUCCESS - The function completed successfully. The decrypted
  244. OwfPassword is in NtOwfPassword
  245. STATUS_UNSUCCESSFUL - Something failed. The NtOwfPassword is undefined.
  246. --*/
  247. {
  248. ASSERT(sizeof(LM_OWF_PASSWORD) == sizeof(NT_OWF_PASSWORD));
  249. ASSERT(sizeof(LM_SESSION_KEY) == sizeof(NT_SESSION_KEY));
  250. ASSERT(sizeof(ENCRYPTED_LM_OWF_PASSWORD) == sizeof(ENCRYPTED_NT_OWF_PASSWORD));
  251. return(RtlDecryptLmOwfPwdWithLmSesKey(
  252. (PENCRYPTED_LM_OWF_PASSWORD)EncryptedNtOwfPassword,
  253. (PLM_SESSION_KEY)NtSessionKey,
  254. (PLM_OWF_PASSWORD)NtOwfPassword));
  255. }
  256. VOID
  257. KeysFromIndex(
  258. IN PCRYPT_INDEX Index,
  259. OUT BLOCK_KEY Key[2])
  260. /*++
  261. Routine Description:
  262. Helper function - generates 2 keys from an index value
  263. --*/
  264. {
  265. PCHAR pKey, pIndex;
  266. PCHAR IndexStart = (PCHAR)&(Index[0]);
  267. PCHAR IndexEnd = (PCHAR)&(Index[1]);
  268. PCHAR KeyStart = (PCHAR)&(Key[0]);
  269. PCHAR KeyEnd = (PCHAR)&(Key[2]);
  270. // Calculate the keys by concatenating the index with itself
  271. pKey = KeyStart;
  272. pIndex = IndexStart;
  273. while (pKey < KeyEnd) {
  274. *pKey++ = *pIndex++;
  275. if (pIndex == IndexEnd) {
  276. // Start at beginning of index again
  277. pIndex = IndexStart;
  278. }
  279. }
  280. }
  281. NTSTATUS
  282. RtlEncryptLmOwfPwdWithIndex(
  283. IN PLM_OWF_PASSWORD LmOwfPassword,
  284. IN PCRYPT_INDEX Index,
  285. OUT PENCRYPTED_LM_OWF_PASSWORD EncryptedLmOwfPassword
  286. )
  287. /*++
  288. Routine Description:
  289. Encrypts an OwfPassword with an index
  290. Arguments:
  291. LmOwfPassword - OwfPassword to be encrypted
  292. INDEX - value to be used as encryption key
  293. EncryptedLmOwfPassword - The ecnrypted OwfPassword is returned here.
  294. Return Values:
  295. STATUS_SUCCESS - The function completed successfully. The encrypted
  296. OwfPassword is in EncryptedLmOwfPassword
  297. STATUS_UNSUCCESSFUL - Something failed. The EncryptedLmOwfPassword is undefined.
  298. --*/
  299. {
  300. NTSTATUS Status;
  301. BLOCK_KEY Key[2];
  302. // Calculate the keys
  303. KeysFromIndex(Index, &(Key[0]));
  304. // Use the keys
  305. Status = RtlEncryptBlock((PCLEAR_BLOCK)&(LmOwfPassword->data[0]),
  306. &(Key[0]),
  307. &(EncryptedLmOwfPassword->data[0]));
  308. if (!NT_SUCCESS(Status)) {
  309. return(Status);
  310. }
  311. Status = RtlEncryptBlock((PCLEAR_BLOCK)&(LmOwfPassword->data[1]),
  312. &(Key[1]),
  313. &(EncryptedLmOwfPassword->data[1]));
  314. return(Status);
  315. }
  316. NTSTATUS
  317. RtlDecryptLmOwfPwdWithIndex(
  318. IN PENCRYPTED_LM_OWF_PASSWORD EncryptedLmOwfPassword,
  319. IN PCRYPT_INDEX Index,
  320. OUT PLM_OWF_PASSWORD LmOwfPassword
  321. )
  322. /*++
  323. Routine Description:
  324. Decrypts an OwfPassword with an index
  325. Arguments:
  326. EncryptedLmOwfPassword - The encrypted OwfPassword to be decrypted
  327. INDEX - value to be used as decryption key
  328. LmOwfPassword - Decrypted OwfPassword is returned here
  329. Return Values:
  330. STATUS_SUCCESS - The function completed successfully. The decrypted
  331. OwfPassword is in LmOwfPassword
  332. STATUS_UNSUCCESSFUL - Something failed. The LmOwfPassword is undefined.
  333. --*/
  334. {
  335. NTSTATUS Status;
  336. BLOCK_KEY Key[2];
  337. // Calculate the keys
  338. KeysFromIndex(Index, &(Key[0]));
  339. // Use the keys
  340. Status = RtlDecryptBlock(&(EncryptedLmOwfPassword->data[0]),
  341. &(Key[0]),
  342. (PCLEAR_BLOCK)&(LmOwfPassword->data[0]));
  343. if (!NT_SUCCESS(Status)) {
  344. return(Status);
  345. }
  346. Status = RtlDecryptBlock(&(EncryptedLmOwfPassword->data[1]),
  347. &(Key[1]),
  348. (PCLEAR_BLOCK)&(LmOwfPassword->data[1]));
  349. return(Status);
  350. }
  351. NTSTATUS
  352. RtlEncryptNtOwfPwdWithIndex(
  353. IN PNT_OWF_PASSWORD NtOwfPassword,
  354. IN PCRYPT_INDEX Index,
  355. OUT PENCRYPTED_NT_OWF_PASSWORD EncryptedNtOwfPassword
  356. )
  357. /*++
  358. Routine Description:
  359. Encrypts an OwfPassword with an index
  360. Arguments:
  361. NtOwfPassword - OwfPassword to be encrypted
  362. Index - value to be used as encryption key
  363. EncryptedNtOwfPassword - The encrypted OwfPassword is returned here.
  364. Return Values:
  365. STATUS_SUCCESS - The function completed successfully. The encrypted
  366. OwfPassword is in EncryptedNtOwfPassword
  367. STATUS_UNSUCCESSFUL - Something failed. The EncryptedNtOwfPassword is undefined.
  368. --*/
  369. {
  370. ASSERT(sizeof(LM_OWF_PASSWORD) == sizeof(NT_OWF_PASSWORD));
  371. ASSERT(sizeof(ENCRYPTED_LM_OWF_PASSWORD) == sizeof(ENCRYPTED_NT_OWF_PASSWORD));
  372. return(RtlEncryptLmOwfPwdWithIndex(
  373. (PLM_OWF_PASSWORD)NtOwfPassword,
  374. Index,
  375. (PENCRYPTED_LM_OWF_PASSWORD)EncryptedNtOwfPassword));
  376. }
  377. NTSTATUS
  378. RtlDecryptNtOwfPwdWithIndex(
  379. IN PENCRYPTED_NT_OWF_PASSWORD EncryptedNtOwfPassword,
  380. IN PCRYPT_INDEX Index,
  381. OUT PNT_OWF_PASSWORD NtOwfPassword
  382. )
  383. /*++
  384. Routine Description:
  385. Decrypts an NtOwfPassword with an index
  386. Arguments:
  387. EncryptedNtOwfPassword - The encrypted OwfPassword to be decrypted
  388. Index - value to be used as decryption key
  389. NtOwfPassword - Decrypted NtOwfPassword is returned here
  390. Return Values:
  391. STATUS_SUCCESS - The function completed successfully. The decrypted
  392. OwfPassword is in NtOwfPassword
  393. STATUS_UNSUCCESSFUL - Something failed. The NtOwfPassword is undefined.
  394. --*/
  395. {
  396. ASSERT(sizeof(LM_OWF_PASSWORD) == sizeof(NT_OWF_PASSWORD));
  397. ASSERT(sizeof(ENCRYPTED_LM_OWF_PASSWORD) == sizeof(ENCRYPTED_NT_OWF_PASSWORD));
  398. return(RtlDecryptLmOwfPwdWithIndex(
  399. (PENCRYPTED_LM_OWF_PASSWORD)EncryptedNtOwfPassword,
  400. Index,
  401. (PLM_OWF_PASSWORD)NtOwfPassword));
  402. }
  403. NTSTATUS
  404. RtlEncryptLmOwfPwdWithUserKey(
  405. IN PLM_OWF_PASSWORD LmOwfPassword,
  406. IN PUSER_SESSION_KEY UserSessionKey,
  407. OUT PENCRYPTED_LM_OWF_PASSWORD EncryptedLmOwfPassword
  408. )
  409. /*++
  410. Routine Description:
  411. Encrypts an OwfPassword with a session key
  412. Arguments:
  413. LmOwfPassword - OwfPassword to be encrypted
  414. UserSessionKey - key to the encryption
  415. EncryptedLmOwfPassword - The encrypted OwfPassword is returned here.
  416. Return Values:
  417. STATUS_SUCCESS - The function completed successfully. The encrypted
  418. OwfPassword is in EncryptedLmOwfPassword
  419. STATUS_UNSUCCESSFUL - Something failed. The EncryptedLmOwfPassword is undefined.
  420. --*/
  421. {
  422. ASSERT(sizeof(USER_SESSION_KEY) == sizeof(LM_OWF_PASSWORD));
  423. return(RtlEncryptLmOwfPwdWithLmOwfPwd(LmOwfPassword,
  424. (PLM_OWF_PASSWORD)UserSessionKey,
  425. EncryptedLmOwfPassword));
  426. }
  427. NTSTATUS
  428. RtlDecryptLmOwfPwdWithUserKey(
  429. IN PENCRYPTED_LM_OWF_PASSWORD EncryptedLmOwfPassword,
  430. IN PUSER_SESSION_KEY UserSessionKey,
  431. OUT PLM_OWF_PASSWORD LmOwfPassword
  432. )
  433. /*++
  434. Routine Description:
  435. Decrypts one OwfPassword with a session key
  436. Arguments:
  437. EncryptedLmOwfPassword - The ecnrypted OwfPassword to be decrypted
  438. UserSessionKey - key to the encryption
  439. LmOwfPassword - The decrypted OwfPassword is returned here.
  440. Return Values:
  441. STATUS_SUCCESS - The function completed successfully. The decrypted
  442. OwfPassword is in LmOwfPassword
  443. STATUS_UNSUCCESSFUL - Something failed. The LmOwfPassword is undefined.
  444. --*/
  445. {
  446. ASSERT(sizeof(USER_SESSION_KEY) == sizeof(LM_OWF_PASSWORD));
  447. return(RtlDecryptLmOwfPwdWithLmOwfPwd(EncryptedLmOwfPassword,
  448. (PLM_OWF_PASSWORD)UserSessionKey,
  449. LmOwfPassword));
  450. }
  451. NTSTATUS
  452. RtlEncryptNtOwfPwdWithUserKey(
  453. IN PNT_OWF_PASSWORD NtOwfPassword,
  454. IN PUSER_SESSION_KEY UserSessionKey,
  455. OUT PENCRYPTED_NT_OWF_PASSWORD EncryptedNtOwfPassword
  456. )
  457. /*++
  458. Routine Description:
  459. Encrypts an OwfPassword with a user session key
  460. Arguments:
  461. NtOwfPassword - OwfPassword to be encrypted
  462. UserSessionKey - key to the encryption
  463. EncryptedNtOwfPassword - The encrypted OwfPassword is returned here.
  464. Return Values:
  465. STATUS_SUCCESS - The function completed successfully. The encrypted
  466. OwfPassword is in EncryptedNtOwfPassword
  467. STATUS_UNSUCCESSFUL - Something failed. The EncryptedNtOwfPassword is undefined.
  468. --*/
  469. {
  470. ASSERT(sizeof(NT_OWF_PASSWORD) == sizeof(LM_OWF_PASSWORD));
  471. ASSERT(sizeof(ENCRYPTED_NT_OWF_PASSWORD) == sizeof(ENCRYPTED_LM_OWF_PASSWORD));
  472. return(RtlEncryptLmOwfPwdWithUserKey(
  473. (PLM_OWF_PASSWORD)NtOwfPassword,
  474. UserSessionKey,
  475. (PENCRYPTED_LM_OWF_PASSWORD)EncryptedNtOwfPassword));
  476. }
  477. NTSTATUS
  478. RtlDecryptNtOwfPwdWithUserKey(
  479. IN PENCRYPTED_NT_OWF_PASSWORD EncryptedNtOwfPassword,
  480. IN PUSER_SESSION_KEY UserSessionKey,
  481. OUT PNT_OWF_PASSWORD NtOwfPassword
  482. )
  483. /*++
  484. Routine Description:
  485. Decrypts one OwfPassword with a user session key
  486. Arguments:
  487. EncryptedNtOwfPassword - The ecnrypted OwfPassword to be decrypted
  488. UserSessionKey - key to the encryption
  489. NtOwfPassword - The decrypted OwfPassword is returned here.
  490. Return Values:
  491. STATUS_SUCCESS - The function completed successfully. The decrypted
  492. OwfPassword is in NtOwfPassword
  493. STATUS_UNSUCCESSFUL - Something failed. The NtOwfPassword is undefined.
  494. --*/
  495. {
  496. ASSERT(sizeof(NT_OWF_PASSWORD) == sizeof(LM_OWF_PASSWORD));
  497. ASSERT(sizeof(ENCRYPTED_NT_OWF_PASSWORD) == sizeof(ENCRYPTED_LM_OWF_PASSWORD));
  498. return(RtlDecryptLmOwfPwdWithUserKey(
  499. (PENCRYPTED_LM_OWF_PASSWORD)EncryptedNtOwfPassword,
  500. UserSessionKey,
  501. (PLM_OWF_PASSWORD)NtOwfPassword));
  502. }