Simplify or specify public key format for DH and DSA #14
No reviewers
Labels
No labels
api-spec
bug
CLA requested
CLA valid
compliance
DO NOT MERGE
duplicate
enhancement
feature branch
good first issue
HEADER FORMATTING ISSUE
help wanted
Information
invalid
Jira status: AWAITING REVIEW
Jira status: CLOSED
Jira status: DONE
Jira status: IN PROGRESS
Jira status: IN REVIEW
Jira status: OPEN
Jira status: REOPENED
Jira status: RESOLVED
mirrored
mirror internally
needs: backports
needs: ci
needs: design review
needs: preceding PR
needs: review
needs: work
notabug
open for community contribution
Product Backlog
question
ready for merge
security
stale
type: bug
type: enhancement
type: question
web pages
wontfix
writing
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-ARMmbed/mbed-crypto!14
Loading…
Reference in a new issue
No description provided.
Delete branch "pubkey-format-dh-dsa"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This PR builds on top of #13 (starting with 63455af9dcf7 "psa: Add get/set domain parameters") to simplify the DSA key format and to specify the DH key format.
TODO:
@ -372,0 +404,4 @@* ```** \param handle Handle to the key to set domain parameters for.* \param[in] data Buffer containing the key domain parameters. The contentDocumentation for handle parameter is missing.
@ -372,0 +435,4 @@* documentation for psa_set_key_domain_parameters().** \param handle Handle to the key to get domain parameters from.* \param[out] data On success, the key domain parameters.Documentation for handle parameter is missing.
Rebased to add Doxygen documentation for handle parameters.
@ -372,0 +379,4 @@** The format for the required domain parameters varies by the key type.* - For DSA public keys (#PSA_KEY_TYPE_DSA_PUBLIC_KEY),* the `Dss-Parms` format as defined by RFC 3279 §2.3.2.“the DER representation of the
Dss-Parmsformat”@ -372,0 +388,4 @@* }* ```* - For Diffie-Hellman key exchange keys (#PSA_KEY_TYPE_DH_PUBLIC_KEY), the* `DomainParameters` format as defined by RFC 3279 §2.3.3.“the DER representation of the
DomainParametersformat”@ -372,0 +395,4 @@* g INTEGER, -- generator, g* q INTEGER, -- factor of p-1* j INTEGER OPTIONAL, -- subgroup factor* validationParms ValidationParms OPTIONALWe try to avoid optional stuff in PSA. Do we allow, mandate or reject
jandvalidationParms? If it's allowed, do we guarantee that the implementation will check it?My gut feeling:
@ -372,0 +405,4 @@** \param handle Handle to the key to set domain parameters for.* \param[in] data Buffer containing the key domain parameters. The content* of this buffer is interpreted according to \p type. ofMissing
\p typeparameter in the documentation and in the prototype.Something's missing before “of
psa_export_key()or …”@ -372,0 +419,4 @@* \retval #PSA_ERROR_HARDWARE_FAILURE* \retval #PSA_ERROR_TAMPERING_DETECTED* \retval #PSA_ERROR_BAD_STATE* The library has not been previously initialized by psa_crypto_init().Not relevant for this function (you won't get a handle in the first place)
@ -372,0 +443,4 @@* \retval #PSA_SUCCESS* \retval #PSA_ERROR_INVALID_HANDLE* \retval #PSA_ERROR_EMPTY_SLOT* There is no key in the specified slot.That's not an error: you can read domain parameters that have been set even before importing a key. The possible errors here are that no domain parameters have been set, or that the slot contains a key which does not have any domain parameters.
@ -372,0 +444,4 @@* \retval #PSA_ERROR_INVALID_HANDLE* \retval #PSA_ERROR_EMPTY_SLOT* There is no key in the specified slot.* \retval #PSA_ERROR_INVALID_ARGUMENT+
NOT_SUPPORTEDif the implementation doesn't have code to format domain parameters@ -372,0 +450,4 @@* \retval #PSA_ERROR_HARDWARE_FAILURE* \retval #PSA_ERROR_TAMPERING_DETECTED* \retval #PSA_ERROR_BAD_STATE* The library has not been previously initialized by psa_crypto_init().Not relevant for this function (you won't get a handle in the first place)
@ -372,0 +453,4 @@* The library has not been previously initialized by psa_crypto_init().* It is implementation-dependent whether a failure to initialize* results in this error code.*/Needs a macro in
crypto_sizes.hto determine the buffer size from the key type and bit-size.“key pairs” → “private keys” for consistency
It isn't a structure, it's a buffer that will be parsed.
I find this description unclear: it looks like you can pass
extra, useset_key_domain_parameters, or do neither. In fact you need to do at least one, and the last one applies.The logic is exactly the same for DSA and DH, so you can combine their documentation.
@ -372,0 +395,4 @@* g INTEGER, -- generator, g* q INTEGER, -- factor of p-1* j INTEGER OPTIONAL, -- subgroup factor* validationParms ValidationParms OPTIONALThat sounds very good for usability.
Considering it from the security perspective the checks a specific implementation makes have significant impact and I think that we should be very explicit about it. How about allowing the
validationParamsto be present and allowing the implementations to ignore them, but adding a new function for parameter validation?By the way can't we just drop custom parameter FFDH from 1.0 and use named groups instead. We could reintroduce custom parameters if and when customers ask for it.
(I know I have asked this before, but I don't remember what was the conclusion.)
I dislike custom parameter FFDH, because it can be backdoored and no matter how hard you validate your parameters, you won't notice:
https://tls.mbed.org/tech-updates/blog/dh-backdoors
(Of course you can argue that named groups have to be bigger because of logjam, but I wouldn't advise to use keys that short with custom parameters either.)
For the beta1 API release, I'm adding a
typeparameter topsa_set_key_domain_parameters. https://github.com/gilles-peskine-arm/mbed-crypto/tree/pubkey-format-dh-dsa-pass_type_to_set_domain_parametersClosing as very out of date. Needs to be redone in a PSA Crypto API 1.0b3 way.
Pull request closed