Compare commits

..

2 Commits

Author SHA1 Message Date
Eric 469aae80dc
Merge pull request #8 from GabrielF7/master
Adding explicit typecast to DWord to avoid overflow assertion error
2019-03-01 09:34:03 -08:00
Gabriel Frones f295a07cd3 Adding explicit typecast to DWord to avoid overflow assertion error (I was having problems with debugger) 2018-09-27 23:32:02 -03:00
1 changed files with 4 additions and 6 deletions

View File

@ -486,7 +486,6 @@ begin
end; end;
end; { TBCryptHash.EKSKey } end; { TBCryptHash.EKSKey }
{$OVERFLOWCHECKS OFF}
procedure TBCryptHash.Encipher(var lr: array of DWord; const offset: SizeInt); procedure TBCryptHash.Encipher(var lr: array of DWord; const offset: SizeInt);
var var
i, n, block, r: DWord; i, n, block, r: DWord;
@ -498,23 +497,22 @@ begin
while i <= BLOWFISH_NUM_ROUNDS - 1 do while i <= BLOWFISH_NUM_ROUNDS - 1 do
begin begin
n := FSBox[(block shr 24) and $FF]; n := FSBox[(block shr 24) and $FF];
n := n + FSBox[$100 or ((block shr 16) and $FF)]; n := DWord(n + FSBox[$100 or ((block shr 16) and $FF)]);
n := n xor FSBox[$200 or ((block shr 8) and $FF)]; n := n xor FSBox[$200 or ((block shr 8) and $FF)];
n := n + FSBox[$300 or (block and $FF)]; n := DWord(n + FSBox[$300 or (block and $FF)]);
r := r xor (n xor FPBox[i]); r := r xor (n xor FPBox[i]);
Inc(i); Inc(i);
n := FSBox[(r shr 24) and $FF]; n := FSBox[(r shr 24) and $FF];
n := n + FSBox[$100 or ((r shr 16) and $FF)]; n := DWord(n + FSBox[$100 or ((r shr 16) and $FF)]);
n := n xor FSBox[$200 or ((r shr 8) and $FF)]; n := n xor FSBox[$200 or ((r shr 8) and $FF)];
n := n + FSBox[$300 or (r and $FF)]; n := DWord(n + FSBox[$300 or (r and $FF)]);
block := block xor (n xor FPBox[i]); block := block xor (n xor FPBox[i]);
Inc(i); Inc(i);
end; end;
lr[offset] := r xor FPBox[BLOWFISH_NUM_ROUNDS + 1]; lr[offset] := r xor FPBox[BLOWFISH_NUM_ROUNDS + 1];
lr[offset + 1] := block; lr[offset + 1] := block;
end; end;
{$OVERFLOWCHECKS ON}
function TBCryptHash.FormatPasswordHash(const Salt, Hash: TBytes; Cost : Byte; HashType : THashTypes): AnsiString; function TBCryptHash.FormatPasswordHash(const Salt, Hash: TBytes; Cost : Byte; HashType : THashTypes): AnsiString;
var var