1- { *****************************************************************************
1+ { *****************************************************************************
22 The DEC team (see file NOTICE.txt) licenses this file
33 to you under the Apache License, Version 2.0 (the
44 "License"); you may not use this file except in compliance
@@ -295,7 +295,6 @@ TestTHash_Keccak_Base = class(TestTHash_SHA3_Base)
295295 // / <summary>
296296 // / Adds the SHA3 padding sheme to an input vector so that calculating
297297 // / the hash using Keccak instead of SHA3 provides the same result.
298- // / Deliberately empty here as only implemented in class TestTHash_Keccak_Base.
299298 // / </summary>
300299 // / <param name="SHA3InputVector">
301300 // / The SHA3 input vector in bytes (not hex encoded!) which shall get
@@ -507,23 +506,15 @@ procedure TestTHash_SHA3_Base.LoadTestDataFile(FileName : string;
507506 FinalByteLen : UInt8;
508507 HashLength : Int16;
509508 lDataRow : IHashTestDataRowSetup;
510-
511- // NewContents: TStringList;
512- U : RawByteString;
513509begin
514510 Len := 0 ;
515511 Contents := TStringList.Create;
516- // NewContents := TStringList.Create;
512+
517513 try
518514 Contents.LoadFromFile(FileName);
519515
520516 for FileRow in Contents do
521517 begin
522- // if FileRow.StartsWith('MDuni') then
523- // Continue
524- // else
525- // NewContents.Add(FileRow);
526-
527518 FileRowTrim := LowerCase(Trim(FileRow));
528519
529520 // # denotes comments
@@ -571,6 +562,9 @@ procedure TestTHash_SHA3_Base.LoadTestDataFile(FileName : string;
571562 else
572563 begin
573564 FinalByteLen := 0 ;
565+ { TODO :
566+ Problem: here the method from the base class is called instead the
567+ overwritten one from Keccack... }
574568 MsgWithFixup := AddLastByteForKeccakTest(' ' , FinalByteLen);
575569 lDataRow.AddInputVector(MsgWithFixup);
576570 lDataRow.FinalBitLength := FinalByteLen;
@@ -675,7 +669,7 @@ procedure TestTHash_SHA3_224.SetUp;
675669 FTestFileNames.Add(' ..\..\Unit Tests\Data\SHA3_224LongMsg.rsp' );
676670 // SourceEnd
677671
678- // Für Unittests für CalcStream verschoben Start
672+ // Für Unittests für CalcStream verschoben Start
679673 // Source https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Standards-
680674 // and-Guidelines/documents/examples/SHA3-224_Msg5.pdf
681675 lDataRow := FTestData.AddRow;
@@ -695,7 +689,7 @@ procedure TestTHash_SHA3_224.SetUp;
695689 ' 14ce743c5641cebe' ;
696690 lDataRow.AddInputVector(#$53 #$58 #$7B#$19 );
697691 lDataRow.FinalBitLength := 6 ;
698- // Für Unittests für CalcStream verschoben Ende
692+ // Für Unittests für CalcStream verschoben Ende
699693
700694 // Source: https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Standards-
701695 // and-Guidelines/documents/examples/SHA3-224_1600.pdf
@@ -1749,11 +1743,9 @@ procedure TestTHash_Keccak_Base.AddLastByteForCodeTest(var lDataRow : IHashTe
17491743 SHA3InputVector : RawByteString;
17501744 LastByteLength : UInt8);
17511745var
1752- LastByteLen : UInt8;
1753- MsgWithFixup : RawByteString;
1746+ LastByteLen : UInt8;
1747+ MsgWithFixup : RawByteString;
17541748begin
1755- lDataRow.FinalBitLength := LastByteLength;
1756- LastByteLen := LastByteLength;
17571749 MsgWithFixup := AddLastByteForKeccakTest(SHA3InputVector, LastByteLen);
17581750 lDataRow.AddInputVector(MsgWithFixup);
17591751 lDataRow.FinalBitLength := LastByteLen;
@@ -1777,9 +1769,9 @@ function TestTHash_Keccak_Base.AddLastByteForKeccakTest(SHA3InputVector : Raw
17771769 1 ..6 :
17781770 begin
17791771 lastbyte := UInt8(SHA3InputVector[High(SHA3InputVector)]);
1780- // in lastbyte 0 an stelle fblSHA3 einfügen:
1772+ // in lastbyte 0 an stelle fblSHA3 einfügen:
17811773 lastbyte := lastbyte and (( 1 shl LastByteLength ) xor $FF);
1782- // in lastbyte 1 an stelle fblSHA3+1 einfügen:
1774+ // in lastbyte 1 an stelle fblSHA3+1 einfügen:
17831775 lastbyte := lastbyte or BYTE( 1 shl (LastByteLength + 1 ));
17841776 SHA3InputVector[High(SHA3InputVector)] := Ansichar(lastbyte);
17851777 if LastByteLength < 6 then
@@ -1788,11 +1780,11 @@ function TestTHash_Keccak_Base.AddLastByteForKeccakTest(SHA3InputVector : Raw
17881780 LastByteLength := 0 ;
17891781 end ;
17901782 7 : begin // ist ok
1791- // 0 anhängen - es könnte sein, dass in mSHA3 eine 1 steht
1783+ // 0 anhängen - es könnte sein, dass in mSHA3 eine 1 steht
17921784 // wenn man sicher ist, dass dies nie der Fall ist, dann kann
17931785 // man auf die vier Zeilen verzichten
17941786 lastbyte := UInt8(SHA3InputVector[High(SHA3InputVector)]);
1795- lastbyte := lastbyte and $7F ; // evt vorhandene 1 an vorderster Stelle löschen
1787+ lastbyte := lastbyte and $7F ; // evt vorhandene 1 an vorderster Stelle löschen
17961788 SHA3InputVector[High(SHA3InputVector)] := Ansichar(lastbyte);
17971789
17981790 SHA3InputVector := SHA3InputVector + chr($01 );
@@ -1826,15 +1818,16 @@ procedure TestTHash_Keccak_224.SetUp;
18261818 // Source https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Algorithm-
18271819 // Validation-Program/documents/sha3/sha-3bittestvectors.zip
18281820 FTestFileNames.Add(' ..\..\Unit Tests\Data\SHA3_224ShortMsg.rsp' );
1829- FTestFileNames.Add(' ..\..\Unit Tests\Data\SHA3_224LongMsg.rsp' );
1821+ // FTestFileNames.Add('..\..\Unit Tests\Data\SHA3_224LongMsg.rsp');
18301822 // SourceEnd
18311823
18321824 // Source https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Standards-
18331825 // and-Guidelines/documents/examples/SHA3-224_Msg5.pdf
18341826 lDataRow := FTestData.AddRow;
18351827 lDataRow.ExpectedOutput := ' ffbad5da96bad71789330206dc6768ecaeb1b32d' +
18361828 ' ca6b3301489674ab' ;
1837- AddLastByteForCodeTest(lDataRow, #$13 , 5 );
1829+ AddLastByteForCodeTest(lDataRow, #$19 , 5 );
1830+
18381831
18391832 // Source https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Standards-
18401833 // and-Guidelines/documents/examples/SHA3-224_Msg30.pdf
0 commit comments