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.

156 lines
4.1 KiB

  1. /* Copyright (c) 1993, Microsoft Corporation, all rights reserved
  2. **
  3. ** raspap.h
  4. ** Remote Access PPP Password Authentication Protocol
  5. **
  6. ** 11/05/93 Steve Cobb
  7. */
  8. #ifndef _RASPAP_H_
  9. #define _RASPAP_H_
  10. #include "wincrypt.h"
  11. //General macros
  12. #define GEN_RAND_ENCODE_SEED ((CHAR) ( 1 + rand() % 250 ))
  13. /* PAP packet codes from PAP spec.
  14. */
  15. #define PAPCODE_Req 1
  16. #define PAPCODE_Ack 2
  17. #define PAPCODE_Nak 3
  18. #define MAXPAPCODE 3
  19. /* Returned by receive buffer parsing routines that discover the packet is
  20. ** corrupt, usually because the length fields don't make sense.
  21. */
  22. #define ERRORBADPACKET (DWORD )-1
  23. /* Defines states within the PAP protocol.
  24. */
  25. #define PAPSTATE enum tagPAPSTATE
  26. PAPSTATE
  27. {
  28. PS_Initial,
  29. PS_RequestSent,
  30. PS_WaitForRequest,
  31. PS_WaitForAuthenticationToComplete,
  32. PS_Done
  33. };
  34. /* Defines the WorkBuf stored for us by the PPP engine.
  35. */
  36. #define PAPWB struct tagPAPWB
  37. PAPWB
  38. {
  39. /* True if role is server, false if client.
  40. */
  41. BOOL fServer;
  42. /* The domain\username and password (applies to client only).
  43. */
  44. CHAR szAccount[ DNLEN + 1 + UNLEN + 1 ];
  45. CHAR szPassword[ PWLEN ];
  46. /* The current state in the PAP protocol.
  47. */
  48. PAPSTATE state;
  49. /* Last sequencing ID sent on this port. Incremented for each
  50. ** Authenticate-Req packet sent. Client side only.
  51. */
  52. BYTE bIdSent;
  53. HPORT hPort;
  54. /* Id of the last Authenticate-Req packet received on this port.
  55. ** Server side only.
  56. */
  57. BYTE bLastIdReceived;
  58. //
  59. // Used to get information to send to back-end server.
  60. //
  61. RAS_AUTH_ATTRIBUTE * pUserAttributes;
  62. /* The final result, used to duplicate the original response for all
  63. ** subsequent Authenticate-Req packets. This is per PAP spec to cover
  64. ** lost Ack/Nak case without allowing malicious client to discover
  65. ** alternative identities under the covers during a connection. (applies
  66. ** to server only)
  67. */
  68. PPPAP_RESULT result;
  69. // CHAR chSeed; //Used to encode password. Strange. We
  70. //send password cleartext on the line
  71. //and encode it in the program...
  72. DATA_BLOB DBPassword;
  73. };
  74. /* Prototypes.
  75. */
  76. DWORD CheckCredentials( CHAR*, CHAR*, CHAR*, DWORD*, BOOL*, CHAR*,
  77. BYTE*, CHAR*, HANDLE* );
  78. DWORD PapCMakeMessage( PAPWB*, PPP_CONFIG*, PPP_CONFIG*, DWORD, PPPAP_RESULT* );
  79. DWORD GetCredentialsFromRequest( PPP_CONFIG*, CHAR*, CHAR* );
  80. DWORD GetErrorFromNak( PPP_CONFIG* );
  81. VOID PapMakeRequestMessage( PAPWB*, PPP_CONFIG*, DWORD );
  82. VOID PapMakeResultMessage( DWORD, BYTE, PPP_CONFIG*, DWORD, RAS_AUTH_ATTRIBUTE* );
  83. DWORD PapBegin( VOID**, VOID* );
  84. DWORD PapEnd( VOID* );
  85. DWORD PapMakeMessage( VOID*, PPP_CONFIG*, PPP_CONFIG*, DWORD, PPPAP_RESULT*,
  86. PPPAP_INPUT* pInput );
  87. VOID PapExtractMessage(PPP_CONFIG*, PPPAP_RESULT*);
  88. DWORD PapSMakeMessage( PAPWB*, PPP_CONFIG*, PPP_CONFIG*, DWORD, PPPAP_INPUT* pInput, PPPAP_RESULT* );
  89. /* Globals.
  90. */
  91. #ifdef RASPAPGLOBALS
  92. #define GLOBALS
  93. #define EXTERN
  94. #else
  95. #define EXTERN extern
  96. #endif
  97. /* Next packet identifier to assign. Unlike CPs, APs must handle updating
  98. ** this sequence number themselves because the engine can't make as many
  99. ** assumptions about the protocol. It is stored global to all ports and
  100. ** authentication sessions to make it less likely that an ID will be used in
  101. ** sequential authentication sessions. Not to be confused with the 'bIdSent'
  102. ** updated on a per-port basis and used for matching.
  103. */
  104. EXTERN BYTE BNextIdPap
  105. #ifdef GLOBALS
  106. = 0
  107. #endif
  108. ;
  109. /* This value indicates whether or not to follow strict sequencing as defined
  110. ** in the PPP RFC for PAP. The RFC says that the PAP client MUST increase the
  111. ** sequence number for every new CONFIG_REQ packet sent out. However this
  112. ** causes problems with slow servers. See bug # 22508. Default is FALSE.
  113. */
  114. EXTERN BOOL fFollowStrictSequencing
  115. #ifdef GLOBALS
  116. = FALSE
  117. #endif
  118. ;
  119. EXTERN
  120. DWORD g_dwTraceIdPap
  121. #ifdef GLOBALS
  122. = INVALID_TRACEID;
  123. #endif
  124. ;
  125. #undef EXTERN
  126. #undef GLOBALS
  127. #endif // _RASPAP_H_