TL;DR;
What just jump into my eye is this, cant this be written more efficient?
Delphi-Quellcode:
class function TDECPaddingCommon.CalculatePaddingLength(DataLength, BlockSize, MinLength: Integer): Integer;
begin
if (MinLength < 0) or (DataLength < 0) or (BlockSize < 0) or (MinLength or BlockSize = 0) then
begin
...
like so
Delphi-Quellcode:
class function TDECPaddingCommon.CalculatePaddingLength(DataLength, BlockSize, MinLength: Integer): Integer;
begin
if (MinLength <= 0) or (DataLength <= 0) or (BlockSize <= 0) then
begin
...
Not sure is there is any hidden math trick behind that logic, have not thought too deep into it ...
Simple, none of these can be negative but all can be zero, with only one condition that MinLength and BlockSize can't be zero at the same time.