xref: /titanic_51/usr/src/uts/common/smbsrv/netrauth.h (revision b6917abefc343244b784f0cc34bc65b01469c3bf)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 
32 /*
33  * Interface definitions for the NETR remote authentication and logon
34  * services.
35  */
36 
37 #include <sys/types.h>
38 #include <smbsrv/wintypes.h>
39 #include <smbsrv/mlsvc.h>
40 
41 #ifndef _KERNEL
42 #include <syslog.h>
43 #endif /* _KERNEL */
44 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
49 /*
50  * See also netlogon.ndl.
51  */
52 #define	NETR_WKSTA_TRUST_ACCOUNT_TYPE		0x02
53 #define	NETR_DOMAIN_TRUST_ACCOUNT_TYPE		0x04
54 
55 /*
56  * Negotiation flags for challenge/response authentication.
57  */
58 #define	NETR_NEGOTIATE_STRONG_KEY		1
59 
60 #ifdef NETR_NEGOTIATE_STRONG_KEY
61 #define	NETR_NEGOTIATE_FLAGS			0x000041FF
62 #else
63 #define	NETR_NEGOTIATE_FLAGS			0x000001FF
64 #endif
65 
66 #ifdef NETR_NEGOTIATE_STRONG_KEY
67 #define	NETR_SESSION_KEY_SZ			16
68 #else
69 #define	NETR_SESSION_KEY_SZ			8
70 #endif
71 
72 #define	NETR_CRED_DATA_SZ			8
73 #define	NETR_OWF_PASSWORD_SZ			16
74 
75 
76 /*
77  * SAM logon levels: interactive and network.
78  */
79 #define	NETR_INTERACTIVE_LOGON			0x01
80 #define	NETR_NETWORK_LOGON			0x02
81 
82 
83 /*
84  * SAM logon validation levels.
85  */
86 #define	NETR_VALIDATION_LEVEL3			0x03
87 
88 
89 /*
90  * This is a duplicate of the netr_credential
91  * from netlogon.ndl.
92  */
93 typedef struct netr_cred {
94     BYTE data[NETR_CRED_DATA_SZ];
95 } netr_cred_t;
96 
97 
98 
99 #define	NETR_FLG_NULL		0x00000001
100 #define	NETR_FLG_VALID		0x00000001
101 #define	NETR_FLG_INIT		0x00000002
102 
103 
104 typedef struct netr_info {
105 	DWORD flags;
106 	char server[MLSVC_DOMAIN_NAME_MAX * 2];
107 	char hostname[MLSVC_DOMAIN_NAME_MAX * 2];
108 	netr_cred_t client_challenge;
109 	netr_cred_t server_challenge;
110 	netr_cred_t client_credential;
111 	netr_cred_t server_credential;
112 	BYTE session_key[NETR_SESSION_KEY_SZ];
113 	BYTE password[MLSVC_MACHINE_ACCT_PASSWD_MAX];
114 	time_t timestamp;
115 } netr_info_t;
116 
117 /*
118  * netr_client_t flags
119  *
120  * NETR_CFLG_ANON               Anonymous connection
121  * NETR_CFLG_LOCAL              Local user
122  * NETR_CFLG_DOMAIN		Domain user
123  */
124 #define	NETR_CFLG_ANON  	0x01
125 #define	NETR_CFLG_LOCAL 	0x02
126 #define	NETR_CFLG_DOMAIN	0x04
127 
128 
129 typedef struct netr_client {
130 	uint16_t logon_level;
131 	char *username;
132 	char *domain;
133 	char *workstation;
134 	uint32_t ipaddr;
135 	struct {
136 		uint32_t challenge_key_len;
137 		uint8_t *challenge_key_val;
138 	} challenge_key;
139 	struct {
140 		uint32_t nt_password_len;
141 		uint8_t *nt_password_val;
142 	} nt_password;
143 	struct {
144 		uint32_t lm_password_len;
145 		uint8_t *lm_password_val;
146 	} lm_password;
147 	uint32_t logon_id;
148 	int native_os;
149 	int native_lm;
150 	uint32_t local_ipaddr;
151 	uint16_t local_port;
152 	uint32_t flags;
153 } netr_client_t;
154 
155 
156 /*
157  * NETLOGON private interface.
158  */
159 int netr_gen_session_key(netr_info_t *netr_info);
160 
161 int netr_gen_credentials(BYTE *session_key, netr_cred_t *challenge,
162     DWORD timestamp, netr_cred_t *out_cred);
163 
164 
165 #define	NETR_A2H(c) (isdigit(c)) ? ((c) - '0') : ((c) - 'A' + 10)
166 
167 #ifdef __cplusplus
168 }
169 #endif
170 
171 #endif /* _SMBSRV_NETRAUTH_H */
172