Use heim_ntlm_calculate_ntlm2_sess.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21206 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -285,44 +285,34 @@ _gss_ntlm_init_sec_context
|
|||||||
|
|
||||||
if (1 || type2.targetinfo.length == 0) {
|
if (1 || type2.targetinfo.length == 0) {
|
||||||
struct ntlm_buf sessionkey;
|
struct ntlm_buf sessionkey;
|
||||||
unsigned char challange[8];
|
|
||||||
|
|
||||||
if (type2.flags & NTLM_NEG_NTLM2_SESSION) {
|
if (type2.flags & NTLM_NEG_NTLM2_SESSION) {
|
||||||
unsigned char sessionhash[MD5_DIGEST_LENGTH];
|
unsigned char nonce[8];
|
||||||
MD5_CTX md5ctx;
|
|
||||||
|
|
||||||
type3.lm.length = 24;
|
if (RAND_bytes(nonce, sizeof(nonce)) != 1) {
|
||||||
type3.lm.data = calloc(1, 24);
|
|
||||||
if (type3.lm.data == NULL) {
|
|
||||||
_gss_ntlm_delete_sec_context(minor_status,
|
|
||||||
context_handle, NULL);
|
|
||||||
*minor_status = ENOMEM;
|
|
||||||
return GSS_S_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (RAND_bytes(type3.lm.data, 8) != 1) {
|
|
||||||
free(type3.lm.data);
|
|
||||||
_gss_ntlm_delete_sec_context(minor_status,
|
_gss_ntlm_delete_sec_context(minor_status,
|
||||||
context_handle, NULL);
|
context_handle, NULL);
|
||||||
*minor_status = EINVAL;
|
*minor_status = EINVAL;
|
||||||
return GSS_S_FAILURE;
|
return GSS_S_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
MD5_Init(&md5ctx);
|
ret = heim_ntlm_calculate_ntlm2_sess(nonce,
|
||||||
MD5_Update(&md5ctx, type2.challange, sizeof(type2.challange));
|
type2.challange,
|
||||||
MD5_Update(&md5ctx, type3.lm.data, 8);
|
ctx->client.key.data,
|
||||||
MD5_Final(sessionhash, &md5ctx);
|
&type3.lm,
|
||||||
|
|
||||||
memcpy(challange, sessionhash, 8);
|
|
||||||
} else {
|
|
||||||
memcpy(challange, type2.challange, 8);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
heim_ntlm_calculate_ntlm1(ctx->client.key.data,
|
|
||||||
ctx->client.key.length,
|
|
||||||
challange,
|
|
||||||
&type3.ntlm);
|
&type3.ntlm);
|
||||||
|
} else {
|
||||||
|
ret = heim_ntlm_calculate_ntlm1(ctx->client.key.data,
|
||||||
|
ctx->client.key.length,
|
||||||
|
type2.challange,
|
||||||
|
&type3.ntlm);
|
||||||
|
|
||||||
|
}
|
||||||
|
if (ret) {
|
||||||
|
_gss_ntlm_delete_sec_context(minor_status,context_handle,NULL);
|
||||||
|
*minor_status = ret;
|
||||||
|
return GSS_S_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
ret = heim_ntlm_build_ntlm1_master(ctx->client.key.data,
|
ret = heim_ntlm_build_ntlm1_master(ctx->client.key.data,
|
||||||
ctx->client.key.length,
|
ctx->client.key.length,
|
||||||
@@ -331,6 +321,8 @@ _gss_ntlm_init_sec_context
|
|||||||
if (ret) {
|
if (ret) {
|
||||||
if (type3.lm.data)
|
if (type3.lm.data)
|
||||||
free(type3.lm.data);
|
free(type3.lm.data);
|
||||||
|
if (type3.ntlm.data)
|
||||||
|
free(type3.ntlm.data);
|
||||||
_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;
|
||||||
@@ -342,6 +334,8 @@ _gss_ntlm_init_sec_context
|
|||||||
if (ret) {
|
if (ret) {
|
||||||
if (type3.lm.data)
|
if (type3.lm.data)
|
||||||
free(type3.lm.data);
|
free(type3.lm.data);
|
||||||
|
if (type3.ntlm.data)
|
||||||
|
free(type3.ntlm.data);
|
||||||
_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;
|
||||||
@@ -427,6 +421,8 @@ _gss_ntlm_init_sec_context
|
|||||||
free(type3.sessionkey.data);
|
free(type3.sessionkey.data);
|
||||||
if (type3.lm.data)
|
if (type3.lm.data)
|
||||||
free(type3.lm.data);
|
free(type3.lm.data);
|
||||||
|
if (type3.ntlm.data)
|
||||||
|
free(type3.ntlm.data);
|
||||||
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;
|
||||||
|
Reference in New Issue
Block a user