xref: /titanic_41/usr/src/uts/common/smbsrv/netrauth.h (revision 450396635f70344c58b6b1e4db38cf17ff34445c)
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 2009 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 #include <smbsrv/smb_xdr.h>
39 #include <smbsrv/smbinfo.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_BASE_FLAGS		0x000001FF
59 #define	NETR_NEGOTIATE_STRONGKEY_FLAG		0x00004000
60 
61 #define	NETR_SESSKEY64_SZ			8
62 #define	NETR_SESSKEY128_SZ			16
63 #define	NETR_SESSKEY_MAXSZ			NETR_SESSKEY128_SZ
64 #define	NETR_CRED_DATA_SZ			8
65 #define	NETR_OWF_PASSWORD_SZ			16
66 
67 
68 /*
69  * SAM logon levels: interactive and network.
70  */
71 #define	NETR_INTERACTIVE_LOGON			0x01
72 #define	NETR_NETWORK_LOGON			0x02
73 
74 
75 /*
76  * SAM logon validation levels.
77  */
78 #define	NETR_VALIDATION_LEVEL3			0x03
79 
80 
81 /*
82  * This is a duplicate of the netr_credential
83  * from netlogon.ndl.
84  */
85 typedef struct netr_cred {
86 	BYTE data[NETR_CRED_DATA_SZ];
87 } netr_cred_t;
88 
89 typedef struct netr_session_key {
90 	BYTE key[NETR_SESSKEY_MAXSZ];
91 	short len;
92 } netr_session_key_t;
93 
94 #define	NETR_FLG_NULL		0x00000001
95 #define	NETR_FLG_VALID		0x00000001
96 #define	NETR_FLG_INIT		0x00000002
97 
98 /*
99  * 32-byte machine account password (null-terminated)
100  */
101 #define	NETR_MACHINE_ACCT_PASSWD_MAX	32 + 1
102 
103 typedef struct netr_info {
104 	DWORD flags;
105 	char server[NETBIOS_NAME_SZ * 2];
106 	char hostname[NETBIOS_NAME_SZ * 2];
107 	netr_cred_t client_challenge;
108 	netr_cred_t server_challenge;
109 	netr_cred_t client_credential;
110 	netr_cred_t server_credential;
111 	netr_session_key_t session_key;
112 	BYTE password[NETR_MACHINE_ACCT_PASSWD_MAX];
113 	time_t timestamp;
114 } netr_info_t;
115 
116 typedef struct netr_client {
117 	uint16_t logon_level;
118 	char *username;		/* request username */
119 	char *domain;		/* request domain */
120 	char *e_username;	/* effective username */
121 	char *e_domain;		/* effective domain */
122 	char *workstation;
123 	smb_inaddr_t ipaddr;
124 	struct {
125 		uint32_t challenge_key_len;
126 		uint8_t *challenge_key_val;
127 	} challenge_key;
128 	struct {
129 		uint32_t nt_password_len;
130 		uint8_t *nt_password_val;
131 	} nt_password;
132 	struct {
133 		uint32_t lm_password_len;
134 		uint8_t *lm_password_val;
135 	} lm_password;
136 	uint32_t logon_id;
137 	int native_os;
138 	int native_lm;
139 	smb_inaddr_t local_ipaddr;
140 	uint16_t local_port;
141 } netr_client_t;
142 
143 
144 /*
145  * NETLOGON private interface.
146  */
147 int netr_gen_skey64(netr_info_t *);
148 int netr_gen_skey128(netr_info_t *);
149 
150 int netr_gen_credentials(BYTE *, netr_cred_t *, DWORD, netr_cred_t *);
151 
152 
153 #define	NETR_A2H(c) (isdigit(c)) ? ((c) - '0') : ((c) - 'A' + 10)
154 
155 #ifdef __cplusplus
156 }
157 #endif
158 
159 #endif /* _SMBSRV_NETRAUTH_H */
160