-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
random: add hwrng and puf_sram as FEATURES_OPTIONAL #12166
Conversation
@cladmi does this violate any of the concepts behind the dependency parsing refactor? |
What behavior is this supposed to give? I understand the description but do not get what behavior is wanted. From a reading review of the changes and the previous code only: I think this changed the behavior in some cases. The previous behavior however had determinism issues though, as if So needs some careful look of what is wanted. |
You are right I didn't present enough of a description. I complemented the PR description accordingly.
You are right. I changed this because even though the code gets built it wont end up in the compiled fw, since the initialization for I could revert that specific change and remove |
@cladmi ping! |
What I understand: The current handling is that, What you want, is use Which makes you want to implement I guess, for The current implementation has the limitation that this choice will be done by the C code, and if both are available, both Doing the dependency resolution you want with the current dependency system is not standard. It could be done by looking into |
I will wait for @PeterKietzmann input then. I'll try to get a proof of concept for using LPM to initialize puf_sram and that way it could be used more widely.
Yes which is replicating the explicit hierarchy specified in code.
I will look into this. Thanks for the suggestion.
OK! |
@cladmi would this be ok then?:
I have this result make -C examples/gcoap/ BOARD=samr21-xpro info-build
|
As @fjmolinas pointed out, the puf-sram seeder requires a cold reboot in order to provide entropy. Now that (I assume) many developers are working with a dev kit connected via USB, I wanted to avoid using this as a default. |
@PeterKietzmann @maribu I think now that #13137 its is safe to reactivate this one right? |
e5de1a0
to
ec3bf53
Compare
I implemented the |
ec3bf53
to
387173b
Compare
For some non-cryptographic use cases the PUF SRAM based seed should now be viable even with soft reboots. The remaining issue is that the hash after soft reboots will not look very random (e.g. the first byte will only change after cold boots). And the theoretical possibility of devices being tracked when the seed is used in an observable way. (However, I'm not a cryptographer and don't have the background to estimate how practical such an attack would be. So it could be that this would be super trival, or totally infeasible as an 32 bit hash might just as well leak to little information about the SRAM characteristics to be of use. Or anything in between.) The use of a hash with better pre-image resistance would however solve both issues, but would increase overhead of the boot process significantly and increase ROM requirements. The CPU overhead could be mitigated to some degree by reducing the size of the SRAM chunk to hash to the smallest size that contains enough entropy (plus safety margin). But some research would be required to identify that size. Maybe @PeterKietzmann is already working on this (or similar)? If so, I'd wait for his result getting to RIOT first. |
@maribu sounds good! |
Ping @maribu @PeterKietzmann? |
Makefile.dep
Outdated
ifeq (,$(filter puf_sram,$(USEMODULE))) | ||
FEATURES_OPTIONAL += periph_hwrng | ||
endif | ||
FEATURES_OPTIONAL += $(call find_first_of_these_provided_features, puf_sram periph_hwrng) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think one would prefer periph_hwrng
over puf_sram
(at least currently), as periph_hwrng
has less impact on boot up time and (at least in case of warm boots) more entropy.
Edit: I meant in case both a present, periph_hwrng
should IMO be preferred of puf_sram
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I was doing here resembles the FEATURES_REQUIRED_ONE_OUT_OF
but FEATURES_OPTIONAL_ONE_OUT_OF
, I think I should probably re-work it that way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can I then just invert the ordering here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep :-)
- Include puf_sram module whe puf_sram is in FEATURES_USED - Use FEATURES_REQUIRED to include puf_sram in tests/puf_sram
0e52710
to
f3f0cd0
Compare
Rebased. |
@maribu since what I was doing was similar to your ONE-OUT-OFF approach, I decided to put it in common and use the same approach here. |
Note that |
Needs a rebase. Btw.: with my sleepy_node test I needed to enable |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions. |
Contribution description
This PR adds
periph_hwrng
andpuf_sram
asFEATURES_OPTIONAL
forrandom
module.Right now if
auto_init
is usedrandom
seed is initiated frompuf_sram
,periph_hwrng
,periph_cpuid
orRANDOM_SEED_DEFAULT
RIOT/sys/random/random.c
Lines 42 to 61 in 999fffd
But
pub_sram
is never compiled which means cpu/boards assamr21-xpro
end up using there CPU_ID instead of a random seed. So adding it as aFEATURES_OPTIONAL
allows it to be included in the build if available.Testing procedure
tests/puf_sram
on a board supportingpuf_sram
:make -C tests/puf_sram BOARD=samr21-xpro flash test
DEBUG
inrandom.c
flash an application using random onBOARD
providingpuf_sram
andperiph_hwrng
. In the first case the seed should change everytime the board is power-cycled, on the second case every-time the board is reset.make -C examples/gcoap/ BOARD=samr21-xpro flash term
make -C examples/gcoap/ BOARD=pba-d-01-kw2x flash -j3 term
Issues/PRs references