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.

334 lines
8.5 KiB

  1. // ***************************************************************************
  2. // SSP Parser for parsing security support provider data
  3. //
  4. // A-FLEXD August 14, 1996 Created
  5. // ***************************************************************************
  6. #include "precomp.h"
  7. #pragma hdrstop
  8. CHAR szJunkString[256];
  9. // ***************************************************************************
  10. // Property Table.
  11. // ***************************************************************************
  12. PROPERTYINFO SSPDatabase[] =
  13. {
  14. // 0
  15. { 0,0,
  16. "SSP Summary",
  17. "Security Support Provider Information",
  18. PROP_TYPE_SUMMARY,
  19. PROP_QUAL_NONE,
  20. NULL,
  21. 80,
  22. SSPFormatSummary
  23. },
  24. // 1
  25. { 0,0,
  26. "Authentication Level",
  27. "Authentication Level",
  28. PROP_TYPE_BYTE,
  29. PROP_QUAL_NONE, NULL,
  30. 40,
  31. FormatPropertyInstance
  32. },
  33. // 2
  34. { 0,0,
  35. "Key Sequence Number",
  36. "Key Sequence Number",
  37. PROP_TYPE_BYTE,
  38. PROP_QUAL_NONE, NULL,
  39. 40,
  40. FormatPropertyInstance
  41. },
  42. // 3
  43. { 0,0,
  44. "Pad",
  45. "Pad Bytes",
  46. PROP_TYPE_WORD,
  47. PROP_QUAL_NONE,
  48. NULL,
  49. 32,
  50. FormatPropertyInstance
  51. },
  52. // 4
  53. { 0,0,
  54. "Message Signature",
  55. "NT LanMan Security Support Provider Message Signature",
  56. PROP_TYPE_COMMENT,
  57. PROP_QUAL_NONE, NULL,
  58. 32,
  59. FormatPropertyInstance
  60. },
  61. // 5
  62. { 0,0,
  63. "SSP Data",
  64. "Security Support Provider Data",
  65. PROP_TYPE_COMMENT,
  66. PROP_QUAL_NONE,
  67. NULL,
  68. 40,
  69. FormatPropertyInstance
  70. },
  71. // 6
  72. { 0,0,
  73. "Version",
  74. "Version",
  75. PROP_TYPE_DWORD,
  76. PROP_QUAL_NONE,
  77. NULL,
  78. 40,
  79. FormatPropertyInstance
  80. },
  81. // 7
  82. { 0,0,
  83. "Random Pad",
  84. "Random Pad",
  85. PROP_TYPE_DWORD,
  86. PROP_QUAL_NONE,
  87. NULL,
  88. 40,
  89. FormatPropertyInstance
  90. },
  91. // 8
  92. { 0,0,
  93. "CheckSum",
  94. "CheckSum",
  95. PROP_TYPE_DWORD,
  96. PROP_QUAL_NONE,
  97. NULL,
  98. 40,
  99. FormatPropertyInstance
  100. },
  101. // 9
  102. { 0,0,
  103. "Nonce",
  104. "Nonce",
  105. PROP_TYPE_DWORD,
  106. PROP_QUAL_NONE,
  107. NULL,
  108. 40,
  109. FormatPropertyInstance
  110. },
  111. };
  112. DWORD nSSPProperties = ((sizeof SSPDatabase) / PROPERTYINFO_SIZE);
  113. // ***************************************************************************
  114. // FUNCTION: SSPRegister()
  115. //
  116. // A-FLEXD August 14, 1996 Created
  117. // ***************************************************************************
  118. VOID WINAPI SSPRegister(HPROTOCOL hSSPProtocol)
  119. {
  120. register DWORD i;
  121. //=================================
  122. // Create the property database.
  123. //=================================
  124. CreatePropertyDatabase(hSSPProtocol, nSSPProperties);
  125. for (i = 0; i < nSSPProperties; ++i)
  126. {
  127. SSPDatabase[i].hProperty = AddProperty(hSSPProtocol, &SSPDatabase[i]);
  128. }
  129. }
  130. // ***************************************************************************
  131. // FUNCTION: SSPDeregister()
  132. //
  133. // A-FLEXD August 14, 1996 Created
  134. // ***************************************************************************
  135. VOID WINAPI SSPDeregister(HPROTOCOL hSSPProtocol)
  136. {
  137. DestroyPropertyDatabase(hSSPProtocol);
  138. }
  139. // ***************************************************************************
  140. // FUNCTION: SSPRecognizeFrame()
  141. //
  142. // A-FLEXD August 14, 1996 Created
  143. // ***************************************************************************
  144. LPBYTE WINAPI SSPRecognizeFrame(HFRAME hFrame, // frame handle.
  145. LPBYTE MacFrame, // Frame pointer.
  146. LPBYTE SSPFrame, // relative pointer.
  147. DWORD MacType, // MAC type.
  148. DWORD BytesLeft, // Bytes left.
  149. HPROTOCOL hPreviousProtocol, // Previous protocol or NULL if none.
  150. DWORD nPreviousProtocolOffset, // Offset of previous protocol.
  151. LPDWORD ProtocolStatusCode, // Pointer to return status code in.
  152. LPHPROTOCOL hNextProtocol, // Next protocol to call (optional).
  153. PDWORD_PTR InstData) // Next protocol instance data.
  154. {
  155. // put real code in here for ssp
  156. *ProtocolStatusCode = PROTOCOL_STATUS_CLAIMED;
  157. return NULL;
  158. }
  159. // ***************************************************************************
  160. // FUNCTION: AttachProperties()
  161. //
  162. // A-FLEXD August 14, 1996 Created
  163. // ***************************************************************************
  164. LPBYTE WINAPI SSPAttachProperties(HFRAME hFrame, // Frame handle.
  165. LPVOID MacFrame, // Frame pointer.
  166. LPBYTE SSPFrame, // Relative pointer.
  167. DWORD MacType, // MAC type.
  168. DWORD BytesLeft, // Bytes left.
  169. HPROTOCOL hPreviousProtocol, // Previous protocol or NULL if none.
  170. DWORD nPreviousProtocolOffset, // Offset of previous protocol.
  171. DWORD_PTR InstData)
  172. {
  173. DWORD dwMSRPCStartOffset;
  174. BYTE AuthenticationProtocolID = 0;
  175. PNTLMSSP_MESSAGE_SIGNATURE lpMessageSignature = (PNTLMSSP_MESSAGE_SIGNATURE)(SSPFrame + sizeof(DWORD));
  176. dwMSRPCStartOffset = GetProtocolStartOffset(hFrame,"MSRPC");
  177. // get the authenticationid
  178. if (*(((LPBYTE)MacFrame) + dwMSRPCStartOffset) == 4)
  179. {
  180. AuthenticationProtocolID = *(((LPBYTE)MacFrame) + dwMSRPCStartOffset + 78);
  181. }
  182. //=================================
  183. // Attach summary.
  184. //=================================
  185. AttachPropertyInstanceEx(hFrame,
  186. SSPDatabase[0].hProperty,
  187. BytesLeft,
  188. SSPFrame,
  189. sizeof(BYTE),
  190. &AuthenticationProtocolID,
  191. 0, 0, 0);
  192. AttachPropertyInstance(hFrame,
  193. SSPDatabase[1].hProperty,
  194. sizeof(BYTE),
  195. SSPFrame,
  196. 0, 1, 0);
  197. AttachPropertyInstance(hFrame,
  198. SSPDatabase[2].hProperty,
  199. sizeof(BYTE),
  200. (SSPFrame + sizeof(BYTE)),
  201. 0, 1, 0);
  202. AttachPropertyInstance(hFrame,
  203. SSPDatabase[3].hProperty,
  204. sizeof(WORD),
  205. (SSPFrame + sizeof(WORD)),
  206. 0, 1, 0);
  207. if (AuthenticationProtocolID == 10)
  208. {
  209. AttachPropertyInstance(hFrame,
  210. SSPDatabase[4].hProperty,
  211. BytesLeft - sizeof(DWORD),
  212. lpMessageSignature,
  213. 0, 1, 0);
  214. AttachPropertyInstance(hFrame,
  215. SSPDatabase[6].hProperty,
  216. sizeof(DWORD),
  217. &lpMessageSignature->Version,
  218. 0, 2, 0);
  219. AttachPropertyInstance(hFrame,
  220. SSPDatabase[7].hProperty,
  221. sizeof(DWORD),
  222. &lpMessageSignature->RandomPad,
  223. 0, 2, 0);
  224. AttachPropertyInstance(hFrame,
  225. SSPDatabase[8].hProperty,
  226. sizeof(DWORD),
  227. &lpMessageSignature->CheckSum,
  228. 0, 2, 0);
  229. AttachPropertyInstance(hFrame,
  230. SSPDatabase[9].hProperty,
  231. sizeof(DWORD),
  232. &lpMessageSignature->Nonce,
  233. 0, 2, 0);
  234. }
  235. else
  236. {
  237. AttachPropertyInstance(hFrame,
  238. SSPDatabase[5].hProperty,
  239. BytesLeft - sizeof(DWORD),
  240. lpMessageSignature,
  241. 0, 1, 0);
  242. }
  243. return NULL;
  244. }
  245. // ***************************************************************************
  246. // FUNCTION: FormatProperties()
  247. //
  248. // A-FLEXD August 14, 1996 Created
  249. // ***************************************************************************
  250. DWORD WINAPI SSPFormatProperties(HFRAME hFrame,
  251. LPBYTE MacFrame,
  252. LPBYTE SSPFrame,
  253. DWORD nPropertyInsts,
  254. LPPROPERTYINST p)
  255. {
  256. while (nPropertyInsts--)
  257. {
  258. ((FORMAT) p->lpPropertyInfo->InstanceData)(p);
  259. p++;
  260. }
  261. return NMERR_SUCCESS;
  262. }
  263. // ***************************************************************************
  264. // FUNCTION: SSPFormatSummary()
  265. //
  266. // A-FLEXD August 14, 1996 Created
  267. // ***************************************************************************
  268. VOID WINAPIV SSPFormatSummary(LPPROPERTYINST lpPropertyInst)
  269. {
  270. switch((lpPropertyInst->lpPropertyInstEx->Byte[0]))
  271. {
  272. case 10:
  273. wsprintf(szJunkString,"Microsoft");
  274. break;
  275. default:
  276. wsprintf(szJunkString,"Unknown");
  277. }
  278. wsprintf(szJunkString,"%s Security Support Provider",szJunkString);
  279. // limit the lenght so we don't go too far
  280. szJunkString[79] = '\0';
  281. wsprintf( lpPropertyInst->szPropertyText, "%s",szJunkString);
  282. }
  283. // ***************************************************************************