Allow xxx_drbg_set_entropy_len before xxx_drbg_seed #299
No reviewers
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!299
Loading…
Reference in a new issue
No description provided.
Delete branch "drbg-set_entropy_len"
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?
The functions
mbedtls_ctr_drbg_set_entropy_len()andmbedtls_hmac_drbg_set_entropy_len()were only supported after the call tombedtls_ctr_drbg_seed()andmbedtls_hmac_drbg_seed(), so the initial seeding always grabbed the amount of entropy defined at compile time (MBEDTLS_CTR_DRBG_ENTROPY_LENfor CTR_DRBG, calculated from the hash algorithm for HMAC_DRBG). There was no good reason for that and the documentation was not clear prior to https://github.com/ARMmbed/mbed-crypto/pull/287. Change the API to be intuitive: you can callset_entropy_len()afterinit(), and it will influence both the initial seeding (if you call it beforeseed()) and subsequent reseeds.A side benefit is that this removes the need for the test-only function
mbedtls_ctr_drbg_seed_entropy_len.Upon reflection, the ways this would break existing applications are:
xxx_set_entropy_len()beforexxx_drbg_seedand expected it to do nothing. That's no more likely than an application that calledxxx_set_entropy_len()and expected this to set the entropy length throughout the lifetime of the DRBG object, and is currently unknowingly grabbing the default amount of entropy instead.mbedtls_ctr_drbg_seed_entropy_lendespite it being marked as for internal use only.So I think this should be backported, perhaps with a backward compatibility wrapper
mbedtls_ctr_drbg_seed_entropy_lenfor the sake of linkers that may have performed some cross-module inlining across a shared library call (hopefully that doesn't happen, but maybe we can spare a few bytes of code size to play it safe).A step on the path to IOTCRYPT-180.
CI status: the failures are from tests on one embedded board that looks like an instability with this board affecting other jobs and the ABI compatibility check reporting that
mbedtls_ctr_drbg_seed_entropy_lenhas disappeared as expected. Since the affected board doesn't interact with the entropy seeding differently from other boards, we can merge without a status on this board. So CI is ok for merging.CI passed except for ABI checking (as expected) and
getting-started-CY8CKIT_062_WIFI_BT-IARwhich fails with the same error (looks like a stack overflow) ondevelopment. Ok to merge.Hi @gilles-peskine-arm, is there any reason you didin't use
ctr_drbg_set_entropy_len()here? Maybe you wanted to keep some level of method independency.I can't think of a strong reason one way or the other. Semantically, I want to set the
entropy_lenfield to a certain value.mbedtls_ctr_drbg_set_entropy_len()does that, but so does an assignment. An assignment is simpler than calling a function. Arguably, calling a function is better in case the function changes. But changes to do what? If it changes to add some validation, this validation might not be what is needed at this point insidembedtls_ctr_drbg_seed. And if the meaning of the field changes, there'll be other changes needed in the code, so who knows what would need to change inmbedtls_ctr_drbg_seed. In terms of code size, the assignment is a couple of bytes smaller than a function call. So I have a very slight preference for the direct assignment. But only very slight. I don't remember thinking about it explicitly at the time.Thanks for the perspective.