summaryrefslogtreecommitdiff
path: root/libcli/smb
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2012-08-01 09:28:06 +0200
committerStefan Metzmacher <metze@samba.org>2012-08-04 09:10:21 +0200
commitdbefd7d194cc05a793a480740e9e29558ff95ad3 (patch)
tree0681bb367e01bb200b03da0f848a5ae6ca49e033 /libcli/smb
parentb1a0fda73d13587fd63682bc8e47f6862289f66d (diff)
downloadsamba-dbefd7d194cc05a793a480740e9e29558ff95ad3.tar.gz
samba-dbefd7d194cc05a793a480740e9e29558ff95ad3.tar.bz2
samba-dbefd7d194cc05a793a480740e9e29558ff95ad3.zip
libcli/smb: add smb_key_derivation() for TREE_CONNECT_ANDX_EXTENDED_SIGNATURES support
metze
Diffstat (limited to 'libcli/smb')
-rw-r--r--libcli/smb/smb_signing.c48
-rw-r--r--libcli/smb/smb_signing.h2
2 files changed, 49 insertions, 1 deletions
diff --git a/libcli/smb/smb_signing.c b/libcli/smb/smb_signing.c
index 2f7e8702ba..95c9c27c72 100644
--- a/libcli/smb/smb_signing.c
+++ b/libcli/smb/smb_signing.c
@@ -20,7 +20,7 @@
*/
#include "includes.h"
-#include "../lib/crypto/md5.h"
+#include "../lib/crypto/crypto.h"
#include "smb_common.h"
#include "smb_signing.h"
@@ -455,3 +455,49 @@ bool smb_signing_is_negotiated(struct smb_signing_state *si)
{
return si->negotiated;
}
+
+void smb_key_derivation(const uint8_t *KI, size_t KI_len,
+ uint8_t KO[16])
+{
+ static const uint8_t SSKeyHash[256] = {
+ 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79,
+ 0x20, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75,
+ 0x72, 0x65, 0x20, 0x4b, 0x65, 0x79, 0x20, 0x55,
+ 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x79, 0x07,
+ 0x6e, 0x28, 0x2e, 0x69, 0x88, 0x10, 0xb3, 0xdb,
+ 0x01, 0x55, 0x72, 0xfb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xe2, 0x68, 0xd0, 0x0d, 0xcd, 0x7f, 0x3d, 0xf8,
+ 0x73, 0x7e, 0x35, 0x7f, 0x07, 0x02, 0x0a, 0xb5,
+ 0xe9, 0xb7, 0x87, 0xfb, 0xa1, 0xbf, 0xcb, 0x32,
+ 0x31, 0x66, 0x09, 0x48, 0x88, 0xcc, 0x18, 0xa3,
+ 0xb2, 0x1f, 0x1f, 0x1b, 0x90, 0x4e, 0xd7, 0xe1
+ };
+ HMACMD5Context ctx;
+
+ hmac_md5_init_limK_to_64(KI, KI_len, &ctx);
+ hmac_md5_update(SSKeyHash, sizeof(SSKeyHash), &ctx);
+ hmac_md5_final(KO, &ctx);
+
+ ZERO_STRUCT(ctx);
+}
diff --git a/libcli/smb/smb_signing.h b/libcli/smb/smb_signing.h
index 1e9e1dd812..7427ada2a6 100644
--- a/libcli/smb/smb_signing.h
+++ b/libcli/smb/smb_signing.h
@@ -51,5 +51,7 @@ bool smb_signing_is_mandatory(struct smb_signing_state *si);
bool smb_signing_set_negotiated(struct smb_signing_state *si,
bool allowed, bool mandatory);
bool smb_signing_is_negotiated(struct smb_signing_state *si);
+void smb_key_derivation(const uint8_t *KI, size_t KI_len,
+ uint8_t KO[16]);
#endif /* _SMB_SIGNING_H_ */