procedure EncodeCTSx(S,D: PByteArray; Size: Integer);
var
I: Integer;
begin
Dec(Size, FBufferSize);
I := 0;
while I <= Size
do
begin
XORBuffers(S[I], FFeedback[0], FBufferSize, D[I]);
DoEncode(@D[I], @D[I], FBufferSize);
XORBuffers(D[I], FFeedback[0], FBufferSize, FFeedback[0]);
Inc(I, FBufferSize);
end;
Dec(Size, I - FBufferSize);
if Size > 0
then
begin // padding
//EncodeCFS8(@S[I], @D[I], Size); -------original code
MyEncodeCFS8(@S[I], @D[I], Size);
//my modification
FState := csPadded;
end else FState := csEncode;
end;
procedure EncodeCFS8(S,D: PByteArray; Size: Integer);
// CFS-8, CTS as CFB
var
I: Integer;
begin
I := 0;
while I < Size
do
begin
DoEncode(FFeedback, FBuffer, FBufferSize);
D[I] := S[I]
xor FBuffer[0];
Move(FFeedback[1], FFeedback[0], FBufferSize -1);
FFeedback[FBufferSize -1] := FFeedback[FBufferSize -1]
xor D[I];
Inc(I);
end;
FState := csEncode;
end;
procedure MyEncodeCFS8(S,D: PByteArray; Size: Integer);
begin
Move(FFeedback[0], FBuffer[0], FBufferSize);
DoEncode(FBuffer,FBuffer,FBufferSize);
XORBuffers(S[0], FBuffer[0], Size, D[0]);
XORBuffers(FBuffer[0], FFeedback[0], FBufferSize, FFeedback[0]);
FState := csEncode;
end;