crypto_struct.h and such not self-contained #340
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#340
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Description
I know you don't want anyone to include crypto_struct.h directly, but it should still follow this rule: http://wiki.c2.com/?SelfContainedHeaders. That rule is also part of the TF-M coding guidelines.
My intuition is to include the smallest number of lines of headers possible which is why I thought to include crypto_struct.h and not crypto.h. From the compiler errors because crypto_struct.h is not self-contained, I learned quickly this is not the thing to do. Is this part of the plan to stop people from including it? :-)
I'm working on MacOS with Xcode with MBed 2.0, 1.1 and 1.1 integrated in with TF-M.
Issue request type
Internal Jira reference: https://jira.arm.com/browse/IOTCRYPT-1035
The only reason why
psa/crypto.his divided into several headers is to accommodate builds in different environments that need to implement some things differently, and builds of code that shouldn't have everything.crypto_types.handcrypto_values.his separate because drivers of cryptographic hardware need the types and values, but not the API functions.crypto_types.handcrypto_struct.hare separate because on implementations where the crypto library is in a separate environment that's protected from the application (e.g. a separate process, or a TrustZone secure world, etc.), the application side and the protected environment need different implementations, with a marshalling layer to do the translation (typically the application side has a numeric handle and the unmarshalling looks it up and passes a data pointer to the crypto library proper).crypto_platform.his for things that you might need to change if you port the library to a different platform.crypto_extra.handcrypto_compat.hcontain extensions to the standard PSA specification. I think we should have a build option to make them optional at some point so that you can ensure that your application doesn't rely on these extensions. But at this point they aren't optional and you can't include them separately.We do follow the self-contained header rule as described here:
crypto_struct.hcannot be included top-most in a translation unit. It's only there to be included bycrypto.h.From application code, include
crypto.honly. The organization of the other headers can change at any time.We will not make
crypto_struct.hself-contained since the only place where it should be included iscrypto.h.I can't even think of a good reason to look at
crypto_struct.hin application code. This header is solely for implementation details that may change arbitrarily, essentially the struct definitions that gave the file its name. The only reason why these struct definitions are in a header that's included in application code is so that you can allocate these structures on the stack and usesizeofon them, otherwise we'd have made them private.