add error check of aes_encrypt()#15576
Conversation
ad1f732 to
6e23dac
Compare
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.
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.
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? |
benpicco
left a comment
There was a problem hiding this comment.
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