Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ACVP test harness for ML-DSA #2127

Merged
merged 7 commits into from
Jan 24, 2025
Merged

ACVP test harness for ML-DSA #2127

merged 7 commits into from
Jan 24, 2025

Conversation

jakemas
Copy link
Contributor

@jakemas jakemas commented Jan 17, 2025

Issues:

Resolves #CryptoAlg-2819

Description of changes:

Implements:

Additional Details

Added testing for ML-DSA configured withdeterministic = true externalmu = true, false signatureInterface = internal for parameterSet = ML-DSA-44, ML-DSA-65, ML-DSA-87.

We add the ML-DSA sigGen Test Case JSON Schema:

type mlDsaSigGenTestGroup struct {
	ID                 uint64 `json:"tgId"`
	Type               string `json:"testType"`
	ParameterSet       string `json:"parameterSet"`
	Deterministic      bool   `json:"deterministic"`
	SignatureInterface string `json:"signatureInterface"`
	ExternalMu         bool   `json:"externalMu`
	Tests         []struct {
		ID      uint64               `json:"tcId"`
		Message hexEncodedByteString `json:"message"`
		MU      hexEncodedByteString `json:"mu"`
		SK      hexEncodedByteString `json:"sk"`
		RND     hexEncodedByteString `json:"rnd"`
		Context hexEncodedByteString `json:"context"`
		HashAlg string               `json:"hashAlg"`
	}
}

and ML-DSA sigVer Test Case JSON Schema:

type mlDsaSigVerTestGroup struct {
	ID                 uint64 `json:"tgId"`
	Type               string `json:"testType"`
	ParameterSet       string `json:"parameterSet"`
	Deterministic      bool   `json:"deterministic"`
	SignatureInterface string `json:"signatureInterface"`
	ExternalMu         bool   `json:"externalMu`
	Tests        []struct {
		ID        uint64               `json:"tcId"`
		PK        hexEncodedByteString `json:"pk"`
		Message   hexEncodedByteString `json:"message"`
		MU        hexEncodedByteString `json:"mu"`
		Signature hexEncodedByteString `json:"signature"`
		Context   hexEncodedByteString `json:"context"`
                HashAlg   string               `json:"hashAlg"`
	}
}

Testing:

Running ACVP tests
2025/01/17 14:09:39 40 ACVP tests matched expectations
2025/01/17 14:09:40 1 ACVP tests matched expectations
2025/01/17 14:09:41 1 ACVP tests matched expectations
2025/01/17 14:09:42 1 ACVP tests matched expectations
2025/01/17 14:09:44 1 ACVP tests matched expectations
2025/01/17 14:09:46 1 ACVP tests matched expectations
2025/01/17 14:09:48 1 ACVP tests matched expectations
2025/01/17 14:09:50 1 ACVP tests matched expectations
2025/01/17 14:09:52 1 ACVP tests matched expectations
2025/01/17 14:10:09 1 ACVP tests matched expectations
2025/01/17 14:10:10 1 ACVP tests matched expectations
2025/01/17 14:10:11 1 ACVP tests matched expectations
2025/01/17 14:10:12 1 ACVP tests matched expectations
2025/01/17 14:10:12 1 ACVP tests matched expectations

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.

@jakemas jakemas marked this pull request as ready for review January 17, 2025 22:17
@jakemas jakemas requested a review from a team as a code owner January 17, 2025 22:17
util/fipstools/acvp/acvptool/test/vectors/ML-DSA.bz2 Outdated Show resolved Hide resolved
Comment on lines +1400 to +1401
"min": 8,
"max": 65536,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this min/max? Does this affect what is tested or what is approved?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

FIPS 204 defines the context string as a" byte string of 255 or fewer bytes which can be empty (default)".

Copy link
Contributor

Choose a reason for hiding this comment

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

Should this test min 0, max 255?

Copy link
Contributor Author

@jakemas jakemas Jan 18, 2025

Choose a reason for hiding this comment

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

Reading through the document again, I see now that messageLength is the length of the message to be signed. contextLength is the length of the context string.

Looking at Table 7 https://pages.nist.gov/ACVP/draft-celi-acvp-ml-dsa.html#name-ml-dsa-siggen-capability-pr, which is where this capabilities string comes from, you'll see that message length's valid values are:

Min: 8, Max: 65536, Incr: 8

that's why it is defined this way in my capabilities JSON.

We're not supporting context sign, but you can see in the same table that contextLength is Min: 0, Max: 2040, Incr: 8.

