Skip to content

improve ML-KEM algorithm handling and generic test#1470

Merged
jasonkatonica merged 1 commit into
IBM:java25from
jasonkatonica:katonica/issue/mlkemhonorparam-java25
May 19, 2026
Merged

improve ML-KEM algorithm handling and generic test#1470
jasonkatonica merged 1 commit into
IBM:java25from
jasonkatonica:katonica/issue/mlkemhonorparam-java25

Conversation

@jasonkatonica

Copy link
Copy Markdown
Member
  • Fix ML-KEM encapsulation length calculation to use actual key algorithm instead of generic 'ML-KEM' string
  • Add validation for encapsulation message length in decapsulation
  • Improve key conversion to use actual algorithm from key instead of generic algorithm parameter
  • Add comprehensive test for invalid encapsulation length handling
  • Refactor test skip conditions to use assumeFalse for better JUnit 5 compatibility
  • Add new interoperability tests using NamedParameterSpec:
    • testMLKEMInteropWithNamedParameterSpec
    • testMLKEMInteropEmptyParamsWithNamedParameterSpec
    • testMLKEMInteropSmallerSecretWithNamedParameterSpec
    • testMLKEMBidirectionalInteropWithNamedParameterSpec
  • Remove test unused imports and improve code consistency

This ensures ML-KEM operations correctly handle different parameter sets (ML-KEM-512, ML-KEM-768, ML-KEM-1024) and provides better error messages when encapsulation length mismatches occur.

Back-ported from: #1443

Signed-off-by: Jason Katonica katonica@us.ibm.com

- Fix ML-KEM encapsulation length calculation to use actual key
  algorithm instead of generic 'ML-KEM' string
- Add validation for encapsulation message length in decapsulation
- Improve key conversion to use actual algorithm from key instead
  of generic algorithm parameter
- Add comprehensive test for invalid encapsulation length handling
- Refactor test skip conditions to use assumeFalse for better
  JUnit 5 compatibility
- Add new interoperability tests using NamedParameterSpec:
  * testMLKEMInteropWithNamedParameterSpec
  * testMLKEMInteropEmptyParamsWithNamedParameterSpec
  * testMLKEMInteropSmallerSecretWithNamedParameterSpec
  * testMLKEMBidirectionalInteropWithNamedParameterSpec
- Remove test unused imports and improve code consistency

This ensures ML-KEM operations correctly handle different parameter
sets (ML-KEM-512, ML-KEM-768, ML-KEM-1024) and provides better error
messages when encapsulation length mismatches occur.

Back-ported from: IBM#1443

Signed-off-by: Jason Katonica <katonica@us.ibm.com>

@JinhangZhang JinhangZhang left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@KostasTsiounis KostasTsiounis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@jasonkatonica jasonkatonica merged commit 4167c92 into IBM:java25 May 19, 2026
3 checks passed
@jasonkatonica jasonkatonica deleted the katonica/issue/mlkemhonorparam-java25 branch May 19, 2026 20:05
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.

4 participants