summaryrefslogtreecommitdiff
path: root/source3/libsmb/smbencrypt.c
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2003-02-10 12:22:57 +0000
committerAndrew Bartlett <abartlet@samba.org>2003-02-10 12:22:57 +0000
commitbb9c66462233cffaf406bc8a00f3d14a4069a68f (patch)
tree71ed00688c5aa4765f3d4443dc8a76afbf8ea5c4 /source3/libsmb/smbencrypt.c
parent6c66e42d2ccf025f57e652f7ae689f8a3c2ada59 (diff)
downloadsamba-bb9c66462233cffaf406bc8a00f3d14a4069a68f.tar.gz
samba-bb9c66462233cffaf406bc8a00f3d14a4069a68f.tar.bz2
samba-bb9c66462233cffaf406bc8a00f3d14a4069a68f.zip
Clean up our NTLMv2 code by moving the grunt work into a helper function.
Andrew Bartlett (This used to be commit 6789e237d7b070624ba09e7ed43680b838337b74)
Diffstat (limited to 'source3/libsmb/smbencrypt.c')
-rw-r--r--source3/libsmb/smbencrypt.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/source3/libsmb/smbencrypt.c b/source3/libsmb/smbencrypt.c
index 34689b502c..28a20e76af 100644
--- a/source3/libsmb/smbencrypt.c
+++ b/source3/libsmb/smbencrypt.c
@@ -295,6 +295,33 @@ void SMBsesskeygen_ntv1(const uchar kr[16],
#endif
}
+DATA_BLOB NTLMv2_generate_response(uchar ntlm_v2_hash[16],
+ DATA_BLOB server_chal, size_t client_chal_length)
+{
+ uchar ntlmv2_response[16];
+ DATA_BLOB ntlmv2_client_data;
+ DATA_BLOB final_response;
+
+ /* NTLMv2 */
+
+ /* We also get to specify some random data */
+ ntlmv2_client_data = data_blob(NULL, client_chal_length);
+ generate_random_buffer(ntlmv2_client_data.data, ntlmv2_client_data.length, False);
+
+ /* Given that data, and the challenge from the server, generate a response */
+ SMBOWFencrypt_ntv2(ntlm_v2_hash, server_chal, ntlmv2_client_data, ntlmv2_response);
+
+ /* put it into nt_response, for the code below to put into the packet */
+ final_response = data_blob(NULL, ntlmv2_client_data.length + sizeof(ntlmv2_response));
+ memcpy(final_response.data, ntlmv2_response, sizeof(ntlmv2_response));
+ /* after the first 16 bytes is the random data we generated above, so the server can verify us with it */
+ memcpy(final_response.data + sizeof(ntlmv2_response), ntlmv2_client_data.data, ntlmv2_client_data.length);
+ data_blob_free(&ntlmv2_client_data);
+
+ return final_response;
+}
+
+
/***********************************************************
encode a password buffer. The caller gets to figure out
what to put in it.