-
Notifications
You must be signed in to change notification settings - Fork 107
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
fix(errors): Handle randomness generation and invalid random values as errors in cryptographic code #6385
Conversation
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.
Looks great, thanks for making minimal changes!
I'd just like to check a few cryptographic details.
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #6385 +/- ##
==========================================
+ Coverage 77.92% 77.97% +0.04%
==========================================
Files 306 307 +1
Lines 40236 40249 +13
==========================================
+ Hits 31355 31383 +28
+ Misses 8881 8866 -15 |
I'm not sure we're going to be able to get a cryptography review until after RWC and/or Easter so this may have to move to Sprint 8. EDIT: Unless @upbqdn is around today or tomorrow? |
I'll review this. |
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.
The error names make sense to me, but I'd rather let @dconnolly give it the final approval.
This is waiting for a final review from Deirdre when she gets back. |
@oxarbitrage @upbqdn @teor2345 I made some suggestions in ed6596a, lmk what you think? |
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.
Looks good to me, just needs to resolve a merge conflict?
I question the idea that we want to avoid a panic when a cryptographic RNG fails. #6338 (comment) |
Motivation
We want to avoid some panics in some cryptography code. There are some specific problems that were pointed by the audit.
This should close #6338
The code modified here is currently not used but we expect to use it in the future and we will want to avoid panics.
Solution
Most related code use a string as an error with this pattern.
However, this is not always possible, for example if you want to do that here you will get the following compiler error:
So i think that limitation might be the cause of not using
try_fill_bytes()
in the first place.What is needed is our own errors for handling this and that is what this PR tries to do.
I think all the string errors should be eventually refactored to this but i didnt wanted to do that here as it will be too intrusive so i just fixed what was pointed by the audit ticket.
Review
I think anyone can review, the names chosen could be improved maybe.
Reviewer Checklist
Follow Up Work
Add errors for all string errors used inside zebra-chain ?