Skip to content

Include IANA reference in the definition of ECC curves and DH groups #279

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

Merged
merged 7 commits into from
Oct 11, 2019

Conversation

athoelke
Copy link
Contributor

Fixes ARMmbed/psa-crypto#262

Define a vendor-range within the the private use ranges in the IANA 
registry. Provide recommendations for how to support vendor-defined 
curves and groups.
Connect the types to the key type construction macros by x-refs.
/** Minimum value for a vendor-defined Diffie Hellman group identifier
*
* The range for vendor-defined group identifiers is a subset of the IANA
* registry private use range, `0x01fc` - `0x01ff`.
Copy link
Collaborator

@gilles-peskine-arm gilles-peskine-arm Oct 3, 2019

Choose a reason for hiding this comment

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

Unfortunately, this is a ridiculously small range whereas an implementation may well wish to define many custom groups, since many groups have been common in the wild and specific systems or protocols may define their own groups.

The TLS registry puts EC and FF groups in the same 16-bit range, but we don't have to. I propose to use some values in the IANA EC range for vendor FF groups. We can in particular use the GREASE values, which TLS uses for the purpose of not having a corresponding cryptographic algorithm.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From a quick glance, the proposed GREASE values that can be used in this way are:

0x0A0A, 0x1A1A, 0x2A2A, 0x3A3A, 0x4A4A, 0x5A5A, 0x6A6A, 0x7A7A,
0x8A8A, 0x9A9A, 0xAAAA, 0xBABA, 0xCACA, 0xDADA, 0xEAEA, 0xFAFA

This is still draft and subject to change. This might not affect this API element, but should modify the documentation of psa_dh_group_t.

  1. Is the suggestion to directly list the values, as being permitted for vendor-defined additional DH groups, or indirectly by referencing the specification draft?
  2. Do we want to slice up the GREASE identifiers, and reserve a set for PSA Crypto future use?
  3. Is the [arbitrary] 50/50 split of the TLS support group private use range appropriate (for this and ECC)?

Copy link
Collaborator

Choose a reason for hiding this comment

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

My proposal was to define the GREASE values (stated by value, with the GREASE spec given as an informative rationale) as reserved for vendors in psa_dh_group_t.

Though given that there are only 16 of them, that's not much. We can punt PSA crypto future use until later, but I do think we need more vendor FFDH values. I guess the only solution (short of moving to a bigger type) is to take values that are already assigned to elliptic curves and declare them as vendor-specific FFDH values.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added a commit the extends the recommendations for vendor defined DH groups.

Copy link
Collaborator

@gilles-peskine-arm gilles-peskine-arm left a comment

Choose a reason for hiding this comment

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

Approved for the documentation changes. The xxx_VENDOR_{MIN,MAX} macros need to be excluded from scripts/generate_psa_constants.py and tests/scripts/test_psa_constant_names.py to fix the build.

@athoelke
Copy link
Contributor Author

athoelke commented Oct 9, 2019

The xxx_VENDOR_{MIN,MAX} macros need to be excluded from scripts/generate_psa_constants.py and tests/scripts/test_psa_constant_names.py to fix the build.

Can someone help with making the associated change to those scripts. There is no obviously correct place to exclude these definitions from the testing that is done here.

Why are these values not suitable for this test?

@gilles-peskine-arm
Copy link
Collaborator

generate_psa_constants.py works out preprocessor_expression → numerical_value mappings, and generates C code that constructs a mapping in the other direction. If the mapping is not one-to-one, it errors out. There are rules to exclude certain preprocessor expressions which are considered to be aliases of other expressions.

I'll update the scripts.

@gilles-peskine-arm gilles-peskine-arm self-assigned this Oct 9, 2019
@gilles-peskine-arm
Copy link
Collaborator

The problem was that the (for now) mbedcrypto-specific value PSA_DH_GROUP_CUSTOM had the same value as PSA_DH_GROUP_VENDOR_MIN. I've moved it to be somewhere else in the standard range, far from values that are currently in used. It's for a feature that isn't implemented yet, and we can see later whether this becomes a standard feature (perhaps with the same number, perhaps not) or stays implementation-specific (in which case we'll change the number to be in the vendor range).

@gilles-peskine-arm
Copy link
Collaborator

CI report: the TLS head job failed in test_suite_x509parse because mbedtls needs a bug fix in mbed-crypto that is more recent than this PR. The TLS merge job succeeded so that's good. The crypto merge job failed in the Windows tests due to what seems to have been platform instability (“error MSB4166: Child node "4" exited prematurely”). I'm rerunning the Windows crypto tests: https://jenkins-internal.mbed.com/view/mbed-crypto/job/mbedtls-psa-release-new/574/

@gilles-peskine-arm
Copy link
Collaborator

https://jenkins-internal.mbed.com/view/mbed-crypto/job/mbedtls-psa-release-new/574/ passed so we have full CI approval. Since I made some of the changes, this needs approval from a team member other than me.

@gilles-peskine-arm gilles-peskine-arm dismissed their stale review October 9, 2019 16:58

I pushed a commit to fix the problem. As far as I'm concerned, this PR is approved.

@gilles-peskine-arm gilles-peskine-arm added needs: review The pull request is ready for review. This generally means that it has no known issues. api-spec Issue or PR about the PSA specifications labels Oct 10, 2019
@athoelke
Copy link
Contributor Author

Is there any chance that this could be reviewed, approved and merged today (if there is no issue with the implementation, obviuosly? - please? :-)

Copy link
Contributor

@Patater Patater left a comment

Choose a reason for hiding this comment

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

Looks good to me, but for one question.

CI failures are a known issue with DTLS testing (not introduced by this PR) and some ATECC608A example failures (not introduced by this PR).

/** Minimum value for a vendor-defined Diffie Hellman group identifier
*
* The range for vendor-defined group identifiers is a subset of the IANA
* registry private use range, `0x01fc` - `0x01ff`.
Copy link
Contributor

Choose a reason for hiding this comment

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

@athoelke To confirm, this range is still accurate, but the GREASE values are also available so the practical use of this range is limited.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that is correct. An minor improvement might be to refer to the psa_dh_group_t definition and its description of other ways to allocate a vendor-defined group number.

However, I'd like this merged sooner so I can render the reST and separate the specification from the doxygen source code, which is a pre-requistite to completing the remaing API changes before publishing 1.0.0 of the spec. I can clarify/improve the text after the split if desirable.

Copy link
Contributor

@Patater Patater left a comment

Choose a reason for hiding this comment

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

LGTM

@Patater Patater merged commit cb5fa8b into ARMmbed:development Oct 11, 2019
gilles-peskine-arm added a commit to gilles-peskine-arm/mbed-crypto that referenced this pull request Nov 15, 2019
* ARMmbed#272: Insert doxygen comments on old algorithms so they appear in PSA documentation
* ARMmbed#285: SE driver: make persistent data work
* ARMmbed#279: Include IANA reference in the definition of ECC curves and DH groups
* ARMmbed#287: DRBG documentation improvements
* ARMmbed#297: Fix int overflow in mbedtls_asn1_get_int (Credit to OSS-Fuzz)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-spec Issue or PR about the PSA specifications needs: review The pull request is ready for review. This generally means that it has no known issues.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants