psa_generate_random fails on large requests #206
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#206
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
Bug:
psa_generate_randomfails with the errorPSA_ERROR_NOT_SUPPORTEDif asked to generate more than 1024 bytes in one call. This also affectspsa_generate_keywhen generating symmetric keys.More precisely, the limit is
MBEDTLS_CTR_DRBG_MAX_REQUEST. This limit can be configured inconfig.h, but there is little reason to reduce it since it won't reduce the memory consumption of the library.Workaround: call
psa_generate_randomin a loop, retrieving at most 1024 bytes per call.Affected versions: all versions of Mbed Crypto until this is fixed.
Impact: applications should check the return value of
psa_generate_random, so the bug should at least be detectable. But an application that does not check the return value and assumes thatpsa_generate_randomalways succeeds would silently operate with non-random data. Forpsa_generate_key, there is probably no real-world impact since 1024 bytes is well above the usual size of symmetric keys.Cause:
psa_generate_randomcallsmbedtls_ctr_drbg_randomwhich is unwilling to return more thanMBEDTLS_CTR_DRBG_MAX_REQUESTin a single call.Issue request type
Internal Jira reference: https://jira.arm.com/browse/IOTCRYPT-856
Fixed in https://github.com/ARMmbed/mbed-crypto/pull/197 for the
psa-api-1.0-betabranch. I expect that this will be fixed on thedevelopmentbranch when we mergepsa-api-1.0-betaintodevelopment.psa-api-1.0-betawas merged intodevelopment, so the fix is present in Mbed Crypto 2.0.0.