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.

181 lines
4.3 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1996.
  5. //
  6. // File: lsa.hxx
  7. //
  8. // Contents:
  9. //
  10. // Classes:
  11. //
  12. // Functions: None.
  13. //
  14. // History: 15-May-96 MarkBl Created
  15. //
  16. //----------------------------------------------------------------------------
  17. #ifndef __LSA_HXX__
  18. #define __LSA_HXX__
  19. #define MAX_SECRET_SIZE 65536 // Maximum LSA secret size
  20. #define HASH_DATA_SIZE 64 // MD5 hash data size, less salt.
  21. #define LAST_HASH_BYTE(pbHashedData) pbHashedData[HASH_DATA_SIZE-1]
  22. #define USN_SIZE (sizeof(DWORD))
  23. #define SAC_HEADER_SIZE (USN_SIZE + sizeof(DWORD))
  24. #define SAI_HEADER_SIZE (USN_SIZE + sizeof(DWORD))
  25. //
  26. // With scavenger cleanup of the SAI/SAC information in the LSA, this marker,
  27. // a sequence of bytes, is used to mark identity/credential entries pending
  28. // removal. To mark an entry for removal, the initial marker size number of
  29. // entry bytes are overwritten with this marker.
  30. //
  31. // Size of the following sequence of ANSI characters (see lsa.cxx):
  32. // DELETED_ENTRY
  33. //
  34. extern BYTE grgbDeletedEntryMarker[];
  35. #define DELETED_ENTRY_MARKER_SIZE 13
  36. #define DELETED_ENTRY(pb) \
  37. (memcmp(pb, grgbDeletedEntryMarker, DELETED_ENTRY_MARKER_SIZE) == 0)
  38. #define MARK_DELETED_ENTRY(pb) { \
  39. CopyMemory(pb, grgbDeletedEntryMarker, DELETED_ENTRY_MARKER_SIZE); \
  40. }
  41. #ifdef NOSTATIC
  42. #define STATIC
  43. #else
  44. #define STATIC static
  45. #endif
  46. HRESULT ReadSecurityDBase(
  47. DWORD * pcbSAI,
  48. BYTE ** ppbSAI,
  49. DWORD * pcbSAC,
  50. BYTE ** ppbSAC);
  51. HRESULT WriteSecurityDBase(
  52. DWORD cbSAI,
  53. BYTE * pbSAI,
  54. DWORD cbSAC,
  55. BYTE * pbSAC);
  56. HRESULT SACAddCredential(
  57. BYTE * pbCredentialIdentity,
  58. DWORD cbEncryptedData,
  59. BYTE * pbEncryptedData,
  60. DWORD * pcbSAC,
  61. BYTE ** ppbSAC);
  62. HRESULT SACFindCredential (
  63. BYTE * pbCredentialIdentity,
  64. DWORD cbSAC,
  65. BYTE * pbSAC,
  66. DWORD * pdwCredentialIndex,
  67. DWORD * pcbEncryptedData,
  68. BYTE ** ppbFoundCredential);
  69. HRESULT SACIndexCredential(
  70. DWORD dwCredentialIndex,
  71. DWORD cbSAC,
  72. BYTE * pbSAC,
  73. DWORD * pcbCredential,
  74. BYTE ** ppbFoundCredential);
  75. HRESULT SACRemoveCredential(
  76. DWORD CredentialIndex,
  77. DWORD * pcbSAC,
  78. BYTE ** ppbSAC);
  79. HRESULT SACUpdateCredential(
  80. DWORD cbEncryptedData,
  81. BYTE * pbEncryptedData,
  82. DWORD cbPrevCredential,
  83. BYTE * pbPrevCredential,
  84. DWORD * pcbSAC,
  85. BYTE ** ppbSAC);
  86. HRESULT SAIAddIdentity(
  87. BYTE * pbIdentity,
  88. DWORD * pcbSAI,
  89. BYTE ** ppbSAI);
  90. HRESULT SAIFindIdentity(
  91. BYTE * pbIdentity,
  92. DWORD cbSAI,
  93. BYTE * pbSAI,
  94. DWORD * pdwCredentialIndex,
  95. BOOL * pfIsPasswordNull = NULL,
  96. BYTE ** ppbFoundIdentity = NULL,
  97. DWORD * pdwSetSubCount = NULL,
  98. BYTE ** ppbSet = NULL);
  99. HRESULT SAIIndexIdentity(
  100. DWORD cbSAI,
  101. BYTE * pbSAI,
  102. DWORD dwSetArrayIndex,
  103. DWORD dwSetIndex,
  104. BYTE ** ppbFoundIdentity = NULL,
  105. DWORD * pdwSetSubCount = NULL,
  106. BYTE ** ppbSet = NULL);
  107. HRESULT SAIInsertIdentity(
  108. BYTE * pbIdentity,
  109. BYTE * pbSAIIndex,
  110. DWORD * pcbSAI,
  111. BYTE ** ppbSAI);
  112. HRESULT SAIRemoveIdentity(
  113. BYTE * pbJobIdentity,
  114. BYTE * pbSet,
  115. DWORD * pcbSAI,
  116. BYTE ** ppbSAI,
  117. DWORD CredentialIndex,
  118. DWORD * pcbSAC,
  119. BYTE ** ppbSAC);
  120. HRESULT SAIUpdateIdentity(
  121. const BYTE * pbNewIdentity,
  122. BYTE * pbFoundIdentity,
  123. DWORD cbSAI,
  124. BYTE * pbSAI);
  125. HRESULT SACCoalesceDeletedEntries(
  126. DWORD * pcbSAC,
  127. BYTE ** ppbSAC);
  128. HRESULT SAICoalesceDeletedEntries(
  129. DWORD * pcbSAI,
  130. BYTE ** ppbSAI);
  131. void ScavengeSASecurityDBase(void);
  132. HRESULT ReadLsaData(
  133. WORD cbKey,
  134. LPCWSTR pwszKey,
  135. DWORD * pcbData,
  136. BYTE ** ppbData);
  137. HRESULT WriteLsaData(
  138. WORD cbKey,
  139. LPCWSTR pwszKey,
  140. DWORD cbData,
  141. BYTE * pbData);
  142. HRESULT DeleteLsaData(
  143. WORD cbKey,
  144. LPCWSTR pwszKey);
  145. void SetMysteryDWORDValue(
  146. void);
  147. #if DBG == 1
  148. #define ASSERT_SECURITY_DBASE_CORRUPT() { \
  149. schAssert( \
  150. 0 && "Scheduling Agent security database corruption detected!"); \
  151. }
  152. #else
  153. #define ASSERT_SECURITY_DBASE_CORRUPT()
  154. #endif // DBG
  155. #endif // __LSA_HXX__