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