Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus Humm committed Dec 14, 2020
2 parents b84d1da + 211b2ad commit fad7287
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 19 deletions.
4 changes: 2 additions & 2 deletions Demos/Cipher_FMX/MainForm.pas
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,8 @@ procedure TMainForm.ComboBoxCipherAlgorithmChange(Sender: TObject);
StringGridContext.Cells[1, 0] := (Context.KeySize*8).ToString;
StringGridContext.Cells[1, 1] := (Context.BlockSize*8).ToString;
StringGridContext.Cells[1, 2] := (Context.BufferSize*8).ToString;
StringGridContext.Cells[1, 3] := (Context.UserSize*8).ToString;
StringGridContext.Cells[1, 4] := BoolToStr(Context.UserSave, true);
StringGridContext.Cells[1, 3] := (Context.AdditionalBufferSize*8).ToString;
StringGridContext.Cells[1, 4] := BoolToStr(Context.NeedsAdditionalBufferBackup, true);

if ctBlock in Context.CipherType then
StringGridContext.Cells[1, 5] := 'block cipher'
Expand Down
1 change: 1 addition & 0 deletions Demos/Format_Console/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/__history/
/Win32/
/Format_Console.identcache
/__recovery/
3 changes: 3 additions & 0 deletions Demos/Random_Console/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/Random_Console.identcache
/__history/
/__recovery/
10 changes: 5 additions & 5 deletions Source/DECCipherBase.pas
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ TDECCipherClass = class of TDECCipher;
TDECCipher = class(TDECObject)
strict private
/// <summary>
/// This is the complete memory block containing FVector, FFeedback, FBuffer
/// and FUser
/// This is the complete memory block containing FInitializationVector,
/// FFeedback, FBuffer and FAdditionalBuffer
/// </summary>
FData : PByteArray;
/// <summary>
Expand Down Expand Up @@ -759,7 +759,7 @@ constructor TDECCipher.Create;
FAdditionalBuffer := @FBuffer[FBufferSize];

