summaryrefslogtreecommitdiff
path: root/source3/libsmb
diff options
context:
space:
mode:
Diffstat (limited to 'source3/libsmb')
-rw-r--r--source3/libsmb/clientgen.c23
-rw-r--r--source3/libsmb/smbencrypt.c23
2 files changed, 28 insertions, 18 deletions
diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c
index 025ec5e73f..72d7ca935b 100644
--- a/source3/libsmb/clientgen.c
+++ b/source3/libsmb/clientgen.c
@@ -2021,7 +2021,6 @@ BOOL cli_oem_change_password(struct cli_state *cli, char *user, char *new_passwo
unsigned char new_pw_hash[16];
int data_len;
int param_len = 0;
- int new_pw_len = strlen(new_password);
char *rparam = NULL;
char *rdata = NULL;
int rprcnt, rdrcnt;
@@ -2031,11 +2030,6 @@ BOOL cli_oem_change_password(struct cli_state *cli, char *user, char *new_passwo
return False;
}
- if (new_pw_len > 512) {
- DEBUG(0,("cli_oem_change_password: new password for user %s is too long.\n", user));
- return False;
- }
-
SSVAL(p,0,214); /* SamOEMChangePassword command. */
p += 2;
pstrcpy(p, "zsT");
@@ -2050,25 +2044,18 @@ BOOL cli_oem_change_password(struct cli_state *cli, char *user, char *new_passwo
param_len = PTR_DIFF(p,param);
/*
- * Now setup the data area.
- * We need to generate a random fill
- * for this area to make it harder to
- * decrypt. JRA.
- */
- generate_random_buffer((unsigned char *)data, sizeof(data), False);
- fstrcpy( &data[512 - new_pw_len], new_password);
- SIVAL(data, 512, new_pw_len);
-
- /*
* Get the Lanman hash of the old password, we
- * use this as the key to SamOEMHash().
+ * use this as the key to make_oem_passwd_hash().
*/
memset(upper_case_old_pw, '\0', sizeof(upper_case_old_pw));
fstrcpy(upper_case_old_pw, old_password);
strupper(upper_case_old_pw);
E_P16((uchar *)upper_case_old_pw, old_pw_hash);
- SamOEMhash( (unsigned char *)data, (unsigned char *)old_pw_hash, True);
+ if (!make_oem_passwd_hash( data, new_password, old_pw_hash))
+ {
+ return False;
+ }
/*
* Now place the old password hash in the data.
diff --git a/source3/libsmb/smbencrypt.c b/source3/libsmb/smbencrypt.c
index a9e680ccdd..27c19d5836 100644
--- a/source3/libsmb/smbencrypt.c
+++ b/source3/libsmb/smbencrypt.c
@@ -191,3 +191,26 @@ void SMBNTencrypt(uchar *passwd, uchar *c8, uchar *p24)
}
+BOOL make_oem_passwd_hash(char data[516], char *passwd, char old_pw_hash[16])
+{
+ int new_pw_len = strlen(passwd);
+
+ if (new_pw_len > 512)
+ {
+ DEBUG(0,("make_oem_passwd_hash: new password is too long.\n"));
+ return False;
+ }
+
+ /*
+ * Now setup the data area.
+ * We need to generate a random fill
+ * for this area to make it harder to
+ * decrypt. JRA.
+ */
+ generate_random_buffer((unsigned char *)data, 516, False);
+ fstrcpy( &data[512 - new_pw_len], passwd);
+ SIVAL(data, 512, new_pw_len);
+
+ SamOEMhash( (unsigned char *)data, (unsigned char *)old_pw_hash, True);
+}
+