Skip to content

Fix MD2 rounds validation#2526

Open
marko1olo wants to merge 1 commit into
gchq:masterfrom
marko1olo:fix-md2-rounds-validation
Open

Fix MD2 rounds validation#2526
marko1olo wants to merge 1 commit into
gchq:masterfrom
marko1olo:fix-md2-rounds-validation

Conversation

@marko1olo

Copy link
Copy Markdown

Fixes #2506.

Summary

  • Validate the MD2 rounds option before invoking the hash implementation.
  • Reject negative and fractional round counts with an OperationError instead of producing invalid output.
  • Add regression coverage for negative and fractional MD2 rounds.

Tests

  • node --no-warnings --no-deprecation --openssl-legacy-provider tests/operations/index.mjs
  • npx eslint src/core/operations/MD2.mjs tests/operations/tests/Hash.mjs
  • npx grunt configTests
  • git diff --check

This change was prepared with OpenAI Codex.

Reject negative and fractional MD2 round counts before passing the option into the hash implementation. This prevents negative rounds from producing an all-zero digest while preserving zero and positive integer round counts.

Co-authored-by: OpenAI Codex <codex@openai.com>
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@GCHQDeveloper581

Copy link
Copy Markdown
Contributor

Please could you sign the CLA as we are unable to accept contributions unless this is done (applies to your other PRs too, although you will only need to sign the CLA once)

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

As we are unable to accept contributions unless the CLA has been signed, this PR will be automatically closed if the CLA is not signed within 21 days.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(MD2): setting rounds to a negative number generate just an md2 hash all 0s nothing more

3 participants