summaryrefslogtreecommitdiff
path: root/source3/libsmb/smbencrypt.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2002-06-14 22:38:43 +0000
committerJeremy Allison <jra@samba.org>2002-06-14 22:38:43 +0000
commitcaa4262db6115a6880af9618b7fe8130eecd4b98 (patch)
tree7b0c6f88fd735de9b3991dd04e8faa869b7ddbfe /source3/libsmb/smbencrypt.c
parentd8b685ea2743291593bff0886f29f7359273f39a (diff)
downloadsamba-caa4262db6115a6880af9618b7fe8130eecd4b98.tar.gz
samba-caa4262db6115a6880af9618b7fe8130eecd4b98.tar.bz2
samba-caa4262db6115a6880af9618b7fe8130eecd4b98.zip
More of SMB signing for client - not yet finished (should be harmless).
Jeremy. (This used to be commit c1b20db4bb4bb1ba485466f50b9795470027327c)
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 fa1eaedb5a..de469c0293 100644
--- a/source3/libsmb/smbencrypt.c
+++ b/source3/libsmb/smbencrypt.c
@@ -331,5 +331,32 @@ BOOL decode_pw_buffer(char in_buffer[516], char *new_pwrd,
#endif
return True;
+}
+
+/***********************************************************
+ SMB signing - calculate a MAC to send.
+************************************************************/
+void cli_caclulate_sign_mac(struct cli_state *cli)
+{
+ unsigned char calc_md5_mac[16];
+ struct MD5Context md5_ctx;
+
+ /*
+ * Firstly put the sequence number into the first 4 bytes.
+ * and zero out the next 4 bytes.
+ */
+ SIVAL(cli->outbuf, smb_ss_field, cli->sign_info.send_seq_num);
+ SIVAL(cli->outbuf, smb_ss_field + 4, 0);
+
+ /* Calculate the 16 byte MAC and place first 8 bytes into the field. */
+ MD5Init(&md5_ctx);
+ MD5Update(&md5_ctx, cli->sign_info.mac_key, cli->sign_info.mac_key_len);
+ MD5Update(&md5_ctx, cli->outbuf + 4, smb_len(cli->outbuf));
+ MD5Final(calc_md5_mac, &md5_ctx);
+
+ memcpy(&cli->outbuf[smb_ss_field], calc_md5_mac, 8);
+ cli->sign_info.send_seq_num++;
+ cli->sign_info.reply_seq_num = cli->sign_info.send_seq_num;
+ cli->sign_info.send_seq_num++;
}