@codecov-commenter
Copy link

codecov-commenter commented Jan 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.97%. Comparing base (5270eca) to head (6545eb0).
Report is 16 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2127   +/-   ##
=======================================
  Coverage   78.96%   78.97%           
=======================================
  Files         610      610           
  Lines      105288   105287    -1     
  Branches    14911    14911           
=======================================
+ Hits        83140    83146    +6     
+ Misses      21496    21487    -9     
- Partials      652      654    +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@andrewhop andrewhop merged commit 1b13cd1 into aws:main Jan 24, 2025
122 of 126 checks passed
manastasova pushed a commit to manastasova/aws-lc that referenced this pull request Jan 30, 2025
### Issues:
Resolves #CryptoAlg-2819

### Description of changes: 
Implements:
- https://pages.nist.gov/ACVP/draft-celi-acvp-ml-dsa.html
-
https://github.com/usnistgov/ACVP-Server/tree/master/gen-val/json-files/ML-DSA-keyGen-FIPS204
-
https://github.com/usnistgov/ACVP-Server/tree/master/gen-val/json-files/ML-DSA-sigGen-FIPS204
-
https://github.com/usnistgov/ACVP-Server/tree/master/gen-val/json-files/ML-DSA-sigVer-FIPS204

### Additional Details
Added testing for ML-DSA configured with`deterministic = true`
`externalmu = true, false` `signatureInterface = internal` for
`parameterSet = ML-DSA-44, ML-DSA-65, ML-DSA-87`.

We add the [ML-DSA sigGen Test Case JSON
Schema](https://pages.nist.gov/ACVP/draft-celi-acvp-ml-dsa.html#name-ml-dsa-siggen-test-case-jso):

```
type mlDsaSigGenTestGroup struct {
	ID                 uint64 `json:"tgId"`
	Type               string `json:"testType"`
	ParameterSet       string `json:"parameterSet"`
	Deterministic      bool   `json:"deterministic"`
	SignatureInterface string `json:"signatureInterface"`
	ExternalMu         bool   `json:"externalMu`
	Tests         []struct {
		ID      uint64               `json:"tcId"`
		Message hexEncodedByteString `json:"message"`
		MU      hexEncodedByteString `json:"mu"`
		SK      hexEncodedByteString `json:"sk"`
		RND     hexEncodedByteString `json:"rnd"`
		Context hexEncodedByteString `json:"context"`
		HashAlg string               `json:"hashAlg"`
	}
}
```
and [ML-DSA sigVer Test Case JSON
Schema](https://pages.nist.gov/ACVP/draft-celi-acvp-ml-dsa.html#name-ml-dsa-sigver-test-case-jso):
```
type mlDsaSigVerTestGroup struct {
	ID                 uint64 `json:"tgId"`
	Type               string `json:"testType"`
	ParameterSet       string `json:"parameterSet"`
	Deterministic      bool   `json:"deterministic"`
	SignatureInterface string `json:"signatureInterface"`
	ExternalMu         bool   `json:"externalMu`
	Tests        []struct {
		ID        uint64               `json:"tcId"`
		PK        hexEncodedByteString `json:"pk"`
		Message   hexEncodedByteString `json:"message"`
		MU        hexEncodedByteString `json:"mu"`
		Signature hexEncodedByteString `json:"signature"`
		Context   hexEncodedByteString `json:"context"`
                HashAlg   string               `json:"hashAlg"`
	}
}
```




### Testing:
```
Running ACVP tests
2025/01/17 14:09:39 40 ACVP tests matched expectations
2025/01/17 14:09:40 1 ACVP tests matched expectations
2025/01/17 14:09:41 1 ACVP tests matched expectations
2025/01/17 14:09:42 1 ACVP tests matched expectations
2025/01/17 14:09:44 1 ACVP tests matched expectations
2025/01/17 14:09:46 1 ACVP tests matched expectations
2025/01/17 14:09:48 1 ACVP tests matched expectations
2025/01/17 14:09:50 1 ACVP tests matched expectations
2025/01/17 14:09:52 1 ACVP tests matched expectations
2025/01/17 14:10:09 1 ACVP tests matched expectations
2025/01/17 14:10:10 1 ACVP tests matched expectations
2025/01/17 14:10:11 1 ACVP tests matched expectations
2025/01/17 14:10:12 1 ACVP tests matched expectations
2025/01/17 14:10:12 1 ACVP tests matched expectations
```

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license and the ISC license.
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