summaryrefslogtreecommitdiffstats
path: root/source/libsmb
diff options
context:
space:
mode:
authorLuke Leighton <lkcl@samba.org>1998-10-07 21:42:24 +0000
committerLuke Leighton <lkcl@samba.org>1998-10-07 21:42:24 +0000
commit6677b888bdb45df00646eb7cc13005b9465ff971 (patch)
treec8fb54990c079fd4dfaf97bf2922ad9f4f89ec71 /source/libsmb
parent361c1b7ea994cc25d460ebd25b2ad9025f90848c (diff)
downloadsamba-6677b888bdb45df00646eb7cc13005b9465ff971.tar.gz
samba-6677b888bdb45df00646eb7cc13005b9465ff971.tar.xz
samba-6677b888bdb45df00646eb7cc13005b9465ff971.zip
dce/rpc
Diffstat (limited to 'source/libsmb')
-rw-r--r--source/libsmb/smbdes.c55
-rw-r--r--source/libsmb/smbencrypt.c12
2 files changed, 65 insertions, 2 deletions
diff --git a/source/libsmb/smbdes.c b/source/libsmb/smbdes.c
index eebe0dc54fe..e9f23295500 100644
--- a/source/libsmb/smbdes.c
+++ b/source/libsmb/smbdes.c
@@ -357,6 +357,58 @@ void cred_hash3(unsigned char *out,unsigned char *in,unsigned char *key, int for
smbhash(out + 8, in + 8, key2, forw);
}
+void NTLMSSPhash( unsigned char hash[256], unsigned char const key[5])
+{
+ unsigned char j = 0;
+ int ind;
+
+ unsigned char k2[8];
+
+ memcpy(k2, key, sizeof(key));
+ k2[5] = 0xe5;
+ k2[6] = 0xb8;
+ k2[6] = 0xb0;
+
+ for (ind = 0; ind < 256; ind++)
+ {
+ hash[ind] = (unsigned char)ind;
+ }
+
+ for( ind = 0; ind < 256; ind++)
+ {
+ unsigned char tc;
+
+ j += (hash[ind] + k2[ind%8]);
+
+ tc = hash[ind];
+ hash[ind] = hash[j];
+ hash[j] = tc;
+ }
+}
+
+void NTLMSSPcalc( unsigned char hash[256], unsigned char *data, int len)
+{
+ unsigned char index_i = 0;
+ unsigned char index_j = 0;
+ int ind;
+
+ for( ind = 0; ind < len; ind++)
+ {
+ unsigned char tc;
+ unsigned char t;
+
+ index_i++;
+ index_j += hash[index_i];
+
+ tc = hash[index_i];
+ hash[index_i] = hash[index_j];
+ hash[index_j] = tc;
+
+ t = hash[index_i] + hash[index_j];
+ data[ind] ^= hash[t];
+ }
+}
+
void SamOEMhash( unsigned char *data, unsigned char *key, int val)
{
unsigned char s_box[256];
@@ -380,8 +432,7 @@ void SamOEMhash( unsigned char *data, unsigned char *key, int val)
s_box[ind] = s_box[j];
s_box[j] = tc;
}
-
- for( ind = 0; ind < (val ? 516 : 16); ind++)
+ for( ind = 0; ind < val ? 516 : 8; ind++)
{
unsigned char tc;
unsigned char t;
diff --git a/source/libsmb/smbencrypt.c b/source/libsmb/smbencrypt.c
index bf9736d7242..44dcbd5e05b 100644
--- a/source/libsmb/smbencrypt.c
+++ b/source/libsmb/smbencrypt.c
@@ -152,6 +152,18 @@ void SMBOWFencrypt(uchar passwd[16], uchar *c8, uchar p24[24])
E_P24(p21, c8, p24);
}
+/* Does the des encryption from the FIRST 8 BYTES of the NT or LM MD4 hash. */
+void NTLMSSPOWFencrypt(uchar passwd[8], uchar *ntlmchalresp, uchar p24[24])
+{
+ uchar p21[21];
+
+ memset(p21,'\0',21);
+ memcpy(p21, passwd, 8);
+ memset(p21 + 8, 0xbd, 8);
+
+ E_P24(p21, ntlmchalresp, p24);
+}
+
/* Does the NT MD4 hash then des encryption. */