Skip to content

pkg/micro-ecc: Use random API instead of hwrng#7393

Closed
tobhe wants to merge 2 commits intoRIOT-OS:masterfrom
tobhe:micro-ecc
Closed

pkg/micro-ecc: Use random API instead of hwrng#7393
tobhe wants to merge 2 commits intoRIOT-OS:masterfrom
tobhe:micro-ecc

Conversation

@tobhe
Copy link
Copy Markdown
Contributor

@tobhe tobhe commented Jul 20, 2017

Use the random_bytes() function from #7390 instead of hwrng_read() in the micro-ecc package in order to increase usability for devices which do not support hwrng.

There should be no loss of security as random can be seeded with hwrng.

@aabadie aabadie added Type: new feature The issue requests / The PR implemements a new feature for RIOT Area: pkg Area: External package ports labels Aug 15, 2017
@tobhe
Copy link
Copy Markdown
Contributor Author

tobhe commented Mar 13, 2018

#7390 has been merged, so there is nothing more this is waiting for

@PeterKietzmann
Copy link
Copy Markdown
Member

@tobhe basically I agree with your proposal. However, I'm not really familiar with that package and just realized there are two tests, whereas one explicitly requires hwrng. Wouldn't that require changes as well? Please elaborate on that. Furthermore, the pkg REAMDE needs adaptation.

@miri64
Copy link
Copy Markdown
Member

miri64 commented Dec 18, 2018

Ping @tobhe?

@tobhe
Copy link
Copy Markdown
Contributor Author

tobhe commented Dec 20, 2018

@PeterKietzmann you're right. I think best would be to merge those tests as both can and should work for every device now.
For the readme: I don't think the "Choosing the right API" section is needed any longer, removing it would make it quite a short readme though.

@tobhe tobhe force-pushed the micro-ecc branch 2 times, most recently from 353e6e6 to 0077b4c Compare December 20, 2018 17:00
@tobhe
Copy link
Copy Markdown
Contributor Author

tobhe commented Dec 20, 2018

ok, so i stitched the two old tests together and it is still working for me on 'native'.
I saw that in a recent commit @aabadie increased the hwrng test timeout to 200, readjustment may be necessary as the test now signes and verifies twice.

# Use a custom global timeout for slow hardware. On microbit (nrf51), the
# test completes in 80s.
TIMEOUT = 100
# test completes in 120s.
Copy link
Copy Markdown
Contributor Author

@tobhe tobhe Dec 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 120s are copied from the old pkg_micro-ecc-with-HWRNG test. This is probably bogus, because the test changed quite a bit. Still better than 80s.

@PeterKietzmann
Copy link
Copy Markdown
Member

@tobhe thanks for the cleanup.

  • I tried running the remaining test application which fails for samr21-xpro and nucleo-l073rz. Ideas? Which boards did you test with?
  • I think the documentation of the pkg should still state that ECC_make_key and uECC_sign APIs expect the random module to be seeded with a high entopy, random seed
  • The Micro-Ecc documentation states: "The filled-in values should be either truly random, or from a cryptographically-secure PRNG.". I would propose to make the SHA1PRNG a dependency of that package.

@tobhe
Copy link
Copy Markdown
Contributor Author

tobhe commented Feb 3, 2019

I tried running the remaining test application which fails for samr21-xpro and nucleo-l073rz. Ideas? Which boards did you test with?

I have tested this on the nucleo-f411re and on native because that's what i had at hand. Both ran without failures. I guess i could need some help for tests on further hardware here. Any details on what broke on the boards you tested?

I think the documentation of the pkg should still state that ECC_make_key and uECC_sign APIs expect the random module to be seeded with a high entopy, random seed

Right, i will look it up and fix it.

The Micro-Ecc documentation states: "The filled-in values should be either truly random, or from a cryptographically-secure PRNG.". I would propose to make the SHA1PRNG a dependency of that package.

Good idea, will do.

@PeterKietzmann
Copy link
Copy Markdown
Member

PeterKietzmann commented Feb 4, 2019

@tobhe thanks for the feedback!

  • I got the same error on a nucleo-f411.
  • The test fails to generate a key with uECC_make_key 16 times. In there it fails to uECC_generate_random_int.

@tobhe
Copy link
Copy Markdown
Contributor Author

tobhe commented Feb 4, 2019

* I got the same error on a nucleo-f411.

Indeed, i tested it again later yesterday and got the same error.
I also found the source of the problem and I think i may have fixed it, but as I am in Brussels right now i don't have any device at hand for testing

@tobhe
Copy link
Copy Markdown
Contributor Author

tobhe commented Feb 6, 2019

So, I tested it on a nucleo-f103rb and the test succeeds with the latest fix. @PeterKietzmann it would be nice if you could test and see if it works on your hardware now (whenever you find the time). I still want to look through the documentation and the test once more to see if it is consistent with the changes i made. Also I'd like to make the SHA1PRNG a dependency, but I don't know what I have to do to make this work. Is this just a FEATURES_REQUIRED in the Makefile?

@PeterKietzmann
Copy link
Copy Markdown
Member

@tobhe thanks for addressing. Did you amend your fix? Cause I can't see what the fix was...

I think we need to fix this warning:
micro-ecc/curve-specific.inc:544:59: warning: unused parameter ‘curve’ [-Wunused-parameter]

With boards, the test (make test) succeeds now which is nice! Unfortunately the board crashes afterwards. To see that just use term instead of test.

@PeterKietzmann
Copy link
Copy Markdown
Member

Same one nucleo-f401rb, nucleo-l073rz and samr21-xpro. Not on native.

@stale
Copy link
Copy Markdown

stale bot commented Aug 11, 2019

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.

@stale stale bot added the State: stale State: The issue / PR has no activity for >185 days label Aug 11, 2019
@stale stale bot removed the State: stale State: The issue / PR has no activity for >185 days label Aug 19, 2019
@PeterKietzmann
Copy link
Copy Markdown
Member

@tobhe will fix this PR before the stalebot closes it?

@miri64
Copy link
Copy Markdown
Member

miri64 commented Aug 28, 2019

@tobhe will fix this PR before the stalebot closes it?

Now at least the closing is delayed by another 7 month ;-)

@PeterKietzmann
Copy link
Copy Markdown
Member

Once again a random ping

@stale
Copy link
Copy Markdown

stale bot commented Aug 28, 2020

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.

@stale stale bot added the State: stale State: The issue / PR has no activity for >185 days label Aug 28, 2020
@stale stale bot closed this Sep 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: pkg Area: External package ports State: stale State: The issue / PR has no activity for >185 days Type: new feature The issue requests / The PR implemements a new feature for RIOT

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants