Skip to content

improve ML-KEM algorithm handling and test coverage#1443

Merged
jasonkatonica merged 1 commit into
IBM:mainfrom
jasonkatonica:katonica/issue/mlkemhonorparam
May 14, 2026
Merged

improve ML-KEM algorithm handling and test coverage#1443
jasonkatonica merged 1 commit into
IBM:mainfrom
jasonkatonica:katonica/issue/mlkemhonorparam

Conversation

@jasonkatonica

@jasonkatonica jasonkatonica commented May 6, 2026

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 unused import 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.

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

@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 force-pushed the katonica/issue/mlkemhonorparam branch 3 times, most recently from 2053b69 to 3942042 Compare May 7, 2026 12:26
Comment thread src/main/java/com/ibm/crypto/plus/provider/MLKEMImpl.java
Comment thread src/main/java/com/ibm/crypto/plus/provider/MLKEMImpl.java
Comment thread src/main/java/com/ibm/crypto/plus/provider/MLKEMImpl.java
Comment thread src/main/java/com/ibm/crypto/plus/provider/MLKEMImpl.java

@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

@taoliult taoliult 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

- 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.

Signed-off-by: Jason Katonica <katonica@us.ibm.com>
@jasonkatonica jasonkatonica force-pushed the katonica/issue/mlkemhonorparam branch from 1c01248 to 1d94aff Compare May 14, 2026 17:38
@jasonkatonica jasonkatonica merged commit c1be56f into IBM:main May 14, 2026
2 checks passed
@jasonkatonica jasonkatonica deleted the katonica/issue/mlkemhonorparam branch May 14, 2026 17:39
jasonkatonica added a commit to jasonkatonica/OpenJCEPlus that referenced this pull request May 19, 2026
- 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>
jasonkatonica added a commit that referenced this pull request May 19, 2026
- 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>
jasonkatonica added a commit that referenced this pull request May 19, 2026
- 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>
jasonkatonica added a commit that referenced this pull request May 19, 2026
- 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>
jasonkatonica added a commit that referenced this pull request May 19, 2026
- 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>
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.

5 participants