Can these global or RW symbol be removed? #267
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#267
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?
Hi,
We are planning to put mbed-crypto into some read-only area, but we found there are some RW data available, which makes the putting harder:
0x38006708 0x00000008 Data RW 2856 .data.ecp_mod_p192k1.Rp (ecp_curves.o)
0x38006710 0x00000008 Data RW 2857 .data.ecp_mod_p224k1.Rp (ecp_curves.o)
0x38006718 0x00000008 Data RW 2858 .data.ecp_mod_p256k1.Rp (ecp_curves.o)
0x38006720 0x00000004 Data RW 2855 .data.ecp_mpi_set1.one (ecp_curves.o)
0x3800894d 0x0000000c Zero RW 2757 .bss.ecp_supported_grp_id (ecp.o)
0x38008960 0x000003c8 Zero RW 1909 .bss.global_data (psa_crypto.o)
0x38008d28 0x00000484 Zero RW 3192 .bss.global_data (psa_crypto_slot_management.o)
0x380091ac 0x00000080 Zero RW 1676 .bss.handle_owner (crypto_key.o)
Is it possible to change these part to make a read-only library of mbed-crypto? I know there are some others in memory and aes but there are configurable so no worry on that part.
For the ECP modules (
ecp_curvesandecp), there are data structures that are calculated on the first use of each curve. I recall discussions about trading slightly larger code size for getting rid of these global variables and saving a small amount of time during application start-up. I think it's possible but it may require an API change.For
psa_cryptoandpsa_crypto_slot_management, the API does not have a context pointer passed around to every function. The library needs to keep track of some global data between calls, including key material and a key handle table. I don't think you can implement the PSA crypto API without global data. This was an explicit trade-off during the API design: keep the API simple, and make the implementer do the hard work. We thought that global data is annoying on some platforms because it requires instructions to the linker, but it's possible pretty much everywhere. On PSA platforms, global variables must work. What platform are you building for?crypto_keydoes not exist in Mbed Crypto.Thanks for your reply. The intention is to put mbed-crypto into some shared area. About the context, maybe the memory could be provided by the caller, or use some malloc() things?
We could change the library to support using a malloc'ed block instead of a global array (and indeed we will at some point to make the array size configurable at runtime). But you'd still need a global variable to store the pointer to this allocated block.
Internal Jira reference: https://jira.arm.com/browse/IOTCRYPT-921
Closing as wontfix, as we'll always need some global RW data with the current library design.