File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -129,14 +129,25 @@ function CreateNTPassword(const APassword: String; const ANonce: TIdBytes): TIdB
129129 nt_hpw128: TIdBytes;
130130 nt_resp: array [1 ..24 ] of Byte;
131131 LMD4: TIdHashMessageDigest4;
132+ { $IFNDEF STRING_IS_UNICODE}
133+ i: integer;
134+ lPwUnicode: TIdBytes;
135+ { $ENDIF}
132136begin
133137 CheckMD4Permitted;
134138 LMD4 := TIdHashMessageDigest4.Create;
135139 try
136140 { $IFDEF STRING_IS_UNICODE}
137141 nt_hpw128 := LMD4.HashString(APassword, IndyTextEncoding_UTF16LE);
138142 { $ELSE}
139- nt_hpw128 := LMD4.HashBytes(BuildUnicode(APassword));
143+ // RLebeau: TODO - should this use UTF-16 as well? This logic will
144+ // not produce a valid Unicode string if non-ASCII characters are present!
145+ SetLength(lPwUnicode, Length(S) * SizeOf(WideChar));
146+ for i := 0 to Length(S)-1 do begin
147+ lPwUnicode[i*2 ] := Byte(S[i+1 ]);
148+ lPwUnicode[(i*2 )+1 ] := Byte(#0 );
149+ end ;
150+ nt_hpw128 := LMD4.HashBytes(lPwUnicode);
140151 { $ENDIF}
141152 finally
142153 LMD4.Free;
You can’t perform that action at this time.
0 commit comments