]> git.ozlabs.org Git - ppp.git/blob - pppd/chap_ms.h
Add __attribute__((__packed__)) to the MS-CHAP response structures
[ppp.git] / pppd / chap_ms.h
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.12 2004/11/09 22:49:05 paulus Exp $
31  */
32
33 #ifndef __CHAPMS_INCLUDE__
34
35 #define MD4_SIGNATURE_SIZE      16      /* 16 bytes in a MD4 message digest */
36 #define MAX_NT_PASSWORD         256     /* Max (Unicode) chars in an NT pass */
37
38 #define MS_CHAP_RESPONSE_LEN    49      /* Response length for MS-CHAP */
39 #define MS_CHAP2_RESPONSE_LEN   49      /* Response length for MS-CHAPv2 */
40 #define MS_AUTH_RESPONSE_LENGTH 40      /* MS-CHAPv2 authenticator response, */
41                                         /* as ASCII */
42
43 /* E=eeeeeeeeee error codes for MS-CHAP failure messages. */
44 #define MS_CHAP_ERROR_RESTRICTED_LOGON_HOURS    646
45 #define MS_CHAP_ERROR_ACCT_DISABLED             647
46 #define MS_CHAP_ERROR_PASSWD_EXPIRED            648
47 #define MS_CHAP_ERROR_NO_DIALIN_PERMISSION      649
48 #define MS_CHAP_ERROR_AUTHENTICATION_FAILURE    691
49 #define MS_CHAP_ERROR_CHANGING_PASSWORD         709
50
51 /*
52  * Apparently gcc on ARM gives all structures 4-byte alignment
53  * by default.  This tells gcc that these structures may be
54  * unaligned and may not have extra padding inside them.
55  */
56 #ifdef __GNUC__
57 #define PACKED  __attribute__((__packed__))
58 #else
59 #define PACKED
60 #endif
61
62 /*
63  * Use MS_CHAP_RESPONSE_LEN, rather than sizeof(MS_ChapResponse),
64  * in case this struct gets padded.
65  */
66 typedef struct {
67     u_char LANManResp[24];
68     u_char NTResp[24];
69     u_char UseNT[1];            /* If 1, ignore the LANMan response field */
70 } MS_ChapResponse PACKED;
71
72 /*
73  * Use MS_CHAP2_RESPONSE_LEN, rather than sizeof(MS_Chap2Response),
74  * in case this struct gets padded.
75  */
76 typedef struct {
77     u_char PeerChallenge[16];
78     u_char Reserved[8];         /* Must be zero */
79     u_char NTResp[24];
80     u_char Flags[1];            /* Must be zero */
81 } MS_Chap2Response PACKED;
82
83 #ifdef MPPE
84 #include <net/ppp-comp.h>       /* MPPE_MAX_KEY_LEN */
85 extern u_char mppe_send_key[MPPE_MAX_KEY_LEN];
86 extern u_char mppe_recv_key[MPPE_MAX_KEY_LEN];
87 extern int mppe_keys_set;
88
89 /* These values are the RADIUS attribute values--see RFC 2548. */
90 #define MPPE_ENC_POL_ENC_ALLOWED 1
91 #define MPPE_ENC_POL_ENC_REQUIRED 2
92 #define MPPE_ENC_TYPES_RC4_40 2
93 #define MPPE_ENC_TYPES_RC4_128 4
94
95 /* used by plugins (using above values) */
96 extern void set_mppe_enc_types(int, int);
97 #endif
98
99 /* Are we the authenticator or authenticatee?  For MS-CHAPv2 key derivation. */
100 #define MS_CHAP2_AUTHENTICATEE 0
101 #define MS_CHAP2_AUTHENTICATOR 1
102
103 void ChapMS __P((u_char *, char *, int, MS_ChapResponse *));
104 void ChapMS2 __P((u_char *, u_char *, char *, char *, int,
105                   MS_Chap2Response *, u_char[MS_AUTH_RESPONSE_LENGTH+1], int));
106 #ifdef MPPE
107 void mppe_set_keys __P((u_char *, u_char[MD4_SIGNATURE_SIZE]));
108 void mppe_set_keys2(u_char PasswordHashHash[MD4_SIGNATURE_SIZE],
109                     u_char NTResponse[24], int IsServer);
110 #endif
111
112 void    ChallengeHash __P((u_char[16], u_char *, char *, u_char[8]));
113
114 void GenerateAuthenticatorResponse(u_char PasswordHashHash[MD4_SIGNATURE_SIZE],
115                         u_char NTResponse[24], u_char PeerChallenge[16],
116                         u_char *rchallenge, char *username,
117                         u_char authResponse[MS_AUTH_RESPONSE_LENGTH+1]);
118
119 void chapms_init(void);
120
121 #define __CHAPMS_INCLUDE__
122 #endif /* __CHAPMS_INCLUDE__ */