Skip to content

Commit 2e8d2ec

Browse files
Fixed Keccak testcases
All test cases except the Unicode test case are working now. #65
1 parent 8d37cac commit 2e8d2ec

File tree

1 file changed

+9
-21
lines changed

1 file changed

+9
-21
lines changed

Unit Tests/Tests/TestDECHashSHA3.pas

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,7 @@ procedure TestTHash_SHA3_Base.LoadTestDataFile(FileName : string;
571571
{ TODO :
572572
Problem: here the method from the base class is called instead the
573573
overwritten one from Keccack... }
574+
{ Daniel Marschall 5 May 2024: No, since it is virtual, TestTHash_Keccak_Base.AddLastByteForCodeTest is correctly called }
574575
MsgWithFixup := AddLastByteForKeccakTest('', FinalByteLen);
575576
lDataRow.AddInputVector(MsgWithFixup);
576577
lDataRow.FinalBitLength := FinalByteLen;
@@ -1755,14 +1756,13 @@ procedure TestTHash_SHA3_Base.AddLastByteForCodeTest(var lDataRow : IHashTest
17551756
SHA3InputVector : RawByteString;
17561757
LastByteLength : UInt8);
17571758
var
1758-
LastByteLen : UInt8;
17591759
MsgWithFixup : RawByteString;
17601760
begin
1761-
MsgWithFixup := AddLastByteForKeccakTest(SHA3InputVector, LastByteLen);
1761+
MsgWithFixup := AddLastByteForKeccakTest(SHA3InputVector, LastByteLength);
17621762
lDataRow.AddInputVector(MsgWithFixup);
1763-
lDataRow.FinalBitLength := LastByteLen;
1763+
lDataRow.FinalBitLength := LastByteLength;
17641764

1765-
THash_SHA3Base(FHash).FinalByteLength := LastByteLen;
1765+
THash_SHA3Base(FHash).FinalByteLength := LastByteLength;
17661766

17671767
lDataRow.ExpectedOutputUTFStrTest :=
17681768
CalcUnicodeHash(string(TFormat_HexL.Encode(MsgWithFixup)), FHash);
@@ -1845,11 +1845,11 @@ procedure TestTHash_Keccak_224.SetUp;
18451845
lDataRow := FTestData.AddRow;
18461846
lDataRow.ExpectedOutput := 'ffbad5da96bad71789330206dc6768ecaeb1b32d' +
18471847
'ca6b3301489674ab';
1848-
lDataRow.AddInputVector(RawByteString(#$19), 1, 1);
1849-
lDataRow.AddInputVector(RawByteString(#$02), 1, 1);
1850-
lDataRow.FinalBitLength := 5;
1851-
// AddLastByteForCodeTest(lDataRow, #$19, 5);
1852-
//exit;
1848+
// lDataRow.AddInputVector(RawByteString(#$19), 1, 1);
1849+
// lDataRow.AddInputVector(RawByteString(#$02), 1, 1);
1850+
// lDataRow.FinalBitLength := 5;
1851+
AddLastByteForCodeTest(lDataRow, #$13, 5);
1852+
18531853
//
18541854
//// MsgWithFixup := AddLastByteForKeccakTest(
18551855
//// TFormat_HexL.Decode(RawByteString(msg)),
@@ -2067,29 +2067,20 @@ procedure TestTHash_Keccak_256.SetUp;
20672067

20682068
// Source https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Standards-
20692069
// and-Guidelines/documents/examples/SHA3-256_Msg5.pdf
2070-
// TODO:
2071-
// expected: <7b0047cf5a456882363cbf0fb05322cf65f4b7059a46365e830132e3b5d957af>
2072-
// but was: <1594a22d1e1dd176e6f35ae26d8efa294589e23676e1fdc917423a1282546528>
20732070
lDataRow := FTestData.AddRow;
20742071
lDataRow.ExpectedOutput := '7b0047cf5a456882363cbf0fb05322cf65f4b705' +
20752072
'9a46365e830132e3b5d957af';
20762073
AddLastByteForCodeTest(lDataRow, #$13, 5);
20772074

20782075
// Source https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Standards-
20792076
// and-Guidelines/documents/examples/SHA3-256_Msg30.pdf
2080-
// TODO:
2081-
// expected: <c8242fef409e5ae9d1f1c857ae4dc624b92b19809f62aa8c07411c54a078b1d0>
2082-
// but was: <ce8c2109c14e5416785a205f34316b50fa11993fac9c7236c643cb5e7b00afbd>
20832077
lDataRow := FTestData.AddRow;
20842078
lDataRow.ExpectedOutput := 'c8242fef409e5ae9d1f1c857ae4dc624b92b1980' +
20852079
'9f62aa8c07411c54a078b1d0';
20862080
AddLastByteForCodeTest(lDataRow, #$53#$58#$7B#$19, 30 mod 8);
20872081

20882082
// Source https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Standards-
20892083
// and-Guidelines/documents/examples/SHA3-256_Msg1605.pdf
2090-
// TODO:
2091-
// expected: <81ee769bed0950862b1ddded2e84aaa6ab7bfdd3ceaa471be31163d40336363c>
2092-
// but was: <ffc38f204f021c3adf97c55e0d453904749b6ad71c15612f60d018e946d00c24>
20932084
lDataRow := FTestData.AddRow;
20942085
lDataRow.ExpectedOutput := '81ee769bed0950862b1ddded2e84aaa6ab7bfdd3' +
20952086
'ceaa471be31163d40336363c';
@@ -2118,9 +2109,6 @@ procedure TestTHash_Keccak_256.SetUp;
21182109

21192110
// Source https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Standards-
21202111
// and-Guidelines/documents/examples/SHA3-256_1630.pdf
2121-
// TODO:
2122-
// expected: <52860aa301214c610d922a6b6cab981ccd06012e54ef689d744021e738b9ed20>
2123-
// but was: <96eb974c5cfdfc80fe2e8b0203652998827cda5b8ecd2a99ab90e653ed1eacc1>
21242112
lDataRow := FTestData.AddRow;
21252113
lDataRow.ExpectedOutput := '52860aa301214c610d922a6b6cab981ccd06012e' +
21262114
'54ef689d744021e738b9ed20';

0 commit comments

Comments
 (0)