Skip to content

Commit 35a5a5f

Browse files
Address DEC issue with auth tag not being generated for GCM mode for empty data cases and streaming methods.
1 parent cc3af2f commit 35a5a5f

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

Source/DECCipherFormats.pas

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,7 @@ procedure TDECFormattedCipher.DoEncodeDecodeStream(const Source, Dest: TStream;
738738
StartPos := Pos;
739739

740740
if DataSize > 0 then
741+
begin
741742
try
742743
if Assigned(OnProgress) then
743744
OnProgress(Max, 0, Started);
@@ -781,6 +782,13 @@ procedure TDECFormattedCipher.DoEncodeDecodeStream(const Source, Dest: TStream;
781782
if Assigned(OnProgress) then
782783
OnProgress(Max, Max, Finished);
783784
end;
785+
end
786+
else
787+
if (FMode = cmGCM) then
788+
begin
789+
Buffer := nil;
790+
CipherProc(Buffer, Buffer, 0);
791+
end;
784792
end;
785793

786794
procedure TDECFormattedCipher.EncodeStream(const Source, Dest: TStream; DataSize: Int64;

Unit Tests/Tests/TestDECCipherModesGCM.pas

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -654,10 +654,6 @@ procedure TestTDECGCM.TestDecodeStream;
654654
begin
655655
ctBytes := TFormat_HexL.Decode(BytesOf(TestDataSet.TestData[i].CT));
656656

657-
// FIXME: Auth tag does not generate for empty CT
658-
if Length(ctBytes) = 0 then
659-
continue;
660-
661657
try
662658

663659

@@ -735,10 +731,6 @@ procedure TestTDECGCM.TestEncodeStream;
735731
begin
736732
ptBytes := TFormat_HexL.Decode(BytesOf(TestDataSet.TestData[i].PT));
737733

738-
// FIXME: Auth tag does not generate for empty PT
739-
if Length(ptBytes) = 0 then
740-
continue;
741-
742734
FCipherAES.Init(BytesOf(TFormat_HexL.Decode(TestDataSet.TestData[i].CryptKey)),
743735
BytesOf(TFormat_HexL.Decode(TestDataSet.TestData[i].InitVector)),
744736
$FF);

0 commit comments

Comments
 (0)