move where hash is calculated to make it easier to add ccache support.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20479 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -118,6 +118,7 @@ _gss_ntlm_init_sec_context
|
|||||||
struct ntlm_type1 type1;
|
struct ntlm_type1 type1;
|
||||||
struct ntlm_buf data;
|
struct ntlm_buf data;
|
||||||
uint32_t flags = 0;
|
uint32_t flags = 0;
|
||||||
|
char *password;
|
||||||
|
|
||||||
ctx = calloc(1, sizeof(*ctx));
|
ctx = calloc(1, sizeof(*ctx));
|
||||||
if (ctx == NULL) {
|
if (ctx == NULL) {
|
||||||
@@ -126,13 +127,17 @@ _gss_ntlm_init_sec_context
|
|||||||
}
|
}
|
||||||
*context_handle = (gss_ctx_id_t)ctx;
|
*context_handle = (gss_ctx_id_t)ctx;
|
||||||
|
|
||||||
ret = get_userinfo(name->domain, &ctx->username, &ctx->password);
|
ret = get_userinfo(name->domain, &ctx->username, &password);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
_gss_ntlm_delete_sec_context(minor_status, context_handle, NULL);
|
_gss_ntlm_delete_sec_context(minor_status, context_handle, NULL);
|
||||||
*minor_status = ret;
|
*minor_status = ret;
|
||||||
return GSS_S_FAILURE;
|
return GSS_S_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
heim_ntlm_nt_key(password, &ctx->key);
|
||||||
|
memset(password, 0, strlen(password));
|
||||||
|
free(password);
|
||||||
|
|
||||||
if (req_flags & GSS_C_CONF_FLAG)
|
if (req_flags & GSS_C_CONF_FLAG)
|
||||||
flags |= NTLM_NEG_SEAL;
|
flags |= NTLM_NEG_SEAL;
|
||||||
if (req_flags & GSS_C_INTEG_FLAG)
|
if (req_flags & GSS_C_INTEG_FLAG)
|
||||||
@@ -199,13 +204,9 @@ _gss_ntlm_init_sec_context
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if (1 || type2.targetinfo.length == 0) {
|
if (1 || type2.targetinfo.length == 0) {
|
||||||
struct ntlm_buf key;
|
|
||||||
struct ntlm_buf sessionkey;
|
struct ntlm_buf sessionkey;
|
||||||
unsigned char challange[8];
|
unsigned char challange[8];
|
||||||
|
|
||||||
heim_ntlm_nt_key(ctx->password, &key);
|
|
||||||
memset(ctx->password, 0, strlen(ctx->password));
|
|
||||||
|
|
||||||
if (type2.flags & NTLM_NEG_NTLM2_SESSION) {
|
if (type2.flags & NTLM_NEG_NTLM2_SESSION) {
|
||||||
unsigned char sessionhash[MD5_DIGEST_LENGTH];
|
unsigned char sessionhash[MD5_DIGEST_LENGTH];
|
||||||
MD5_CTX md5ctx;
|
MD5_CTX md5ctx;
|
||||||
@@ -238,15 +239,13 @@ _gss_ntlm_init_sec_context
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
heim_ntlm_calculate_ntlm1(key.data, key.length,
|
heim_ntlm_calculate_ntlm1(ctx->key.data, ctx->key.length,
|
||||||
challange,
|
challange,
|
||||||
&type3.ntlm);
|
&type3.ntlm);
|
||||||
|
|
||||||
ret = heim_ntlm_build_ntlm1_master(key.data, key.length,
|
ret = heim_ntlm_build_ntlm1_master(ctx->key.data, ctx->key.length,
|
||||||
&sessionkey,
|
&sessionkey,
|
||||||
&type3.sessionkey);
|
&type3.sessionkey);
|
||||||
memset(key.data, 0, key.length);
|
|
||||||
free(key.data);
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
if (type3.lm.data)
|
if (type3.lm.data)
|
||||||
free(type3.lm.data);
|
free(type3.lm.data);
|
||||||
@@ -268,7 +267,6 @@ _gss_ntlm_init_sec_context
|
|||||||
ctx->status |= STATUS_SESSIONKEY;
|
ctx->status |= STATUS_SESSIONKEY;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
struct ntlm_buf key;
|
|
||||||
struct ntlm_buf sessionkey;
|
struct ntlm_buf sessionkey;
|
||||||
unsigned char ntlmv2[16];
|
unsigned char ntlmv2[16];
|
||||||
struct ntlm_targetinfo ti;
|
struct ntlm_targetinfo ti;
|
||||||
@@ -290,18 +288,13 @@ _gss_ntlm_init_sec_context
|
|||||||
return GSS_S_FAILURE;
|
return GSS_S_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
heim_ntlm_nt_key(ctx->password, &key);
|
ret = heim_ntlm_calculate_ntlm2(ctx->key.data, ctx->key.length,
|
||||||
memset(ctx->password, 0, strlen(ctx->password));
|
|
||||||
|
|
||||||
ret = heim_ntlm_calculate_ntlm2(key.data, key.length,
|
|
||||||
ctx->username,
|
ctx->username,
|
||||||
name->domain,
|
name->domain,
|
||||||
type2.challange,
|
type2.challange,
|
||||||
&type2.targetinfo,
|
&type2.targetinfo,
|
||||||
ntlmv2,
|
ntlmv2,
|
||||||
&type3.ntlm);
|
&type3.ntlm);
|
||||||
memset(key.data, 0, key.length);
|
|
||||||
free(key.data);
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
_gss_ntlm_delete_sec_context(minor_status,
|
_gss_ntlm_delete_sec_context(minor_status,
|
||||||
context_handle, NULL);
|
context_handle, NULL);
|
||||||
|
Reference in New Issue
Block a user