-
Notifications
You must be signed in to change notification settings - Fork 199
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
adding zeroize for stream_core.rs (#1494) #1495
Conversation
…ypto#1501) Replaces the old, significantly less flexible `LinearCombination` trait with the newer `LinearCombinationExt` trait, removing the old trait completely and renaming the new one. The bounds for `CurveArithmetic::ProjectivePoint` have also been updated accordingly.
@@ -35,7 +38,7 @@ pub trait StreamClosure: BlockSizeUser { | |||
} | |||
|
|||
/// Block-level synchronous stream ciphers. | |||
pub trait StreamCipherCore: BlockSizeUser + Sized { | |||
pub trait StreamCipherCore: BlockSizeUser + ParBlocksSizeUser + Sized { |
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.
As I wrote in the issue, this approach is incorrect. StreamCipherCore
does not "know" at compile time the number of blocks which can be generated in parallel at runtime. It's known only by backends which can be selected using runtime target feature detection. For example, chacha20
has SSE2 backend which generates only one block and AVX2 which generates 4 blocks. By default on x86 targets the crate uses runtime autodetection to select between those.
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 approach is not ideal, but it would still work if the x86 ParBlocksSize
for ChaChaCore
was set to U4
.
Is there a better approach for choosing the size at runtime? The last time I tried to pick a variable-sized [T; N]
at runtime, the compiler was yelling at me because it did not know N
at compile time. Is this possible with the array
crate, or something similar?
Regarding #1494