Privatize functions and some types/macros in asymmetric crypto headers #290
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!290
Loading…
Reference in a new issue
No description provided.
Delete branch "privatize-asymmetric-crypto-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 in the following files by guarding them with
MBEDTLS_DECLARE_PRIVATE_IDENTIFIERSPrivatizes the types:
mbedtls_ecdh_sidembedtls_ecp_curve_typembedtls_ecp_curve_infoPrivatizes the macros:
MBEDTLS_MPI_MAX_BITSMBEDTLS_MPI_MAX_BITS_SCALE100MBEDTLS_LN_2_DIV_LN_10_SCALE100MBEDTLS_MPI_RW_BUFFER_SIZEMBEDTLS_ECDSA_MAX_SIG_LENMBEDTLS_ECDSA_MAX_LENMBEDTLS_ECP_SHORT_WEIERSTRASS_ENABLEDMBEDTLS_ECP_MONTGOMERY_ENABLEDMBEDTLS_ECP_DP_MAXMBEDTLS_ECP_OPS_CHKMBEDTLS_ECP_OPS_DBLMBEDTLS_ECP_OPS_ADDMBEDTLS_ECP_OPS_INVMBEDTLS_ECP_BUDGETResolves https://github.com/Mbed-TLS/TF-PSA-Crypto/issues/227
n.b. I made changes inpsa_utilto unlinkMBEDTLS_ECDSA_MAX_SIG_LENfrom the Doxygen documentation. Although this would have had to be done anyway in https://github.com/Mbed-TLS/TF-PSA-Crypto/issues/281 aspsa_util.his public andecdsa.hwill become internal/no longer rendered, I just wanted to make this specific change a bit more visible, as althoughpsa-transition.mdseems to imply that this macro is going away ("The following are specific to the DER format and therefore have no PSA equivalent: MBEDTLS_ECDSA_MAX_SIG_LEN, MBEDTLS_ECDSA_MAX_LEN"), I just want to make sure that the change here makes sense in terms of documentation.Also includes the addition of the macros
MBEDTLS_ECDSA_DER_MAX_SIG_LEN&MBEDTLS_ECDSA_DER_MAX_LEN, which are public equivalents ofMBEDTLS_ECDSA_MAX_SIG_LEN&MBEDTLS_ECDSA_MAX_LEN, specifically for this patch to fix a Doxygen issue, but useful to have anyway.PR Checklist
MBEDTLS_DECLARE_PRIVATE_IDENTIFIERSI think we need public replacements for these macros, so that people know how to size their output buffer when using
MBEDTLS_ECDSA_MAX_LEN- and evenpk_sign()(if we decide to keep it).I think we want them defined in a proper public header - probably
psa_util.h(orpk.hif we keeppk_sign()?). We might take this opportunity to rename them and includeDERin their name.Suggestion: in
psa_util.h:That is, mostly the same as in
ecdsa.h, but using new names and usingPSA_VENDOR_ECC_MAX_CURVE_BITSon the last line.Wdyt? Cc @gilles-peskine-arm
LGTM except for the one point about the ECDSA DER len macros.
@ -112,0 +117,4 @@* \return Maximum signature size in bytes.** \note This macro returns a compile-time constant if its argument* is one. It may evaluate its argument multiple times.As indicated in a previous comment, I think we want a replacement here. TBD whether this needs to be part of this PR (I'm inclined to say yes, until it turns out to be more complex than expected) or can be done in a follow-up.
@ -112,0 +117,4 @@* \return Maximum signature size in bytes.** \note This macro returns a compile-time constant if its argument* is one. It may evaluate its argument multiple times.Make sense to me, I've added the replacements in following your suggestion above. Would this then need a change in the
mbedtlsdocumentation? i.e. inpsa-transition.md:might need to mention the new macros, although I guess they're still not
PSAmacros, just publicmbedtlsmacros (?)@ -112,0 +117,4 @@* \return Maximum signature size in bytes.** \note This macro returns a compile-time constant if its argument* is one. It may evaluate its argument multiple times.I guess
MBEDTLS_PK_SIGNATURE_MAX_SIZEcould be the public way of knowing how large a signature can grow. But this needs some kind of ECDSA-specific macro to be visible to the compiler. And it's also useful for users who implement an ECDSA-based protocol to know how large an ECDSA signature can get, either for a given curve or for all supported curves. So I concur that it's a good idea to have public macros for ECDSA signature length.Just needed a rebase to fix the GCC-15 CI job, otherwise no extra change 👍
LGTM, thanks!