xref: /onnv-gate/usr/src/uts/common/smbsrv/netrauth.h (revision 11963:061945695ce1)
15331Samw /*
25331Samw  * CDDL HEADER START
35331Samw  *
45331Samw  * The contents of this file are subject to the terms of the
55331Samw  * Common Development and Distribution License (the "License").
65331Samw  * You may not use this file except in compliance with the License.
75331Samw  *
85331Samw  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
95331Samw  * or http://www.opensolaris.org/os/licensing.
105331Samw  * See the License for the specific language governing permissions
115331Samw  * and limitations under the License.
125331Samw  *
135331Samw  * When distributing Covered Code, include this CDDL HEADER in each
145331Samw  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
155331Samw  * If applicable, add the following below this CDDL HEADER, with the
165331Samw  * fields enclosed by brackets "[]" replaced with your own identifying
175331Samw  * information: Portions Copyright [yyyy] [name of copyright owner]
185331Samw  *
195331Samw  * CDDL HEADER END
205331Samw  */
215331Samw /*
2211571SShawn.Emery@Sun.COM  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
235331Samw  * Use is subject to license terms.
245331Samw  */
255331Samw 
265331Samw #ifndef _SMBSRV_NETRAUTH_H
275331Samw #define	_SMBSRV_NETRAUTH_H
285331Samw 
295331Samw /*
30*11963SAfshin.Ardakani@Sun.COM  * NETR remote authentication and logon services.
315331Samw  */
325331Samw 
335331Samw #include <sys/types.h>
345331Samw #include <smbsrv/wintypes.h>
357961SNatalie.Li@Sun.COM #include <smbsrv/netbios.h>
368670SJose.Borrego@Sun.COM #include <smbsrv/smbinfo.h>
375331Samw 
385331Samw #ifdef __cplusplus
395331Samw extern "C" {
405331Samw #endif
415331Samw 
425331Samw /*
435331Samw  * See also netlogon.ndl.
445331Samw  */
455331Samw #define	NETR_WKSTA_TRUST_ACCOUNT_TYPE		0x02
465331Samw #define	NETR_DOMAIN_TRUST_ACCOUNT_TYPE		0x04
475331Samw 
485331Samw /*
495331Samw  * Negotiation flags for challenge/response authentication.
505331Samw  */
517619SJose.Borrego@Sun.COM #define	NETR_NEGOTIATE_BASE_FLAGS		0x000001FF
527619SJose.Borrego@Sun.COM #define	NETR_NEGOTIATE_STRONGKEY_FLAG		0x00004000
537052Samw 
547619SJose.Borrego@Sun.COM #define	NETR_SESSKEY64_SZ			8
557619SJose.Borrego@Sun.COM #define	NETR_SESSKEY128_SZ			16
567619SJose.Borrego@Sun.COM #define	NETR_SESSKEY_MAXSZ			NETR_SESSKEY128_SZ
575331Samw #define	NETR_CRED_DATA_SZ			8
585331Samw #define	NETR_OWF_PASSWORD_SZ			16
595331Samw 
605331Samw /*
615331Samw  * SAM logon levels: interactive and network.
625331Samw  */
635331Samw #define	NETR_INTERACTIVE_LOGON			0x01
645331Samw #define	NETR_NETWORK_LOGON			0x02
655331Samw 
665331Samw /*
675331Samw  * SAM logon validation levels.
685331Samw  */
695331Samw #define	NETR_VALIDATION_LEVEL3			0x03
705331Samw 
715331Samw /*
725331Samw  * This is a duplicate of the netr_credential
735331Samw  * from netlogon.ndl.
745331Samw  */
755331Samw typedef struct netr_cred {
767619SJose.Borrego@Sun.COM 	BYTE data[NETR_CRED_DATA_SZ];
775331Samw } netr_cred_t;
785331Samw 
797619SJose.Borrego@Sun.COM typedef struct netr_session_key {
807619SJose.Borrego@Sun.COM 	BYTE key[NETR_SESSKEY_MAXSZ];
817619SJose.Borrego@Sun.COM 	short len;
827619SJose.Borrego@Sun.COM } netr_session_key_t;
835331Samw 
845331Samw #define	NETR_FLG_NULL		0x00000001
855331Samw #define	NETR_FLG_VALID		0x00000001
865331Samw #define	NETR_FLG_INIT		0x00000002
875331Samw 
888334SJose.Borrego@Sun.COM /*
8911571SShawn.Emery@Sun.COM  * 120-byte machine account password (null-terminated)
908334SJose.Borrego@Sun.COM  */
9111571SShawn.Emery@Sun.COM #define	NETR_MACHINE_ACCT_PASSWD_MAX	120 + 1
925331Samw 
935331Samw typedef struct netr_info {
945331Samw 	DWORD flags;
957961SNatalie.Li@Sun.COM 	char server[NETBIOS_NAME_SZ * 2];
967961SNatalie.Li@Sun.COM 	char hostname[NETBIOS_NAME_SZ * 2];
975331Samw 	netr_cred_t client_challenge;
985331Samw 	netr_cred_t server_challenge;
995331Samw 	netr_cred_t client_credential;
1005331Samw 	netr_cred_t server_credential;
1017619SJose.Borrego@Sun.COM 	netr_session_key_t session_key;
1028334SJose.Borrego@Sun.COM 	BYTE password[NETR_MACHINE_ACCT_PASSWD_MAX];
1035331Samw 	time_t timestamp;
1045331Samw } netr_info_t;
1055331Samw 
1065331Samw /*
1075331Samw  * NETLOGON private interface.
1085331Samw  */
1097619SJose.Borrego@Sun.COM int netr_gen_skey64(netr_info_t *);
1107619SJose.Borrego@Sun.COM int netr_gen_skey128(netr_info_t *);
1115331Samw 
1127619SJose.Borrego@Sun.COM int netr_gen_credentials(BYTE *, netr_cred_t *, DWORD, netr_cred_t *);
1135331Samw 
1145331Samw 
1155331Samw #define	NETR_A2H(c) (isdigit(c)) ? ((c) - '0') : ((c) - 'A' + 10)
1165331Samw 
1175331Samw #ifdef __cplusplus
1185331Samw }
1195331Samw #endif
1205331Samw 
1215331Samw #endif /* _SMBSRV_NETRAUTH_H */
122