Skip to content
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

Closed
wants to merge 10 commits into from

Conversation

nstilt1
Copy link

@nstilt1 nstilt1 commented Jan 31, 2024

Regarding #1494

@nstilt1 nstilt1 marked this pull request as draft February 2, 2024 04:03
@@ -35,7 +38,7 @@ pub trait StreamClosure: BlockSizeUser {
}

/// Block-level synchronous stream ciphers.
pub trait StreamCipherCore: BlockSizeUser + Sized {
pub trait StreamCipherCore: BlockSizeUser + ParBlocksSizeUser + Sized {
Copy link
Member

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.

Copy link
Author

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?

@newpavlov newpavlov closed this Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants