Skip to content

Keccak256 and SHA3 crash when input is 0 length #652

Closed
@akovachev

Description

Keccak256 and SHA3 not working as intended

  • State the operating system and version (Ubutnu 17 x86_64, Windows 7 Professional x64, etc)
    Mac OS

  • State the version of the Crypto++ library (Crypto++ 5.6.5, Master, etc)
    Crypto++ 7.0.0

  • State how you built the library (Makefile, Cmake, distro, etc)
    Bazel

  • Show a typical command line (the output of the compiler for cryptlib.cpp)

  • Show the link command (the output of the linker for libcryptopp.so or cryptest.exe)

  • Show the exact error message you are receiving (copy and paste it); or

Assertion failed: external/cryptopp/keccak.cpp(255): Update
Trace/BPT trap: 5
Assertion failed: external/cryptopp/sha3.cpp(254): Update
Trace/BPT trap: 5
  • Clearly state the undesired behavior (and state the expected behavior)

Both SHA3 and Keccak256 have valid test vectors with 0-length input as follows:

SHA3("") = A7FFC6F8BF1ED76651C14756A061D662F580FF4DE43B49FA82D80A4B80F8434A
Keccak256("") = C5D2460186F7233C927E7DB2DCC703C0E500B653CA82273B7BFAD8045D85A470

Please note that when compiled in release test vectors succeed, however in debug the assert added due to some vulnerability is changing the behavior of these two functions.

Looking at the history I see that the asserts were added due to some vulnerability listed here:
399a154

Commit was made by @noloader

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions