/*The following definitions come from libsmb/smbdes.c */
+void smbhash(unsigned char *out, unsigned char *in, unsigned char *key, int forw);
void E_P16(unsigned char *p14,unsigned char *p16);
void E_P24(unsigned char *p21, unsigned char *c8, unsigned char *p24);
void D_P16(unsigned char *p14, unsigned char *in, unsigned char *out);
void NTLMSSPOWFencrypt(uchar passwd[8], uchar *ntlmchalresp, uchar p24[24]);
void SMBNTencrypt(uchar *passwd, uchar *c8, uchar *p24);
BOOL make_oem_passwd_hash(char data[516], const char *passwd, uchar old_pw_hash[16], BOOL unicode);
+int nt_decrypt_string2(STRING2 *out, STRING2 *in, char nt_hash[16]);
/*The following definitions come from libsmb/smberr.c */
POLICY_HND *hnd_pol, char *secret_name, uint32 des_access,
POLICY_HND *hnd_secret);
BOOL lsa_query_secret(struct cli_state *cli, uint16 fnum,
- POLICY_HND *pol, unsigned char secret[24],
- NTTIME *lastupdate);
+ POLICY_HND *pol, STRING2 *enc_secret,
+ NTTIME *last_update);
BOOL lsa_lookup_names(struct cli_state *cli, uint16 fnum,
POLICY_HND *hnd,
int num_names,
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;
+}