Privatize functions and some types/macros in cipher.h #259
Labels
No labels
api-break
approved
bug
component-docs
component-platform
component-test
dependencies
deprecation
DO-NOT-MERGE
enhancement
good first issue
help wanted
needs-adoption
needs-backports
needs-ci
needs-design-approval
needs-info
needs-preceding-pr
needs-review
needs-reviewer
needs-work
priority-high
priority-low
priority-medium
priority-scheduled
priority-very-high
resolved-after-1.1
single-reviewer
size-l
size-m
size-optimisation
size-s
size-xs
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-Mbed-TLS/TF-PSA-Crypto!259
Loading…
Reference in a new issue
No description provided.
Delete branch "privatize-cipher-functions"
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?
Privatizes all functions and some types/macros (below) by guarding them with
MBEDTLS_DECLARE_PRIVATE_IDENTIFIERS. Any types/macros not listed/privatized here will break the build if they are privatized.Types privatized:
mbedtls_cipher_padding_tenum that includes MBEDTLS_KEY_LENGTH_<NONE|DES|DES_EDE|DES_EDE3>mbedtls_cipher_base_tMacros privatized:
MBEDTLS_MAX_KEY_LENGTHMBEDTLS_CIPHER_VARIABLE_IV_LENMBEDTLS_CIPHER_VARIABLE_KEY_LENMBEDTLS_KEY_BITLEN_SHIFT(required unlinking from Doxygen comment)MBEDTLS_IV_SIZE_SHIFT(required unlinking from Doxygen comment)Resolves https://github.com/Mbed-TLS/TF-PSA-Crypto/issues/220
PR checklist
MBEDTLS_DECLARE_PRIVATE_IDENTIFIERSA lot more types & macros could probably be privatized too, however doing so would break the CI for other reasons. e.g.
MBEDTLS_KEY_BITLEN_SHIFTbreaks the doxygen build as it's used in a comment above. So I guess the question is do we want to do any extra work to get more types/macros privatized or just only privatize ones that don't break the CI to keep the amount of work down?I think we should try to find a reasonable compromise between the two. We don't have time to spend hours analyzing every single macro. But we should take quick wins.
For example,
MBEDTLS_KEY_BITLEN_SHIFTis only used in existing Doxygen comments that will not be part of the public documentation (and actually shouldn't be even in 3.x, since it only appears in the documentation of a private field of a structure, and those should not be documented). So here I think the best solution is to unlink the reference in the Doxygen comment, and guard the macro.I wouldn't insist on doing this kind of analysis for all macros, especially for ones that are used in more places or in more complex ways. But I'd prefer to privatize macros when the analysis and fix is as easy as this case.
Sounds good - I've re-privatized those two macros then. I can't see any other macros/types that are privatized as easily, so the ones privatized in this PR should be the complete list - on my end at least.
Looks good to me, but I think now that GCC/CCM are done, we can probably go a bit further here. For example, in a local copy of this branch (with development merged in) I was able to make
mbedtls_cipher_mode_tprivate and things are still compiling (at least in the default config).Ah yes - done that now & updated the PR description to include the newly-privatized types/macros, cheers!
...And the CI reminded my why they were left unprivatized (at least
mbedtls_cipher_id_tandmbedtls_cipher_mode_t) - they are present indrivers/builtin/src/psa_crypto_cipher.hwhich is then used to buildlibtestdriver1which can't find privatized types. Althoughmbedtls_cipher_base_t&MBEDTLS_MAX_KEY_LENGTHare now also privatized (presuming CI passes...)Ah, thanks for trying it out and explaining the results!
LGTM, thanks!
@bjwtaylor Gentle reminder that this is waiting for you to review again :)