chap_ms.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * chap_ms.h - Challenge Handshake Authentication Protocol definitions.
  3. *
  4. * Copyright (c) 1995 Eric Rosenquist. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. *
  13. * 2. Redistributions in binary form must reproduce the above copyright
  14. * notice, this list of conditions and the following disclaimer in
  15. * the documentation and/or other materials provided with the
  16. * distribution.
  17. *
  18. * 3. The name(s) of the authors of this software must not be used to
  19. * endorse or promote products derived from this software without
  20. * prior written permission.
  21. *
  22. * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
  23. * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  24. * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
  25. * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  26. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
  27. * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
  28. * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  29. *
  30. * $Id: chap_ms.h,v 1.13 2004/11/15 22:13:26 paulus Exp $
  31. */
  32. #ifndef __CHAPMS_INCLUDE__
  33. #define MD4_SIGNATURE_SIZE 16 /* 16 bytes in a MD4 message digest */
  34. #define MAX_NT_PASSWORD 256 /* Max (Unicode) chars in an NT pass */
  35. #define MS_CHAP_RESPONSE_LEN 49 /* Response length for MS-CHAP */
  36. #define MS_CHAP2_RESPONSE_LEN 49 /* Response length for MS-CHAPv2 */
  37. #define MS_AUTH_RESPONSE_LENGTH 40 /* MS-CHAPv2 authenticator response, */
  38. /* as ASCII */
  39. /* E=eeeeeeeeee error codes for MS-CHAP failure messages. */
  40. #define MS_CHAP_ERROR_RESTRICTED_LOGON_HOURS 646
  41. #define MS_CHAP_ERROR_ACCT_DISABLED 647
  42. #define MS_CHAP_ERROR_PASSWD_EXPIRED 648
  43. #define MS_CHAP_ERROR_NO_DIALIN_PERMISSION 649
  44. #define MS_CHAP_ERROR_AUTHENTICATION_FAILURE 691
  45. #define MS_CHAP_ERROR_CHANGING_PASSWORD 709
  46. /*
  47. * Offsets within the response field for MS-CHAP
  48. */
  49. #define MS_CHAP_LANMANRESP 0
  50. #define MS_CHAP_LANMANRESP_LEN 24
  51. #define MS_CHAP_NTRESP 24
  52. #define MS_CHAP_NTRESP_LEN 24
  53. #define MS_CHAP_USENT 48
  54. /*
  55. * Offsets within the response field for MS-CHAP2
  56. */
  57. #define MS_CHAP2_PEER_CHALLENGE 0
  58. #define MS_CHAP2_PEER_CHAL_LEN 16
  59. #define MS_CHAP2_RESERVED_LEN 8
  60. #define MS_CHAP2_NTRESP 24
  61. #define MS_CHAP2_NTRESP_LEN 24
  62. #define MS_CHAP2_FLAGS 48
  63. #ifdef MPPE
  64. #include "mppe.h" /* MPPE_MAX_KEY_LEN */
  65. extern u_char mppe_send_key[MPPE_MAX_KEY_LEN];
  66. extern u_char mppe_recv_key[MPPE_MAX_KEY_LEN];
  67. extern int mppe_keys_set;
  68. /* These values are the RADIUS attribute values--see RFC 2548. */
  69. #define MPPE_ENC_POL_ENC_ALLOWED 1
  70. #define MPPE_ENC_POL_ENC_REQUIRED 2
  71. #define MPPE_ENC_TYPES_RC4_40 2
  72. #define MPPE_ENC_TYPES_RC4_128 4
  73. /* used by plugins (using above values) */
  74. extern void set_mppe_enc_types(int, int);
  75. #endif
  76. /* Are we the authenticator or authenticatee? For MS-CHAPv2 key derivation. */
  77. #define MS_CHAP2_AUTHENTICATEE 0
  78. #define MS_CHAP2_AUTHENTICATOR 1
  79. void ChapMS __P((u_char *, char *, int, u_char *));
  80. void ChapMS2 __P((u_char *, u_char *, char *, char *, int,
  81. u_char *, u_char[MS_AUTH_RESPONSE_LENGTH+1], int));
  82. #ifdef MPPE
  83. void mppe_set_keys __P((u_char *, u_char[MD4_SIGNATURE_SIZE]));
  84. void mppe_set_keys2(u_char PasswordHashHash[MD4_SIGNATURE_SIZE],
  85. u_char NTResponse[24], int IsServer);
  86. #endif
  87. void ChallengeHash __P((u_char[16], u_char *, char *, u_char[8]));
  88. void GenerateAuthenticatorResponse(u_char PasswordHashHash[MD4_SIGNATURE_SIZE],
  89. u_char NTResponse[24], u_char PeerChallenge[16],
  90. u_char *rchallenge, char *username,
  91. u_char authResponse[MS_AUTH_RESPONSE_LENGTH+1]);
  92. void chapms_init(void);
  93. #define __CHAPMS_INCLUDE__
  94. #endif /* __CHAPMS_INCLUDE__ */