diff options
author | Matthew Chapman <matty@samba.org> | 1999-03-19 15:09:25 +0000 |
---|---|---|
committer | Matthew Chapman <matty@samba.org> | 1999-03-19 15:09:25 +0000 |
commit | b5a5236f207867d52acb8573d69c92a7691b2d3f (patch) | |
tree | b13a8b9507e276b9ded132c54665b1ba6309ed3c /source3/libsmb | |
parent | fda194255c156ce373d5f195e960bf8712fe4d67 (diff) | |
download | samba-b5a5236f207867d52acb8573d69c92a7691b2d3f.tar.gz samba-b5a5236f207867d52acb8573d69c92a7691b2d3f.tar.bz2 samba-b5a5236f207867d52acb8573d69c92a7691b2d3f.zip |
Implemented encryption algorithm used for a number of RPC buffers.
(actually, decryption only currently because I need to get some sleep).
Basically another Microsoft twist on DES; the "master key" is the user's
NT hash MD4'd and subsets of this are chosen as the 56-bit DES keys.
(This used to be commit f09388fa6f41a13ca035b5b2ff40be804608f619)
Diffstat (limited to 'source3/libsmb')
-rw-r--r-- | source3/libsmb/smbdes.c | 2 | ||||
-rw-r--r-- | source3/libsmb/smbencrypt.c | 45 |
2 files changed, 46 insertions, 1 deletions
diff --git a/source3/libsmb/smbdes.c b/source3/libsmb/smbdes.c index d0e1c6e85f..08bc929f01 100644 --- a/source3/libsmb/smbdes.c +++ b/source3/libsmb/smbdes.c @@ -277,7 +277,7 @@ static void str_to_key(unsigned char *str,unsigned char *key) } -static void smbhash(unsigned char *out, unsigned char *in, unsigned char *key, int forw) +void smbhash(unsigned char *out, unsigned char *in, unsigned char *key, int forw) { int i; char outb[64]; diff --git a/source3/libsmb/smbencrypt.c b/source3/libsmb/smbencrypt.c index e35cccd734..3835c99815 100644 --- a/source3/libsmb/smbencrypt.c +++ b/source3/libsmb/smbencrypt.c @@ -226,3 +226,48 @@ BOOL make_oem_passwd_hash(char data[516], const char *passwd, uchar old_pw_hash[ return True; } +int nt_decrypt_string2(STRING2 *out, STRING2 *in, char nt_hash[16]) +{ + uchar bufhdr[8]; + int datalen; + + uchar key[16]; + uchar *keyptr = key; + uchar *keyend = key + sizeof(key); + + uchar *outbuf = (uchar *)out->buffer; + uchar *inbuf = (uchar *)in->buffer; + uchar *inbufend; + + + mdfour(key, nt_hash, 16); + + smbhash(bufhdr, inbuf, keyptr, 0); + datalen = IVAL(bufhdr, 0); + + if ((datalen > in->str_str_len) || (datalen > MAX_STRINGLEN)) + { + DEBUG(0, ("nt_decrypt_string2: failed\n")); + return False; + } + + out->str_max_len = out->str_str_len = datalen; + inbuf += 8; + inbufend = inbuf + datalen; + + while (inbuf < inbufend) + { + keyptr += 7; + if (keyptr + 7 > keyend) + { + keyptr = (keyend - keyptr) + key; + } + + smbhash(outbuf, inbuf, keyptr, 0); + + inbuf += 8; + outbuf += 8; + } + + return True; +} |