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