Skip to content

Conversation

@dhardy
Copy link
Member

@dhardy dhardy commented Jan 29, 2026

  • Added a CHANGELOG.md entry

Motivation

Removes CryptoGenerator since rust-random/rand#1722 makes it useless.

Removes fn Generator::drop since it can be confusing.

Adds fn BlockRng::clear explicitly for use with zeroize, since it is clear we do need to care about that and an explicit method appears to be the best solution (without actually depending on the zeroize crate).

Soft-blocker: chacha20 will need a new zeroize release to use clear correctly.

@dhardy dhardy requested a review from newpavlov January 29, 2026 08:27
@dhardy
Copy link
Member Author

dhardy commented Jan 29, 2026

@tarcieri this PR requires using code like the following to implement zeroization. Do you approve?

block_rng.core.zeroize();
block_rng.clear();
zeroize::optimization_barrier(&block_rng)

@tarcieri
Copy link
Contributor

Has anyone inspected the generated assembly to confirm zeroization is actually working correctly?

@dhardy
Copy link
Member Author

dhardy commented Jan 29, 2026

I haven't.

If we don't get confirmation this works before Sunday, I guess I'll only remove CryptoGenerator and publish that. Or would you prefer to delay again? (I won't have any time on Saturday, should have some tomorrow.)

@tarcieri
Copy link
Contributor

I would prefer to avoid delays if possible

@newpavlov
Copy link
Member

@tarcieri
I demonstrated generated assembly for optimization_barrier using godbolt links in the zeroize PRs. Sure, I used [u8; N] instead of the BlockRng::clear method but it should make no difference.

@dhardy dhardy force-pushed the push-ytsnmttsyuqz branch from 5978a5e to d8d93fe Compare January 31, 2026 17:44
@dhardy dhardy requested a review from tarcieri January 31, 2026 17:44
@dhardy dhardy merged commit a20120c into master Jan 31, 2026
13 checks passed
@dhardy dhardy deleted the push-ytsnmttsyuqz branch January 31, 2026 17:47
@dhardy dhardy changed the title Remove CryptoGenerator and Generator::drop; add BlockRng::clear Remove CryptoGenerator Jan 31, 2026
@dhardy
Copy link
Member Author

dhardy commented Feb 1, 2026

I opted to remove the commits replacing fn Generator::drop with BlockRng::clear since it is easier to prove that drop works as intented at the use-site, and the priority for now is to get out something reliably usable for v0.10. Possibly we should drop the block module altogether before 1.0.

    /// Clear the results buffer
    ///
    /// This overwrites all bits of the results buffer, and thus may be useful
    /// in conjunction with [`zeroize`](https://docs.rs/zeroize/).
    #[inline]
    pub fn clear(&mut self) {
        self.results = [W::default(); N];
        self.results[0] = W::from_usize(N);
    }

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.

4 participants