@@ -10,7 +10,7 @@ use core::fmt::Debug;
1010
1111use rand_core:: {
1212 CryptoRng , RngCore , SeedableRng ,
13- block:: { BlockRng , BlockRngCore , CryptoBlockRng } ,
13+ block:: { BlockRng , CryptoGenerator , Generator } ,
1414} ;
1515
1616#[ cfg( feature = "zeroize" ) ]
@@ -146,35 +146,6 @@ pub type StreamId = U32x2;
146146/// The arrays should be in little endian order.
147147pub type BlockPos = U32x2 ;
148148
149- /// The results buffer that zeroizes on drop when the `zeroize` feature is enabled.
150- #[ derive( Clone ) ]
151- pub struct BlockRngResults ( [ u32 ; BUFFER_SIZE ] ) ;
152-
153- impl AsRef < [ u32 ] > for BlockRngResults {
154- fn as_ref ( & self ) -> & [ u32 ] {
155- & self . 0
156- }
157- }
158-
159- impl AsMut < [ u32 ] > for BlockRngResults {
160- fn as_mut ( & mut self ) -> & mut [ u32 ] {
161- & mut self . 0
162- }
163- }
164-
165- impl Default for BlockRngResults {
166- fn default ( ) -> Self {
167- Self ( [ 0u32 ; BUFFER_SIZE ] )
168- }
169- }
170-
171- #[ cfg( feature = "zeroize" ) ]
172- impl Drop for BlockRngResults {
173- fn drop ( & mut self ) {
174- self . 0 . zeroize ( ) ;
175- }
176- }
177-
178149const BUFFER_SIZE : usize = 64 ;
179150
180151// NB. this must remain consistent with some currently hard-coded numbers in this module
@@ -334,7 +305,7 @@ macro_rules! impl_chacha_rng {
334305 self . core. fill_bytes( dest)
335306 }
336307 }
337- impl CryptoBlockRng for $ChaChaXCore { }
308+ impl CryptoGenerator for $ChaChaXCore { }
338309 impl CryptoRng for $ChaChaXRng { }
339310
340311 #[ cfg( feature = "zeroize" ) ]
@@ -535,13 +506,17 @@ macro_rules! impl_chacha_rng {
535506 }
536507 }
537508
538- impl BlockRngCore for $ChaChaXCore {
539- type Item = u32 ;
540- type Results = BlockRngResults ;
509+ impl Generator for $ChaChaXCore {
510+ type Output = [ u32 ; BUFFER_SIZE ] ;
541511
542512 #[ inline]
543- fn generate( & mut self , r: & mut Self :: Results ) {
544- self . 0 . generate( & mut r. 0 ) ;
513+ fn generate( & mut self , r: & mut Self :: Output ) {
514+ self . 0 . generate( r) ;
515+ }
516+
517+ #[ cfg( feature = "zeroize" ) ]
518+ fn drop( & mut self , output: & mut Self :: Output ) {
519+ output. zeroize( ) ;
545520 }
546521 }
547522 } ;
0 commit comments