summaryrefslogtreecommitdiff
path: root/source3/libsmb/smbdes.c
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2001-09-14 04:34:06 +0000
committerTim Potter <tpot@samba.org>2001-09-14 04:34:06 +0000
commit82a8f8a171e4290cbae3d24069034191bf7f9f47 (patch)
tree1c7dc4d7731a71b3e98c593b46a422aa878bb72f /source3/libsmb/smbdes.c
parent0dab2c3e319d89183c2f3d75dbd1c25cbf738284 (diff)
downloadsamba-82a8f8a171e4290cbae3d24069034191bf7f9f47.tar.gz
samba-82a8f8a171e4290cbae3d24069034191bf7f9f47.tar.bz2
samba-82a8f8a171e4290cbae3d24069034191bf7f9f47.zip
Merge of sam_pwd_hash() function from tng.
(This used to be commit b6cb6b837ac06d8b9cb898668e69236b64a8b698)
Diffstat (limited to 'source3/libsmb/smbdes.c')
-rw-r--r--source3/libsmb/smbdes.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/source3/libsmb/smbdes.c b/source3/libsmb/smbdes.c
index c5dbbdf99a..30a5746934 100644
--- a/source3/libsmb/smbdes.c
+++ b/source3/libsmb/smbdes.c
@@ -397,3 +397,20 @@ void SamOEMhash( unsigned char *data, unsigned char *key, int val)
data[ind] = data[ind] ^ s_box[t];
}
}
+
+/* Decode a sam password hash into a password. The password hash is the
+ same method used to store passwords in the NT registry. The DES key
+ used is based on the RID of the user. */
+
+void sam_pwd_hash(unsigned int rid, const uchar *in, uchar *out, int forw)
+{
+ uchar s[14];
+
+ s[0] = s[4] = s[8] = s[12] = (uchar)(rid & 0xFF);
+ s[1] = s[5] = s[9] = s[13] = (uchar)((rid >> 8) & 0xFF);
+ s[2] = s[6] = s[10] = (uchar)((rid >> 16) & 0xFF);
+ s[3] = s[7] = s[11] = (uchar)((rid >> 24) & 0xFF);
+
+ smbhash(out, in, s, forw);
+ smbhash(out+8, in+8, s+7, forw);
+}