-
Notifications
You must be signed in to change notification settings - Fork 68
chacha20 - minor improvements
#456
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
…se identical--they could be reduced to one 'DoubleWord' type or something
|
So I was able to consolidate the StreamId and BlockPos structs/impls with a One thing we could do is switch Also, by using a more generic type for the |
|
I added some better diagnostics in the event that a new backend will be developed. I mutated and and if PARBLOCK number 1 is off, it says that ChaCha was implemented incorrectly, suggesting to look in |
dhardy
left a comment
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.
LGTM
Test may be a little over-complex (that it tests counter overflow twice or fills output in two steps isn't clearly signposted; block_pos constant isn't needed). Still acceptable.
| /// The arrays should be in little endian order. You should not need to use | ||
| /// this directly, as the methods in this crate that use this type call | ||
| /// `.into()` for you, so you only need to supply any of the above types. | ||
| pub struct U32x2([u32; Self::LEN]); |
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.
Seems like a bit of an odd name with something with a specific purpose that's only used in a single part of the API, particularly since it's public. I'll admit "stream ID" also seemed like an odd name for a nonce to me, but seemed OK in the context of the RNG API, particularly given the legacy of rand_chacha.
I guess this is because it now has a dual role as both a nonce and a block position identifier?
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.
Yes; this was discussed in #453. No comments on the name.
StreamIdandBlockPoswith type aliasescounter_overflow_1test to be more descriptive when the 64-bit counter is not implemented correctly for the 4th parblock - may be unnecessary, but it provides a better error message than the other test that would fail in the same scenariofixes #453