@@ -784,7 +784,7 @@ procedure TDECFormattedCipher.DoEncodeDecodeStream(const Source, Dest: TStream;
784
784
StartPos := Pos;
785
785
doPadding := false;
786
786
doStartOnlyPadding := (DataSize = 0 ) and IsEncode and
787
- (FPaddingMode in [pmPKCS5, pmPKCS7] );
787
+ (FPaddingMode <> pmNone );
788
788
789
789
if (DataSize > 0 ) or doStartOnlyPadding then
790
790
begin
@@ -817,7 +817,7 @@ procedure TDECFormattedCipher.DoEncodeDecodeStream(const Source, Dest: TStream;
817
817
doAdjustBuffer := Bytes > DataSize;
818
818
Bytes := DataSize;
819
819
// Handle padding mode
820
- doPadding := FPaddingMode <> pmNone;
820
+ doPadding := ( FPaddingMode <> pmNone) and assigned(FPaddingCLass) ;
821
821
if doPadding and doAdjustBuffer then
822
822
if IsEncode then
823
823
begin
@@ -836,9 +836,7 @@ procedure TDECFormattedCipher.DoEncodeDecodeStream(const Source, Dest: TStream;
836
836
837
837
if IsEncode and doPadding then
838
838
begin
839
- if not (FPaddingCLass = nil ) then
840
- Buffer := FPaddingClass.AddPadding(Buffer, Context.BlockSize);
841
-
839
+ Buffer := FPaddingClass.AddPadding(Buffer, Context.BlockSize);
842
840
Bytes := length(Buffer);
843
841
SetLength(outBuffer, length(Buffer));
844
842
end ;
@@ -847,9 +845,7 @@ procedure TDECFormattedCipher.DoEncodeDecodeStream(const Source, Dest: TStream;
847
845
CipherProc(Buffer[0 ], outBuffer[0 ], Bytes);
848
846
if not IsEncode and doPadding then
849
847
begin
850
- if not (FPaddingCLass = nil ) then
851
- outBuffer := FPaddingCLass.RemovePadding(outBuffer, Context.BlockSize);
852
-
848
+ outBuffer := FPaddingCLass.RemovePadding(outBuffer, Context.BlockSize);
853
849
Bytes := length(outBuffer);
854
850
end ;
855
851
if Bytes > 0 then
@@ -1034,7 +1030,7 @@ function TDECFormattedCipher.DecodeStringToBytes(const Source: RawByteString; Fo
1034
1030
SetLength(Result, 0 );
1035
1031
1036
1032
if not (FPaddingCLass = nil ) then
1037
- Result := FpaddingClass .RemovePadding(Result, Context.BlockSize);
1033
+ Result := FPaddingClass .RemovePadding(Result, Context.BlockSize);
1038
1034
end ;
1039
1035
1040
1036
{ $IFDEF ANSISTRINGSUPPORTED}
0 commit comments