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