summaryrefslogtreecommitdiff
path: root/source4/libcli/util
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2003-12-01 22:13:11 +0000
committerAndrew Tridgell <tridge@samba.org>2003-12-01 22:13:11 +0000
commit8b30b0071cb7668f49b2ea5951d1180bf90371e3 (patch)
tree95fd324add9a362e7f25c7bec06ec28af1e95841 /source4/libcli/util
parentf9e2a8af391f8ecb7cf6aa2d017898503d16985f (diff)
downloadsamba-8b30b0071cb7668f49b2ea5951d1180bf90371e3.tar.gz
samba-8b30b0071cb7668f49b2ea5951d1180bf90371e3.tar.bz2
samba-8b30b0071cb7668f49b2ea5951d1180bf90371e3.zip
* another small API change in the credentials code
* don't use static variables in the smbdes code (This used to be commit e6e09064646c347169852fa162c72fc0542c6d5c)
Diffstat (limited to 'source4/libcli/util')
-rw-r--r--source4/libcli/util/smbdes.c82
1 files changed, 40 insertions, 42 deletions
diff --git a/source4/libcli/util/smbdes.c b/source4/libcli/util/smbdes.c
index cde77f94a3..e5c4c6f3f1 100644
--- a/source4/libcli/util/smbdes.c
+++ b/source4/libcli/util/smbdes.c
@@ -306,7 +306,7 @@ static void smbhash(unsigned char *out, const unsigned char *in, const unsigned
void E_P16(const unsigned char *p14,unsigned char *p16)
{
- unsigned char sp8[8] = {0x4b, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25};
+ unsigned const char sp8[8] = {0x4b, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25};
smbhash(p16, sp8, p14, 1);
smbhash(p16+8, sp8, p14+7, 1);
}
@@ -341,8 +341,8 @@ void cred_hash1(unsigned char *out, const unsigned char *in, const unsigned char
void cred_hash2(unsigned char *out, const unsigned char *in, const unsigned char *key)
{
unsigned char buf[8];
- static unsigned char key2[8];
-
+ unsigned char key2[8];
+ ZERO_STRUCT(key2);
smbhash(buf, in, key, 1);
key2[0] = key[7];
smbhash(out, buf, key2, 1);
@@ -350,8 +350,8 @@ void cred_hash2(unsigned char *out, const unsigned char *in, const unsigned char
void cred_hash3(unsigned char *out, unsigned char *in, const unsigned char *key, int forw)
{
- static unsigned char key2[8];
-
+ unsigned char key2[8];
+ ZERO_STRUCT(key2);
smbhash(out, in, key, forw);
key2[0] = key[7];
smbhash(out + 8, in + 8, key2, forw);
@@ -359,48 +359,46 @@ void cred_hash3(unsigned char *out, unsigned char *in, const unsigned char *key,
void SamOEMhash( unsigned char *data, const unsigned char *key, int val)
{
- unsigned char s_box[256];
- unsigned char index_i = 0;
- unsigned char index_j = 0;
- unsigned char j = 0;
- int ind;
-
- for (ind = 0; ind < 256; ind++)
- {
- s_box[ind] = (unsigned char)ind;
- }
-
- for( ind = 0; ind < 256; ind++)
- {
- unsigned char tc;
-
- j += (s_box[ind] + key[ind%16]);
-
- tc = s_box[ind];
- s_box[ind] = s_box[j];
- s_box[j] = tc;
- }
- for( ind = 0; ind < val; ind++)
- {
- unsigned char tc;
- unsigned char t;
-
- index_i++;
- index_j += s_box[index_i];
-
- tc = s_box[index_i];
- s_box[index_i] = s_box[index_j];
- s_box[index_j] = tc;
-
- t = s_box[index_i] + s_box[index_j];
- data[ind] = data[ind] ^ s_box[t];
- }
+ unsigned char s_box[256];
+ unsigned char index_i = 0;
+ unsigned char index_j = 0;
+ unsigned char j = 0;
+ int ind;
+
+ for (ind = 0; ind < 256; ind++) {
+ s_box[ind] = (unsigned char)ind;
+ }
+
+ for( ind = 0; ind < 256; ind++) {
+ unsigned char tc;
+
+ j += (s_box[ind] + key[ind%16]);
+
+ tc = s_box[ind];
+ s_box[ind] = s_box[j];
+ s_box[j] = tc;
+ }
+
+ for (ind = 0; ind < val; ind++){
+ unsigned char tc;
+ unsigned char t;
+
+ index_i++;
+ index_j += s_box[index_i];
+
+ tc = s_box[index_i];
+ s_box[index_i] = s_box[index_j];
+ s_box[index_j] = tc;
+
+ t = s_box[index_i] + s_box[index_j];
+ 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];