xref: /titanic_50/usr/src/uts/common/smbsrv/netrauth.h (revision 37ffaf8335982d89ab569e9a1020419e32003404)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _SMBSRV_NETRAUTH_H
27 #define	_SMBSRV_NETRAUTH_H
28 
29 
30 /*
31  * Interface definitions for the NETR remote authentication and logon
32  * services.
33  */
34 
35 #include <sys/types.h>
36 #include <smbsrv/wintypes.h>
37 #include <smbsrv/netbios.h>
38 
39 #ifndef _KERNEL
40 #include <syslog.h>
41 #endif /* _KERNEL */
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 /*
48  * See also netlogon.ndl.
49  */
50 #define	NETR_WKSTA_TRUST_ACCOUNT_TYPE		0x02
51 #define	NETR_DOMAIN_TRUST_ACCOUNT_TYPE		0x04
52 
53 /*
54  * Negotiation flags for challenge/response authentication.
55  */
56 #define	NETR_NEGOTIATE_BASE_FLAGS		0x000001FF
57 #define	NETR_NEGOTIATE_STRONGKEY_FLAG		0x00004000
58 
59 #define	NETR_SESSKEY64_SZ			8
60 #define	NETR_SESSKEY128_SZ			16
61 #define	NETR_SESSKEY_MAXSZ			NETR_SESSKEY128_SZ
62 #define	NETR_CRED_DATA_SZ			8
63 #define	NETR_OWF_PASSWORD_SZ			16
64 
65 
66 /*
67  * SAM logon levels: interactive and network.
68  */
69 #define	NETR_INTERACTIVE_LOGON			0x01
70 #define	NETR_NETWORK_LOGON			0x02
71 
72 
73 /*
74  * SAM logon validation levels.
75  */
76 #define	NETR_VALIDATION_LEVEL3			0x03
77 
78 
79 /*
80  * This is a duplicate of the netr_credential
81  * from netlogon.ndl.
82  */
83 typedef struct netr_cred {
84 	BYTE data[NETR_CRED_DATA_SZ];
85 } netr_cred_t;
86 
87 typedef struct netr_session_key {
88 	BYTE key[NETR_SESSKEY_MAXSZ];
89 	short len;
90 } netr_session_key_t;
91 
92 #define	NETR_FLG_NULL		0x00000001
93 #define	NETR_FLG_VALID		0x00000001
94 #define	NETR_FLG_INIT		0x00000002
95 
96 /*
97  * 32-byte machine account password (null-terminated)
98  */
99 #define	NETR_MACHINE_ACCT_PASSWD_MAX	32 + 1
100 
101 typedef struct netr_info {
102 	DWORD flags;
103 	char server[NETBIOS_NAME_SZ * 2];
104 	char hostname[NETBIOS_NAME_SZ * 2];
105 	netr_cred_t client_challenge;
106 	netr_cred_t server_challenge;
107 	netr_cred_t client_credential;
108 	netr_cred_t server_credential;
109 	netr_session_key_t session_key;
110 	BYTE password[NETR_MACHINE_ACCT_PASSWD_MAX];
111 	time_t timestamp;
112 } netr_info_t;
113 
114 /*
115  * netr_client_t flags
116  *
117  * NETR_CFLG_ANON               Anonymous connection
118  * NETR_CFLG_LOCAL              Local user
119  * NETR_CFLG_DOMAIN		Domain user
120  */
121 #define	NETR_CFLG_ANON  	0x01
122 #define	NETR_CFLG_LOCAL 	0x02
123 #define	NETR_CFLG_DOMAIN	0x04
124 
125 
126 typedef struct netr_client {
127 	uint16_t logon_level;
128 	char *username;
129 	char *domain;
130 	char *workstation;
131 	uint32_t ipaddr;
132 	struct {
133 		uint32_t challenge_key_len;
134 		uint8_t *challenge_key_val;
135 	} challenge_key;
136 	struct {
137 		uint32_t nt_password_len;
138 		uint8_t *nt_password_val;
139 	} nt_password;
140 	struct {
141 		uint32_t lm_password_len;
142 		uint8_t *lm_password_val;
143 	} lm_password;
144 	uint32_t logon_id;
145 	int native_os;
146 	int native_lm;
147 	uint32_t local_ipaddr;
148 	uint16_t local_port;
149 	uint32_t flags;
150 } netr_client_t;
151 
152 
153 /*
154  * NETLOGON private interface.
155  */
156 int netr_gen_skey64(netr_info_t *);
157 int netr_gen_skey128(netr_info_t *);
158 
159 int netr_gen_credentials(BYTE *, netr_cred_t *, DWORD, netr_cred_t *);
160 
161 
162 #define	NETR_A2H(c) (isdigit(c)) ? ((c) - '0') : ((c) - 'A' + 10)
163 
164 #ifdef __cplusplus
165 }
166 #endif
167 
168 #endif /* _SMBSRV_NETRAUTH_H */
169