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.

943 lines
18 KiB

  1. /*++
  2. Copyright (c) 1997-1999 Microsoft Corporation
  3. Module Name:
  4. efssrv.hxx
  5. Abstract:
  6. EFS (Encrypting File System) defines, data and function prototypes.
  7. Author:
  8. Robert Reichel (RobertRe)
  9. Robert Gu (RobertG)
  10. Environment:
  11. Revision History:
  12. --*/
  13. #ifndef _EFSSRV_
  14. #define _EFSSRV_
  15. #include <efsstruc.h>
  16. #include <wincrypt.h>
  17. #include <winefs.h>
  18. #include <des.h>
  19. #include <des3.h>
  20. #include <aes.h>
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. #define FILE_SIGNATURE L"ROBS"
  25. #define STREAM_SIGNATURE L"NTFS"
  26. #define DATA_SIGNATURE L"GURE"
  27. #define DEFAULT_STREAM L"::$DATA"
  28. #define DEF_STR_LEN 14
  29. #define MAX_PATH_LENGTH 1024
  30. #define EFSDIR L"\\System Volume Information"
  31. #define EFSLOGPATTERN L"\\EFS*.LOG"
  32. #define EFSSOURCE L"EFS"
  33. #define LOGEXT L"LOG"
  34. #define LOGSIG L"GUJR"
  35. #define LOGSIGLEN 4
  36. #define LOGVERID 100
  37. #define EFSDIRLEN (sizeof(EFSDIR) - sizeof (WCHAR))
  38. #define DAVHEADER 0x01
  39. #define WEBDAVPATH 0x0001
  40. #define OPEN_FOR_ENC 0x00000001
  41. #define OPEN_FOR_DEC 0x00000002
  42. #define OPEN_FOR_REC 0x00000004
  43. #define OPEN_FOR_EXP 0x00000008
  44. #define OPEN_FOR_IMP 0x00000010
  45. #define OPEN_FOR_FTR 0x00000020
  46. #define CERT_NOT_VALIDATED 0
  47. #define CERT_VALIDATION_FAILED 1
  48. #define CERT_VALIDATED 2
  49. #define RECOVERY_POLICY_EMPTY 0x01
  50. #define RECOVERY_POLICY_NULL 0x02
  51. #define RECOVERY_POLICY_NO_AGENT 0x04
  52. #define RECOVERY_POLICY_OK 0x20
  53. #define RECOVERY_POLICY_EXPIRED_CERTS 0x100
  54. #define RECOVERY_POLICY_NOT_EFFECT_CERTS 0x200
  55. #define RECOVERY_POLICY_BAD_POLICY 0x400
  56. #define RECOVERY_POLICY_UNKNOWN_BAD 0x800
  57. #define RECOVERY_POLICY_NO_MEMORY 0x1000
  58. #define RECOVERY_POLICY_STATUS_CHANGE 0x80000000
  59. #define USER_INTERACTIVE 2
  60. #define USER_REMOTE 1
  61. #define USER_UNKNOWN 0
  62. #define CERTINLMTRUSTEDSTORE 2
  63. extern DESTable DesTable;
  64. extern UCHAR DriverSessionKey[];
  65. extern HCRYPTPROV hProvVerify;
  66. extern WCHAR EfsComputerName[];
  67. extern LIST_ENTRY UserCacheList;
  68. extern RTL_CRITICAL_SECTION GuardCacheListLock;
  69. extern LONG UserCacheListLimit;
  70. extern LONG UserCacheListCount;
  71. extern LONGLONG CACHE_CERT_VALID_TIME;
  72. //
  73. // Useful flags for passing around what we're doing.
  74. //
  75. typedef enum _EFSP_OPERATION {
  76. Encrypting,
  77. Decrypting,
  78. EncryptRecovering,
  79. DecryptRecovering
  80. } EFSP_OPERATION;
  81. typedef enum _EFS_ACTION_STATUS {
  82. BeginEncryptDir,
  83. BeginDecryptDir,
  84. BeginEncryptFile,
  85. BeginDecryptFile,
  86. EncryptTmpFileWritten,
  87. DecryptTmpFileWritten,
  88. EncryptionDone,
  89. DecryptionDone,
  90. EncryptionBackout,
  91. EncryptionMessup,
  92. EncryptionSrcDone,
  93. } EFS_ACTION_STATUS;
  94. //
  95. // Common log file header
  96. //
  97. #define LOG_DECRYPTION 0x00000001
  98. #define LOG_DIRECTORY 0x00000002
  99. typedef struct _LOGHEADER {
  100. WCHAR SIGNATURE[4];
  101. ULONG VerID;
  102. ULONG SectorSize;
  103. ULONG HeaderSize; //Size in bytes. Including the padding zero of TempFilePath
  104. ULONG HeaderBlockSize; //Size in bytes including the checksum. Multiple of SectorSize
  105. ULONG Flag; //Encryption or Decryption, File or Directory
  106. ULONG TargetFilePathOffset; //Offset to Target file name in user readable format
  107. ULONG TargetFilePathLength; //The length of the above name including ending 0
  108. ULONG TempFilePathOffset; //Offset to Temp file name in user readable format
  109. ULONG TempFilePathLength; //The length of the above name including ending 0
  110. ULONG OffsetStatus1; //Point to the first copy of the status info
  111. ULONG OffsetStatus2; //Point to the second copy of the status info
  112. ULONG Reserved[3];
  113. ULONG LengthOfTargetFileInternalName; //Size in bytes ( 8 for V 1.0)
  114. LARGE_INTEGER TargetFileInternalName; //Use File ID for V 1.0
  115. ULONG LengthOfTempFileInternalName; //Size in bytes ( 8 for V 1.0)
  116. LARGE_INTEGER TempFileInternalName; //Use File ID for V 1.0
  117. } LOGHEADER, *PLOGHEADER;
  118. //
  119. // Local structure containing recovery information.
  120. // More easily digestable than the stuff we get out
  121. // of the policy.
  122. //
  123. typedef struct _CURRENT_RECOVERY_POLICY {
  124. PBYTE Base;
  125. LARGE_INTEGER TimeStamp;
  126. LONG CertValidated;
  127. DWORD dwKeyCount;
  128. DWORD PolicyStatus;
  129. PBYTE * pbHash;
  130. DWORD * cbHash;
  131. PBYTE * pbPublicKeys;
  132. DWORD * cbPublicKeys;
  133. LPWSTR * lpDisplayInfo;
  134. PCCERT_CONTEXT * pCertContext;
  135. PSID * pSid;
  136. } CURRENT_RECOVERY_POLICY, *PCURRENT_RECOVERY_POLICY;
  137. //
  138. // User Cache Node
  139. //
  140. typedef struct _USER_CACHE {
  141. LUID AuthId;
  142. LONG UseRefCount;
  143. LONG StopUseCount; //For the purpose of free the cache
  144. PBYTE pbHash;
  145. DWORD cbHash;
  146. LONG CertValidated;
  147. LPWSTR ContainerName;
  148. LPWSTR DisplayInformation;
  149. LPWSTR ProviderName;
  150. PCCERT_CONTEXT pCertContext;
  151. HCRYPTPROV hProv;
  152. HCRYPTKEY hUserKey;
  153. LARGE_INTEGER TimeStamp;
  154. LIST_ENTRY CacheChain;
  155. } USER_CACHE, *PUSER_CACHE;
  156. typedef struct _EFS_USER_INFO {
  157. LPWSTR lpUserName;
  158. LPWSTR lpDomainName;
  159. LPWSTR lpProfilePath; // may be NULL
  160. LPWSTR lpUserSid;
  161. LPWSTR lpKeyPath;
  162. PTOKEN_USER pTokenUser;
  163. PUSER_CACHE pUserCache;
  164. LUID AuthId;
  165. LONG InterActiveUser;
  166. BOOLEAN bDomainAccount;
  167. BOOLEAN bIsSystem;
  168. BOOLEAN UserCacheStop;
  169. BOOLEAN Reserved;
  170. } EFS_USER_INFO, *PEFS_USER_INFO;
  171. typedef struct _EFS_POL_CALLBACK {
  172. HANDLE *EfsPolicyEventHandle;
  173. BOOLEAN *EfsDisable;
  174. } EFS_POL_CALLBACK, *PEFS_POL_CALLBACK;
  175. BOOLEAN
  176. EfspIsSystem(
  177. PEFS_USER_INFO pEfsUserInfo,
  178. OUT PBOOLEAN System
  179. );
  180. BOOLEAN
  181. EfspGetUserInfo(
  182. IN OUT PEFS_USER_INFO pEfsUserInfo
  183. );
  184. VOID
  185. EfspFreeUserInfo(
  186. IN PEFS_USER_INFO pEfsUserInfo
  187. );
  188. BOOLEAN
  189. EfspInitUserCacheNode(
  190. IN OUT PUSER_CACHE pCacheNode,
  191. IN PBYTE pbHash,
  192. IN DWORD cbHash,
  193. IN LPWSTR ContainerName,
  194. IN LPWSTR ProviderName,
  195. IN LPWSTR DisplayInformation,
  196. IN PCCERT_CONTEXT pCertContext,
  197. IN HCRYPTKEY hKey,
  198. IN HCRYPTPROV hProv,
  199. IN LUID *AuthId,
  200. IN LONG CertValidated
  201. );
  202. BOOLEAN
  203. EfspAddUserCache(
  204. IN PUSER_CACHE pUserCache
  205. );
  206. VOID
  207. EfspReleaseUserCache(
  208. IN PUSER_CACHE pUserCache
  209. );
  210. DWORD
  211. GenerateDRF(
  212. IN PEFS_KEY Fek,
  213. OUT PENCRYPTED_KEYS *pNewDRF,
  214. OUT DWORD *cbDRF
  215. );
  216. BOOLEAN
  217. GenerateFEK(
  218. IN OUT PEFS_KEY *Key
  219. );
  220. BOOLEAN
  221. ConstructEFS(
  222. PEFS_USER_INFO pEfsUserInfo,
  223. PEFS_KEY Fek,
  224. PEFS_DATA_STREAM_HEADER ParentEfsStreamHeader,
  225. PEFS_DATA_STREAM_HEADER * EfsStreamHeader
  226. );
  227. BOOLEAN
  228. ConstructDirectoryEFS(
  229. PEFS_USER_INFO pEfsUserInfo,
  230. PEFS_KEY Fek,
  231. PEFS_DATA_STREAM_HEADER * ChildEfs
  232. );
  233. DWORD
  234. DecryptFek(
  235. PEFS_USER_INFO pEfsUserInfo,
  236. PEFS_DATA_STREAM_HEADER EfsStream,
  237. PEFS_KEY * Fek,
  238. PEFS_DATA_STREAM_HEADER * NewEfs,
  239. ULONG OpenType
  240. );
  241. DWORD
  242. EfsGetFek(
  243. IN PEFS_USER_INFO pEfsUserInfo,
  244. IN PEFS_DATA_STREAM_HEADER EfsStream,
  245. OUT PEFS_KEY * Fek
  246. );
  247. NTSTATUS
  248. InitDriverSessionKey(
  249. VOID
  250. );
  251. NTSTATUS
  252. GenerateDriverSessionKey(
  253. PEFS_INIT_DATAEXG InitDataExg
  254. );
  255. NTSTATUS
  256. EfsServerInit(
  257. VOID
  258. );
  259. DWORD WINAPI
  260. EFSRecover(
  261. IN LPVOID Param
  262. );
  263. VOID
  264. DumpBytes(
  265. PBYTE Blob,
  266. ULONG Length
  267. );
  268. VOID
  269. DumpEFS(
  270. PEFS_DATA_STREAM_HEADER Efs
  271. );
  272. NTSTATUS
  273. EfspGetTokenUser(
  274. IN OUT PEFS_USER_INFO pEfsUserInfo
  275. );
  276. NTSTATUS
  277. EfspGetUserName(
  278. IN OUT PEFS_USER_INFO pEfsUserInfo
  279. );
  280. PWCHAR
  281. ConvertSidToWideCharString(
  282. PSID Sid
  283. );
  284. BOOL
  285. EfsErrorToNtStatus(
  286. IN DWORD WinError,
  287. OUT PNTSTATUS NtStatus
  288. );
  289. DWORD
  290. EfspInstallCertAsUserKey(
  291. PEFS_USER_INFO pEfsUserInfo,
  292. PENCRYPTION_CERTIFICATE pEncryptionCertificate
  293. );
  294. DWORD
  295. EfspReplaceUserKeyInformation(
  296. PEFS_USER_INFO pEfsUserInfo
  297. );
  298. VOID
  299. MarkFileForDelete(
  300. HANDLE FileHandle
  301. );
  302. DWORD
  303. GetVolumeRoot(
  304. IN PUNICODE_STRING SrcFileName,
  305. OUT PUNICODE_STRING RootPath
  306. );
  307. NTSTATUS
  308. GetLogFile(
  309. IN PUNICODE_STRING RootPath,
  310. OUT HANDLE *LogFile
  311. );
  312. NTSTATUS
  313. MakeSystemFullControlSD(
  314. OUT PSECURITY_DESCRIPTOR *ppSD
  315. );
  316. NTSTATUS
  317. CreateLogFile(
  318. IN PUNICODE_STRING FileName,
  319. IN PSECURITY_DESCRIPTOR SD,
  320. OUT HANDLE *LogFile
  321. );
  322. NTSTATUS
  323. CreateLogHeader(
  324. IN HANDLE LogFile,
  325. IN ULONG SectorSize,
  326. IN PLARGE_INTEGER TragetID,
  327. IN PLARGE_INTEGER TempID OPTIONAL,
  328. IN LPCWSTR SrcFileName,
  329. IN LPCWSTR TempFileName OPTIONAL,
  330. IN EFSP_OPERATION Operation,
  331. IN EFS_ACTION_STATUS Action,
  332. OUT ULONG *LogInfoOffset
  333. );
  334. ULONG
  335. GetCheckSum(
  336. IN BYTE *WorkBuffer,
  337. IN ULONG Length
  338. );
  339. VOID
  340. CreateBlockSum(
  341. IN BYTE *WorkBuffer,
  342. IN ULONG Length,
  343. IN ULONG SectorSize
  344. );
  345. NTSTATUS
  346. CreateBackupFile(
  347. IN PUNICODE_STRING SourceFileNameU,
  348. OUT HANDLE *hBackupFile,
  349. OUT FILE_INTERNAL_INFORMATION *BackupID,
  350. OUT LPWSTR *BackupFileName
  351. );
  352. NTSTATUS
  353. WriteLogFile(
  354. IN HANDLE LogFileH,
  355. IN ULONG SectorSize,
  356. IN ULONG StartOffset,
  357. IN EFS_ACTION_STATUS Action
  358. );
  359. void
  360. TryRecoverVol(
  361. IN const WCHAR *VolumeName,
  362. IN WCHAR *CacheDir
  363. );
  364. void
  365. TryRecoverFile(
  366. IN const WCHAR *VolumeName,
  367. IN LPWIN32_FIND_DATA FindFileInfo,
  368. IN HANDLE EventHandleLog
  369. );
  370. NTSTATUS
  371. ReadLogFile(
  372. IN HANDLE LogFile,
  373. OUT BYTE* ReadBuffer,
  374. IN ULONG FirstCopy,
  375. IN ULONG SecondCopy
  376. );
  377. NTSTATUS
  378. DoRecover(
  379. IN HANDLE Target,
  380. IN HANDLE TmpFile OPTIONAL,
  381. IN HANDLE LogFile,
  382. IN LPCWSTR TargetName,
  383. IN LPCWSTR TmpName OPTIONAL,
  384. IN ULONG StatusCopySize,
  385. IN ULONG StatusStartOffset,
  386. IN ULONG Action,
  387. IN HANDLE EventHandleLog
  388. );
  389. ULONG
  390. GetCheckSum(
  391. IN BYTE *WorkBuffer,
  392. IN ULONG Length
  393. );
  394. NTSTATUS
  395. DecryptDir(
  396. IN HANDLE Target,
  397. IN LPCWSTR TargetName
  398. );
  399. NTSTATUS
  400. SendGenFsctl(
  401. IN HANDLE Target,
  402. IN ULONG Psc,
  403. IN ULONG Csc,
  404. IN ULONG EfsCode,
  405. IN ULONG FsCode
  406. );
  407. NTSTATUS
  408. RestoreTarget(
  409. IN HANDLE Target,
  410. IN HANDLE TmpFile,
  411. IN LPCWSTR TargetName,
  412. IN LPCWSTR TmpName,
  413. IN HANDLE EventHandleLog,
  414. EFSP_OPERATION Operation
  415. );
  416. DWORD
  417. EFSSendPipeData(
  418. char *DataBuf,
  419. ULONG DataLength,
  420. PVOID Context
  421. );
  422. DWORD
  423. EFSReceivePipeData(
  424. char *DataBuf,
  425. ULONG* DataLength,
  426. PVOID Context
  427. );
  428. DWORD
  429. GetOverWriteEfsAttrFsctlInput(
  430. ULONG Flag,
  431. ULONG AccessFlag,
  432. char *InputData,
  433. ULONG InputDataLength,
  434. char *OutputData,
  435. ULONG *OutputDataLength
  436. );
  437. PBYTE
  438. GetCertHashFromCertContext(
  439. IN PCCERT_CONTEXT pCertContext,
  440. OUT PDWORD pcbHash
  441. );
  442. PCRYPT_KEY_PROV_INFO
  443. GetKeyProvInfo(
  444. PCCERT_CONTEXT pCertContext
  445. );
  446. PCERT_PUBLIC_KEY_INFO
  447. ExportPublicKeyInfo(
  448. IN HCRYPTPROV hProv,
  449. IN DWORD dwKeySpec,
  450. IN DWORD dwCertEncodingType,
  451. IN OUT DWORD *pcbInfo
  452. );
  453. BOOLEAN
  454. AddUserToEFS(
  455. IN PEFS_DATA_STREAM_HEADER EfsStream,
  456. IN PSID NewUserSid OPTIONAL,
  457. IN PEFS_KEY Fek,
  458. IN PBYTE pbCert,
  459. IN DWORD cbCert,
  460. OUT PEFS_DATA_STREAM_HEADER * NewEfs
  461. );
  462. BOOL
  463. RemoveUsersFromEfsStream(
  464. IN PEFS_DATA_STREAM_HEADER pEfsStream,
  465. IN DWORD nHashes,
  466. IN PENCRYPTION_CERTIFICATE_HASH * pHashes,
  467. IN PEFS_KEY Fek,
  468. OUT PEFS_DATA_STREAM_HEADER * pNewEfsStream
  469. );
  470. BOOL
  471. QueryCertsFromEncryptedKeys(
  472. IN PENCRYPTED_KEYS pEncryptedKeys,
  473. OUT PDWORD pnUsers,
  474. OUT PENCRYPTION_CERTIFICATE_HASH ** pHashes
  475. );
  476. PCCERT_CONTEXT
  477. GetCertContextFromCertHash(
  478. IN PBYTE pbHash,
  479. IN DWORD cbHash,
  480. IN DWORD dwFlags
  481. );
  482. LPWSTR
  483. EfspGetCertDisplayInformation(
  484. IN PCCERT_CONTEXT pCertContext
  485. );
  486. VOID
  487. RecoveryInformationCallback(
  488. POLICY_NOTIFICATION_INFORMATION_CLASS ChangedInfoClass
  489. );
  490. VOID
  491. EfspRoleChangeCallback(
  492. POLICY_NOTIFICATION_INFORMATION_CLASS ChangedInfoClass
  493. );
  494. BOOL
  495. UpdateRecoveryPolicy(
  496. PLSAPR_POLICY_DOMAIN_EFS_INFO * PolicyEfsInfo,
  497. PBOOLEAN Reformatted
  498. );
  499. VOID
  500. FreeParsedRecoveryPolicy(
  501. PCURRENT_RECOVERY_POLICY ParsedRecoveryPolicy
  502. );
  503. BOOL
  504. GetPublicKey(
  505. HCRYPTKEY hKey,
  506. PBYTE * PublicKeyBlob,
  507. PDWORD KeyLength
  508. );
  509. DWORD
  510. CreatePublicKeyInformationCertificate(
  511. IN PSID pUserSid OPTIONAL,
  512. PBYTE pbCert,
  513. DWORD cbCert,
  514. OUT PEFS_PUBLIC_KEY_INFO * PublicKeyInformation
  515. );
  516. BOOL
  517. ParseRecoveryCertificate(
  518. IN PEFS_PUBLIC_KEY_INFO pPublicKeyInfo,
  519. OUT PBYTE * pbHash,
  520. OUT PDWORD cbHash,
  521. OUT PBYTE * pbPublicKey,
  522. OUT PDWORD cbPublicKey,
  523. OUT LPWSTR * lpDisplayInfo,
  524. OUT PCCERT_CONTEXT * pCertContext,
  525. OUT PSID * pSid
  526. );
  527. VOID
  528. FreeParsedRecoveryPolicy(
  529. PCURRENT_RECOVERY_POLICY ParsedRecoveryPolicy
  530. );
  531. NTSTATUS
  532. GetStreamInformation(
  533. IN HANDLE SourceFile,
  534. OUT PFILE_STREAM_INFORMATION * StreamInfoBase,
  535. PULONG StreamInfoSize
  536. );
  537. DWORD
  538. OpenFileStreams(
  539. IN HANDLE hSourceFile,
  540. IN ULONG ShareMode,
  541. IN ULONG Flag,
  542. IN PFILE_STREAM_INFORMATION StreamInfoBase,
  543. IN ULONG FileAccess,
  544. IN ULONG CreateDisposition,
  545. IN ULONG CreateOption,
  546. IN PFILE_FS_SIZE_INFORMATION VolInfo,
  547. OUT PUNICODE_STRING * StreamNames,
  548. OUT PHANDLE * StreamHandles,
  549. OUT PEFS_STREAM_SIZE * StreamSizes,
  550. OUT PULONG StreamCount
  551. );
  552. BOOLEAN
  553. GetDecryptFsInput(
  554. IN HANDLE Handle,
  555. OUT PUCHAR InputData,
  556. OUT PULONG InputDataSize
  557. );
  558. DWORD
  559. CopyFileStreams(
  560. PHANDLE SourceStreams,
  561. PHANDLE StreamHandles,
  562. ULONG StreamCount,
  563. PEFS_STREAM_SIZE StreamSizes,
  564. EFSP_OPERATION Operation,
  565. PUCHAR FsInputData,
  566. ULONG FsInputDataSize,
  567. PBOOLEAN CleanupSuccessful
  568. );
  569. BOOLEAN
  570. EfspValidateEfsStream(
  571. PEFS_DATA_STREAM_HEADER pEFS,
  572. PEFS_KEY Fek
  573. );
  574. BOOLEAN
  575. EfspChecksumEfs(
  576. PEFS_DATA_STREAM_HEADER pEFS,
  577. PEFS_KEY Fek
  578. );
  579. void
  580. DumpRecoveryKey(
  581. PRECOVERY_KEY_1_1 pRecoveryKey
  582. );
  583. LPWSTR
  584. MakeDNName(
  585. BOOLEAN RecoveryKey,
  586. IN PEFS_USER_INFO pEfsUserInfo
  587. );
  588. BOOL
  589. EncodeAndAlloc(
  590. DWORD dwEncodingType,
  591. LPCSTR lpszStructType,
  592. const void * pvStructInfo,
  593. PBYTE * pbEncoded,
  594. PDWORD pcbEncoded
  595. );
  596. BOOL
  597. EfspIsDomainUser(
  598. IN LPWSTR lpDomainName,
  599. OUT PBOOLEAN IsDomain
  600. );
  601. VOID
  602. EfspUnloadUserProfile(
  603. IN HANDLE hToken,
  604. IN HANDLE hProfile
  605. );
  606. BOOL
  607. EfspLoadUserProfile(
  608. IN PEFS_USER_INFO pEfsUserInfo,
  609. OUT PHANDLE hToken,
  610. OUT PHANDLE hProfile
  611. );
  612. PWCHAR
  613. ConstructKeyPath(
  614. PWCHAR SidString
  615. );
  616. VOID
  617. EfsLogEntry (
  618. WORD wType,
  619. WORD wCategory,
  620. DWORD dwEventID,
  621. WORD wNumStrings,
  622. DWORD dwDataSize,
  623. LPCTSTR *lpStrings,
  624. LPVOID lpRawData
  625. );
  626. DWORD
  627. EfsGetCertNameFromCertContext(
  628. IN PCCERT_CONTEXT CertContext,
  629. OUT LPWSTR * UserDispName
  630. );
  631. DWORD
  632. EfsAddCertToTrustStoreStore(
  633. IN PCCERT_CONTEXT pCert,
  634. OUT DWORD *ImpersonationError
  635. );
  636. BOOL
  637. EfsGetBasicConstraintExt(
  638. IN OUT PCERT_EXTENSION *basicRestraint
  639. );
  640. BOOL
  641. EfsGetAltNameExt(
  642. IN OUT PCERT_EXTENSION *altNameExt,
  643. IN LPWSTR UPNName
  644. );
  645. DWORD
  646. EfsMakeCertNames(
  647. IN PEFS_USER_INFO pEfsUserInfo,
  648. OUT LPWSTR *DispInfo,
  649. OUT LPWSTR *SubjectName,
  650. OUT LPWSTR *UPNName
  651. );
  652. DWORD
  653. EfsFindCertOid(
  654. IN LPSTR pEfsCertOid,
  655. IN PCCERT_CONTEXT pCertContext,
  656. OUT BOOL *OidFound
  657. );
  658. VOID
  659. EfsMarkCertAddedToStore(
  660. IN PEFS_USER_INFO pEfsUserInfo
  661. );
  662. /////////////////////////////////////////////////////////////////////////////////////
  663. // /
  664. // /
  665. // Entry points for exported API /
  666. // /
  667. // /
  668. /////////////////////////////////////////////////////////////////////////////////////
  669. DWORD
  670. EncryptFileSrv(
  671. IN PEFS_USER_INFO pEfsUserData,
  672. IN PUNICODE_STRING SourceFileName,
  673. IN HANDLE LogFile
  674. );
  675. DWORD
  676. DecryptFileSrv(
  677. IN PUNICODE_STRING SourceFileName,
  678. IN HANDLE LogFileH,
  679. IN ULONG Recovery
  680. );
  681. DWORD
  682. AddUsersToFileSrv(
  683. IN PEFS_USER_INFO pEfsUserInfo,
  684. IN LPCWSTR lpFileName,
  685. IN DWORD nUsers,
  686. IN PENCRYPTION_CERTIFICATE * pEncryptionCertificates
  687. );
  688. DWORD
  689. QueryUsersOnFileSrv(
  690. IN LPCWSTR lpFileName,
  691. OUT PDWORD pnUsers,
  692. OUT PENCRYPTION_CERTIFICATE_HASH ** pUsers
  693. );
  694. DWORD
  695. QueryRecoveryAgentsSrv(
  696. IN LPCWSTR lpFileName,
  697. OUT PDWORD pnRecoveryAgents,
  698. OUT PENCRYPTION_CERTIFICATE_HASH ** pRecoveryAgents
  699. );
  700. DWORD
  701. RemoveUsersFromFileSrv(
  702. IN PEFS_USER_INFO PEfsUserInfo,
  703. IN LPCWSTR lpFileName,
  704. IN DWORD nUsers,
  705. IN PENCRYPTION_CERTIFICATE_HASH * pHashes
  706. );
  707. DWORD
  708. SetFileEncryptionKeySrv(
  709. IN PEFS_USER_INFO PEfsUserInfo,
  710. IN PENCRYPTION_CERTIFICATE pEncryptionCertificate
  711. );
  712. DWORD
  713. DuplicateEncryptionInfoFileSrv (
  714. PEFS_USER_INFO pEfsUserInfo,
  715. LPCWSTR lpSrcFileName,
  716. LPCWSTR lpDestFileName,
  717. LPCWSTR lpDestUncName,
  718. DWORD dwCreationDistribution,
  719. DWORD dwAttributes,
  720. PEFS_RPC_BLOB pRelativeSD,
  721. BOOL bInheritHandle
  722. );
  723. DWORD
  724. EfsFileKeyInfoSrv(
  725. IN LPCWSTR lpFileName,
  726. IN DWORD InfoClass,
  727. OUT PDWORD nbData,
  728. OUT PBYTE *pbData
  729. );
  730. DWORD
  731. EfsOpenFileRaw(
  732. IN LPCWSTR FileName,
  733. IN LPCWSTR LocalFileName,
  734. IN BOOL NetSession,
  735. IN ULONG Flags,
  736. OUT PVOID * Context
  737. );
  738. VOID
  739. EfsCloseFileRaw(
  740. IN PVOID Context
  741. );
  742. long
  743. EfsReadFileRaw(
  744. PVOID Context,
  745. PVOID EfsOutPipe
  746. );
  747. long
  748. EfsWriteFileRaw(
  749. PVOID Context,
  750. PVOID EfsInPipe
  751. );
  752. BOOL
  753. GetSaltLength(
  754. ALG_ID AlgID,
  755. DWORD *SaltLength,
  756. DWORD *SaltBlockLength
  757. );
  758. DWORD
  759. EfsAlignBlock(
  760. IN PVOID InKey,
  761. OUT PVOID *OutKey,
  762. OUT BOOLEAN *NewKey
  763. );
  764. VOID
  765. EfsGetPolRegSettings(
  766. IN PVOID lpThreadData,
  767. IN BOOLEAN timeExpired
  768. );
  769. VOID
  770. EfsApplyLastPolicy(
  771. IN BOOLEAN* pEfsDisabled
  772. );
  773. VOID
  774. EfsRemoveKey(
  775. VOID
  776. );
  777. extern LONG EFSDebugLevel;
  778. extern DESTable DesTable;
  779. extern UCHAR DriverSessionKey[DES_BLOCKLEN];
  780. extern HANDLE LsaPid;
  781. extern BOOLEAN EfspInDomain;
  782. #ifdef __cplusplus
  783. } // extern C
  784. #endif
  785. #endif // _EFSSRV_