diff options
Diffstat (limited to 'source3/libsmb')
-rw-r--r-- | source3/libsmb/credentials.c | 11 | ||||
-rw-r--r-- | source3/libsmb/smbdes.c | 19 |
2 files changed, 20 insertions, 10 deletions
diff --git a/source3/libsmb/credentials.c b/source3/libsmb/credentials.c index 8881704a7a..f1a41b0b3b 100644 --- a/source3/libsmb/credentials.c +++ b/source3/libsmb/credentials.c @@ -35,7 +35,6 @@ void cred_session_key(DOM_CHAL *clnt_chal, DOM_CHAL *srv_chal, char *pass, { uint32 sum[2]; char sum2[8]; - char buf[8]; char netsesskey[8]; sum[0] = IVAL(clnt_chal->data, 0) + IVAL(srv_chal->data, 0); @@ -44,8 +43,7 @@ void cred_session_key(DOM_CHAL *clnt_chal, DOM_CHAL *srv_chal, char *pass, SIVAL(sum2,0,sum[0]); SIVAL(sum2,4,sum[1]); - smbhash(buf, sum2, pass); - smbhash(netsesskey, buf, pass+9); + cred_hash1(netsesskey, sum2, pass); session_key[0] = IVAL(netsesskey, 0); session_key[1] = IVAL(netsesskey, 4); @@ -74,8 +72,6 @@ Output: void cred_create(uint32 session_key[2], DOM_CHAL *stor_cred, UTIME timestamp, DOM_CHAL *cred) { - char key2[7]; - char buf[8]; char calc_cred[8]; char timecred[8]; char netsesskey[8]; @@ -86,10 +82,7 @@ void cred_create(uint32 session_key[2], DOM_CHAL *stor_cred, UTIME timestamp, SIVAL(timecred, 0, IVAL(stor_cred, 0) + timestamp.time); SIVAL(timecred, 4, IVAL(stor_cred, 4)); - smbhash(buf, timecred, netsesskey); - memset(key2, 0, 7); - key2[0] = netsesskey[7]; - smbhash(calc_cred, buf, key2); + cred_hash2(calc_cred, timecred, netsesskey); cred->data[0] = IVAL(calc_cred, 0); cred->data[1] = IVAL(calc_cred, 4); diff --git a/source3/libsmb/smbdes.c b/source3/libsmb/smbdes.c index b62a160418..90bad778c5 100644 --- a/source3/libsmb/smbdes.c +++ b/source3/libsmb/smbdes.c @@ -275,7 +275,7 @@ void str_to_key(unsigned char *str,unsigned char *key) } -void smbhash(unsigned char *out, unsigned char *in, unsigned char *key) +static void smbhash(unsigned char *out, unsigned char *in, unsigned char *key) { int i; char outb[64]; @@ -317,4 +317,21 @@ void E_P24(unsigned char *p21, unsigned char *c8, unsigned char *p24) smbhash(p24+16, c8, p21+14); } +void cred_hash1(char *out, char *in, char *key) +{ + char buf[8]; + + smbhash(buf, in, key); + smbhash(out, buf, key+9); +} + +void cred_hash2(char *out, char *in, char *key) +{ + char buf[8]; + static char key2[8]; + + smbhash(buf, in, key); + key2[0] = key[7]; + smbhash(out, buf, key2); +} |