#include "includes.h"
#include "utils/ntlm_auth.h"
+#include "../libcli/auth/libcli_auth.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_WINBIND
{
static const char zeros[16] = { 0, };
NTSTATUS nt_status;
- char *error_string;
+ char *error_string = NULL;
uint8 lm_key[8];
uint8 user_sess_key[16];
char *unix_name = NULL;
ntlmssp_state->auth_context = NULL;
}
+ SAFE_FREE(error_string);
SAFE_FREE(unix_name);
return nt_status;
}
static NTSTATUS local_pw_check(struct ntlmssp_state *ntlmssp_state, DATA_BLOB *user_session_key, DATA_BLOB *lm_session_key)
{
NTSTATUS nt_status;
- uint8 lm_pw[16], nt_pw[16];
+ struct samr_Password lm_pw, nt_pw;
- nt_lm_owf_gen (opt_password, nt_pw, lm_pw);
+ nt_lm_owf_gen (opt_password, nt_pw.hash, lm_pw.hash);
nt_status = ntlm_password_check(ntlmssp_state,
+ true, true, 0,
&ntlmssp_state->chal,
&ntlmssp_state->lm_resp,
&ntlmssp_state->nt_resp,
- NULL, NULL,
ntlmssp_state->user,
ntlmssp_state->user,
ntlmssp_state->domain,
- lm_pw, nt_pw, user_session_key, lm_session_key);
+ &lm_pw, &nt_pw, user_session_key, lm_session_key);
if (NT_STATUS_IS_OK(nt_status)) {
ntlmssp_state->auth_context = talloc_asprintf(ntlmssp_state,
&principal, &pac_data, &ap_rep,
&session_key, True);
- talloc_destroy(mem_ctx);
-
/* Now in "principal" we have the name we are
authenticated as. */
user = SMB_STRDUP(principal);
data_blob_free(&ap_rep);
-
- SAFE_FREE(principal);
}
+
+ TALLOC_FREE(mem_ctx);
}
#endif
x_fprintf(x_stdout, "Authenticated: No\n");
x_fprintf(x_stdout, "Authentication-Error: %s\n.\n", error_string);
- SAFE_FREE(error_string);
} else {
static char zeros[16];
char *hex_lm_key;
TALLOC_FREE(hex_user_session_key);
}
}
+ SAFE_FREE(error_string);
}
/* clear out the state */
challenge = data_blob_null;
encode_pw_buffer(new_lm_pswd.data, newpswd,
STR_UNICODE);
- SamOEMhash(new_lm_pswd.data, old_nt_hash, 516);
+ arcfour_crypt(new_lm_pswd.data, old_nt_hash, 516);
E_old_pw_hash(new_nt_hash, old_lm_hash,
old_lm_hash_enc.data);
} else {
encode_pw_buffer(new_nt_pswd.data, newpswd,
STR_UNICODE);
- SamOEMhash(new_nt_pswd.data, old_nt_hash, 516);
+ arcfour_crypt(new_nt_pswd.data, old_nt_hash, 516);
E_old_pw_hash(new_nt_hash, old_nt_hash,
old_nt_hash_enc.data);
}
if (request_lm_key
&& (memcmp(zeros, lm_key,
sizeof(lm_key)) != 0)) {
- hex_lm_key = hex_encode_talloc(NULL, (const unsigned char *)lm_key,
+ hex_lm_key = hex_encode_talloc(talloc_tos(), (const unsigned char *)lm_key,
sizeof(lm_key));
x_fprintf(x_stdout, "LM_KEY: %s\n", hex_lm_key);
TALLOC_FREE(hex_lm_key);
if (request_user_session_key
&& (memcmp(zeros, user_session_key,
sizeof(user_session_key)) != 0)) {
- hex_user_session_key = hex_encode_talloc(NULL, (const unsigned char *)user_session_key,
+ hex_user_session_key = hex_encode_talloc(talloc_tos(), (const unsigned char *)user_session_key,
sizeof(user_session_key));
x_fprintf(x_stdout, "NT_KEY: %s\n", hex_user_session_key);
TALLOC_FREE(hex_user_session_key);