Skip to content

std/crypto/hmac: add HMAC-SHA-512 - #3359

Open
seromarin-dev wants to merge 1 commit into
nim-lang:masterfrom
seromarin-dev:hmac-sha512
Open

seromarin-dev wants to merge 1 commit into
nim-lang:masterfrom
seromarin-dev:hmac-sha512

Conversation

@seromarin-dev

Copy link
Copy Markdown
Contributor

No description provided.

@seromarin-dev

Copy link
Copy Markdown
Contributor Author

What this changes

Adds the missing HMAC-SHA-512 to std/crypto/hmac, following the existing SHA-384 layout:

  • HmacSha512
  • initHmacSha512, update, finish
  • hmacSha512(key, data)
  • 128-byte block, 64-byte output

Purely additive; the SHA-256 and SHA-384 paths are unchanged.

Why

The module exposes HMAC-SHA-256 and HMAC-SHA-384 but not SHA-512, so the SHA-2 family is incomplete. A protocol may legitimately negotiate the 512-bit variant, and without a primitive in std callers must hand-roll it or depend on a third-party library — both are worse for review, portability and dependency surface than a small additive function in the existing style.

Tests

tests/nimony/crypto/thmac512.nim covers RFC 4231 cases 1-4, 6 and 7 for SHA-512, plus a check that the incremental form agrees with the one-shot form.

CI warnings

The warnings in the job annotations are pre-existing and unrelated to this change. Every annotation points at compiler sources this PR does not modify (src/lib/*, src/nifmake/*, src/niflink/*, src/hastur/*, src/nimony/*), and the same set of UnusedImport / Deprecated annotations is present on current master. This branch touches only lib/std/crypto/hmac.nim and its new test, and compiling that test directly emits no warnings.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant