-
Notifications
You must be signed in to change notification settings - Fork 2.1k
add error check of aes_encrypt() #15576
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
Conversation
ad1f732
to
6e23dac
Compare
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.
this looks good too :)
sys/random/fortuna/fortuna.c
Outdated
aes_encrypt(&cipher, state->gen.counter.bytes, out + (i * 16)); | ||
res = aes_encrypt(&cipher, state->gen.counter.bytes, out + (i * 16)); | ||
if (res != 1) { | ||
return res; |
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 wrote this implementation some time ago. I think the return code should be negative, and I'm not sure about res
being negative.
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.
Frme the doc:
1 on success
A negative value if the cipher key cannot be expanded with the AES key schedule
fortuna_generate_blocks
is an internal function so it should be fine to return the negative value. But maybe an "internal" documentation of that function would be beneficial.
ping @Hxinrong! :) |
@basilfx you put a change request on this PR. What did you want changed? |
@PeterKietzmann I think that it should not The documentation states that |
@basilfx could you give it another look? |
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 this should just blow an assert()
since nothing about this should depend on the run-time state.
But then again I don't expect anyone to use this over any of the more 'slim' RNGs, so it probably doesn't matter ¯\(ツ)/¯
c130b98
to
b7c7c32
Compare
b7c7c32
to
bf3c038
Compare
Contribution description
sys/random/fortuna/fortuna.c:add error check of aes_encrypt()
I'm not sure which exact value should be returned when aes_encrypt() is not on success. I just return the return value of it.
Issues/PRs references
Addresses parts of #15524