ARM-software / psa-api

Documentation source and development of the PSA Certified API
https://arm-software.github.io/psa-api/
Other
58 stars 28 forks source link

Module Latice Keys #210

Closed MarcusJGStreets closed 1 month ago

MarcusJGStreets commented 2 months ago

Adding ML keys now that FIPS 203 and 204 have been issued.

athoelke commented 2 months ago

The branch is very stale, and overwrites many commits since made into the main branch of the repository. I am not sure this will be suitably repaired by merging main into the development branch (though that might be worth a try); rebasing the commits on top of main might be better, or cherry-picking them onto a new branch?

athoelke commented 2 months ago

I am not convinced that the proposed API for ML-DSA properly aligns with the specification of the ML-DSA and HashML-DSA operations. Two primary concerns:

Pure vs pre-hash

This suggest to me that we should have two algorithms, one for ML-DSA and one for HashML-DSA. The one for ML-DSA is only usable with psa_sign_message(), and is not parameterized by a hash algorithm. The one for HashML-DSA is parameterized by the message-hashing algorithm, and can be used with both psa_sign_message() (which does the hashing), and psa_sign_hash() which expects the the hash to be provided by the caller.

"Hedged" vs deterministic

FIPS 204 describes the default "hedged" signature process, that uses 32-bytes of fresh randomness to generate a distinct signature for each invocation (with the same key, context, and message); but permits a deterministic variant where this value is all zeros.

We need two versions of each of the ML-DSA and HashML-DSA algorithms, a default one for the hedged version, and a xxx_DETERMINISTIC_xxx on for the deterministic version. This mirrors the pattern with ECDSA and DETERMINISTIC_ECDSA.

athoelke commented 2 months ago

There is no discussion in the PR yet about the 0-255 byte context string, present in the FIPS 204 specification. NIST suggests a default context value of the empty string, but "applications may specify the use of non-empty strings".

We should be explicit that the initial API only supports an empty context string. When an application use case arises that requires a non-empty context, we will need to add an API for providing a context to the signature and verification functions.

athoelke commented 2 months ago

In parallel, I was writing up my thoughts on ML-KEM in #95. See my latest comment.