mirror of
https://github.com/samba-team/samba.git
synced 2025-02-01 05:47:28 +03:00
ntlmssp: Move ntlmssp code to auth/ntlmssp
This brings in the code from both libcli/auth and source4/auth/ntlmssp. Andrew Bartlett Signed-off-by: Stefan Metzmacher <metze@samba.org>
This commit is contained in:
parent
5e6543ad76
commit
0c6e4adcb2
@ -22,7 +22,114 @@
|
||||
#include "includes.h"
|
||||
#include "auth/ntlmssp/ntlmssp.h"
|
||||
#include "auth/gensec/gensec.h"
|
||||
#include "../libcli/auth/ntlmssp_private.h"
|
||||
#include "auth/ntlmssp/ntlmssp_private.h"
|
||||
|
||||
NTSTATUS gensec_ntlmssp_magic(struct gensec_security *gensec_security,
|
||||
const DATA_BLOB *first_packet)
|
||||
{
|
||||
if (ntlmssp_blob_matches_magic(first_packet)) {
|
||||
return NT_STATUS_OK;
|
||||
} else {
|
||||
return NT_STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the NTLMSSP master session key
|
||||
*
|
||||
* @param ntlmssp_state NTLMSSP State
|
||||
*/
|
||||
|
||||
NTSTATUS gensec_ntlmssp_session_key(struct gensec_security *gensec_security,
|
||||
TALLOC_CTX *mem_ctx,
|
||||
DATA_BLOB *session_key)
|
||||
{
|
||||
struct gensec_ntlmssp_context *gensec_ntlmssp =
|
||||
talloc_get_type_abort(gensec_security->private_data,
|
||||
struct gensec_ntlmssp_context);
|
||||
struct ntlmssp_state *ntlmssp_state = gensec_ntlmssp->ntlmssp_state;
|
||||
|
||||
if (ntlmssp_state->expected_state != NTLMSSP_DONE) {
|
||||
return NT_STATUS_NO_USER_SESSION_KEY;
|
||||
}
|
||||
|
||||
if (!ntlmssp_state->session_key.data) {
|
||||
return NT_STATUS_NO_USER_SESSION_KEY;
|
||||
}
|
||||
*session_key = data_blob_talloc(mem_ctx, ntlmssp_state->session_key.data, ntlmssp_state->session_key.length);
|
||||
if (!session_key->data) {
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
||||
bool gensec_ntlmssp_have_feature(struct gensec_security *gensec_security,
|
||||
uint32_t feature)
|
||||
{
|
||||
struct gensec_ntlmssp_context *gensec_ntlmssp =
|
||||
talloc_get_type_abort(gensec_security->private_data,
|
||||
struct gensec_ntlmssp_context);
|
||||
struct ntlmssp_state *ntlmssp_state = gensec_ntlmssp->ntlmssp_state;
|
||||
|
||||
if (feature & GENSEC_FEATURE_SIGN) {
|
||||
if (!ntlmssp_state->session_key.length) {
|
||||
return false;
|
||||
}
|
||||
if (ntlmssp_state->neg_flags & NTLMSSP_NEGOTIATE_SIGN) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (feature & GENSEC_FEATURE_SEAL) {
|
||||
if (!ntlmssp_state->session_key.length) {
|
||||
return false;
|
||||
}
|
||||
if (ntlmssp_state->neg_flags & NTLMSSP_NEGOTIATE_SEAL) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (feature & GENSEC_FEATURE_SESSION_KEY) {
|
||||
if (ntlmssp_state->session_key.length) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (feature & GENSEC_FEATURE_DCE_STYLE) {
|
||||
return true;
|
||||
}
|
||||
if (feature & GENSEC_FEATURE_ASYNC_REPLIES) {
|
||||
if (ntlmssp_state->neg_flags & NTLMSSP_NEGOTIATE_NTLM2) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
NTSTATUS gensec_ntlmssp_start(struct gensec_security *gensec_security)
|
||||
{
|
||||
struct gensec_ntlmssp_context *gensec_ntlmssp;
|
||||
struct ntlmssp_state *ntlmssp_state;
|
||||
|
||||
gensec_ntlmssp = talloc_zero(gensec_security,
|
||||
struct gensec_ntlmssp_context);
|
||||
if (!gensec_ntlmssp) {
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
gensec_ntlmssp->gensec_security = gensec_security;
|
||||
|
||||
ntlmssp_state = talloc_zero(gensec_ntlmssp,
|
||||
struct ntlmssp_state);
|
||||
if (!ntlmssp_state) {
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
ntlmssp_state->callback_private = gensec_ntlmssp;
|
||||
|
||||
gensec_ntlmssp->ntlmssp_state = ntlmssp_state;
|
||||
|
||||
gensec_security->private_data = gensec_ntlmssp;
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
||||
NTSTATUS gensec_ntlmssp_sign_packet(struct gensec_security *gensec_security,
|
||||
TALLOC_CTX *sig_mem_ctx,
|
||||
@ -103,14 +210,14 @@ NTSTATUS gensec_ntlmssp_unseal_packet(struct gensec_security *gensec_security,
|
||||
return nt_status;
|
||||
}
|
||||
|
||||
size_t gensec_ntlmssp_sig_size(struct gensec_security *gensec_security, size_t data_size)
|
||||
size_t gensec_ntlmssp_sig_size(struct gensec_security *gensec_security, size_t data_size)
|
||||
{
|
||||
return NTLMSSP_SIG_SIZE;
|
||||
}
|
||||
|
||||
NTSTATUS gensec_ntlmssp_wrap(struct gensec_security *gensec_security,
|
||||
NTSTATUS gensec_ntlmssp_wrap(struct gensec_security *gensec_security,
|
||||
TALLOC_CTX *out_mem_ctx,
|
||||
const DATA_BLOB *in,
|
||||
const DATA_BLOB *in,
|
||||
DATA_BLOB *out)
|
||||
{
|
||||
struct gensec_ntlmssp_context *gensec_ntlmssp =
|
||||
@ -123,9 +230,9 @@ NTSTATUS gensec_ntlmssp_wrap(struct gensec_security *gensec_security,
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS gensec_ntlmssp_unwrap(struct gensec_security *gensec_security,
|
||||
NTSTATUS gensec_ntlmssp_unwrap(struct gensec_security *gensec_security,
|
||||
TALLOC_CTX *out_mem_ctx,
|
||||
const DATA_BLOB *in,
|
||||
const DATA_BLOB *in,
|
||||
DATA_BLOB *out)
|
||||
{
|
||||
struct gensec_ntlmssp_context *gensec_ntlmssp =
|
@ -22,8 +22,8 @@
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
#include "../libcli/auth/ntlmssp.h"
|
||||
#include "../libcli/auth/ntlmssp_private.h"
|
||||
#include "../auth/ntlmssp/ntlmssp.h"
|
||||
#include "../auth/ntlmssp/ntlmssp_private.h"
|
||||
|
||||
/**
|
||||
* Print out the NTLMSSP flags for debugging
|
@ -22,6 +22,14 @@
|
||||
|
||||
#include "../librpc/gen_ndr/ntlmssp.h"
|
||||
|
||||
NTSTATUS gensec_ntlmssp_init(void);
|
||||
|
||||
struct gensec_ntlmssp_context {
|
||||
struct gensec_security *gensec_security;
|
||||
struct ntlmssp_state *ntlmssp_state;
|
||||
struct auth_user_info_dc *user_info_dc;
|
||||
};
|
||||
|
||||
/* NTLMSSP mode */
|
||||
enum ntlmssp_role
|
||||
{
|
||||
@ -171,3 +179,49 @@ NTSTATUS ntlmssp_unwrap(struct ntlmssp_state *ntlmssp_stae,
|
||||
NTSTATUS ntlmssp_sign_init(struct ntlmssp_state *ntlmssp_state);
|
||||
|
||||
bool ntlmssp_blob_matches_magic(const DATA_BLOB *blob);
|
||||
/* The following definitions come from ../source4/auth/ntlmssp/ntlmssp.c */
|
||||
|
||||
|
||||
/**
|
||||
* Return the NTLMSSP master session key
|
||||
*
|
||||
* @param ntlmssp_state NTLMSSP State
|
||||
*/
|
||||
NTSTATUS gensec_ntlmssp_magic(struct gensec_security *gensec_security,
|
||||
const DATA_BLOB *first_packet);
|
||||
bool gensec_ntlmssp_have_feature(struct gensec_security *gensec_security,
|
||||
uint32_t feature);
|
||||
NTSTATUS gensec_ntlmssp_session_key(struct gensec_security *gensec_security,
|
||||
TALLOC_CTX *mem_ctx,
|
||||
DATA_BLOB *session_key);
|
||||
NTSTATUS gensec_ntlmssp_start(struct gensec_security *gensec_security);
|
||||
|
||||
/* The following definitions come from ../source4/auth/ntlmssp/ntlmssp_sign.c */
|
||||
|
||||
NTSTATUS gensec_ntlmssp_sign_packet(struct gensec_security *gensec_security,
|
||||
TALLOC_CTX *sig_mem_ctx,
|
||||
const uint8_t *data, size_t length,
|
||||
const uint8_t *whole_pdu, size_t pdu_length,
|
||||
DATA_BLOB *sig);
|
||||
NTSTATUS gensec_ntlmssp_check_packet(struct gensec_security *gensec_security,
|
||||
const uint8_t *data, size_t length,
|
||||
const uint8_t *whole_pdu, size_t pdu_length,
|
||||
const DATA_BLOB *sig);
|
||||
NTSTATUS gensec_ntlmssp_seal_packet(struct gensec_security *gensec_security,
|
||||
TALLOC_CTX *sig_mem_ctx,
|
||||
uint8_t *data, size_t length,
|
||||
const uint8_t *whole_pdu, size_t pdu_length,
|
||||
DATA_BLOB *sig);
|
||||
NTSTATUS gensec_ntlmssp_unseal_packet(struct gensec_security *gensec_security,
|
||||
uint8_t *data, size_t length,
|
||||
const uint8_t *whole_pdu, size_t pdu_length,
|
||||
const DATA_BLOB *sig);
|
||||
size_t gensec_ntlmssp_sig_size(struct gensec_security *gensec_security, size_t data_size) ;
|
||||
NTSTATUS gensec_ntlmssp_wrap(struct gensec_security *gensec_security,
|
||||
TALLOC_CTX *out_mem_ctx,
|
||||
const DATA_BLOB *in,
|
||||
DATA_BLOB *out);
|
||||
NTSTATUS gensec_ntlmssp_unwrap(struct gensec_security *gensec_security,
|
||||
TALLOC_CTX *out_mem_ctx,
|
||||
const DATA_BLOB *in,
|
||||
DATA_BLOB *out);
|
@ -20,7 +20,7 @@
|
||||
|
||||
#include "includes.h"
|
||||
#include "../librpc/gen_ndr/ndr_ntlmssp.h"
|
||||
#include "../libcli/auth/ntlmssp_ndr.h"
|
||||
#include "ntlmssp_ndr.h"
|
||||
|
||||
#define NTLMSSP_PULL_MESSAGE(type, blob, mem_ctx, r) \
|
||||
do { \
|
@ -39,13 +39,13 @@ union ntlmssp_crypt_state {
|
||||
} ntlm2;
|
||||
};
|
||||
|
||||
/* The following definitions come from libcli/auth/ntlmssp.c */
|
||||
/* The following definitions come from auth/ntlmssp.c */
|
||||
|
||||
void debug_ntlmssp_flags(uint32_t neg_flags);
|
||||
void ntlmssp_handle_neg_flags(struct ntlmssp_state *ntlmssp_state,
|
||||
uint32_t neg_flags, bool allow_lm);
|
||||
|
||||
/* The following definitions come from libcli/auth/ntlmssp_server.c */
|
||||
/* The following definitions come from auth/ntlmssp_server.c */
|
||||
|
||||
const char *ntlmssp_target_name(struct ntlmssp_state *ntlmssp_state,
|
||||
uint32_t neg_flags, uint32_t *chal_flags);
|
@ -21,10 +21,10 @@
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
#include "../libcli/auth/ntlmssp.h"
|
||||
#include "../libcli/auth/ntlmssp_private.h"
|
||||
#include "auth/ntlmssp/ntlmssp.h"
|
||||
#include "auth/ntlmssp/ntlmssp_private.h"
|
||||
#include "../librpc/gen_ndr/ndr_ntlmssp.h"
|
||||
#include "../libcli/auth/ntlmssp_ndr.h"
|
||||
#include "auth/ntlmssp/ntlmssp_ndr.h"
|
||||
#include "../libcli/auth/libcli_auth.h"
|
||||
#include "../lib/crypto/crypto.h"
|
||||
|
@ -19,12 +19,12 @@
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
#include "../libcli/auth/ntlmssp.h"
|
||||
#include "../auth/ntlmssp/ntlmssp.h"
|
||||
#include "../libcli/auth/libcli_auth.h"
|
||||
#include "../lib/crypto/md5.h"
|
||||
#include "../lib/crypto/hmacmd5.h"
|
||||
#include "../lib/crypto/crc32.h"
|
||||
#include "../libcli/auth/ntlmssp_private.h"
|
||||
#include "../auth/ntlmssp/ntlmssp_private.h"
|
||||
|
||||
#define CLI_SIGN "session key to client-to-server signing key magic constant"
|
||||
#define CLI_SEAL "session key to client-to-server sealing key magic constant"
|
3
auth/ntlmssp/wscript_build
Normal file
3
auth/ntlmssp/wscript_build
Normal file
@ -0,0 +1,3 @@
|
||||
bld.SAMBA_SUBSYSTEM('NTLMSSP_COMMON',
|
||||
source='gensec_ntlmssp.c ntlmssp.c ntlmssp_ndr.c ntlmssp_server.c ntlmssp_sign.c',
|
||||
deps='samba-util NDR_NTLMSSP MSRPC_PARSE NTLM_CHECK')
|
@ -8,4 +8,5 @@ bld.SAMBA_LIBRARY('auth_sam_reply',
|
||||
)
|
||||
|
||||
bld.RECURSE('gensec')
|
||||
bld.RECURSE('ntlmssp')
|
||||
bld.RECURSE('credentials')
|
||||
|
@ -2,20 +2,19 @@
|
||||
|
||||
bld.SAMBA_LIBRARY('cliauth',
|
||||
source='',
|
||||
deps='NTLMSSP_COMMON MSRPC_PARSE LIBCLI_AUTH COMMON_SCHANNEL PAM_ERRORS SPNEGO_PARSE KRB5_WRAP errors',
|
||||
deps='NTLMSSP_COMMON MSRPC_PARSE LIBCLI_AUTH COMMON_SCHANNEL PAM_ERRORS SPNEGO_PARSE KRB5_WRAP errors NTLM_CHECK',
|
||||
private_library=True,
|
||||
grouping_library=True)
|
||||
|
||||
bld.SAMBA_SUBSYSTEM('NTLMSSP_COMMON',
|
||||
source='ntlmssp.c ntlmssp_ndr.c ntlmssp_server.c ntlmssp_sign.c ntlm_check.c',
|
||||
deps='samba-util NDR_NTLMSSP MSRPC_PARSE')
|
||||
|
||||
|
||||
bld.SAMBA_SUBSYSTEM('MSRPC_PARSE',
|
||||
source='msrpc_parse.c',
|
||||
deps='talloc'
|
||||
)
|
||||
|
||||
bld.SAMBA_SUBSYSTEM('NTLM_CHECK',
|
||||
source='ntlm_check.c',
|
||||
deps = 'talloc'
|
||||
)
|
||||
|
||||
bld.SAMBA_SUBSYSTEM('LIBCLI_AUTH',
|
||||
source='credentials.c session.c smbencrypt.c smbdes.c',
|
||||
|
@ -562,11 +562,11 @@ LIBSMB_OBJ0 = \
|
||||
../auth/gensec/gensec_start.o \
|
||||
../auth/credentials/credentials.o \
|
||||
../auth/credentials/credentials_samba3.o \
|
||||
../libcli/auth/ntlmssp.o \
|
||||
../libcli/auth/ntlmssp_sign.o \
|
||||
../auth/ntlmssp/ntlmssp.o \
|
||||
../auth/ntlmssp/ntlmssp_sign.o \
|
||||
$(LIBNDR_NTLMSSP_OBJ) \
|
||||
../libcli/auth/ntlmssp_ndr.o \
|
||||
../libcli/auth/ntlmssp_server.o
|
||||
../auth/ntlmssp/ntlmssp_ndr.o \
|
||||
../auth/ntlmssp/ntlmssp_server.o
|
||||
|
||||
LIBSAMBA_OBJ = $(LIBSMB_OBJ0) \
|
||||
$(LIBSMB_ERR_OBJ)
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
#include "includes.h"
|
||||
#include "auth.h"
|
||||
#include "../libcli/auth/ntlmssp.h"
|
||||
#include "../auth/ntlmssp/ntlmssp.h"
|
||||
#include "ntlmssp_wrap.h"
|
||||
#include "../librpc/gen_ndr/netlogon.h"
|
||||
#include "../lib/tsocket/tsocket.h"
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
#include "includes.h"
|
||||
#include "../libcli/auth/spnego.h"
|
||||
#include "../libcli/auth/ntlmssp.h"
|
||||
#include "../auth/ntlmssp/ntlmssp.h"
|
||||
#include "ads.h"
|
||||
#include "smb_krb5.h"
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "../libcli/auth/spnego.h"
|
||||
#include "include/ntlmssp_wrap.h"
|
||||
#include "librpc/gen_ndr/ntlmssp.h"
|
||||
#include "libcli/auth/ntlmssp.h"
|
||||
#include "auth/ntlmssp/ntlmssp.h"
|
||||
#include "librpc/crypto/gse.h"
|
||||
#include "librpc/crypto/spnego.h"
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include "librpc/gen_ndr/ndr_schannel.h"
|
||||
#include "../libcli/auth/schannel.h"
|
||||
#include "../libcli/auth/spnego.h"
|
||||
#include "../libcli/auth/ntlmssp.h"
|
||||
#include "../auth/ntlmssp/ntlmssp.h"
|
||||
#include "ntlmssp_wrap.h"
|
||||
#include "librpc/crypto/gse.h"
|
||||
#include "librpc/crypto/spnego.h"
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include "../libcli/auth/libcli_auth.h"
|
||||
#include "../libcli/auth/spnego.h"
|
||||
#include "smb_krb5.h"
|
||||
#include "../libcli/auth/ntlmssp.h"
|
||||
#include "../auth/ntlmssp/ntlmssp.h"
|
||||
#include "libads/kerberos_proto.h"
|
||||
#include "krb5_env.h"
|
||||
#include "../lib/util/tevent_ntstatus.h"
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "includes.h"
|
||||
#include "libsmb/libsmb.h"
|
||||
#include "../libcli/auth/spnego.h"
|
||||
#include "../libcli/auth/ntlmssp.h"
|
||||
#include "../auth/ntlmssp/ntlmssp.h"
|
||||
#include "../lib/util/tevent_ntstatus.h"
|
||||
#include "async_smb.h"
|
||||
#include "smb_crypt.h"
|
||||
|
@ -22,11 +22,11 @@
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
#include "../libcli/auth/ntlmssp.h"
|
||||
#include "../libcli/auth/ntlmssp_private.h"
|
||||
#include "../auth/ntlmssp/ntlmssp.h"
|
||||
#include "../auth/ntlmssp/ntlmssp_private.h"
|
||||
#include "../libcli/auth/libcli_auth.h"
|
||||
#include "../librpc/gen_ndr/ndr_ntlmssp.h"
|
||||
#include "../libcli/auth/ntlmssp_ndr.h"
|
||||
#include "../auth/ntlmssp/ntlmssp_ndr.h"
|
||||
#include "../lib/crypto/md5.h"
|
||||
#include "../lib/crypto/arcfour.h"
|
||||
#include "../lib/crypto/hmacmd5.h"
|
||||
|
@ -19,7 +19,7 @@
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
#include "libcli/auth/ntlmssp.h"
|
||||
#include "auth/ntlmssp/ntlmssp.h"
|
||||
#include "ntlmssp_wrap.h"
|
||||
#include "auth/gensec/gensec.h"
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include "libsmb/proto.h"
|
||||
#include "lib/util/tevent_ntstatus.h"
|
||||
#include "../libcli/auth/spnego.h"
|
||||
#include "../libcli/auth/ntlmssp.h"
|
||||
#include "../auth/ntlmssp/ntlmssp.h"
|
||||
|
||||
struct smb2cli_session_setup_state {
|
||||
uint8_t fixed[24];
|
||||
|
@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
#include "../libcli/auth/ntlmssp.h"
|
||||
#include "../auth/ntlmssp/ntlmssp.h"
|
||||
#include "smb_crypt.h"
|
||||
#include "libsmb/libsmb.h"
|
||||
#include "ntlmssp_wrap.h"
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include "../librpc/gen_ndr/ndr_dssetup.h"
|
||||
#include "../libcli/auth/schannel.h"
|
||||
#include "../libcli/auth/spnego.h"
|
||||
#include "../libcli/auth/ntlmssp.h"
|
||||
#include "../auth/ntlmssp/ntlmssp.h"
|
||||
#include "ntlmssp_wrap.h"
|
||||
#include "librpc/gen_ndr/ndr_dcerpc.h"
|
||||
#include "librpc/rpc/dcerpc.h"
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
#include "includes.h"
|
||||
#include "rpc_server/dcesrv_ntlmssp.h"
|
||||
#include "../libcli/auth/ntlmssp.h"
|
||||
#include "../auth/ntlmssp/ntlmssp.h"
|
||||
#include "ntlmssp_wrap.h"
|
||||
#include "auth.h"
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "smbd/smbd.h"
|
||||
#include "smbd/globals.h"
|
||||
#include "../libcli/auth/spnego.h"
|
||||
#include "../libcli/auth/ntlmssp.h"
|
||||
#include "../auth/ntlmssp/ntlmssp.h"
|
||||
#include "ntlmssp_wrap.h"
|
||||
#include "smb_crypt.h"
|
||||
#include "../lib/util/asn1.h"
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include "smbd/smbd.h"
|
||||
#include "smbd/globals.h"
|
||||
#include "../libcli/auth/spnego.h"
|
||||
#include "../libcli/auth/ntlmssp.h"
|
||||
#include "../auth/ntlmssp/ntlmssp.h"
|
||||
#include "ntlmssp_wrap.h"
|
||||
#include "../librpc/gen_ndr/krb5pac.h"
|
||||
#include "libads/kerberos_proto.h"
|
||||
|
@ -24,8 +24,8 @@
|
||||
#include "smbd/globals.h"
|
||||
#include "../libcli/smb/smb_common.h"
|
||||
#include "../libcli/auth/spnego.h"
|
||||
#include "../libcli/auth/ntlmssp.h"
|
||||
#include "../auth/gensec/gensec.h"
|
||||
#include "../auth/ntlmssp/ntlmssp.h"
|
||||
#include "ntlmssp_wrap.h"
|
||||
#include "../librpc/gen_ndr/krb5pac.h"
|
||||
#include "libads/kerberos_proto.h"
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include "utils/ntlm_auth.h"
|
||||
#include "../libcli/auth/libcli_auth.h"
|
||||
#include "../libcli/auth/spnego.h"
|
||||
#include "../libcli/auth/ntlmssp.h"
|
||||
#include "../auth/ntlmssp/ntlmssp.h"
|
||||
#include "smb_krb5.h"
|
||||
#include <iniparser.h>
|
||||
#include "../lib/crypto/arcfour.h"
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
#include "includes.h"
|
||||
#include "winbindd.h"
|
||||
#include "../libcli/auth/ntlmssp.h"
|
||||
#include "../auth/ntlmssp/ntlmssp.h"
|
||||
|
||||
#undef DBGC_CLASS
|
||||
#define DBGC_CLASS DBGC_WINBIND
|
||||
|
@ -21,8 +21,11 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
struct auth_session_info;
|
||||
|
||||
#include "includes.h"
|
||||
#include "auth/ntlmssp/ntlmssp.h"
|
||||
#include "source4/auth/ntlmssp/proto.h"
|
||||
#include "../libcli/auth/libcli_auth.h"
|
||||
#include "librpc/gen_ndr/ndr_dcerpc.h"
|
||||
#include "auth/gensec/gensec.h"
|
||||
@ -61,16 +64,6 @@ static const struct ntlmssp_callbacks {
|
||||
};
|
||||
|
||||
|
||||
static NTSTATUS gensec_ntlmssp_magic(struct gensec_security *gensec_security,
|
||||
const DATA_BLOB *first_packet)
|
||||
{
|
||||
if (ntlmssp_blob_matches_magic(first_packet)) {
|
||||
return NT_STATUS_OK;
|
||||
} else {
|
||||
return NT_STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
|
||||
static NTSTATUS gensec_ntlmssp_update_find(struct ntlmssp_state *ntlmssp_state,
|
||||
const DATA_BLOB input, uint32_t *idx)
|
||||
{
|
||||
@ -175,103 +168,6 @@ static NTSTATUS gensec_ntlmssp_update(struct gensec_security *gensec_security,
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the NTLMSSP master session key
|
||||
*
|
||||
* @param ntlmssp_state NTLMSSP State
|
||||
*/
|
||||
|
||||
NTSTATUS gensec_ntlmssp_session_key(struct gensec_security *gensec_security,
|
||||
TALLOC_CTX *mem_ctx,
|
||||
DATA_BLOB *session_key)
|
||||
{
|
||||
struct gensec_ntlmssp_context *gensec_ntlmssp =
|
||||
talloc_get_type_abort(gensec_security->private_data,
|
||||
struct gensec_ntlmssp_context);
|
||||
struct ntlmssp_state *ntlmssp_state = gensec_ntlmssp->ntlmssp_state;
|
||||
|
||||
if (ntlmssp_state->expected_state != NTLMSSP_DONE) {
|
||||
return NT_STATUS_NO_USER_SESSION_KEY;
|
||||
}
|
||||
|
||||
if (!ntlmssp_state->session_key.data) {
|
||||
return NT_STATUS_NO_USER_SESSION_KEY;
|
||||
}
|
||||
*session_key = data_blob_talloc(mem_ctx, ntlmssp_state->session_key.data, ntlmssp_state->session_key.length);
|
||||
if (!session_key->data) {
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
||||
static bool gensec_ntlmssp_have_feature(struct gensec_security *gensec_security,
|
||||
uint32_t feature)
|
||||
{
|
||||
struct gensec_ntlmssp_context *gensec_ntlmssp =
|
||||
talloc_get_type_abort(gensec_security->private_data,
|
||||
struct gensec_ntlmssp_context);
|
||||
struct ntlmssp_state *ntlmssp_state = gensec_ntlmssp->ntlmssp_state;
|
||||
|
||||
if (feature & GENSEC_FEATURE_SIGN) {
|
||||
if (!ntlmssp_state->session_key.length) {
|
||||
return false;
|
||||
}
|
||||
if (ntlmssp_state->neg_flags & NTLMSSP_NEGOTIATE_SIGN) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (feature & GENSEC_FEATURE_SEAL) {
|
||||
if (!ntlmssp_state->session_key.length) {
|
||||
return false;
|
||||
}
|
||||
if (ntlmssp_state->neg_flags & NTLMSSP_NEGOTIATE_SEAL) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (feature & GENSEC_FEATURE_SESSION_KEY) {
|
||||
if (ntlmssp_state->session_key.length) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (feature & GENSEC_FEATURE_DCE_STYLE) {
|
||||
return true;
|
||||
}
|
||||
if (feature & GENSEC_FEATURE_ASYNC_REPLIES) {
|
||||
if (ntlmssp_state->neg_flags & NTLMSSP_NEGOTIATE_NTLM2) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
NTSTATUS gensec_ntlmssp_start(struct gensec_security *gensec_security)
|
||||
{
|
||||
struct gensec_ntlmssp_context *gensec_ntlmssp;
|
||||
struct ntlmssp_state *ntlmssp_state;
|
||||
|
||||
gensec_ntlmssp = talloc_zero(gensec_security,
|
||||
struct gensec_ntlmssp_context);
|
||||
if (!gensec_ntlmssp) {
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
gensec_ntlmssp->gensec_security = gensec_security;
|
||||
|
||||
ntlmssp_state = talloc_zero(gensec_ntlmssp,
|
||||
struct ntlmssp_state);
|
||||
if (!ntlmssp_state) {
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
ntlmssp_state->callback_private = gensec_ntlmssp;
|
||||
|
||||
gensec_ntlmssp->ntlmssp_state = ntlmssp_state;
|
||||
|
||||
gensec_security->private_data = gensec_ntlmssp;
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
||||
static const char *gensec_ntlmssp_oids[] = {
|
||||
GENSEC_OID_NTLMSSP,
|
||||
NULL
|
||||
|
@ -1,37 +0,0 @@
|
||||
/*
|
||||
Unix SMB/CIFS implementation.
|
||||
SMB parameters and setup
|
||||
Copyright (C) Andrew Tridgell 1992-1997
|
||||
Copyright (C) Luke Kenneth Casson Leighton 1996-1997
|
||||
Copyright (C) Paul Ashton 1997
|
||||
Copyright (C) Andrew Bartlett 2010
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "../librpc/gen_ndr/ntlmssp.h"
|
||||
#include "../libcli/auth/ntlmssp.h"
|
||||
|
||||
struct gensec_ntlmssp_context {
|
||||
struct gensec_security *gensec_security;
|
||||
struct ntlmssp_state *ntlmssp_state;
|
||||
struct auth_user_info_dc *user_info_dc;
|
||||
};
|
||||
|
||||
struct loadparm_context;
|
||||
struct auth_session_info;
|
||||
|
||||
NTSTATUS gensec_ntlmssp_init(void);
|
||||
|
||||
#include "auth/ntlmssp/proto.h"
|
@ -21,14 +21,17 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
struct auth_session_info;
|
||||
|
||||
#include "includes.h"
|
||||
#include "auth/ntlmssp/ntlmssp.h"
|
||||
#include "source4/auth/ntlmssp/proto.h"
|
||||
#include "../lib/crypto/crypto.h"
|
||||
#include "../libcli/auth/libcli_auth.h"
|
||||
#include "auth/credentials/credentials.h"
|
||||
#include "auth/gensec/gensec.h"
|
||||
#include "param/param.h"
|
||||
#include "libcli/auth/ntlmssp_private.h"
|
||||
#include "auth/ntlmssp/ntlmssp_private.h"
|
||||
|
||||
/*********************************************************************
|
||||
Client side NTLMSSP
|
||||
|
@ -26,14 +26,15 @@
|
||||
#include "lib/tsocket/tsocket.h"
|
||||
#include "auth/ntlmssp/ntlmssp.h"
|
||||
#include "../librpc/gen_ndr/ndr_ntlmssp.h"
|
||||
#include "../libcli/auth/ntlmssp_ndr.h"
|
||||
#include "../libcli/auth/ntlmssp_private.h"
|
||||
#include "auth/ntlmssp/ntlmssp_ndr.h"
|
||||
#include "auth/ntlmssp/ntlmssp_private.h"
|
||||
#include "../libcli/auth/libcli_auth.h"
|
||||
#include "../lib/crypto/crypto.h"
|
||||
#include "auth/gensec/gensec.h"
|
||||
#include "auth/gensec/gensec_proto.h"
|
||||
#include "auth/auth.h"
|
||||
#include "param/param.h"
|
||||
#include "source4/auth/ntlmssp/proto.h"
|
||||
|
||||
/**
|
||||
* Next state function for the Negotiate packet (GENSEC wrapper)
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
bld.SAMBA_MODULE('gensec_ntlmssp',
|
||||
source='''ntlmssp.c ntlmssp_sign.c
|
||||
source='''ntlmssp.c
|
||||
ntlmssp_client.c ntlmssp_server.c''',
|
||||
autoproto='proto.h',
|
||||
subsystem='gensec',
|
||||
|
Loading…
x
Reference in New Issue
Block a user