Skip to contentSkip to conversation

NTLM authentication and signing - Make tiblob as part of session key (response)

PATCH In review [email protected] 2 participants 6 messages Oct 12, 2010 – Oct 15, 2010 5 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 2/4 NTLM authentication and signing - Make tiblob as part of session key (response)

From: Shirish Pargaonkar <[email protected]>

Have to move av_pair/ti blob to session key as part of ntlmv2 response. This entire blob is part of the response and is use to calculate signature for cases like ntlmv2 (without extended security) authentication. The size of the blob is hard coded to 1024 byte which should be sufficient to accomodate all 11 types of av pair types and their lenghts/values.

---
 fs/cifs/cifsencrypt.c |   22 ++++++++--------------
 fs/cifs/cifsglob.h    |    2 +-
 fs/cifs/cifspdu.h     |    5 +++++
 fs/cifs/connect.c     |    1 -
 fs/cifs/sess.c        |   24 ++++++------------------
 5 files changed, 20 insertions(+), 34 deletions(-)
fs/cifs/cifsencrypt.c +8 -14
index 7ac0056..83a17d7 100644
@@ -295,14 +295,7 @@ build_avpair_blob(struct cifsSesInfo *ses, const struct nls_table *nls_cp)
 	 * size of a timestamp (which is 8 bytes).
 	 */
 	ses->tilen = size + 2 * (2 * dlen) + 2 * (2 * wlen) + 8;
-	ses->tiblob = kzalloc(ses->tilen, GFP_KERNEL);
-	if (!ses->tiblob) {
-		ses->tilen = 0;
-		cERROR(1, "Challenge target info allocation failure");
-		return -ENOMEM;
-	}
-
-	blobptr = ses->tiblob;
+	blobptr = ses->auth_key.data.ntlmv2.tiblob;
 	attrptr = (struct ntlmssp2_name *) blobptr;
 
 	attrptr->type = cpu_to_le16(NTLMSSP_AV_NB_DOMAIN_NAME);
@@ -366,11 +359,11 @@ find_domain_name(struct cifsSesInfo *ses)
 	unsigned char *blobend;
 	struct ntlmssp2_name *attrptr;
 
-	if (!ses->tilen || !ses->tiblob)
+	if (!ses->tilen)
 		return 0;
 
-	blobptr = ses->tiblob;
-	blobend = ses->tiblob + ses->tilen;
+	blobptr = ses->auth_key.data.ntlmv2.tiblob;
+	blobend = blobptr + ses->tilen;
 
 	while (blobptr + onesize < blobend) {
 		attrptr = (struct ntlmssp2_name *) blobptr;
@@ -510,12 +503,12 @@ setup_ntlmv2_rsp(struct cifsSesInfo *ses, char *resp_buf,
 	memcpy(&ses->auth_key.data.ntlmv2.resp, resp_buf,
 	       sizeof(struct ntlmv2_resp));
 	ses->auth_key.len = 16 + sizeof(struct ntlmv2_resp);
+	if (ses->tilen)
+		ses->auth_key.len += ses->tilen;
 
 	return 0;
 
 setup_ntlmv2_rsp_ret:
-	kfree(ses->tiblob);
-	ses->tiblob = NULL;
 	ses->tilen = 0;
 
 	return rc;
@@ -533,7 +526,8 @@ void CalcNTLMv2_response(const struct cifsSesInfo *ses,
 			sizeof(struct ntlmv2_resp) - 8, &context);
 
 	if (ses->tilen)
-		hmac_md5_update(ses->tiblob, ses->tilen, &context);
+		hmac_md5_update(ses->auth_key.data.ntlmv2.tiblob, ses->tilen,
+					&context);
 
 	hmac_md5_final(v2_session_response, &context);
 /*	cifs_dump_mem("v2_sess_rsp: ", v2_session_response, 32); */
fs/cifs/cifsglob.h +1 -1
index 7d834b1..5dd5659 100644
@@ -105,6 +105,7 @@ struct session_key {
 		struct {
 			char key[16];
 			struct ntlmv2_resp resp;
+			unsigned char tiblob[CIFS_MAX_NTLMV2_AVPAIR_SIZE];
 		} ntlmv2;
 	} data;
 };
@@ -226,7 +227,6 @@ struct cifsSesInfo {
 	struct session_key auth_key;
 	char ntlmv2_hash[16];
 	unsigned int tilen; /* length of the target info blob */
-	unsigned char *tiblob; /* target info blob in challenge response */
 	bool need_reconnect:1; /* connection reset, uid now invalid */
 };
 /* no more than one of the following three session flags may be set */
fs/cifs/cifspdu.h +5 -0
index b0f4b56..e778165 100644
@@ -136,6 +136,11 @@
 #define CIFS_SESS_KEY_SIZE (24)
 
 /*
+ * Max expected size of an av pair blob in ntlmv2 auth exchange
+ */
+#define CIFS_MAX_NTLMV2_AVPAIR_SIZE (1024)
+
+/*
  * Maximum user name length
  */
 #define CIFS_UNLEN (20)
fs/cifs/connect.c +0 -1
index 3606ba8..ca207e8 100644
@@ -1802,7 +1802,6 @@ cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb_vol *volume_info)
 		goto get_ses_fail;
 
 	ses->tilen = 0;
