xref: /titanic_50/usr/src/uts/common/smbsrv/netrauth.h (revision b3700b074e637f8c6991b70754c88a2cfffb246b)
1da6c28aaSamw /*
2da6c28aaSamw  * CDDL HEADER START
3da6c28aaSamw  *
4da6c28aaSamw  * The contents of this file are subject to the terms of the
5da6c28aaSamw  * Common Development and Distribution License (the "License").
6da6c28aaSamw  * You may not use this file except in compliance with the License.
7da6c28aaSamw  *
8da6c28aaSamw  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9da6c28aaSamw  * or http://www.opensolaris.org/os/licensing.
10da6c28aaSamw  * See the License for the specific language governing permissions
11da6c28aaSamw  * and limitations under the License.
12da6c28aaSamw  *
13da6c28aaSamw  * When distributing Covered Code, include this CDDL HEADER in each
14da6c28aaSamw  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15da6c28aaSamw  * If applicable, add the following below this CDDL HEADER, with the
16da6c28aaSamw  * fields enclosed by brackets "[]" replaced with your own identifying
17da6c28aaSamw  * information: Portions Copyright [yyyy] [name of copyright owner]
18da6c28aaSamw  *
19da6c28aaSamw  * CDDL HEADER END
20da6c28aaSamw  */
21da6c28aaSamw /*
2277191e87SShawn Emery  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
23da6c28aaSamw  * Use is subject to license terms.
2412b65585SGordon Ross  *
2512b65585SGordon Ross  * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
26da6c28aaSamw  */
27da6c28aaSamw 
28da6c28aaSamw #ifndef _SMBSRV_NETRAUTH_H
29da6c28aaSamw #define	_SMBSRV_NETRAUTH_H
30da6c28aaSamw 
31da6c28aaSamw /*
329fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States  * NETR remote authentication and logon services.
33da6c28aaSamw  */
34da6c28aaSamw 
35da6c28aaSamw #include <sys/types.h>
36da6c28aaSamw #include <smbsrv/wintypes.h>
37b89a8333Snatalie li - Sun Microsystems - Irvine United States #include <smbsrv/netbios.h>
387f667e74Sjose borrego #include <smbsrv/smbinfo.h>
39*b3700b07SGordon Ross #include <netdb.h>
40da6c28aaSamw 
41da6c28aaSamw #ifdef __cplusplus
42da6c28aaSamw extern "C" {
43da6c28aaSamw #endif
44da6c28aaSamw 
45da6c28aaSamw /*
46da6c28aaSamw  * See also netlogon.ndl.
47da6c28aaSamw  */
48da6c28aaSamw #define	NETR_WKSTA_TRUST_ACCOUNT_TYPE		0x02
49da6c28aaSamw #define	NETR_DOMAIN_TRUST_ACCOUNT_TYPE		0x04
50da6c28aaSamw 
51da6c28aaSamw /*
52da6c28aaSamw  * Negotiation flags for challenge/response authentication.
53da6c28aaSamw  */
542c1b14e5Sjose borrego #define	NETR_NEGOTIATE_BASE_FLAGS		0x000001FF
552c1b14e5Sjose borrego #define	NETR_NEGOTIATE_STRONGKEY_FLAG		0x00004000
56da6c28aaSamw 
572c1b14e5Sjose borrego #define	NETR_SESSKEY64_SZ			8
582c1b14e5Sjose borrego #define	NETR_SESSKEY128_SZ			16
592c1b14e5Sjose borrego #define	NETR_SESSKEY_MAXSZ			NETR_SESSKEY128_SZ
60da6c28aaSamw #define	NETR_CRED_DATA_SZ			8
61da6c28aaSamw #define	NETR_OWF_PASSWORD_SZ			16
62da6c28aaSamw 
63da6c28aaSamw /*
64da6c28aaSamw  * SAM logon levels: interactive and network.
65da6c28aaSamw  */
66da6c28aaSamw #define	NETR_INTERACTIVE_LOGON			0x01
67da6c28aaSamw #define	NETR_NETWORK_LOGON			0x02
68da6c28aaSamw 
69da6c28aaSamw /*
70da6c28aaSamw  * SAM logon validation levels.
71da6c28aaSamw  */
72da6c28aaSamw #define	NETR_VALIDATION_LEVEL3			0x03
73da6c28aaSamw 
74da6c28aaSamw /*
7512b65585SGordon Ross  * Most of these are from: "MSV1_0_LM20_LOGON structure"
7612b65585SGordon Ross  * http://msdn.microsoft.com/en-us/library/windows/desktop/aa378762
7712b65585SGordon Ross  * and a few are from the ntddk (ntmsv1_0.h) found many places.
7812b65585SGordon Ross  */
7912b65585SGordon Ross #define	MSV1_0_CLEARTEXT_PASSWORD_ALLOWED	0x00000002
8012b65585SGordon Ross #define	MSV1_0_UPDATE_LOGON_STATISTICS		0x00000004
8112b65585SGordon Ross #define	MSV1_0_RETURN_USER_PARAMETERS		0x00000008
8212b65585SGordon Ross #define	MSV1_0_DONT_TRY_GUEST_ACCOUNT		0x00000010
8312b65585SGordon Ross #define	MSV1_0_ALLOW_SERVER_TRUST_ACCOUNT	0x00000020
8412b65585SGordon Ross #define	MSV1_0_RETURN_PASSWORD_EXPIRY		0x00000040
8512b65585SGordon Ross /*
8612b65585SGordon Ross  * MSV1_0_USE_CLIENT_CHALLENGE means the LM response field contains the
8712b65585SGordon Ross  * "client challenge" in the first 8 bytes instead of the LM response.
8812b65585SGordon Ross  */
8912b65585SGordon Ross #define	MSV1_0_USE_CLIENT_CHALLENGE		0x00000080
9012b65585SGordon Ross #define	MSV1_0_TRY_GUEST_ACCOUNT_ONLY		0x00000100
9112b65585SGordon Ross #define	MSV1_0_RETURN_PROFILE_PATH		0x00000200
9212b65585SGordon Ross #define	MSV1_0_TRY_SPECIFIED_DOMAIN_ONLY	0x00000400
9312b65585SGordon Ross #define	MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT	0x00000800
9412b65585SGordon Ross #define	MSV1_0_DISABLE_PERSONAL_FALLBACK	0x00001000
9512b65585SGordon Ross #define	MSV1_0_ALLOW_FORCE_GUEST		0x00002000
9612b65585SGordon Ross #define	MSV1_0_CLEARTEXT_PASSWORD_SUPPLIED	0x00004000
9712b65585SGordon Ross #define	MSV1_0_USE_DOMAIN_FOR_ROUTING_ONLY	0x00008000
9812b65585SGordon Ross #define	MSV1_0_SUBAUTHENTICATION_DLL_EX		0x00100000
9912b65585SGordon Ross 
10012b65585SGordon Ross /*
101da6c28aaSamw  * This is a duplicate of the netr_credential
102da6c28aaSamw  * from netlogon.ndl.
103da6c28aaSamw  */
104da6c28aaSamw typedef struct netr_cred {
105da6c28aaSamw 	BYTE data[NETR_CRED_DATA_SZ];
106da6c28aaSamw } netr_cred_t;
107da6c28aaSamw 
1082c1b14e5Sjose borrego typedef struct netr_session_key {
1092c1b14e5Sjose borrego 	BYTE key[NETR_SESSKEY_MAXSZ];
1102c1b14e5Sjose borrego 	short len;
1112c1b14e5Sjose borrego } netr_session_key_t;
112da6c28aaSamw 
113da6c28aaSamw #define	NETR_FLG_NULL		0x00000001
114da6c28aaSamw #define	NETR_FLG_VALID		0x00000001
115da6c28aaSamw #define	NETR_FLG_INIT		0x00000002
116da6c28aaSamw 
1178d7e4166Sjose borrego /*
11877191e87SShawn Emery  * 120-byte machine account password (null-terminated)
1198d7e4166Sjose borrego  */
12077191e87SShawn Emery #define	NETR_MACHINE_ACCT_PASSWD_MAX	120 + 1
121da6c28aaSamw 
122da6c28aaSamw typedef struct netr_info {
123da6c28aaSamw 	DWORD flags;
124*b3700b07SGordon Ross 	char server[MAXHOSTNAMELEN];		/* Current DC, FQDN */
125*b3700b07SGordon Ross 	char hostname[NETBIOS_NAME_SZ * 2];	/* local "flat" name */
126da6c28aaSamw 	netr_cred_t client_challenge;
127da6c28aaSamw 	netr_cred_t server_challenge;
128da6c28aaSamw 	netr_cred_t client_credential;
129da6c28aaSamw 	netr_cred_t server_credential;
1302c1b14e5Sjose borrego 	netr_session_key_t session_key;
1318d7e4166Sjose borrego 	BYTE password[NETR_MACHINE_ACCT_PASSWD_MAX];
132da6c28aaSamw 	time_t timestamp;
133da6c28aaSamw } netr_info_t;
134da6c28aaSamw 
135da6c28aaSamw /*
136da6c28aaSamw  * NETLOGON private interface.
137da6c28aaSamw  */
1382c1b14e5Sjose borrego int netr_gen_skey64(netr_info_t *);
1392c1b14e5Sjose borrego int netr_gen_skey128(netr_info_t *);
140da6c28aaSamw 
1412c1b14e5Sjose borrego int netr_gen_credentials(BYTE *, netr_cred_t *, DWORD, netr_cred_t *);
142da6c28aaSamw 
143da6c28aaSamw 
144da6c28aaSamw #define	NETR_A2H(c) (isdigit(c)) ? ((c) - '0') : ((c) - 'A' + 10)
145da6c28aaSamw 
146da6c28aaSamw #ifdef __cplusplus
147da6c28aaSamw }
148da6c28aaSamw #endif
149da6c28aaSamw 
150da6c28aaSamw #endif /* _SMBSRV_NETRAUTH_H */
151