Remove domain parameters from API 1.0 #112
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!112
Loading…
Reference in a new issue
No description provided.
Delete branch "psa-remove_domain_parameters"
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?
Domain parameters aren't quite working yet. So remove them from the API, but keep them as an experimental extension in our reference implementation. At this point, we plan to fix the domain parameter API and add them to the specification in a point release, possibly in a modified form.
This has the following impact for applications:
Shouldn't we remove
psa_reset_key_attributes()from the API too?No. It stays. You can get away without it now, but it's extremely likely that a future API version will require it. You are supposed to call it after
psa_get_key_attributes.Copypasta: this should be
PSA_KEY_TYPE_DH_PUBLIC_KEY. Same goes for the macros in the lines below.I made a fixup commit to fix this and add
KEY_TYPE_IS_DH.Do you say that it is extremely likely, because of the reintroduction of
key_attributesor do you have some other use case in mind as well?Domain parameters are the definite thing I have in mind. But also I'd be surprised if nothing else came up, especially when we consider more server and other rich platform use cases.
I found a small mistake in one of the comments.
"Either" is duplicated in this sentence.
Fixed here and in other places that had the same copypasted sentence.
Rebased on top of the target branch. The previous version is at https://github.com/gilles-peskine-arm/mbed-crypto/tree/psa-remove_domain_parameters-1
@ -109,3 +108,3 @@* for some key type additional domain parameters.* - Information about the key itself: the key type and its size.* - Implementations may define additional attributes.*Commit message for "Remove domain parameters from the official API " says "This leaves DH and DSA effectively unusable.", but isn't it usable with implementation-specific extensions?
Our RSA implementation also uses "domain parameters". Should we mention that RSA is effectively unusable?
...minutes later...
I see in a later commit we now require e=65537, so RSA should be perfectly usable. No problem for RSA here.
I'm not sure we should make this optional. Certain implementations might require
psa_reset_key_attributes()to be called to free implementation-specific resources like domain parameters. It'd also be nice if applications would continue to work when domain parameters become part of the official API.Do we need to provide an implementation specific
PSA_ALG_IS_HASH_AND_SIGN()that understandsPSA_ALG_IS_DSA()?Yes, if we implement DSA, which we don't.
The current tooling doesn't allow us to document a macro without giving a definition for it. When we move away from Doxygen we'll be able to do it.
We debated this internally and concluded that we might as well allow it.
@ -109,3 +108,3 @@* for some key type additional domain parameters.* - Information about the key itself: the key type and its size.* - Implementations may define additional attributes.*Sure, everything is usable with implementation-specific extensions.
I’m proposing stronger than allowing it, but to maintain requiring it. (We removed the word "must" in this PR, but I'd recommend keeping the word "must" in.)
But I actually did preserve the definition with DSA support in
crypto_extra.h, anyway.@ -109,3 +108,3 @@* for some key type additional domain parameters.* - Information about the key itself: the key type and its size.* - Implementations may define additional attributes.*The commit message is all lies!
See internal discussion https://github.com/ARMmbed/psa-crypto/issues/140#issuecomment-486767289 and https://github.com/ARMmbed/mbedtls-psa/pull/263#discussion_r279832614
I've read those threads.
My recommendation is to encourage future-proof use of the API by always requiring a reset.
I can see your chosen approach is to only require calling reset when it might be actually necessary; and without key domain parameters, Mbed Crypto doesn't allocate resources when handling attributes. I think this assumes too much about the implementation, as some implementations could require the user calling reset for the attributes currently specified, although Mbed Crypto wouldn't. Applications written for an implementation that doesn't require calling reset will not be portable to implementations that require reset.
If we dont't want to always require it, I'd suggest removing reset from the API for now, so that no implementations that require it appear and cause application portability issues. Then, when we add domain parameters back or other attributes that we'd expect implementations to allocate resources for, we can take the "call it if you set any of these attributes" approach again. New applications that use these new attributes will have to call reset, but old applications that don't use those attributes will remain correct.
I don't have strong feelings about this, but for me the removal seems the best solution. Mainly because I am secretly hoping that we can get away without adding domain parameters back:
I'm also feeling that this halfway house is not ideal. There's still the issue with how to extract a variable sized key attributes in an efficient way when we reintroduce them. I think the real options are:
Extended attributes are not part of the psa_key_attributes_t.
reset()to zero the attributes if apps want to do this, is is not required to be called. Releasing memory is an operation on the extended attributes.Make
reset()mandatory for applications to use in this version of the spec. When domain params are added to the attributes,reset()starts checking if there is memory to be released. This adds cost to all apps as many won't touch the zero'd attributes after reset and many compilers will not elide the pointless memset().Remove
reset()from the API right now. Reintroduce it as "conditional mandatory" - if you use domain parameters then you must callreset()I think I actually prefer approach 1. It moves the tricky memory management into a separate structure and allows
psa_key_attributes_tto always be a simple plain-old-data struct.The risk of some implementations requiring free to come up for the currentlt defined parameters is fairly low. Reset just zeros in this version, and is optional.
CI failure is ABI job (known to fail until https://github.com/ARMmbed/mbedtls/pull/2636 lands in the development branch) and
USE_PSA_CRYPTO, which doesn't work on the API branch.With my gatekeeper hat for the API, I say: this stays as is in beta3. It's out of scope of this PR anyway. Let's discuss it further for the next beta: we can still make reset officially mandatory or completely optional. This commits us to keeping the function, but it's useful anyway to zero the structure.