da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw/*
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * CDDL HEADER START
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The contents of this file are subject to the terms of the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Common Development and Distribution License (the "License").
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * You may not use this file except in compliance with the License.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * or http://www.opensolaris.org/os/licensing.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * See the License for the specific language governing permissions
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * and limitations under the License.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * When distributing Covered Code, include this CDDL HEADER in each
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * If applicable, add the following below this CDDL HEADER, with the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * fields enclosed by brackets "[]" replaced with your own identifying
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * information: Portions Copyright [yyyy] [name of copyright owner]
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * CDDL HEADER END
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw/*
77191e8775ec29406dec7210fc064d8fd759dd24Shawn Emery * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Use is subject to license terms.
12b65585e720714b31036daaa2b30eb76014048eGordon Ross *
12b65585e720714b31036daaa2b30eb76014048eGordon Ross * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#ifndef _SMBSRV_NETRAUTH_H
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#define _SMBSRV_NETRAUTH_H
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw/*
9fb67ea305c66b6a297583b9b0db6796b0dfe497afshin salek ardakani - Sun Microsystems - Irvine United States * NETR remote authentication and logon services.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#include <sys/types.h>
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#include <smbsrv/wintypes.h>
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States#include <smbsrv/netbios.h>
7f667e74610492ddbce8ce60f52ece95d2401949jose borrego#include <smbsrv/smbinfo.h>
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross#include <netdb.h>
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#ifdef __cplusplus
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwextern "C" {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#endif
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw/*
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * See also netlogon.ndl.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#define NETR_WKSTA_TRUST_ACCOUNT_TYPE 0x02
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#define NETR_DOMAIN_TRUST_ACCOUNT_TYPE 0x04
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw/*
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Negotiation flags for challenge/response authentication.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
2c1b14e51525da2c09064641416fc4aed457c72fjose borrego#define NETR_NEGOTIATE_BASE_FLAGS 0x000001FF
2c1b14e51525da2c09064641416fc4aed457c72fjose borrego#define NETR_NEGOTIATE_STRONGKEY_FLAG 0x00004000
3db3f65c6274eb042354801a308c8e9bc4994553amw
2c1b14e51525da2c09064641416fc4aed457c72fjose borrego#define NETR_SESSKEY64_SZ 8
2c1b14e51525da2c09064641416fc4aed457c72fjose borrego#define NETR_SESSKEY128_SZ 16
2c1b14e51525da2c09064641416fc4aed457c72fjose borrego#define NETR_SESSKEY_MAXSZ NETR_SESSKEY128_SZ
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#define NETR_CRED_DATA_SZ 8
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#define NETR_OWF_PASSWORD_SZ 16
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw/*
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * SAM logon levels: interactive and network.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#define NETR_INTERACTIVE_LOGON 0x01
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#define NETR_NETWORK_LOGON 0x02
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw/*
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * SAM logon validation levels.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#define NETR_VALIDATION_LEVEL3 0x03
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
12b65585e720714b31036daaa2b30eb76014048eGordon Ross/*
12b65585e720714b31036daaa2b30eb76014048eGordon Ross * Most of these are from: "MSV1_0_LM20_LOGON structure"
12b65585e720714b31036daaa2b30eb76014048eGordon Ross * http://msdn.microsoft.com/en-us/library/windows/desktop/aa378762
12b65585e720714b31036daaa2b30eb76014048eGordon Ross * and a few are from the ntddk (ntmsv1_0.h) found many places.
12b65585e720714b31036daaa2b30eb76014048eGordon Ross */
12b65585e720714b31036daaa2b30eb76014048eGordon Ross#define MSV1_0_CLEARTEXT_PASSWORD_ALLOWED 0x00000002
12b65585e720714b31036daaa2b30eb76014048eGordon Ross#define MSV1_0_UPDATE_LOGON_STATISTICS 0x00000004
12b65585e720714b31036daaa2b30eb76014048eGordon Ross#define MSV1_0_RETURN_USER_PARAMETERS 0x00000008
12b65585e720714b31036daaa2b30eb76014048eGordon Ross#define MSV1_0_DONT_TRY_GUEST_ACCOUNT 0x00000010
12b65585e720714b31036daaa2b30eb76014048eGordon Ross#define MSV1_0_ALLOW_SERVER_TRUST_ACCOUNT 0x00000020
12b65585e720714b31036daaa2b30eb76014048eGordon Ross#define MSV1_0_RETURN_PASSWORD_EXPIRY 0x00000040
12b65585e720714b31036daaa2b30eb76014048eGordon Ross/*
12b65585e720714b31036daaa2b30eb76014048eGordon Ross * MSV1_0_USE_CLIENT_CHALLENGE means the LM response field contains the
12b65585e720714b31036daaa2b30eb76014048eGordon Ross * "client challenge" in the first 8 bytes instead of the LM response.
12b65585e720714b31036daaa2b30eb76014048eGordon Ross */
12b65585e720714b31036daaa2b30eb76014048eGordon Ross#define MSV1_0_USE_CLIENT_CHALLENGE 0x00000080
12b65585e720714b31036daaa2b30eb76014048eGordon Ross#define MSV1_0_TRY_GUEST_ACCOUNT_ONLY 0x00000100
12b65585e720714b31036daaa2b30eb76014048eGordon Ross#define MSV1_0_RETURN_PROFILE_PATH 0x00000200
12b65585e720714b31036daaa2b30eb76014048eGordon Ross#define MSV1_0_TRY_SPECIFIED_DOMAIN_ONLY 0x00000400
12b65585e720714b31036daaa2b30eb76014048eGordon Ross#define MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT 0x00000800
12b65585e720714b31036daaa2b30eb76014048eGordon Ross#define MSV1_0_DISABLE_PERSONAL_FALLBACK 0x00001000
12b65585e720714b31036daaa2b30eb76014048eGordon Ross#define MSV1_0_ALLOW_FORCE_GUEST 0x00002000
12b65585e720714b31036daaa2b30eb76014048eGordon Ross#define MSV1_0_CLEARTEXT_PASSWORD_SUPPLIED 0x00004000
12b65585e720714b31036daaa2b30eb76014048eGordon Ross#define MSV1_0_USE_DOMAIN_FOR_ROUTING_ONLY 0x00008000
12b65585e720714b31036daaa2b30eb76014048eGordon Ross#define MSV1_0_SUBAUTHENTICATION_DLL_EX 0x00100000
12b65585e720714b31036daaa2b30eb76014048eGordon Ross
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw/*
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * This is a duplicate of the netr_credential
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * from netlogon.ndl.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwtypedef struct netr_cred {
2c1b14e51525da2c09064641416fc4aed457c72fjose borrego BYTE data[NETR_CRED_DATA_SZ];
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw} netr_cred_t;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
2c1b14e51525da2c09064641416fc4aed457c72fjose borregotypedef struct netr_session_key {
2c1b14e51525da2c09064641416fc4aed457c72fjose borrego BYTE key[NETR_SESSKEY_MAXSZ];
2c1b14e51525da2c09064641416fc4aed457c72fjose borrego short len;
2c1b14e51525da2c09064641416fc4aed457c72fjose borrego} netr_session_key_t;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#define NETR_FLG_NULL 0x00000001
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#define NETR_FLG_VALID 0x00000001
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#define NETR_FLG_INIT 0x00000002
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
8d7e41661dc4633488e93b13363137523ce59977jose borrego/*
77191e8775ec29406dec7210fc064d8fd759dd24Shawn Emery * 120-byte machine account password (null-terminated)
8d7e41661dc4633488e93b13363137523ce59977jose borrego */
77191e8775ec29406dec7210fc064d8fd759dd24Shawn Emery#define NETR_MACHINE_ACCT_PASSWD_MAX 120 + 1
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwtypedef struct netr_info {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw DWORD flags;
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross char server[MAXHOSTNAMELEN]; /* Current DC, FQDN */
b3700b074e637f8c6991b70754c88a2cfffb246bGordon Ross char hostname[NETBIOS_NAME_SZ * 2]; /* local "flat" name */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw netr_cred_t client_challenge;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw netr_cred_t server_challenge;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw netr_cred_t client_credential;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw netr_cred_t server_credential;
2c1b14e51525da2c09064641416fc4aed457c72fjose borrego netr_session_key_t session_key;
8d7e41661dc4633488e93b13363137523ce59977jose borrego BYTE password[NETR_MACHINE_ACCT_PASSWD_MAX];
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw time_t timestamp;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw} netr_info_t;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw/*
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * NETLOGON private interface.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
2c1b14e51525da2c09064641416fc4aed457c72fjose borregoint netr_gen_skey64(netr_info_t *);
2c1b14e51525da2c09064641416fc4aed457c72fjose borregoint netr_gen_skey128(netr_info_t *);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
2c1b14e51525da2c09064641416fc4aed457c72fjose borregoint netr_gen_credentials(BYTE *, netr_cred_t *, DWORD, netr_cred_t *);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#define NETR_A2H(c) (isdigit(c)) ? ((c) - '0') : ((c) - 'A' + 10)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#ifdef __cplusplus
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw}
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#endif
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#endif /* _SMBSRV_NETRAUTH_H */