Skip to content

Feature-detect KMAC key size limits - #131424

Merged
vcsjones merged 1 commit into
dotnet:mainfrom
vcsjones:fix-129939
Jul 27, 2026
Merged

Feature-detect KMAC key size limits#131424
vcsjones merged 1 commit into
dotnet:mainfrom
vcsjones:fix-129939

Conversation

@vcsjones

Copy link
Copy Markdown
Member

KMAC on OpenSSL's default provider has key size limits, the key must be in the range of [4, 512]. Windows does not have this limit, and SymCrypt-OpenSSL does not have this limit, either.

Detecting the presence of which provider is the default is tricky; we can look for a provider's presence on the system, but which is active is not always clear, and sometimes one provider defers to another.

This changes our KMAC tests to do a check it see if can import a zero-length key to determine the key size limits, rather than trying to detect provider presence.

Contributes to #129939

@vcsjones vcsjones added this to the 11.0.0 milestone Jul 27, 2026
@vcsjones
vcsjones requested a review from bartonjs July 27, 2026 16:30
@vcsjones vcsjones self-assigned this Jul 27, 2026
Copilot AI review requested due to automatic review settings July 27, 2026 16:30
@vcsjones vcsjones added area-System.Security test-bug Problem in test source code (most likely) labels Jul 27, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @bartonjs, @vcsjones, @dotnet/area-system-security
See info in area-owners.md if you want to be subscribed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the KMAC test infrastructure to infer OpenSSL key-size restrictions by probing whether a zero-length key can be imported, instead of attempting to identify the active/default OpenSSL provider via platform detection heuristics.

Changes:

  • Replace provider-based detection of KMAC key size limits with a runtime probe (Create with an empty key).
  • Compute PlatformKeySizeRequirements from the probe result to drive test expectations and the default MinimalKey.
Show a summary per file
File Description
src/libraries/System.Security.Cryptography/tests/KmacTestDriver.cs Adds a runtime probe to detect OpenSSL KMAC key-size limits and uses it to set PlatformKeySizeRequirements.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 1

Comment thread src/libraries/System.Security.Cryptography/tests/KmacTestDriver.cs
@vcsjones
vcsjones merged commit e050d85 into dotnet:main Jul 27, 2026
101 of 102 checks passed
@vcsjones
vcsjones deleted the fix-129939 branch July 27, 2026 20:04
@dotnet-milestone-bot dotnet-milestone-bot Bot modified the milestones: 11.0.0, 11.0-rc1 Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-System.Security test-bug Problem in test source code (most likely)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants