-
Notifications
You must be signed in to change notification settings - Fork 46
refactor random.c and add extra entropy during RNG #225
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
refactor random.c and add extra entropy during RNG #225
Conversation
src/random.c
Outdated
{ | ||
uint32_t i = 0; | ||
#ifndef TESTING | ||
uint32_t l = 0; |
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.
Maybe do the opposite, #ifdef TESTING
? It seem when in TESTING it's just a few lines at the bottom, while most of the func is unnecessary indented. Just saying, it would improve readability of random_bytes
overall, imho. But maybe not in this change though.
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'll do that and agree readability will improve, but what do you mean by 'unnecessary indented'? (I don't see how the indentation changes.)
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.
Ah sorry, my mistake. Please, ignore the indentation part. I was thinking in a different language. :)
// Add entropy from ataes RNG | ||
while (len > l) { | ||
if (update_seed) { | ||
ret = ataes_process(ataes_cmd_up, sizeof(ataes_cmd_up), ataes_ret, sizeof(ataes_ret)); |
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.
Maybe also move ataes_cmd
and other vars closer to this loop? Otherwise, one needs to scroll up and down a couple times now to see where those are declared and what the values are.
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.
ack
src/random.c
Outdated
ret = ataes_process(ataes_cmd, sizeof(ataes_cmd), ataes_ret, sizeof(ataes_ret)); | ||
} | ||
if (ret == DBB_OK && ataes_ret[0] && !ataes_ret[1]) { | ||
for (i = 0; i < MIN(len - l, 16); i++) { |
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 number 16
is important enough that it deserves a #define
imho.
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.
ACK.
There is a future commit that adds some ATAES-specific defines. I'll include this in that PR.
src/random.c
Outdated
} | ||
#endif | ||
// Add entropy from ataes RNG | ||
while (len > l) { |
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.
For the first few minutes I thought it was len > 1
, i.e. len
is greater than one, not the var l
. Change the name to something like n
to avoid ambiguity? Maybe it's just me.
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.
ACK
LGTM |
db9cf56
to
0672207
Compare
0672207 refactor random.c; include extra source of entropy from usersig (djb)
No description provided.