File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -5582,7 +5582,6 @@ procedure THash_TestBase.DoTestCalcStreamNoDoneMulti(HashClass: TDECHash);
55825582 ProgressCalled := true;
55835583 end , true);
55845584
5585-
55865585 Hash := HashClass.DigestAsBytes;
55875586
55885587 if (i = FTestData.Count-1 ) then
Original file line number Diff line number Diff line change @@ -151,6 +151,7 @@ TestTHash_SHA3_224 = class(TestTHash_SHA3_Base)
151151 procedure TestIdentity ;
152152 procedure TestFinalByteLength ;
153153 procedure TestFinalByteLengthOverflow ;
154+ procedure TestRegressionDoneCalledTwice ;
154155 end ;
155156
156157 // Test methods for class THash_SHA3_256
@@ -648,6 +649,36 @@ procedure TestTHash_SHA3_224.TestIsPasswordHash;
648649 CheckNotEquals(true, FHash.IsPasswordHash);
649650end ;
650651
652+ procedure TestTHash_SHA3_224.TestRegressionDoneCalledTwice ;
653+ var
654+ Hash : THash_SHA3_224;
655+ Stream : TMemoryStream;
656+ Result : TBytes;
657+ begin
658+ // Regression test for a bug reported by Harry Rogers via private e-mail.
659+ // The failure was that Done raisedn an exception when called after calling
660+ // one of the CalcFile or CalcStream variants which automatically call Done
661+ // at the end.
662+ Hash := THash_SHA3_224.Create;
663+ try
664+ Stream := TMemoryStream.Create;
665+ try
666+ Stream.WriteData($af);
667+ Stream.Seek(0 , TSeekOrigin.soBeginning);
668+
669+ Hash.CalcStream(Stream, 1 , Result, nil );
670+ Hash.Done;
671+
672+ CheckEquals(RawByteString(' 1545e234dd648d51afe85b758f865c4855715cccf276eeb004a37a74' ),
673+ BytesToRawString(TFormat_HEXL.Encode(Result)));
674+ finally
675+ Stream.Free;
676+ end ;
677+ finally
678+ Hash.Free;
679+ end ;
680+ end ;
681+
651682{ TestTHash_SHA3_256 }
652683
653684procedure TestTHash_SHA3_256.ConfigHashClass (HashClass: TDECHash;
You can’t perform that action at this time.
0 commit comments