#include "auth/auth.h"
#include "param/param.h"
#include "auth/gensec/schannel_state.h"
+#include "../libcli/auth/schannel_state_proto.h"
static struct ldb_val *schannel_dom_sid_ldb_val(TALLOC_CTX *mem_ctx,
struct dom_sid *sid)
TLDAP_OBJ = lib/tldap.o lib/tldap_util.o lib/util_tsock.o
SCHANNEL_OBJ = ../libcli/auth/credentials.o \
+ ../libcli/auth/schannel_sign.o \
../libcli/auth/schannel_state_tdb.o \
../librpc/gen_ndr/ndr_schannel.o \
../librpc/ndr/ndr_schannel.o \
return status;
}
+ /*
+ * We have to fake a struct dcinfo, so that
+ * rpccli_netlogon_sam_network_logon_ex can decrypt the session keys.
+ */
+
+ p->dc = netlogon_creds_client_init_session_key(p, schannel_key);
+ if (p->dc == NULL) {
+ DEBUG(0, ("talloc failed\n"));
+ TALLOC_FREE(p);
+ return NT_STATUS_NO_MEMORY;
+ }
+
status = rpccli_schannel_bind_data(p, lp_workgroup(),
DCERPC_AUTH_LEVEL_PRIVACY,
- schannel_key, &auth);
+ p->dc, &auth);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(10, ("rpccli_schannel_bind_data failed: %s\n",
nt_errstr(status)));
return status;
}
- /*
- * We have to fake a struct dcinfo, so that
- * rpccli_netlogon_sam_network_logon_ex can decrypt the session keys.
- */
-
- p->dc = netlogon_creds_client_init_session_key(p, schannel_key);
- if (p->dc == NULL) {
- DEBUG(0, ("talloc failed\n"));
- TALLOC_FREE(p);
- return NT_STATUS_NO_MEMORY;
- }
-
status = rpccli_netlogon_sam_network_logon_ex(
p, p,
user_info->logon_parameters,/* flags such as 'allow
DATA_BLOB user_session_key;
union {
- struct schannel_auth_struct *schannel_auth;
+ struct schannel_state *schannel_auth;
NTLMSSP_STATE *ntlmssp_state;
struct kerberos_auth_struct *kerberos_auth;
} a_u;
enum pipe_auth_type auth_type; /* switch for union below. */
enum dcerpc_AuthLevel auth_level;
union {
- struct schannel_auth_struct *schannel_auth;
+ struct schannel_state *schannel_auth;
AUTH_NTLMSSP_STATE *auth_ntlmssp_state;
/* struct kerberos_auth_struct *kerberos_auth; TO BE ADDED... */
} a_u;
struct cli_pipe_auth_data **presult);
NTSTATUS rpccli_schannel_bind_data(TALLOC_CTX *mem_ctx, const char *domain,
enum dcerpc_AuthLevel auth_level,
- const uint8_t sess_key[16],
+ struct netlogon_creds_CredentialState *creds,
struct cli_pipe_auth_data **presult);
NTSTATUS rpccli_kerberos_bind_data(TALLOC_CTX *mem_ctx,
enum dcerpc_AuthLevel auth_level,
#include "../libcli/auth/libcli_auth.h"
#include "librpc/gen_ndr/cli_epmapper.h"
#include "../librpc/gen_ndr/ndr_schannel.h"
+#include "../libcli/auth/schannel.h"
+#include "../libcli/auth/schannel_proto.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_CLI
struct NL_AUTH_SIGNATURE schannel_chk;
uint32 auth_len = prhdr->auth_len;
uint32 save_offset = prs_offset(current_pdu);
- struct schannel_auth_struct *schannel_auth =
+ struct schannel_state *schannel_auth =
cli->auth->a_u.schannel_auth;
uint32 data_len;
enum ndr_err_code ndr_err;
DATA_BLOB blob;
+ NTSTATUS status;
if (cli->auth->auth_level == DCERPC_AUTH_LEVEL_NONE
|| cli->auth->auth_level == DCERPC_AUTH_LEVEL_CONNECT) {
NDR_PRINT_DEBUG(NL_AUTH_SIGNATURE, &schannel_chk);
}
- if (!schannel_decode(schannel_auth,
- cli->auth->auth_level,
- SENDER_IS_ACCEPTOR,
- &schannel_chk,
- prs_data_p(current_pdu)+RPC_HEADER_LEN+RPC_HDR_RESP_LEN,
- data_len)) {
+ switch (cli->auth->auth_level) {
+ case DCERPC_AUTH_LEVEL_PRIVACY:
+ status = schannel_unseal_packet(schannel_auth,
+ talloc_tos(),
+ (uint8_t *)prs_data_p(current_pdu)+RPC_HEADER_LEN+RPC_HDR_RESP_LEN,
+ data_len,
+ &blob);
+ break;
+ case DCERPC_AUTH_LEVEL_INTEGRITY:
+ status = schannel_check_packet(schannel_auth,
+ talloc_tos(),
+ (uint8_t *)prs_data_p(current_pdu)+RPC_HEADER_LEN+RPC_HDR_RESP_LEN,
+ data_len,
+ &blob);
+ break;
+ default:
+ status = NT_STATUS_INTERNAL_ERROR;
+ break;
+ }
+
+ if (!NT_STATUS_IS_OK(status)) {
DEBUG(3,("cli_pipe_verify_schannel: failed to decode PDU "
- "Connection to %s.\n",
- rpccli_pipe_txt(debug_ctx(), cli)));
+ "Connection to %s (%s).\n",
+ rpccli_pipe_txt(debug_ctx(), cli),
+ nt_errstr(status)));
return NT_STATUS_INVALID_PARAMETER;
}
- /* The sequence number gets incremented on both send and receive. */
- schannel_auth->seq_num++;
-
/*
* Return the current pointer to the data offset.
*/
{
RPC_HDR_AUTH auth_info;
struct NL_AUTH_SIGNATURE verf;
- struct schannel_auth_struct *sas = cli->auth->a_u.schannel_auth;
+ struct schannel_state *sas = cli->auth->a_u.schannel_auth;
char *data_p = prs_data_p(outgoing_pdu) + RPC_HEADER_LEN + RPC_HDR_RESP_LEN;
size_t data_and_pad_len = prs_offset(outgoing_pdu) - RPC_HEADER_LEN - RPC_HDR_RESP_LEN;
enum ndr_err_code ndr_err;
DATA_BLOB blob;
+ NTSTATUS status;
if (!sas) {
return NT_STATUS_INVALID_PARAMETER;
return NT_STATUS_NO_MEMORY;
}
- switch (cli->auth->auth_level) {
- case DCERPC_AUTH_LEVEL_PRIVACY:
- case DCERPC_AUTH_LEVEL_INTEGRITY:
- DEBUG(10,("add_schannel_auth_footer: SCHANNEL seq_num=%d\n",
- sas->seq_num));
+ DEBUG(10,("add_schannel_auth_footer: SCHANNEL seq_num=%d\n",
+ sas->seq_num));
- schannel_encode(sas,
- cli->auth->auth_level,
- SENDER_IS_INITIATOR,
- &verf,
- data_p,
- data_and_pad_len);
-
- sas->seq_num++;
- break;
-
- default:
- /* Can't happen. */
- smb_panic("bad auth level");
- /* Notreached. */
- return NT_STATUS_INVALID_PARAMETER;
+ switch (cli->auth->auth_level) {
+ case DCERPC_AUTH_LEVEL_PRIVACY:
+ status = schannel_seal_packet(sas,
+ talloc_tos(),
+ (uint8_t *)data_p,
+ data_and_pad_len,
+ &blob);
+ break;
+ case DCERPC_AUTH_LEVEL_INTEGRITY:
+ status = schannel_sign_packet(sas,
+ talloc_tos(),
+ (uint8_t *)data_p,
+ data_and_pad_len,
+ &blob);
+ break;
+ default:
+ status = NT_STATUS_INTERNAL_ERROR;
+ break;
}
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(1,("add_schannel_auth_footer: failed to process packet: %s\n",
+ nt_errstr(status)));
+ return status;
+ }
+#if 0
ndr_err = ndr_push_struct_blob(&blob, talloc_tos(), NULL, &verf,
(ndr_push_flags_fn_t)ndr_push_NL_AUTH_SIGNATURE);
if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
if (DEBUGLEVEL >= 10) {
NDR_PRINT_DEBUG(NL_AUTH_SIGNATURE, &verf);
}
-
+#endif
/* Finally marshall the blob. */
if (!prs_copy_data_in(outgoing_pdu, (const char *)blob.data, blob.length)) {
return NT_STATUS_NO_MEMORY;
NTSTATUS rpccli_schannel_bind_data(TALLOC_CTX *mem_ctx, const char *domain,
enum dcerpc_AuthLevel auth_level,
- const uint8_t sess_key[16],
+ struct netlogon_creds_CredentialState *creds,
struct cli_pipe_auth_data **presult)
{
struct cli_pipe_auth_data *result;
goto fail;
}
- result->a_u.schannel_auth = talloc(result,
- struct schannel_auth_struct);
+ result->a_u.schannel_auth = talloc(result, struct schannel_state);
if (result->a_u.schannel_auth == NULL) {
goto fail;
}
- memcpy(result->a_u.schannel_auth->sess_key, sess_key,
- sizeof(result->a_u.schannel_auth->sess_key));
+ result->a_u.schannel_auth->state = SCHANNEL_STATE_START;
result->a_u.schannel_auth->seq_num = 0;
+ result->a_u.schannel_auth->initiator = true;
+ result->a_u.schannel_auth->creds = creds;
*presult = result;
return NT_STATUS_OK;
}
status = rpccli_schannel_bind_data(result, domain, auth_level,
- (*pdc)->session_key, &auth);
+ *pdc, &auth);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("rpccli_schannel_bind_data returned %s\n",
nt_errstr(status)));
switch (cli->auth->auth_type) {
case PIPE_AUTH_TYPE_SCHANNEL:
*session_key = data_blob_talloc(mem_ctx,
- cli->auth->a_u.schannel_auth->sess_key, 16);
+ cli->auth->a_u.schannel_auth->creds->session_key, 16);
break;
case PIPE_AUTH_TYPE_NTLMSSP:
case PIPE_AUTH_TYPE_SPNEGO_NTLMSSP:
#include "includes.h"
#include "../libcli/auth/libcli_auth.h"
#include "../libcli/auth/schannel_state.h"
+#include "../libcli/auth/schannel.h"
extern userdom_struct current_user_info;
|| (p->auth.a_u.schannel_auth == NULL)) {
return NT_STATUS_INVALID_HANDLE;
}
- memcpy(pipe_session_key, p->auth.a_u.schannel_auth->sess_key, 16);
+ memcpy(pipe_session_key, p->auth.a_u.schannel_auth->creds->session_key, 16);
}
switch (r->in.validation_level) {
#include "includes.h"
#include "../libcli/auth/libcli_auth.h"
#include "../librpc/gen_ndr/ndr_schannel.h"
+#include "../libcli/auth/schannel.h"
+#include "../libcli/auth/schannel_proto.h"
extern struct current_user current_user;
uint32 data_space_available;
uint32 data_len_left;
uint32 data_pos;
+ NTSTATUS status;
/*
* If we're in the fault state, keep returning fault PDU's until
return False;
}
- schannel_encode(p->auth.a_u.schannel_auth,
- p->auth.auth_level, SENDER_IS_ACCEPTOR, &verf,
- prs_data_p(&p->out_data.frag) + data_pos,
- data_len + ss_padding_len);
+ switch (p->auth.auth_level) {
+ case DCERPC_AUTH_LEVEL_PRIVACY:
+ status = schannel_seal_packet(p->auth.a_u.schannel_auth,
+ talloc_tos(),
+ (uint8_t *)prs_data_p(&p->out_data.frag) + data_pos,
+ data_len + ss_padding_len,
+ &blob);
+ break;
+ case DCERPC_AUTH_LEVEL_INTEGRITY:
+ status = schannel_sign_packet(p->auth.a_u.schannel_auth,
+ talloc_tos(),
+ (uint8_t *)prs_data_p(&p->out_data.frag) + data_pos,
+ data_len + ss_padding_len,
+ &blob);
+ break;
+ default:
+ status = NT_STATUS_INTERNAL_ERROR;
+ break;
+ }
+
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0,("create_next_pdu_schannel: failed to process packet: %s\n",
+ nt_errstr(status)));
+ prs_mem_free(&p->out_data.frag);
+ return false;
+ }
/* Finally marshall the blob. */
+#if 0
ndr_err = ndr_push_struct_blob(&blob, talloc_tos(), NULL, &verf,
(ndr_push_flags_fn_t)ndr_push_NL_AUTH_SIGNATURE);
if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
if (DEBUGLEVEL >= 10) {
NDR_PRINT_DEBUG(NL_AUTH_SIGNATURE, &verf);
}
-
+#endif
if (!prs_copy_data_in(&p->out_data.frag, (const char *)blob.data, blob.length)) {
prs_mem_free(&p->out_data.frag);
return false;
}
-
- p->auth.a_u.schannel_auth->seq_num++;
}
/*
*/
become_root();
- status = schannel_fetch_session_key(p->mem_ctx,
+ status = schannel_fetch_session_key(p,
neg.oem_netbios_computer.a,
&creds);
unbecome_root();
return False;
}
- p->auth.a_u.schannel_auth = talloc(p, struct schannel_auth_struct);
+ p->auth.a_u.schannel_auth = talloc(p, struct schannel_state);
if (!p->auth.a_u.schannel_auth) {
TALLOC_FREE(creds);
return False;
}
- memset(p->auth.a_u.schannel_auth->sess_key, 0, sizeof(p->auth.a_u.schannel_auth->sess_key));
- memcpy(p->auth.a_u.schannel_auth->sess_key, creds->session_key,
- sizeof(creds->session_key));
-
- TALLOC_FREE(creds);
-
+ p->auth.a_u.schannel_auth->state = SCHANNEL_STATE_START;
p->auth.a_u.schannel_auth->seq_num = 0;
+ p->auth.a_u.schannel_auth->initiator = false;
+ p->auth.a_u.schannel_auth->creds = creds;
/*
* JRA. Should we also copy the schannel session key into the pipe session key p->session_key
struct NL_AUTH_SIGNATURE schannel_chk;
enum ndr_err_code ndr_err;
DATA_BLOB blob;
+ NTSTATUS status;
auth_len = p->hdr.auth_len;
NDR_PRINT_DEBUG(NL_AUTH_SIGNATURE, &schannel_chk);
}
- if (!schannel_decode(p->auth.a_u.schannel_auth,
- p->auth.auth_level,
- SENDER_IS_INITIATOR,
- &schannel_chk,
- prs_data_p(rpc_in)+RPC_HDR_REQ_LEN, data_len)) {
- DEBUG(3,("failed to decode PDU\n"));
- return False;
+ switch (auth_info.auth_level) {
+ case DCERPC_AUTH_LEVEL_PRIVACY:
+ status = schannel_unseal_packet(p->auth.a_u.schannel_auth,
+ talloc_tos(),
+ (uint8_t *)prs_data_p(rpc_in)+RPC_HDR_REQ_LEN,
+ data_len,
+ &blob);
+ break;
+ case DCERPC_AUTH_LEVEL_INTEGRITY:
+ status = schannel_check_packet(p->auth.a_u.schannel_auth,
+ talloc_tos(),
+ (uint8_t *)prs_data_p(rpc_in)+RPC_HDR_REQ_LEN,
+ data_len,
+ &blob);
+ break;
+ default:
+ status = NT_STATUS_INTERNAL_ERROR;
+ break;
+ }
+
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0,("failed to unseal packet: %s\n", nt_errstr(status)));
+ return false;
}
/*
return False;
}
- /* The sequence number gets incremented on both send and receive. */
- p->auth.a_u.schannel_auth->seq_num++;
-
/*
* Remember the padding length. We must remove it from the real data
* stream once the sign/seal is done.