if MustAdditionalBufferSave then
// buffer contents: FData, then FUser then FUserSave
// buffer contents: FData, then FFeedback, then FBuffer then FAdditionalBuffer
FAdditionalBufferBackup := @PByteArray(FAdditionalBuffer)[FAdditionalBufferSize]
else
FAdditionalBufferBackup := nil;
Expand Down Expand Up @@ -832,15 +832,15 @@ procedure TDECCipher.Init(const Key; Size: Integer; const IVector; IVectorSize:

DoInit(Key, Size);
if FAdditionalBufferBackup <> nil then
// create backup of FUser
// create backup of FBuffer
Move(FAdditionalBuffer^, FAdditionalBufferBackup^, FAdditionalBufferSize);

FillChar(FInitializationVector^, FBufferSize, IFiller);
if IVectorSize = 0 then
begin
DoEncode(FInitializationVector, FInitializationVector, FBufferSize);
if FAdditionalBufferBackup <> nil then
// Restore backup fo FUser
// Restore backup fo FBuffer
Move(FAdditionalBufferBackup^, FAdditionalBuffer^, FAdditionalBufferSize);
end
else
Expand Down
22 changes: 11 additions & 11 deletions Source/DECCiphers.pas
Original file line number Diff line number Diff line change
Expand Up @@ -974,8 +974,8 @@ procedure TCipher_Blowfish.DoEncode(Source, Dest: Pointer; Size: Integer);
Assert(Size = Context.BlockSize, 'Size of ' + IntToStr(Size) + ' does not equal '+
'block size of ' + IntToStr(Context.BlockSize));

D := FUser;
P := Pointer(PByte(FUser) + SizeOf(Blowfish_Data)); // for Pointer Math
D := FBuffer;
P := Pointer(PByte(FBuffer) + SizeOf(Blowfish_Data)); // for Pointer Math
A := SwapUInt32(PUInt32Array(Source)[0]) xor P[0]; P := @P[1];
B := SwapUInt32(PUInt32Array(Source)[1]);
for I := 0 to 7 do
Expand Down Expand Up @@ -1048,8 +1048,8 @@ procedure TCipher_Blowfish.DoDecode(Source, Dest: Pointer; Size: Integer);
begin
Assert(Size = Context.BlockSize);

D := FUser;
P := Pointer(PByte(FUser) + SizeOf(Blowfish_Data) + SizeOf(Blowfish_Key) - SizeOf(Int32));
D := FBuffer;
P := Pointer(PByte(FBuffer) + SizeOf(Blowfish_Data) + SizeOf(Blowfish_Key) - SizeOf(Int32));
A := SwapUInt32(PUInt32Array(Source)[0]) xor P[0];
B := SwapUInt32(PUInt32Array(Source)[1]);
for I := 0 to 7 do
Expand Down Expand Up @@ -2424,7 +2424,7 @@ procedure TCipher_RC6.DoEncode(Source, Dest: Pointer; Size: Integer);
begin
Assert(Size = Context.BlockSize);

K := FUser;
K := FBuffer;
A := PUInt32Array(Source)[0];
B := PUInt32Array(Source)[1] + K[0];
C := PUInt32Array(Source)[2];
Expand Down Expand Up @@ -2507,7 +2507,7 @@ procedure TCipher_RC6.DoDecode(Source, Dest: Pointer; Size: Integer);
begin
Assert(Size = Context.BlockSize);

K := @PUInt32Array(FUser)[FRounds * 2];
K := @PUInt32Array(FBuffer)[FRounds * 2];
A := PUInt32Array(Source)[0] - K[2];
B := PUInt32Array(Source)[1];
C := PUInt32Array(Source)[2] - K[3];
Expand Down Expand Up @@ -2574,7 +2574,7 @@ procedure TCipher_Rijndael.DoInit(const Key; Size: Integer);
begin
while (J < FRounds - 6) and (T < Rijndael_Blocks) do
begin
PUInt32Array(FUser)[R * Rijndael_Blocks + T] := K[J];
PUInt32Array(FBuffer)[R * Rijndael_Blocks + T] := K[J];
Inc(J);
Inc(T);
end;
Expand Down Expand Up @@ -2627,8 +2627,8 @@ procedure TCipher_Rijndael.DoInit(const Key; Size: Integer);
I: Integer;
D: PUInt32;
begin
D := Pointer(PAnsiChar(FUser) + FUserSize shr 1); // for Pointer Math
Move(FUser^, D^, FUserSize shr 1);
D := Pointer(PAnsiChar(FBuffer) + FBufferSize shr 1); // for Pointer Math
Move(FBuffer^, D^, FBufferSize shr 1);
Inc(D, 4);
for I := 0 to FRounds * 4 - 5 do
begin
Expand Down Expand Up @@ -4723,7 +4723,7 @@ procedure TCipher_Q128.DoEncode(Source, Dest: Pointer; Size: Integer);
begin
Assert(Size = Context.BlockSize);

D := FUser;
D := FBuffer;
B0 := PUInt32Array(Source)[0];
B1 := PUInt32Array(Source)[1];
B2 := PUInt32Array(Source)[2];
Expand Down Expand Up @@ -4802,7 +4802,7 @@ procedure TCipher_Q128.DoDecode(Source, Dest: Pointer; Size: Integer);
begin
Assert(Size = Context.BlockSize);

D := @PUInt32Array(FUser)[60];
D := @PUInt32Array(FBuffer)[60];
B0 := PUInt32Array(Source)[0];
B1 := PUInt32Array(Source)[1];
B2 := PUInt32Array(Source)[2];
Expand Down
2 changes: 1 addition & 1 deletion Source/DECOptions.inc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

{$UNDEF OLD_SHA_NAME}
{$UNDEF OLD_WHIRLPOOL_NAMES}
//{$UNDEF AUTO_PRNG}
{$UNDEF AUTO_PRNG}
{$UNDEF DEC52_IDENTITY}
{$UNDEF DEC3_CMCTS}

Expand Down
1 change: 1 addition & 0 deletions Unit Tests/Tests/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/__history/
/__recovery/

0 comments on commit fad7287

Please sign in to comment.