mirror of
https://github.com/samba-team/samba.git
synced 2024-12-25 23:21:54 +03:00
r7033: Call a spade a spade :-).
Jeremy.
This commit is contained in:
parent
f82dcac25f
commit
f5027f6370
@ -276,7 +276,7 @@ static void str_to_key(const unsigned char *str,unsigned char *key)
|
||||
}
|
||||
|
||||
|
||||
void smbhash(unsigned char *out, const unsigned char *in, const unsigned char *key, int forw)
|
||||
void des_crypt56(unsigned char *out, const unsigned char *in, const unsigned char *key, int forw)
|
||||
{
|
||||
int i;
|
||||
char outb[64];
|
||||
@ -307,35 +307,35 @@ void smbhash(unsigned char *out, const unsigned char *in, const unsigned char *k
|
||||
void E_P16(const unsigned char *p14,unsigned char *p16)
|
||||
{
|
||||
unsigned char sp8[8] = {0x4b, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25};
|
||||
smbhash(p16, sp8, p14, 1);
|
||||
smbhash(p16+8, sp8, p14+7, 1);
|
||||
des_crypt56(p16, sp8, p14, 1);
|
||||
des_crypt56(p16+8, sp8, p14+7, 1);
|
||||
}
|
||||
|
||||
void E_P24(const unsigned char *p21, const unsigned char *c8, unsigned char *p24)
|
||||
{
|
||||
smbhash(p24, c8, p21, 1);
|
||||
smbhash(p24+8, c8, p21+7, 1);
|
||||
smbhash(p24+16, c8, p21+14, 1);
|
||||
des_crypt56(p24, c8, p21, 1);
|
||||
des_crypt56(p24+8, c8, p21+7, 1);
|
||||
des_crypt56(p24+16, c8, p21+14, 1);
|
||||
}
|
||||
|
||||
void D_P16(const unsigned char *p14, const unsigned char *in, unsigned char *out)
|
||||
{
|
||||
smbhash(out, in, p14, 0);
|
||||
smbhash(out+8, in+8, p14+7, 0);
|
||||
des_crypt56(out, in, p14, 0);
|
||||
des_crypt56(out+8, in+8, p14+7, 0);
|
||||
}
|
||||
|
||||
void E_old_pw_hash( unsigned char *p14, const unsigned char *in, unsigned char *out)
|
||||
{
|
||||
smbhash(out, in, p14, 1);
|
||||
smbhash(out+8, in+8, p14+7, 1);
|
||||
des_crypt56(out, in, p14, 1);
|
||||
des_crypt56(out+8, in+8, p14+7, 1);
|
||||
}
|
||||
|
||||
void cred_hash1(unsigned char *out, const unsigned char *in, const unsigned char *key)
|
||||
{
|
||||
unsigned char buf[8];
|
||||
|
||||
smbhash(buf, in, key, 1);
|
||||
smbhash(out, buf, key+9, 1);
|
||||
des_crypt56(buf, in, key, 1);
|
||||
des_crypt56(out, buf, key+9, 1);
|
||||
}
|
||||
|
||||
void cred_hash2(unsigned char *out, const unsigned char *in, const unsigned char *key)
|
||||
@ -343,98 +343,92 @@ void cred_hash2(unsigned char *out, const unsigned char *in, const unsigned char
|
||||
unsigned char buf[8];
|
||||
static unsigned char key2[8];
|
||||
|
||||
smbhash(buf, in, key, 1);
|
||||
des_crypt56(buf, in, key, 1);
|
||||
key2[0] = key[7];
|
||||
smbhash(out, buf, key2, 1);
|
||||
des_crypt56(out, buf, key2, 1);
|
||||
}
|
||||
|
||||
void cred_hash3(unsigned char *out, unsigned char *in, const unsigned char *key, int forw)
|
||||
{
|
||||
static unsigned char key2[8];
|
||||
|
||||
smbhash(out, in, key, forw);
|
||||
des_crypt56(out, in, key, forw);
|
||||
key2[0] = key[7];
|
||||
smbhash(out + 8, in + 8, key2, forw);
|
||||
des_crypt56(out + 8, in + 8, key2, forw);
|
||||
}
|
||||
|
||||
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;
|
||||
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++) {
|
||||
s_box[ind] = (unsigned char)ind;
|
||||
}
|
||||
|
||||
for( ind = 0; ind < 256; ind++)
|
||||
{
|
||||
unsigned char tc;
|
||||
for( ind = 0; ind < 256; ind++) {
|
||||
unsigned char tc;
|
||||
|
||||
j += (s_box[ind] + key[ind%16]);
|
||||
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;
|
||||
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];
|
||||
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;
|
||||
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];
|
||||
}
|
||||
t = s_box[index_i] + s_box[index_j];
|
||||
data[ind] = data[ind] ^ s_box[t];
|
||||
}
|
||||
}
|
||||
|
||||
void SamOEMhashBlob( unsigned char *data, int len, DATA_BLOB *key)
|
||||
{
|
||||
unsigned char s_box[256];
|
||||
unsigned char index_i = 0;
|
||||
unsigned char index_j = 0;
|
||||
unsigned char j = 0;
|
||||
int ind;
|
||||
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++) {
|
||||
s_box[ind] = (unsigned char)ind;
|
||||
}
|
||||
|
||||
for( ind = 0; ind < 256; ind++)
|
||||
{
|
||||
unsigned char tc;
|
||||
for( ind = 0; ind < 256; ind++) {
|
||||
unsigned char tc;
|
||||
|
||||
j += (s_box[ind] + key->data[ind%key->length]);
|
||||
j += (s_box[ind] + key->data[ind%key->length]);
|
||||
|
||||
tc = s_box[ind];
|
||||
s_box[ind] = s_box[j];
|
||||
s_box[j] = tc;
|
||||
}
|
||||
for( ind = 0; ind < len; ind++)
|
||||
{
|
||||
unsigned char tc;
|
||||
unsigned char t;
|
||||
tc = s_box[ind];
|
||||
s_box[ind] = s_box[j];
|
||||
s_box[j] = tc;
|
||||
}
|
||||
for( ind = 0; ind < len; ind++) {
|
||||
unsigned char tc;
|
||||
unsigned char t;
|
||||
|
||||
index_i++;
|
||||
index_j += s_box[index_i];
|
||||
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;
|
||||
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];
|
||||
}
|
||||
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
|
||||
@ -450,6 +444,6 @@ void sam_pwd_hash(unsigned int rid, const uchar *in, uchar *out, int forw)
|
||||
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);
|
||||
des_crypt56(out, in, s, forw);
|
||||
des_crypt56(out+8, in+8, s+7, forw);
|
||||
}
|
||||
|
@ -578,7 +578,7 @@ void sess_crypt_blob(DATA_BLOB *out, const DATA_BLOB *in, const DATA_BLOB *sessi
|
||||
}
|
||||
memcpy(key, &session_key->data[k], 7);
|
||||
|
||||
smbhash(bout, bin, key, forward?1:0);
|
||||
des_crypt56(bout, bin, key, forward?1:0);
|
||||
|
||||
memcpy(&out->data[i], bout, MIN(8, in->length-i));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user