-	ses->tiblob = NULL;
 	/* new SMB session uses our server ref */
 	ses->server = server;
 	if (server->addr.sockAddr6.sin6_family == AF_INET6)
fs/cifs/sess.c +6 -18
index 2111bed..28aedae 100644
@@ -411,15 +411,9 @@ static int decode_ntlmssp_challenge(char *bcc_ptr, int blob_len,
 	tioffset = cpu_to_le16(pblob->TargetInfoArray.BufferOffset);
 	tilen = cpu_to_le16(pblob->TargetInfoArray.Length);
 	ses->tilen = tilen;
-	if (ses->tilen) {
-		ses->tiblob = kmalloc(tilen, GFP_KERNEL);
-		if (!ses->tiblob) {
-			cERROR(1, "Challenge target info allocation failure");
-			ses->tilen = 0;
-			return -ENOMEM;
-		}
-		memcpy(ses->tiblob,  bcc_ptr + tioffset, ses->tilen);
-	}
+	if (ses->tilen && ses->tilen <= CIFS_MAX_NTLMV2_AVPAIR_SIZE)
+		memcpy(ses->auth_key.data.ntlmv2.tiblob,  bcc_ptr + tioffset,
+				ses->tilen);
 
 	return 0;
 }
@@ -505,16 +499,13 @@ static int build_ntlmssp_auth_blob(unsigned char *pbuffer,
 	memcpy(tmp, (char *)&ntlmv2_response, size);
 	tmp += size;
 	if (ses->tilen > 0) {
-		memcpy(tmp, ses->tiblob, ses->tilen);
+		memcpy(tmp, ses->auth_key.data.ntlmv2.tiblob, ses->tilen);
 		tmp += ses->tilen;
 	}
 
 	sec_blob->NtChallengeResponse.Length = cpu_to_le16(size + ses->tilen);
 	sec_blob->NtChallengeResponse.MaximumLength =
 				cpu_to_le16(size + ses->tilen);
-	kfree(ses->tiblob);
-	ses->tiblob = NULL;
-	ses->tilen = 0;
 
 	if (ses->domainName == NULL) {
 		sec_blob->DomainName.BufferOffset = cpu_to_le32(tmp - pbuffer);
@@ -747,12 +738,9 @@ ssetup_ntlmssp_authenticate:
 		pSMB->req_no_secext.CaseSensitivePasswordLength =
 			cpu_to_le16(sizeof(struct ntlmv2_resp) + ses->tilen);
 		if (ses->tilen > 0) {
-			memcpy(bcc_ptr, ses->tiblob, ses->tilen);
+			memcpy(bcc_ptr, ses->auth_key.data.ntlmv2.tiblob,
+					ses->tilen);
 			bcc_ptr += ses->tilen;
-			/* we never did allocate ses->domainName to free */
-			kfree(ses->tiblob);
-			ses->tiblob = NULL;
-			ses->tilen = 0;
 		}
 
 		if (ses->capabilities & CAP_UNICODE) {
Signature · 1 line
1.6.0.2

A message that is not in the archive (sent off-list or not yet received): 1286912719-22686-1-git-send-email-shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#2 lore raw
Quoted 12 lines · On Tue, 12 Oct 2010 14:45:19 -0500 shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@pub…

From: Shirish Pargaonkar <[email protected]>

Have to move av_pair/ti blob to session key as part of ntlmv2 response. This entire blob is part of the response and is use to calculate signature for cases like ntlmv2 (without extended security) authentication. The size of the blob is hard coded to 1024 byte which should be sufficient to accomodate all 11 types of av pair types and their lenghts/values.

[...]

fs/cifs/cifsglob.h struct session_key { · line 108

Quoted 11 lines
fs/cifs/cifsencrypt.c +0 -0
 	hmac_md5_final(v2_session_response, &context);
 /*	cifs_dump_mem("v2_sess_rsp: ", v2_session_response, 32); */
fs/cifs/cifsglob.h +1 -0
index 7d834b1..5dd5659 100644
@@ -105,6 +105,7 @@ struct session_key {
 		struct {
 			char key[16];
 			struct ntlmv2_resp resp;
+			unsigned char tiblob[CIFS_MAX_NTLMV2_AVPAIR_SIZE];
			^^^^^

Is this really the best way to do this? We're increasing the size of this struct substantially, thereby increasing the size of every TCP_Server_Info and cifsSesInfo struct by 1k.

Would it be better to keep the tiblob dynamically allocated, and hand off the pointer to it? If it really is necessary to add this field to the session_key struct in this way, would it be better to change how session keys are managed? i.e. not embed them inside of TCP_Server_Info and cifsSesInfo?

Quoted 24 lines
fs/cifs/cifsglob.h +0 -1
 		} ntlmv2;
 	} data;
 };
@@ -226,7 +227,6 @@ struct cifsSesInfo {
 	struct session_key auth_key;
 	char ntlmv2_hash[16];
 	unsigned int tilen; /* length of the target info blob */
-	unsigned char *tiblob; /* target info blob in challenge response */
 	bool need_reconnect:1; /* connection reset, uid now invalid */
 };
 /* no more than one of the following three session flags may be set */
fs/cifs/cifspdu.h +5 -0
index b0f4b56..e778165 100644
@@ -136,6 +136,11 @@
 #define CIFS_SESS_KEY_SIZE (24)
 
 /*
+ * Max expected size of an av pair blob in ntlmv2 auth exchange
+ */
+#define CIFS_MAX_NTLMV2_AVPAIR_SIZE (1024)
+
+/*
Signature · 1 line
Jeff Layton <[email protected]>

A message that is not in the archive (sent off-list or not yet received): 20101015100252.3960b34d-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org

#4 lore raw
Quoted 35 lines · Jeff Layton
Quoted 12 lines · On Tue, 12 Oct 2010 14:45:19 -0500 shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@pub…

From: Shirish Pargaonkar <[email protected]>

Have to move av_pair/ti blob to session key as part of ntlmv2 response. This entire blob is part of the response and is use to calculate signature for cases like ntlmv2 (without extended security) authentication. The size of the blob is hard coded to 1024 byte which should be sufficient to accomodate all 11 types of av pair types and their lenghts/values.

[...]

fs/cifs/cifsglob.h struct session_key { · line 108

Quoted 11 lines

      hmac_md5_final(v2_session_response, &context);
 /*   cifs_dump_mem("v2_sess_rsp: ", v2_session_response, 32); */

fs/cifs/cifsglob.h +1 -0
index 7d834b1..5dd5659 100644
@@ -105,6 +105,7 @@ struct session_key {
               struct {
                       char key[16];
                       struct ntlmv2_resp resp;
+                     unsigned char tiblob[CIFS_MAX_NTLMV2_AVPAIR_SIZE];

                       ^^^^^
Is this really the best way to do this? We're increasing the size of this struct substantially, thereby increasing the size of every TCP_Server_Info and cifsSesInfo struct by 1k.

Quoted 5 lines

Would it be better to keep the tiblob dynamically allocated, and hand off the pointer to it? If it really is necessary to add this field to the session_key struct in this way, would it be better to change how session keys are managed? i.e. not embed them inside of TCP_Server_Info and cifsSesInfo?

Jeff, we need to have a contiguous block of ntlmv2 client response i.e. First part of client response (CR1), the 16 bytes and the variable second part of client response which consists of struct ntlmv2_resp and tiblob. Without contiguous blob, i.e. if tiblob is a pointer pointing to a dynamically allocated memory, when it comes to calculating signature, this code,

        crypto_shash_update(&server->secmech.sdescmd5->shash,
                (char *)&server->session_key.data, len);

we end up copying incorrect contents.

I agree 1K is a lot but I can reduce it. av pair/target info blob can vary in size, we can only guestimate how large it could.

Perhaps I can keep the way it is, and do two updates, one update with fixed part, key + ntlmv2_resp structure and another with tiblob.
Let me try that, I think that will work and if it works, we do not need this patch,
I can make that change as part of current 4/4 patch.

Quoted 29 lines
Quoted 17 lines
fs/cifs/cifsglob.h +0 -0
               } ntlmv2;
       } data;
  };
@@ -226,7 +227,6 @@ struct cifsSesInfo {
       struct session_key auth_key;
       char ntlmv2_hash[16];

      unsigned int tilen; /* length of the target info blob */
-     unsigned char *tiblob; /* target info blob in challenge response */ bool need_reconnect:1; /* connection reset, uid now invalid */ };
 /* no more than one of the following three session flags may be set */

fs/cifs/cifspdu.h +0 -0
index b0f4b56..e778165 100644

fs/cifs/cifspdu.h line 143

Quoted 8 lines
fs/cifs/cifspdu.h +5 -0
@@ -136,6 +136,11 @@
  #define CIFS_SESS_KEY_SIZE (24)
 
  /*
+ * Max expected size of an av pair blob in ntlmv2 auth exchange
+ */
+#define CIFS_MAX_NTLMV2_AVPAIR_SIZE (1024)
+
+/*

--
Jeff Layton <[email protected]>

A message that is not in the archive (sent off-list or not yet received): AANLkTinAftYfvJs-MSN5zbO0ejEBkdT9fcgVzpuJ9eWU-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#6 lore raw
Quoted 53 lines · Shirish Pargaonkar
Quoted 35 lines · Jeff Layton
Quoted 12 lines · On Tue, 12 Oct 2010 14:45:19 -0500 shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@pub…

From: Shirish Pargaonkar <[email protected]>

Have to move av_pair/ti blob to session key as part of ntlmv2 response. This entire blob is part of the response and is use to calculate signature for cases like ntlmv2 (without extended security) authentication. The size of the blob is hard coded to 1024 byte which should be sufficient to accomodate all 11 types of av pair types and their lenghts/values.

[...]

fs/cifs/cifsglob.h struct session_key { · line 108

Quoted 11 lines

      hmac_md5_final(v2_session_response, &context);
 /*   cifs_dump_mem("v2_sess_rsp: ", v2_session_response, 32); */

fs/cifs/cifsglob.h +1 -0
index 7d834b1..5dd5659 100644
@@ -105,6 +105,7 @@ struct session_key {
               struct {
                       char key[16];
                       struct ntlmv2_resp resp;
+                     unsigned char tiblob[CIFS_MAX_NTLMV2_AVPAIR_SIZE];

                       ^^^^^
Is this really the best way to do this? We're increasing the size of this struct substantially, thereby increasing the size of every TCP_Server_Info and cifsSesInfo struct by 1k.

Quoted 5 lines

Would it be better to keep the tiblob dynamically allocated, and hand off the pointer to it? If it really is necessary to add this field to the session_key struct in this way, would it be better to change how session keys are managed? i.e. not embed them inside of TCP_Server_Info and cifsSesInfo?

Jeff, we need to have a contiguous block of ntlmv2 client response i.e. First part of client response (CR1), the 16 bytes and the variable second part of client response which consists of struct ntlmv2_resp and tiblob. Without contiguous blob, i.e. if tiblob is a pointer pointing to a dynamically allocated memory, when it comes to calculating signature, this code,

       crypto_shash_update(&server->secmech.sdescmd5->shash, (char *)&server->session_key.data, len);

we end up copying incorrect contents.

Quoted 8 lines

I agree 1K is a lot but I can reduce it. av pair/target info blob can vary in size, we can only guestimate how large it could.

Perhaps I can keep the way it is, and do two updates, one update with fixed part, key + ntlmv2_resp structure and another with tiblob.
Let me try that, I think that will work and if it works, we do not need this patch,
I can make that change as part of current 4/4 patch.

In which case we have to keep tiblob and tilen for the life of the smb connection.
This is an issue for ntlmv2 authentication without extended security only since the entire client response is used in signature calculation. For ntlmv2 in ntlmssp, only first 16 bytes of the client response are needed for signature calculation.

Quoted 32 lines
Quoted 31 lines
Quoted 19 lines
fs/cifs/cifsglob.h +0 -0
               } ntlmv2;
       } data;
  };
@@ -226,7 +227,6 @@ struct cifsSesInfo {
       struct session_key auth_key;
       char ntlmv2_hash[16];

      unsigned int tilen; /* length of the target info blob */
-     unsigned char *tiblob; /* target info blob in challenge response */ bool need_reconnect:1; /* connection reset, uid now invalid */ };
 /* no more than one of the following three session flags may be set */

fs/cifs/cifspdu.h +0 -0
index b0f4b56..e778165 100644

fs/cifs/cifspdu.h line 143

Quoted 8 lines
fs/cifs/cifspdu.h +5 -0
@@ -136,6 +136,11 @@
  #define CIFS_SESS_KEY_SIZE (24)
 
  /*
+ * Max expected size of an av pair blob in ntlmv2 auth exchange
+ */
+#define CIFS_MAX_NTLMV2_AVPAIR_SIZE (1024)
+
+/*

--
Jeff Layton <[email protected]>

A message that is not in the archive (sent off-list or not yet received): AANLkTimEKGZgzBW+V_UdL3dVa1HNwjHWaYhcT=PHxKra-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#8 lore raw
Quoted 64 lines · On Fri, 15 Oct 2010 09:51:59 -0500 Shirish Pargaonkar…
Quoted 53 lines · Shirish Pargaonkar
Quoted 35 lines · Jeff Layton
Quoted 12 lines · On Tue, 12 Oct 2010 14:45:19 -0500 shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@pub…

From: Shirish Pargaonkar <[email protected]>

Have to move av_pair/ti blob to session key as part of ntlmv2 response. This entire blob is part of the response and is use to calculate signature for cases like ntlmv2 (without extended security) authentication. The size of the blob is hard coded to 1024 byte which should be sufficient to accomodate all 11 types of av pair types and their lenghts/values.

[...]

fs/cifs/cifsglob.h struct session_key { · line 108

Quoted 11 lines

      hmac_md5_final(v2_session_response, &context);
 /*   cifs_dump_mem("v2_sess_rsp: ", v2_session_response, 32); */

fs/cifs/cifsglob.h +1 -0
index 7d834b1..5dd5659 100644
@@ -105,6 +105,7 @@ struct session_key {
               struct {
                       char key[16];
                       struct ntlmv2_resp resp;
+                     unsigned char tiblob[CIFS_MAX_NTLMV2_AVPAIR_SIZE];

                       ^^^^^
Is this really the best way to do this? We're increasing the size of this struct substantially, thereby increasing the size of every TCP_Server_Info and cifsSesInfo struct by 1k.

Quoted 5 lines

Would it be better to keep the tiblob dynamically allocated, and hand off the pointer to it? If it really is necessary to add this field to the session_key struct in this way, would it be better to change how session keys are managed? i.e. not embed them inside of TCP_Server_Info and cifsSesInfo?

Jeff, we need to have a contiguous block of ntlmv2 client response i.e. First part of client response (CR1), the 16 bytes and the variable second part of client response which consists of struct ntlmv2_resp and tiblob. Without contiguous blob, i.e. if tiblob is a pointer pointing to a dynamically allocated memory, when it comes to calculating signature, this code,

       crypto_shash_update(&server->secmech.sdescmd5->shash, (char *)&server->session_key.data, len);

we end up copying incorrect contents.

Quoted 8 lines

I agree 1K is a lot but I can reduce it. av pair/target info blob can vary in size, we can only guestimate how large it could.

Perhaps I can keep the way it is, and do two updates, one update with fixed part, key + ntlmv2_resp structure and another with tiblob.
Let me try that, I think that will work and if it works, we do not need this patch,
I can make that change as part of current 4/4 patch.

Quoted 7 lines

In which case we have to keep tiblob and tilen for the life of the smb connection.
This is an issue for ntlmv2 authentication without extended security only since the entire client response is used in signature calculation. For ntlmv2 in ntlmssp, only first 16 bytes of the client response are needed for signature calculation.

We only need to keep one of these for the life of the connection, right? After the initial authentication is done, only the first session_key established on the socket will ever be used again.

Instead of memcpy'ing this key around between embedded session_key structs, wouldn't it make more sense to allocate them dynamically, and "hand off" the first session key to the socket. Then you could just free the others.

It also sort of sucks that this session_key is a union instead of having its size dynamically determined. That's quite a bit of wasted space for the other cases that don't need a session_key this large.

Maybe the session key should just be a pointer and a length field, that gets set up whenever the thing is created?

Signature · 1 line
Jeff Layton <[email protected]>

A message that is not in the archive (sent off-list or not yet received): 20101015110847.2ebf4469-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org

#10 lore raw
Quoted 76 lines · Jeff Layton
Quoted 64 lines · On Fri, 15 Oct 2010 09:51:59 -0500 Shirish Pargaonkar…
Quoted 53 lines · Shirish Pargaonkar
Quoted 35 lines · Jeff Layton
Quoted 12 lines · On Tue, 12 Oct 2010 14:45:19 -0500 shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@pub…

From: Shirish Pargaonkar <[email protected]>

Have to move av_pair/ti blob to session key as part of ntlmv2 response. This entire blob is part of the response and is use to calculate signature for cases like ntlmv2 (without extended security) authentication. The size of the blob is hard coded to 1024 byte which should be sufficient to accomodate all 11 types of av pair types and their lenghts/values.

[...]

fs/cifs/cifsglob.h struct session_key { · line 108

Quoted 11 lines

      hmac_md5_final(v2_session_response, &context);
 /*   cifs_dump_mem("v2_sess_rsp: ", v2_session_response, 32); */

fs/cifs/cifsglob.h +1 -0
index 7d834b1..5dd5659 100644
@@ -105,6 +105,7 @@ struct session_key {
               struct {
                       char key[16];
                       struct ntlmv2_resp resp;
+                     unsigned char tiblob[CIFS_MAX_NTLMV2_AVPAIR_SIZE];

                       ^^^^^
Is this really the best way to do this? We're increasing the size of this struct substantially, thereby increasing the size of every TCP_Server_Info and cifsSesInfo struct by 1k.

Quoted 5 lines

Would it be better to keep the tiblob dynamically allocated, and hand off the pointer to it? If it really is necessary to add this field to the session_key struct in this way, would it be better to change how session keys are managed? i.e. not embed them inside of TCP_Server_Info and cifsSesInfo?

Jeff, we need to have a contiguous block of ntlmv2 client response i.e. First part of client response (CR1), the 16 bytes and the variable second part of client response which consists of struct ntlmv2_resp and tiblob. Without contiguous blob, i.e. if tiblob is a pointer pointing to a dynamically allocated memory, when it comes to calculating signature, this code,

       crypto_shash_update(&server->secmech.sdescmd5->shash, (char *)&server->session_key.data, len);

we end up copying incorrect contents.

Quoted 8 lines

I agree 1K is a lot but I can reduce it. av pair/target info blob can vary in size, we can only guestimate how large it could.

Perhaps I can keep the way it is, and do two updates, one update with fixed part, key + ntlmv2_resp structure and another with tiblob.
Let me try that, I think that will work and if it works, we do not need this patch,
I can make that change as part of current 4/4 patch.

Quoted 7 lines

In which case we have to keep tiblob and tilen for the life of the smb connection.
This is an issue for ntlmv2 authentication without extended security only since the entire client response is used in signature calculation. For ntlmv2 in ntlmssp, only first 16 bytes of the client response are needed for signature calculation.

Quoted 4 lines

We only need to keep one of these for the life of the connection, right? After the initial authentication is done, only the first session_key established on the socket will ever be used again.

Jeff, yes.

Quoted 15 lines

Instead of memcpy'ing this key around between embedded session_key structs, wouldn't it make more sense to allocate them dynamically, and "hand off" the first session key to the socket. Then you could just free the others.

It also sort of sucks that this session_key is a union instead of having its size dynamically determined. That's quite a bit of wasted space for the other cases that don't need a session_key this large.

Maybe the session key should just be a pointer and a length field, that gets set up whenever the thing is created?

--
Jeff Layton <[email protected]>