Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed some Keccak testcases #67

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 9 additions & 21 deletions Unit Tests/Tests/TestDECHashSHA3.pas
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,7 @@ procedure TestTHash_SHA3_Base.LoadTestDataFile(FileName : string;
{ TODO :
Problem: here the method from the base class is called instead the
overwritten one from Keccack... }
{ Daniel Marschall 5 May 2024: No, since it is virtual, TestTHash_Keccak_Base.AddLastByteForCodeTest is correctly called }
MsgWithFixup := AddLastByteForKeccakTest('', FinalByteLen);
lDataRow.AddInputVector(MsgWithFixup);
lDataRow.FinalBitLength := FinalByteLen;
Expand Down Expand Up @@ -1755,14 +1756,13 @@ procedure TestTHash_SHA3_Base.AddLastByteForCodeTest(var lDataRow : IHashTest
SHA3InputVector : RawByteString;
LastByteLength : UInt8);
var
LastByteLen : UInt8;
MsgWithFixup : RawByteString;
begin
MsgWithFixup := AddLastByteForKeccakTest(SHA3InputVector, LastByteLen);
MsgWithFixup := AddLastByteForKeccakTest(SHA3InputVector, LastByteLength);
lDataRow.AddInputVector(MsgWithFixup);
lDataRow.FinalBitLength := LastByteLen;
lDataRow.FinalBitLength := LastByteLength;

THash_SHA3Base(FHash).FinalByteLength := LastByteLen;
THash_SHA3Base(FHash).FinalByteLength := LastByteLength;

lDataRow.ExpectedOutputUTFStrTest :=
CalcUnicodeHash(string(TFormat_HexL.Encode(MsgWithFixup)), FHash);
Expand Down Expand Up @@ -1845,11 +1845,11 @@ procedure TestTHash_Keccak_224.SetUp;
lDataRow := FTestData.AddRow;
lDataRow.ExpectedOutput := 'ffbad5da96bad71789330206dc6768ecaeb1b32d' +
'ca6b3301489674ab';
lDataRow.AddInputVector(RawByteString(#$19), 1, 1);
lDataRow.AddInputVector(RawByteString(#$02), 1, 1);
lDataRow.FinalBitLength := 5;
// AddLastByteForCodeTest(lDataRow, #$19, 5);
//exit;
// lDataRow.AddInputVector(RawByteString(#$19), 1, 1);
// lDataRow.AddInputVector(RawByteString(#$02), 1, 1);
// lDataRow.FinalBitLength := 5;
AddLastByteForCodeTest(lDataRow, #$13, 5);

//
//// MsgWithFixup := AddLastByteForKeccakTest(
//// TFormat_HexL.Decode(RawByteString(msg)),
Expand Down Expand Up @@ -2067,29 +2067,20 @@ procedure TestTHash_Keccak_256.SetUp;

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

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

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

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